Changeset 27388 for trunk/ippTools/src/regtool.c
- Timestamp:
- Mar 22, 2010, 12:30:48 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/regtool.c (modified) (36 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/regtool.c
r27315 r27388 82 82 MODECASE(REGTOOL_MODE_REVERTPROCESSEDEXP, revertprocessedexpMode); 83 83 MODECASE(REGTOOL_MODE_UPDATEPROCESSEDEXP, updateprocessedexpMode); 84 MODECASE(REGTOOL_MODE_UPDATEBYQUERY, updatebyqueryMode);85 MODECASE(REGTOOL_MODE_PENDINGCOMPRESSIMFILE, pendingcompressimfileMode);86 MODECASE(REGTOOL_MODE_FINISHCOMPRESSEXP, finishcompressexpMode);84 MODECASE(REGTOOL_MODE_UPDATEBYQUERY, updatebyqueryMode); 85 MODECASE(REGTOOL_MODE_PENDINGCOMPRESSIMFILE, pendingcompressimfileMode); 86 MODECASE(REGTOOL_MODE_FINISHCOMPRESSEXP, finishcompressexpMode); 87 87 MODECASE(REGTOOL_MODE_CLEARDUPEXP, cleardupexpMode); 88 88 MODECASE(REGTOOL_MODE_EXPORTRUN, exportrunMode); … … 264 264 class_id, 265 265 uri, 266 data_state,266 data_state, 267 267 exp_type, 268 268 filelevel, … … 505 505 PXOPT_LOOKUP_STR(set_md5sum, config->args, "-set_md5sum", false, false); 506 506 PXOPT_LOOKUP_STR(set_state, config->args, "-set_state", false, false); 507 507 508 508 if ((fault == INT16_MAX) && !isfinite(burntool_state) && !(set_state)) { 509 509 psError(PS_ERR_UNKNOWN, false, "one of -fault or -burntool_state or -set_state must be selected"); … … 526 526 return false; 527 527 } 528 psFree (where);529 return(true);528 psFree (where); 529 return(true); 530 530 } 531 531 psFree (where); 532 532 533 533 psString setvalues = NULL; 534 534 if (burntool_state != INT16_MAX) { … … 537 537 if (set_bytes != INT32_MAX) { 538 538 if (setvalues) { 539 psStringAppend(&setvalues,",");539 psStringAppend(&setvalues,","); 540 540 } 541 541 psStringAppend(&setvalues,"rawImfile.bytes = %d",set_bytes); … … 543 543 if (set_md5sum) { 544 544 if (setvalues) { 545 psStringAppend(&setvalues,",");545 psStringAppend(&setvalues,","); 546 546 } 547 547 psStringAppend(&setvalues,"rawImfile.md5sum = '%s'",set_md5sum); … … 549 549 if (set_state) { 550 550 if (setvalues) { 551 psStringAppend(&setvalues,",");551 psStringAppend(&setvalues,","); 552 552 } 553 553 psStringAppend(&setvalues,"rawImfile.data_state = '%s'",set_state); 554 554 } 555 555 556 556 psString query = pxDataGet("regtool_updateprocessedimfile.sql"); 557 557 if (!query) { … … 587 587 PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false); 588 588 589 if ((compress && clean) ||(!compress& !clean)) {590 psStringAppend(&whereClause, "\n AND ((data_state = 'goto_compressed' AND state = 'goto_compressed')\n OR (data_state = 'goto_lossy' AND state = 'goto_lossy')) ");589 if ((compress && clean) || (!compress && !clean)) { 590 psStringAppend(&whereClause, "\n AND ((data_state = 'goto_compressed' AND state = 'goto_compressed')\n OR (data_state = 'goto_lossy' AND state = 'goto_lossy')) "); 591 591 } 592 592 else if (compress) { … … 598 598 else { 599 599 psStringAppend(&whereClause, "\n AND ((data_state = 'goto_compressed' AND state = 'goto_compressed')\n OR (data_state = 'goto_lossy' AND state = 'goto_lossy')) "); 600 } 601 600 } 601 602 602 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 603 603 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 604 604 605 605 psString query = pxDataGet("regtool_pendingcompressimfile.sql"); 606 606 if (!query) { 607 607 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 608 608 return(false); 609 } 609 } 610 610 psString limitString = NULL; 611 611 if (limit) { … … 626 626 psFree(whereClause); 627 627 psFree(where); 628 628 629 629 psArray *output = p_psDBFetchResult(config->dbh); 630 630 if (!output) { … … 638 638 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 639 639 } 640 640 641 641 return false; 642 642 } … … 646 646 return true; 647 647 } 648 648 649 649 // negate simple so the default is true 650 650 if (!ippdbPrintMetadatas(stdout, output, "regPendingCompressImfile", !simple)) { … … 653 653 return false; 654 654 } 655 655 656 656 psFree(output); 657 657 658 658 return true; 659 659 } 660 660 661 661 662 662 static bool pendingexpMode(pxConfig *config) … … 1091 1091 PXOPT_COPY_F32(config->args, where, "-sun_angle_min", "sun_angle", ">="); 1092 1092 PXOPT_COPY_F32(config->args, where, "-sun_angle_max", "sun_angle", "<"); 1093 1093 1094 1094 psString where2 = NULL; 1095 1095 if (!pxmagicAddWhere(config, &where2, "rawExp")) { … … 1105 1105 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1106 1106 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 1107 1107 1108 1108 if (psListLength(where->list)) { 1109 1109 psString whereClause = psDBGenerateWhereConditionSQL(where, "rawExp"); 1110 1110 psStringAppend(&query, " AND %s", whereClause); 1111 1111 psFree(whereClause); 1112 } 1112 } 1113 1113 psFree(where); 1114 1114 1115 1115 if (where2) { 1116 1116 psStringAppend(&query, " %s ", where2); … … 1125 1125 psStringAppend(&query, " %s", "AND rawExp.fault = 0"); 1126 1126 } 1127 1127 1128 1128 // treat limit == 0 as "no limit" 1129 1129 if (limit) { … … 1132 1132 psFree(limitString); 1133 1133 } 1134 1134 1135 1135 if (!p_psDBRunQuery(config->dbh, query)) { 1136 1136 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1138 1138 } 1139 1139 psFree(query); 1140 1140 1141 1141 psArray *output = p_psDBFetchResult(config->dbh); 1142 1142 if (!output) { … … 1144 1144 switch (err) { 1145 1145 case PS_ERR_DB_CLIENT: 1146 psError(PXTOOLS_ERR_SYS, false, "database error");1146 psError(PXTOOLS_ERR_SYS, false, "database error"); 1147 1147 case PS_ERR_DB_SERVER: 1148 psError(PXTOOLS_ERR_PROG, false, "database error");1148 psError(PXTOOLS_ERR_PROG, false, "database error"); 1149 1149 default: 1150 psError(PXTOOLS_ERR_PROG, false, "unknown error");1150 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1151 1151 } 1152 1152 1153 1153 return false; 1154 1154 } … … 1158 1158 return true; 1159 1159 } 1160 1160 1161 1161 if (psArrayLength(output)) { 1162 1162 // negative simple so the default is true 1163 1163 if (!ippdbPrintMetadatas(stdout, output, "rawExp", !simple)) { 1164 psError(PS_ERR_UNKNOWN, false, "failed to print array");1165 psFree(output);1166 return false;1164 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1165 psFree(output); 1166 return false; 1167 1167 } 1168 1168 } 1169 1169 1170 1170 psFree(output); 1171 1171 1172 1172 return true; 1173 1173 } … … 1176 1176 { 1177 1177 PS_ASSERT_PTR_NON_NULL(config, false); 1178 1178 1179 1179 psMetadata *where = psMetadataAlloc(); 1180 1180 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); … … 1182 1182 PXOPT_COPY_S64(config->args, where, "-exp_id_begin", "exp_id", ">="); 1183 1183 PXOPT_COPY_S64(config->args, where, "-exp_id_end", "exp_id", "<="); 1184 1184 1185 1185 psString query = pxDataGet("regtool_revertprocessedexp.sql"); 1186 1186 if (!query) { … … 1189 1189 return false; 1190 1190 } 1191 1191 1192 1192 if (psListLength(where->list)) { 1193 1193 psString whereClause = psDBGenerateWhereConditionSQL(where, "rawExp"); … … 1200 1200 } 1201 1201 psFree(where); 1202 1202 1203 1203 if (!p_psDBRunQuery(config->dbh, query)) { 1204 1204 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1207 1207 } 1208 1208 psFree(query); 1209 1209 1210 1210 int numUpdated = psDBAffectedRows(config->dbh); 1211 1211 1212 1212 psLogMsg("regtool", PS_LOG_INFO, "Updated %d rawExp", numUpdated); 1213 1213 1214 1214 return true; 1215 1215 } … … 1219 1219 { 1220 1220 PS_ASSERT_PTR_NON_NULL(config, false); 1221 1221 1222 1222 psMetadata *where = psMetadataAlloc(); 1223 1223 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 1224 1224 1225 1225 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false); 1226 1226 1227 1227 if (!pxSetFaultCode(config->dbh, "rawExp", where, fault)) { 1228 1228 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); … … 1231 1231 } 1232 1232 psFree(where); 1233 1233 1234 1234 return true; 1235 1235 } … … 1237 1237 1238 1238 static bool finishcompressexpMode(pxConfig *config) { 1239 1239 1240 1240 PS_ASSERT_PTR_NON_NULL(config, false); 1241 1241 1242 1242 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1243 1243 1244 1244 psMetadata *where = psMetadataAlloc(); 1245 1245 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 1246 1246 1247 1247 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1248 1248 1249 1249 psString query = pxDataGet("regtool_finishcompressexp.sql"); 1250 1250 if (!query) { … … 1258 1258 } 1259 1259 psFree(where); 1260 1260 1261 1261 if (limit) { 1262 1262 psString limitString = psDBGenerateLimitSQL(limit); … … 1272 1272 } 1273 1273 psFree(query); 1274 1274 1275 1275 psArray *output = p_psDBFetchResult(config->dbh); 1276 1276 if (!output) { … … 1283 1283 return(true); 1284 1284 } 1285 1285 1286 1286 for (long i = 0; i < psArrayLength(output); i++) { 1287 1287 psMetadata *md = output->data[i]; 1288 1288 1289 1289 rawExpRow *row = rawExpObjectFromMetadata(md); 1290 1290 if (!psDBTransaction(config->dbh)) { … … 1292 1292 return(false); 1293 1293 } 1294 1294 1295 1295 if (strcmp(row->state,"goto_compressed") == 0) { 1296 1296 if (!pxrawExpSetState(config,row->exp_id, "compressed")) { 1297 psError(PS_ERR_UNKNOWN, false, "failed to set rawExp.state for exp_id: %" PRId64, row->exp_id);1298 psFree(row);1299 psFree(output);1300 return(false);1297 psError(PS_ERR_UNKNOWN, false, "failed to set rawExp.state for exp_id: %" PRId64, row->exp_id); 1298 psFree(row); 1299 psFree(output); 1300 return(false); 1301 1301 } 1302 1302 } 1303 1303 else if (strcmp(row->state,"goto_lossy") == 0) { 1304 1304 if (!pxrawExpSetState(config,row->exp_id, "lossy")) { 1305 psError(PS_ERR_UNKNOWN, false, "failed to set rawExp.state for exp_id: %" PRId64, row->exp_id);1306 psFree(row);1307 psFree(output);1308 return(false);1305 psError(PS_ERR_UNKNOWN, false, "failed to set rawExp.state for exp_id: %" PRId64, row->exp_id); 1306 psFree(row); 1307 psFree(output); 1308 return(false); 1309 1309 } 1310 1310 } … … 1315 1315 psFree(row); 1316 1316 } 1317 1317 1318 1318 psFree(output); 1319 1319 return(true); … … 1324 1324 1325 1325 PXOPT_LOOKUP_STR(set_state, config->args, "-set_state", true, false); 1326 1326 1327 1327 // XX test this out; need to make this consistent with the list in regtoolConfig.c 1328 1328 psMetadata *where = psMetadataAlloc(); … … 1399 1399 psFree(query); 1400 1400 // Now up date the exposure. 1401 query = pxDataGet("regtool_updatebyquery.sql"); 1401 query = pxDataGet("regtool_updatebyquery.sql"); 1402 1402 if (!query) { 1403 1403 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); … … 1412 1412 return(false); 1413 1413 } 1414 1414 1415 1415 psFree(limitString); 1416 1416 psFree(query); 1417 1417 psFree(whereClause); 1418 1418 psFree(where); 1419 1419 1420 1420 return true; 1421 1421 } 1422 1422 1423 1423 1424 1424 1425 1425 static bool cleardupexpMode(pxConfig *config)
Note:
See TracChangeset
for help on using the changeset viewer.
