Changeset 26567 for trunk/ippTools/src/magicdstool.c
- Timestamp:
- Jan 12, 2010, 2:07:51 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/magicdstool.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/magicdstool.c
r26495 r26567 44 44 static bool tocleanupMode(pxConfig *config); 45 45 46 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, ps Metadata *where, const char *state);46 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, psString extraSetString, psMetadata *where, const char *state); 47 47 48 48 # define MODECASE(caseName, func) \ … … 326 326 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 327 327 328 // optional 329 PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false); 330 psString setString = NULL; 331 if (set_label) { 332 psStringAppend(&setString, ", label = '%s'", set_label); 333 } 334 328 335 PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", false, false); 329 336 if (magic_ds_id) { 330 337 331 return setmagicDSRunState(config, magic_ds_id, NULL, state);338 return setmagicDSRunState(config, magic_ds_id, setString, NULL, state); 332 339 333 340 } else if (!strcmp(state, "full")) { … … 336 343 } 337 344 // we can transition by query as well 345 338 346 339 347 psMetadata *where = psMetadataAlloc(); … … 342 350 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); 343 351 344 345 352 if (psListLength(where->list) < 2) { 346 353 psError(PS_ERR_UNKNOWN, true, "at least 2 search arguments are required"); … … 353 360 psMetadataAddS32(where, PS_LIST_TAIL, "re_place", 0, ">", 0); 354 361 } 355 bool result = setmagicDSRunState(config, magic_ds_id, where, state);362 bool result = setmagicDSRunState(config, magic_ds_id, setString, where, state); 356 363 psFree(where); 357 364 … … 445 452 { 446 453 // first query the magicDSRun to find the stage and the stage_id 447 psString query = "SELECT stage, stage_id from magicDSRun where magic_ds_id = %" PRId64;454 psString query = "SELECT stage, stage_id, magic_id from magicDSRun where magic_ds_id = %" PRId64; 448 455 449 456 if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id)) { … … 472 479 psString stage= psMetadataLookupStr(NULL, row, "stage"); 473 480 psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id"); 481 psS64 magic_id = psMetadataLookupS64(NULL, row, "magic_id"); 474 482 475 483 ippStage stageNum = ippStringToStage(stage); … … 499 507 } 500 508 501 if (!p_psDBRunQueryF(config->dbh, query, magic_ ds_id, stage_id, component)) {509 if (!p_psDBRunQueryF(config->dbh, query, magic_id, stage_id, component)) { 502 510 psError(PS_ERR_UNKNOWN, false, "database error"); 503 511 return false; … … 518 526 { 519 527 // first query the magicDSRun to find the stage and the stage_id 520 psString query = "SELECT stage, stage_id from magicDSRun where magic_ds_id = %" PRId64;528 psString query = "SELECT stage, stage_id, magic_id from magicDSRun where magic_ds_id = %" PRId64; 521 529 522 530 if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id)) { … … 545 553 psString stage = psMetadataLookupStr(NULL, row, "stage"); 546 554 psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id"); 555 psS64 magic_id = psMetadataLookupS64(NULL, row, "magic_id"); 547 556 548 557 ippStage stageNum = ippStringToStage(stage); … … 570 579 return false; 571 580 } 572 if (!p_psDBRunQueryF(config->dbh, query, magic_ ds_id, stage_id)) {581 if (!p_psDBRunQueryF(config->dbh, query, magic_id, stage_id)) { 573 582 psError(PS_ERR_UNKNOWN, false, "database error"); 574 583 return false; … … 710 719 711 720 // set magicDSRun.state to 'full' 712 if (!setmagicDSRunState(config, magic_ds_id, NULL, "full")) {721 if (!setmagicDSRunState(config, magic_ds_id, NULL, NULL, "full")) { 713 722 psError(PS_ERR_UNKNOWN, false, "failed to change magicDSRun.state for magic_ds_id: %" PRId64, 714 723 magic_ds_id); … … 927 936 } 928 937 929 static bool setmagicDSRunState(pxConfig *config, psS64 magic_ds_id, ps Metadata *where, const char *state)938 static bool setmagicDSRunState(pxConfig *config, psS64 magic_ds_id, psString extraSetStr, psMetadata *where, const char *state) 930 939 { 931 940 PS_ASSERT_PTR_NON_NULL(state, false); … … 937 946 } 938 947 939 psString query = psStringCopy("UPDATE magicDSRun SET state = '%s'"); 948 psString query = NULL; 949 psStringAppend(&query, "UPDATE magicDSRun SET state = '%s' %s\n", state, extraSetStr ? extraSetStr : ""); 940 950 if (magic_ds_id) { 941 951 psStringAppend(&query, " WHERE magic_ds_id = %" PRId64, magic_ds_id); … … 949 959 } 950 960 951 if (!p_psDBRunQuery F(config->dbh, query, state)) {961 if (!p_psDBRunQuery(config->dbh, query)) { 952 962 psError(PS_ERR_UNKNOWN, false, 953 963 "failed to change state for magic_id %" PRId64, magic_ds_id);
Note:
See TracChangeset
for help on using the changeset viewer.
