Changeset 28364
- Timestamp:
- Jun 16, 2010, 2:41:22 PM (16 years ago)
- Location:
- trunk/ippTools
- Files:
-
- 2 edited
-
share/diffphottool_advance.sql (modified) (1 diff)
-
src/diffphottool.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/share/diffphottool_advance.sql
r28343 r28364 1 UPDATE diffPhotRun 2 SET state = 'full' 3 WHERE diff_phot_id IN ( 4 SELECT 5 diff_phot_id 6 FROM diffPhotRun 7 JOIN diffSkyfile USING(diff_id) 8 JOIN diffPhotSkyfile USING(diff_phot_id) 9 WHERE diffPhotRun.state = 'new' 10 AND diffPhotSkyfile.fault = 0 11 AND diffSkyfile.fault = 0 12 AND diffSkyfile.quality = 0 13 -- WHERE hook %s 14 HAVING COUNT(diffPhotSkyfile.skycell_id) = COUNT(diffSkyfile.skycell_id) 15 ) AS diffPhotRunsDone 1 SELECT 2 diff_phot_id 3 FROM diffPhotRun 4 JOIN diffSkyfile USING(diff_id) 5 JOIN diffPhotSkyfile USING(diff_phot_id) 6 WHERE diffPhotRun.state = 'new' 7 AND diffPhotSkyfile.fault = 0 8 AND diffSkyfile.fault = 0 9 AND diffSkyfile.quality = 0 10 -- WHERE hook %s 11 HAVING COUNT(diffPhotSkyfile.skycell_id) = COUNT(diffSkyfile.skycell_id) -
trunk/ippTools/src/diffphottool.c
r28358 r28364 126 126 127 127 if (!psDBTransaction(config->dbh)) { 128 psError( PS_ERR_UNKNOWN, false, "database error");128 psError(psErrorCodeLast(), false, "database error"); 129 129 return false; 130 130 } 131 131 132 132 if (!p_psDBRunQuery(config->dbh, query)) { 133 psError( PS_ERR_UNKNOWN, false, "Unable to run query: %s", query);133 psError(psErrorCodeLast(), false, "Unable to run query: %s", query); 134 134 psFree(where); 135 135 return false; … … 326 326 327 327 if (!p_psDBRunQuery(config->dbh, query)) { 328 psError( PS_ERR_UNKNOWN, false, "database error");328 psError(psErrorCodeLast(), false, "database error"); 329 329 psFree(query); 330 330 return false; … … 376 376 if (!diffPhotSkyfileInsert(config->dbh, diff_phot_id, skycell_id, path_base, dtime_script, hostname, 377 377 fault, quality, version)) { 378 psError( PS_ERR_UNKNOWN, false, "database error");378 psError(psErrorCodeLast(), false, "database error"); 379 379 return false; 380 380 } … … 405 405 psFree(where); 406 406 407 if (!psDBTransaction(config->dbh)) { 408 psError(psErrorCodeLast(), false, "database error"); 409 return false; 410 } 411 407 412 if (!p_psDBRunQueryF(config->dbh, query, whereClause)) { 408 413 psError(psErrorCodeLast(), false, "database error"); 409 414 psFree(query); 410 psFree(whereClause);411 415 return false; 412 416 } 413 417 psFree(query); 414 psFree(whereClause) 418 psFree(whereClause); 419 420 psArray *output = p_psDBFetchResult(config->dbh); 421 if (!output) { 422 psError(psErrorCodeLast(), false, "database error"); 423 return false; 424 } 425 426 for (int i = 0; i < output->n; i++) { 427 psMetadata *row = output->data[i]; // Row of interest 428 psS64 diff_phot_id = psMetadataLookupS64(NULL, row, "diff_phot_id"); 429 430 const char *query = "UPDATE diffRun SET state = 'full' WHERE diff_id = %" PRId64; 431 if (!p_psDBRunQueryF(config->dbh, query, diff_phot_id)) { 432 psError(psErrorCodeLast(), false, 433 "failed to change state for diff_phot_id %" PRId64, diff_phot_id); 434 if (!psDBRollback(config->dbh)) { 435 psError(psErrorCodeLast(), false, "database error"); 436 } 437 psFree(output); 438 return false; 439 } 440 } 441 psFree(output); 442 443 if (!psDBCommit(config->dbh)) { 444 psError(psErrorCodeLast(), false, "database error"); 445 return false; 446 } 415 447 416 448 return true; … … 449 481 450 482 if (!p_psDBRunQuery(config->dbh, query)) { 451 psError( PS_ERR_UNKNOWN, false, "database error");483 psError(psErrorCodeLast(), false, "database error"); 452 484 psFree(query); 453 485 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
