Changeset 21433 for trunk/ippTools/src/magicdstool.c
- Timestamp:
- Feb 10, 2009, 11:01:23 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/magicdstool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/magicdstool.c
r21402 r21433 43 43 static bool magicDSGetIDs(pxConfig *config, psString stage, psS64 magic_id, psS64 *stage_id, psS64 *cam_id); 44 44 45 #ifdef notdef46 static bool toprocessMode(pxConfig *config);47 static bool addresultMode(pxConfig *config);48 static bool revertnodeMode(pxConfig *config);49 static bool inputsMode(pxConfig *config);50 static bool tomaskMode(pxConfig *config);51 static bool addmaskMode(pxConfig *config);52 static bool revertmaskMode(pxConfig *config);53 static bool maskMode(pxConfig *config);54 static bool diffskyfileMode(pxConfig *config);55 static bool warpskyfileMode(pxConfig *config);56 static bool chipprocessedimfileMode(pxConfig *config);57 static bool rawimfileMode(pxConfig *config);58 59 static bool setmagicRunState(pxConfig *config, psS64 magic_id, const char *state);60 static bool parseAndInsertNodeDeps(pxConfig *config, psS64 magic_id, const char *filename);61 #endif62 63 45 # define MODECASE(caseName, func) \ 64 46 case caseName: \ … … 482 464 483 465 466 static bool 467 setMagicked(pxConfig *config, psS64 magic_ds_id, psString component) 468 { 469 // first query the magicDSRun to find the stage and the stage_id 470 psString query = "SELECT stage, stage_id from magicDSRun where magic_ds_id = %" PRId64; 471 472 if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id)) { 473 psError(PS_ERR_UNKNOWN, false, "database error"); 474 return false; 475 } 476 477 psArray *output = p_psDBFetchResult(config->dbh); 478 if (!output) { 479 psError(PS_ERR_UNKNOWN, false, "database error"); 480 return false; 481 } 482 if (!psArrayLength(output)) { 483 psTrace("magicdstool", PS_LOG_INFO, "magic_ds_id: %" PRId64 " not found", magic_ds_id); 484 psFree(output); 485 return true; 486 } 487 if (psArrayLength(output) > 1) { 488 psError(PS_ERR_UNKNOWN, true, "unexpected number of rows found %ld for magic_ds_id %" PRId64, 489 psArrayLength(output), magic_ds_id); 490 psFree(output); 491 return false; 492 } 493 psMetadata *row = output->data[0]; 494 495 psString stage = psMetadataLookupStr(NULL, row, "stage"); 496 psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id"); 497 498 499 // chose the appropriate query based on the stage 500 if (!strcmp(stage, "raw")) { 501 query = "UPDATE rawImfile SET magicked = 1 where exp_id = %" PRId64 " AND class_id = '%s'"; 502 } else if (!strcmp(stage, "chip")) { 503 query = "UPDATE chipProcessedImfile SET magicked = 1 where chip_id = %" PRId64 " AND class_id = '%s'"; 504 } else if (!strcmp(stage, "warp")) { 505 query = "UPDATE warpSkyfile SET magicked = 1 where warp_id = %" PRId64 " AND skycell_id = '%s'"; 506 } else if (!strcmp(stage, "diff")) { 507 query = "UPDATE diffSkyfile SET magicked = 1 where diff_id = %" PRId64 " AND skycell_id = '%s'"; 508 } else { 509 psError(PS_ERR_UNKNOWN, true, "unexpected value for stage: %s found", stage); 510 psFree(output); 511 return false; 512 } 513 if (!p_psDBRunQueryF(config->dbh, query, stage_id, component)) { 514 psError(PS_ERR_UNKNOWN, false, "database error"); 515 return false; 516 } 517 psFree(output); 518 519 psU64 affected = psDBAffectedRows(config->dbh); 520 if (affected != 1) { 521 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row"); 522 return false; 523 } 524 525 return true; 526 } 527 484 528 static bool adddestreakedfileMode(pxConfig *config) 485 529 { … … 494 538 PXOPT_LOOKUP_STR(backup_path_base, config->args, "-backup_path_base", false, false); 495 539 PXOPT_LOOKUP_STR(recovery_path_base, config->args, "-recovery_path_base", false, false); 540 PXOPT_LOOKUP_BOOL(setmagicked, config->args, "-setmagicked", false); 541 542 if (setmagicked && (code != 0)) { 543 psError(PS_ERR_UNKNOWN, true, " cannot setmagicked for faulted file"); 544 return false; 545 } 496 546 497 547 if (!psDBTransaction(config->dbh)) { … … 500 550 } 501 551 552 if (setmagicked) { 553 if (!setMagicked(config, magic_ds_id, component)) { 554 psError(PS_ERR_UNKNOWN, false, "setMagicked failed"); 555 return false; 556 } 557 } 502 558 503 559 if (!magicDSFileInsert(config->dbh, magic_ds_id, component, backup_path_base, recovery_path_base, code)) {
Note:
See TracChangeset
for help on using the changeset viewer.
