Changeset 27838 for branches/tap_branches/ippTools/src/pxtools.c
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/pxtools.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/ippTools/src
- Property svn:ignore
-
old new 16 16 difftool 17 17 disttool 18 dqstatstool 18 19 faketool 19 20 flatcorr
-
- Property svn:ignore
-
branches/tap_branches/ippTools/src/pxtools.c
r25851 r27838 61 61 if (!state) { 62 62 psError(PS_ERR_PROGRAMMING, false, "%s not found in row %ld of table %s", 63 columnName, i, tableName);63 columnName, i, tableName); 64 64 return false; 65 65 } … … 70 70 // if state isn't cleaned or full we can't set it to cleaned 71 71 psError(PS_ERR_PROGRAMMING, true, "%s with state %s may not be exported cleaned", 72 tableName, state);72 tableName, state); 73 73 return false; 74 74 } … … 90 90 psAssert (entry, "%s should at least have a place-holder", name); 91 91 if (entry->data.str) { 92 psListIterator *iter = psListIteratorAlloc (item->data.list, PS_LIST_HEAD, true);93 psMetadataItem *item = NULL;94 while ((item = psListGetAndIncrement(iter))) {95 // need to change the name and comment96 psFree (item->name);97 item->name = psStringCopy (field);98 psFree (item->comment);99 item->comment = psStringCopy (op);100 if (!psMetadataAddItem(where, item, PS_LIST_TAIL, PS_META_DUPLICATE_OK)) {101 psError(PS_ERR_UNKNOWN, false, "failed to add item %s", field);102 psFree(where);103 return false;104 }105 }106 psFree (iter);92 psListIterator *iter = psListIteratorAlloc (item->data.list, PS_LIST_HEAD, true); 93 psMetadataItem *item = NULL; 94 while ((item = psListGetAndIncrement(iter))) { 95 // need to change the name and comment 96 psFree (item->name); 97 item->name = psStringCopy (field); 98 psFree (item->comment); 99 item->comment = psStringCopy (op); 100 if (!psMetadataAddItem(where, item, PS_LIST_TAIL, PS_META_DUPLICATE_OK)) { 101 psError(PS_ERR_UNKNOWN, false, "failed to add item %s", field); 102 psFree(where); 103 return false; 104 } 105 } 106 psFree (iter); 107 107 } 108 108 return true; … … 110 110 111 111 // shared code for updating the various strings for a Run 112 bool pxUpdateRun(pxConfig *config, psMetadata *where, psString *pQuery, psString table, bool has_dist_group)112 bool pxUpdateRun(pxConfig *config, psMetadata *where, psString *pQuery, psString runTable, psString idColumn, psString fileTable, bool has_dist_group) 113 113 { 114 114 PS_ASSERT_PTR_NON_NULL(config, false); … … 116 116 PS_ASSERT_PTR_NON_NULL(pQuery, false); 117 117 PS_ASSERT_PTR_NON_NULL(*pQuery, false); 118 PS_ASSERT_PTR_NON_NULL(runTable, false); 119 PS_ASSERT_PTR_NON_NULL(idColumn, false); 120 PS_ASSERT_PTR_NON_NULL(fileTable, false); 118 121 119 122 // make sure that -state is not the only selection parameter 120 123 PXOPT_LOOKUP_STR(where_state, config->args, "-state", false, false); 121 124 if (where_state && (psListLength(where->list) < 2)) { 122 psError(PXTOOLS_ERR_ DATA, true, "selection by -state alone is not allowed");125 psError(PXTOOLS_ERR_CONFIG, true, "selection by -state alone is not allowed"); 123 126 return false; 124 127 } … … 136 139 137 140 if ((!state) && (!label) && (!data_group) && (has_dist_group && !dist_group) && !(note)) { 138 psError(PXTOOLS_ERR_ DATA, false, "parameters are required");141 psError(PXTOOLS_ERR_CONFIG, false, "parameters are required"); 139 142 return false; 140 143 } 141 144 142 145 if (state && ! pxIsValidState(state)) { 143 psError(PXTOOLS_ERR_ DATA, false, "pxIsValidState failed");146 psError(PXTOOLS_ERR_CONFIG, false, "pxIsValidState failed"); 144 147 return false; 145 148 } … … 158 161 } while (0) 159 162 160 addColumn( table, state);161 addColumn( table, data_group);163 addColumn(runTable, state); 164 addColumn(runTable, data_group); 162 165 if (has_dist_group) { 163 addColumn(table, dist_group); 164 } 165 addColumn(table, note); 166 addColumn(table, label); 166 addColumn(runTable, dist_group); 167 } 168 addColumn(runTable, note); 169 addColumn(runTable, label); 170 171 psString joinHook = psStringCopy(""); 172 psString fileWhere = NULL; 173 if (state && !strcmp(state, "update")) { 174 psStringAppend(&joinHook, "\n JOIN %s USING(%s)", fileTable, idColumn); 175 psStringAppend(pQuery, ", %s.data_state = 'update'", fileTable); 176 psStringAppend(&fileWhere, "AND %s.data_state = 'cleaned'", fileTable); 177 } 167 178 168 179 psString whereClause = psDBGenerateWhereSQL(where, NULL); 169 180 psStringAppend(pQuery, " %s", whereClause); 170 181 psFree(whereClause); 171 172 if (!p_psDBRunQuery(config->dbh, *pQuery)) { 182 if (fileWhere) { 183 psStringAppend(pQuery, "%s", fileWhere); 184 } 185 186 bool mdok; // Status of MD lookup 187 if (psMetadataLookupBool(&mdok, config->args, "-pretend")) { 188 psLogMsg("pxtools", PS_LOG_INFO, "Query to run: %s\n", *pQuery); 189 return true; 190 } 191 192 if (!p_psDBRunQueryF(config->dbh, *pQuery, joinHook)) { 173 193 psError(PS_ERR_UNKNOWN, false, "database error"); 174 194 return false; … … 198 218 } 199 219 if (psArrayLength(output) > 1) { 200 psError(PS_ERR_UNKNOWN, true, "unexpected number of rows found in dbversion: % " PRId64,220 psError(PS_ERR_UNKNOWN, true, "unexpected number of rows found in dbversion: %ld", 201 221 psArrayLength(output)); 202 222 return false; … … 221 241 return NULL; 222 242 } 223 243 224 244 psString version = psMetadataLookupStr(NULL, md, "schema_version"); 225 245 … … 257 277 return false; 258 278 } 259 279 260 280 psMetadataItem *dbversion = psListGet(multi_item->data.list, 0); 261 281 if (!dbversion) { … … 272 292 return false; 273 293 } 274 294 275 295 psString import_version = psMetadataLookupStr(NULL, md, "schema_version"); 276 296 if (import_version && strcmp(import_version, schema_version)) {
Note:
See TracChangeset
for help on using the changeset viewer.
