Changeset 7143
- Timestamp:
- May 18, 2006, 10:08:33 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/db/psDB.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/db/psDB.c
r7078 r7143 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.5 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-05- 05 23:56:51$14 * @version $Revision: 1.52 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-05-18 20:08:33 $ 16 16 * 17 17 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 1134 1134 } 1135 1135 1136 1137 // find database indexes 1138 // check for Primary Keys first as they have to be part of the same Primary 1139 // Key stmt 1136 1140 // Reset iterator to head of list 1137 1141 psListIteratorSet(cursor, 0); 1138 1139 // find database indexes 1142 psArray *pKeys = psArrayAlloc(1); 1140 1143 while ((item = psListGetAndIncrement(cursor))) { 1141 // XXX NOTE: check for "Primary Key" first before "Key". Yes we're1142 // playing fast and loose here, but I think it's fine...1143 1144 if (strstr(item->comment, "Primary Key")) { 1144 psStringAppend(&query, ", PRIMARY KEY(%s)", item->name); 1145 } else if (strstr(item->comment, "Key")) { 1145 psArrayAdd(pKeys, 0, item->name); 1146 } 1147 } 1148 if (psArrayLength(pKeys)) { 1149 psStringAppend(&query, ", PRIMARY KEY("); 1150 for (int i = 0; i < psArrayLength(pKeys); i++) { 1151 if (i < 1) { 1152 psStringAppend(&query, "%s", pKeys->data[i]); 1153 } else { 1154 psStringAppend(&query, ", %s", pKeys->data[i]); 1155 } 1156 } 1157 psStringAppend(&query, ")"); 1158 } 1159 psFree(pKeys); 1160 1161 // Reset iterator to head of list 1162 psListIteratorSet(cursor, 0); 1163 // look for regular keys 1164 while ((item = psListGetAndIncrement(cursor))) { 1165 if (strstr(item->comment, "Key")) { 1146 1166 psStringAppend(&query, ", KEY(%s)", item->name); 1147 1167 } else if (strstr(item->comment, "AUTO_INCREMENT")) {
Note:
See TracChangeset
for help on using the changeset viewer.
