Changeset 18561 for trunk/ippTools/src/pstamptool.c
- Timestamp:
- Jul 15, 2008, 10:30:59 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pstamptool.c (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pstamptool.c
r18531 r18561 102 102 PS_ASSERT_PTR_NON_NULL(config, false); 103 103 104 bool status = false; 105 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 106 if (!status) { 107 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 108 return false; 109 } 110 if (!uri) { 111 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 112 return false; 113 } 114 psString outProduct = psMetadataLookupStr(&status, config->args, "-out_product"); 115 if (!status) { 116 psError(PS_ERR_UNKNOWN, false, "failed to looku value for -out_product"); 117 return false; 118 } 119 if (!outProduct) { 120 psError(PS_ERR_UNKNOWN, true, "-out_product is required"); 121 return false; 122 } 123 124 psString lastFileset = psMetadataLookupStr(&status, config->args, "-last_fileset"); 125 psString state = psMetadataLookupStr(&status, config->args, "-state"); 126 if (!state) { 127 state = "enabled"; 128 } 104 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); 105 PXOPT_LOOKUP_STR(outProduct, config->args, "-out_product", true, false); 106 PXOPT_LOOKUP_STR(lastFileset, config->args, "-last_fileset", false, false); 107 PXOPT_LOOKUP_STR(state, config->args, "-state", false, false); 129 108 130 109 if (!pstampDataStoreInsert(config->dbh, … … 144 123 static bool datastoreMode(pxConfig *config) 145 124 { 146 bool status = false; 147 PS_ASSERT_PTR_NON_NULL(config, false); 148 149 psString ds_id = psMetadataLookupStr(&status, config->args, "-ds_id"); 150 if (!status) { 151 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ds_id"); 152 return false; 153 } 154 155 psString query = NULL; 156 psStringAppend(&query, "SELECT * FROM pstampDataStore"); 157 if (ds_id) { 158 psStringAppend(&query, " WHERE ds_id = '%s'", ds_id); 159 } 125 PS_ASSERT_PTR_NON_NULL(config, false); 126 127 psMetadata *where = psMetadataAlloc(); 128 PXOPT_COPY_STR(config->args, where, "-ds_id", "ds_id", "=="); 129 130 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 131 132 psString query = pxDataGet("pstamptool_datastore.sql"); 133 if (!query) { 134 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 135 return false; 136 } 137 138 if (psListLength(where->list)) { 139 psString whereClause = psDBGenerateWhereSQL(where, NULL); 140 psStringAppend(&query, " %s", whereClause); 141 psFree(whereClause); 142 } 143 psFree(where); 144 160 145 if (!p_psDBRunQuery(config->dbh, query)) { 161 146 psError(PS_ERR_UNKNOWN, false, "database error"); … … 172 157 psFree(output); 173 158 return true; 174 }175 176 bool simple = false;177 {178 bool status = false;179 simple = psMetadataLookupBool(&status, config->args, "-simple");180 if (!status) {181 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");182 return false;183 }184 159 } 185 160 … … 197 172 static bool moddatastoreMode(pxConfig *config) 198 173 { 199 bool status; 200 201 PS_ASSERT_PTR_NON_NULL(config, false); 202 203 psString ds_id = psMetadataLookupStr(&status, config->args, "-ds_id"); 204 if (!status) { 205 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ds_id"); 206 return false; 207 } 208 if (!ds_id) { 209 psError(PS_ERR_UNKNOWN, true, "-ds_id is required"); 210 return false; 211 } 212 psString lastFileset = psMetadataLookupStr(&status, config->args, "-last_fileset"); 213 if (!status) { 214 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -last_fileset"); 215 return false; 216 } 217 psString state = psMetadataLookupStr(&status, config->args, "-state"); 218 if (!status) { 219 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state"); 220 return false; 221 } 174 PS_ASSERT_PTR_NON_NULL(config, false); 175 176 PXOPT_LOOKUP_STR(ds_id, config->args, "-ds_id", true, false); 177 PXOPT_LOOKUP_STR(lastFileset, config->args, "-last_fileset", false, false); 178 PXOPT_LOOKUP_STR(state, config->args, "-state", false, false); 222 179 223 180 if (!state && !lastFileset) { … … 226 183 } 227 184 228 char *query = NULL;185 char *query = psStringCopy ("UPDATE pstampDataStore SET"); 229 186 bool needComma = false; 230 187 231 psStringAppend(&query, "UPDATE pstampDataStore SET");232 233 188 if (lastFileset) { 234 189 psStringAppend(&query, " lastFileset = '%s'", lastFileset); … … 237 192 238 193 if (state) { 239 psStringAppend(&query, "%s state = '%s'", needComma ? "," : " ", 240 state); 194 psStringAppend(&query, "%s state = '%s'", needComma ? "," : " ", state); 241 195 needComma = true; // be ready in case we add another field 242 196 } … … 262 216 static bool addReqMode(pxConfig *config) 263 217 { 264 bool status; 265 266 PS_ASSERT_PTR_NON_NULL(config, false); 267 268 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 269 if (!status) { 270 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 271 return false; 272 } 273 if (!uri) { 274 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 275 return false; 276 } 277 278 // Data Store ID is optional 279 psString ds_id = psMetadataLookupStr(&status, config->args, "-ds_id"); 280 if (!status) { 281 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ds_id"); 282 return false; 283 } 284 if (!ds_id) { 285 ds_id = "0"; 286 } 218 PS_ASSERT_PTR_NON_NULL(config, false); 219 220 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); 221 // PXOPT_LOOKUP_STR(outFileset, config->args, "-out_fileset", true, false); 222 PXOPT_LOOKUP_STR(ds_id, config->args, "-ds_id", false, false); 287 223 288 224 char *query ="INSERT INTO pstampRequest" … … 313 249 PS_ASSERT_PTR_NON_NULL(config, false); 314 250 315 bool status = false; 316 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 317 if (!status) { 318 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 319 return false; 320 } 321 322 psString query = psStringCopy( 323 "SELECT" 324 " *" 325 " FROM pstampRequest" 326 " WHERE state = 'new'" 327 ); 328 329 if (config->where) { 330 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "pstampRequest"); 251 psMetadata *where = psMetadataAlloc(); 252 PXOPT_COPY_STR(config->args, where, "-ds_id", "ds_id", "=="); 253 254 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 255 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 256 257 psString query = pxDataGet("pstamptool_pendingreq.sql"); 258 if (!query) { 259 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 260 return false; 261 } 262 263 if (psListLength(where->list)) { 264 psString whereClause = psDBGenerateWhereConditionSQL(where, "pstampRequest"); 331 265 psStringAppend(&query, " AND %s", whereClause); 332 266 psFree(whereClause); 333 267 } 268 psFree(where); 334 269 335 270 // treat limit == 0 as "no limit" … … 358 293 } 359 294 360 bool simple = false;361 {362 bool status = false;363 simple = psMetadataLookupBool(&status, config->args, "-simple");364 if (!status) {365 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");366 psFree(output);367 return false;368 }369 }370 371 295 // negative simple so the default is true 372 296 if (!ippdbPrintMetadatas(stdout, output, "pstampRequest", !simple)) { … … 380 304 return true; 381 305 } 382 static bool completedReqMode(pxConfig *config) 383 { 384 PS_ASSERT_PTR_NON_NULL(config, false); 385 386 bool status = false; 387 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 388 if (!status) { 389 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 390 return false; 391 } 306 307 static bool listReqMode(pxConfig *config) 308 { 309 PS_ASSERT_PTR_NON_NULL(config, false); 310 311 PXOPT_LOOKUP_STR(req_id, config->args, "-req_id", true, false); 312 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 313 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 392 314 393 315 psString query = NULL; 394 316 psStringAppend(&query, 395 "SELECT * FROM pstampRequest WHERE state = 'run' AND "396 "(SELECT count(*) FROM pstampJob WHERE pstampJob.req_id = pstampRequest.req_id "397 " AND pstampJob.state != 'stop') = 0" );398 317 "SELECT * FROM pstampRequest WHERE state = 'run' AND " 318 "(SELECT count(*) FROM pstampJob WHERE pstampJob.req_id = pstampRequest.req_id " 319 " AND pstampJob.state != 'stop') = 0" ); 320 399 321 // treat limit == 0 as "no limit" 400 322 if (limit) { … … 409 331 return false; 410 332 } 333 psFree(query); 411 334 412 335 psArray *output = p_psDBFetchResult(config->dbh); … … 415 338 return false; 416 339 } 417 418 340 if (!psArrayLength(output)) { 419 341 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 420 342 psFree(output); 421 343 return true; 422 }423 424 bool simple = false;425 {426 bool status = false;427 simple = psMetadataLookupBool(&status, config->args, "-simple");428 if (!status) {429 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");430 psFree(output);431 return false;432 }433 344 } 434 345 … … 445 356 } 446 357 447 static bool listReqMode(pxConfig *config) 448 { 449 PS_ASSERT_PTR_NON_NULL(config, false); 450 451 bool status = false; 452 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 453 if (!status) { 454 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 455 return false; 456 } 457 458 psString query = NULL; 459 460 psString req_id = psMetadataLookupStr(&status, config->args, "-req_id"); 461 462 if (req_id) { 463 psStringAppend(&query, 464 "SELECT" 465 " *" 466 " FROM pstampRequest" 467 " WHERE req_id = %s", req_id 468 ); 469 } else { 470 fprintf(stderr, "req_id must be specified\n"); 471 exit (1); 472 } 358 static bool completedReqMode(pxConfig *config) 359 { 360 PS_ASSERT_PTR_NON_NULL(config, false); 361 362 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 363 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 364 365 psString query = 366 "SELECT * FROM pstampRequest WHERE state = 'run' AND " 367 "(SELECT count(*) FROM pstampJob WHERE pstampJob.req_id = pstampRequest.req_id " 368 " AND pstampJob.state != 'stop') = 0" ; 473 369 474 370 // treat limit == 0 as "no limit" … … 484 380 return false; 485 381 } 486 psFree(query);487 382 488 383 psArray *output = p_psDBFetchResult(config->dbh); … … 491 386 return false; 492 387 } 388 493 389 if (!psArrayLength(output)) { 494 390 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 495 391 psFree(output); 496 392 return true; 497 }498 499 bool simple = false;500 {501 bool status = false;502 simple = psMetadataLookupBool(&status, config->args, "-simple");503 if (!status) {504 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");505 psFree(output);506 return false;507 }508 393 } 509 394 … … 522 407 static bool processedReqMode(pxConfig *config) 523 408 { 524 bool status; 525 526 PS_ASSERT_PTR_NON_NULL(config, false); 527 528 psString req_id = psMetadataLookupStr(&status, config->args, "-req_id"); 529 if (!status) { 530 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -req_id"); 531 return false; 532 } 533 if (!req_id) { 534 psError(PS_ERR_UNKNOWN, true, "-req_id is required"); 535 return false; 536 } 537 psString state = psMetadataLookupStr(&status, config->args, "-state"); 538 if (!status) { 539 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state"); 540 return false; 541 } 542 psString outProduct = psMetadataLookupStr(&status, config->args, "-outProduct"); 543 if (!status) { 544 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -outProduct"); 545 return false; 546 } 547 psString fault = psMetadataLookupStr(&status, config->args, "-fault"); 548 if (!status) { 549 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fault"); 550 return false; 551 } 552 553 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 554 if (!status) { 555 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 556 return false; 557 } 558 psString name = psMetadataLookupStr(&status, config->args, "-name"); 559 if (!status) { 560 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -name"); 561 return false; 562 } 563 psString reqType = psMetadataLookupStr(&status, config->args, "-reqType"); 564 if (!status) { 565 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -reqType"); 566 return false; 567 } 409 PS_ASSERT_PTR_NON_NULL(config, false); 410 411 PXOPT_LOOKUP_STR(req_id, config->args, "-req_id", true, false); 412 PXOPT_LOOKUP_STR(state, config->args, "-state", false, false); 413 PXOPT_LOOKUP_STR(outProduct, config->args, "-outProduct", false, false); 414 PXOPT_LOOKUP_STR(fault, config->args, "-fault", false, false); 415 PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false); 416 PXOPT_LOOKUP_STR(name, config->args, "-name", false, false); 417 PXOPT_LOOKUP_STR(reqType, config->args, "-reqType", false, false); 568 418 569 419 psString query = NULL; … … 621 471 static bool revertReqMode(pxConfig *config) 622 472 { 623 bool status; 624 625 PS_ASSERT_PTR_NON_NULL(config, false); 626 627 psS64 req_id = psMetadataLookupS64(&status, config->args, "-req_id"); 628 if (!status) { 629 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -req_id"); 630 return false; 631 } 632 if (!req_id) { 633 psError(PS_ERR_UNKNOWN, true, "-req_id is required"); 634 return false; 635 } 636 473 PS_ASSERT_PTR_NON_NULL(config, false); 474 475 PXOPT_LOOKUP_S64(req_id, config->args, "-req_id", true, false); 637 476 638 477 printf("Revert request %" PRId64 "\n", req_id); … … 653 492 static bool addJobMode(pxConfig *config) 654 493 { 655 bool status;656 494 bool stampJob = false; 657 658 PS_ASSERT_PTR_NON_NULL(config, false); 659 660 psString job_type = psMetadataLookupStr(&status, config->args, "-job_type"); 661 if (!status) { 662 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -job_type"); 663 return false; 664 } 665 if (job_type) { 666 if (!strcmp(job_type, "get_image") || !strcmp(job_type, "detect_query")) { 667 stampJob = false; 668 } else if (!strcmp(job_type, "stamp")) { 669 stampJob = true; 670 } else { 671 psError(PS_ERR_UNKNOWN, false, "unknown value for -job_type: %s", job_type); 672 return false; 673 } 495 char *query = NULL; 496 497 PS_ASSERT_PTR_NON_NULL(config, false); 498 499 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); 500 PXOPT_LOOKUP_STR(req_id, config->args, "-req_id", true, false); 501 PXOPT_LOOKUP_STR(rownum, config->args, "-rownum", true, false); 502 PXOPT_LOOKUP_STR(job_type, config->args, "-job_type", false, false); 503 PXOPT_LOOKUP_STR(outputBase, config->args, "-outputBase", true, false); 504 PXOPT_LOOKUP_STR(argString, config->args, "-args", false, false); 505 PXOPT_LOOKUP_STR(stateString, config->args, "-state", false, false); 506 PXOPT_LOOKUP_STR(fault, config->args, "-fault", false, false); 507 508 // default value for job_type is defined in pstamptoolConfig.c 509 if (!strcmp(job_type, "get_image") || !strcmp(job_type, "detect_query")) { 510 stampJob = false; 511 } else if (!strcmp(job_type, "stamp")) { 512 stampJob = true; 674 513 } else { 675 job_type = "stamp"; 676 stampJob = true; 677 } 678 679 psString rownum = psMetadataLookupStr(&status, config->args, "-rownum"); 680 if (!status) { 681 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -rownum"); 682 return false; 683 } 684 if (!rownum) { 685 psError(PS_ERR_UNKNOWN, true, "-rownum is required"); 686 return false; 687 } 688 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 689 if (!status) { 690 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 691 return false; 692 } 693 if (!uri) { 694 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 695 return false; 696 } 697 698 psString req_id = psMetadataLookupStr(&status, config->args, "-req_id"); 699 if (!status) { 700 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -req_id"); 701 return false; 702 } 703 if (!req_id) { 704 psError(PS_ERR_UNKNOWN, true, "-req_id is required"); 705 return false; 706 } 707 708 psString outputBase = psMetadataLookupStr(&status, config->args, "-outputBase"); 709 if (!status) { 710 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -outputBase"); 711 return false; 712 } 713 if (!outputBase) { 714 psError(PS_ERR_UNKNOWN, true, "-outputBase is required"); 715 return false; 716 } 717 718 psString argString = psMetadataLookupStr(&status, config->args, "-args"); 719 if (!status) { 720 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -args"); 721 return false; 722 } 723 if (!argString) { 724 if (stampJob) { 725 psError(PS_ERR_UNKNOWN, true, "-args is required"); 726 return false; 727 } 728 } 729 730 psString stateString = psMetadataLookupStr(&status, config->args, "-state"); 731 if (!status) { 732 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state"); 733 return false; 734 } 735 if (!stateString) { 736 stateString = "run"; 737 } 738 psString fault = psMetadataLookupStr(&status, config->args, "-fault"); 739 if (!status) { 740 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fault"); 741 return false; 742 } 743 if (!fault) { 744 fault = "0"; 745 } 746 747 char *query; 748 514 psError(PS_ERR_UNKNOWN, false, "unknown value for -job_type: %s", job_type); 515 return false; 516 } 517 518 if (stampJob && !argString) { 519 psError(PS_ERR_UNKNOWN, true, "-args is required for stamp job"); 520 return false; 521 } 522 749 523 if (stampJob) { 750 query ="INSERT INTO pstampJob" 751 " (req_id, rownum, state, jobType, uri, outputBase, fault, args)" 752 " VALUES( %s, '%s', '%s', '%s', '%s', '%s', %s, '%s')"; 524 query = pxDataGet("pstamptool_addjob_stampjob.sql"); 753 525 } else { 754 query ="INSERT INTO pstampJob" 755 " (req_id, rownum, state, jobType, uri, outputBase, fault)" 756 " VALUES( %s, '%s', '%s', '%s', '%s', '%s', %s)"; 526 query = pxDataGet("pstamptool_addjob_otherjob.sql"); 527 } 528 if (!query) { 529 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 530 return false; 757 531 } 758 532 … … 780 554 PS_ASSERT_PTR_NON_NULL(config, false); 781 555 782 bool status = false; 783 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 784 if (!status) { 785 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 786 return false; 787 } 556 PXOPT_LOOKUP_STR(req_id, config->args, "-req_id", false, false); 557 PXOPT_LOOKUP_STR(job_id, config->args, "-job_id", false, false); 558 559 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 560 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 788 561 789 562 psString query = NULL; 790 563 791 psString req_id = psMetadataLookupStr(&status, config->args, "-req_id"); 792 psString job_id = psMetadataLookupStr(&status, config->args, "-job_id"); 793 564 if (!req_id && !job_id) { 565 fprintf(stderr, "either req_id or job_id must be specified\n"); 566 exit (1); 567 } 568 794 569 if (req_id) { 795 570 psStringAppend(&query, … … 799 574 " WHERE req_id = %s", req_id 800 575 ); 801 } else if (job_id){576 } else { 802 577 psStringAppend(&query, 803 578 "SELECT" … … 806 581 " WHERE job_id = %s", job_id 807 582 ); 808 } else { 809 fprintf(stderr, "either req_id or job_id must be specified\n"); 810 exit (1); 811 } 583 } 812 584 813 585 // treat limit == 0 as "no limit" … … 836 608 } 837 609 838 bool simple = false;839 {840 bool status = false;841 simple = psMetadataLookupBool(&status, config->args, "-simple");842 if (!status) {843 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");844 psFree(output);845 return false;846 }847 }848 849 610 // negative simple so the default is true 850 611 if (!ippdbPrintMetadatas(stdout, output, "pstampJob", !simple)) { … … 863 624 PS_ASSERT_PTR_NON_NULL(config, false); 864 625 865 bool status = false; 866 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 867 if (!status) { 868 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 869 return false; 870 } 871 872 psString query = psStringCopy( 873 "SELECT" 874 " *" 875 " FROM pstampJob" 876 " WHERE state = 'run'" 877 ); 878 879 if (config->where) { 880 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "pstampJob"); 626 psMetadata *where = psMetadataAlloc(); 627 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "=="); 628 629 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 630 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 631 632 psString query = pxDataGet("pstamptool_pendingjob.sql"); 633 if (!query) { 634 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 635 return false; 636 } 637 638 // use psDBGenerateWhereSQL because the SQL yields an intermediate table 639 if (psListLength(where->list)) { 640 psString whereClause = psDBGenerateWhereConditionSQL(where, "pstampJob"); 881 641 psStringAppend(&query, " AND %s", whereClause); 882 642 psFree(whereClause); 883 643 } 644 psFree(where); 884 645 885 646 // treat limit == 0 as "no limit" … … 908 669 } 909 670 910 bool simple = false;911 {912 bool status = false;913 simple = psMetadataLookupBool(&status, config->args, "-simple");914 if (!status) {915 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");916 psFree(output);917 return false;918 }919 }920 921 671 // negative simple so the default is true 922 672 if (!ippdbPrintMetadatas(stdout, output, "pstampJob", !simple)) { … … 933 683 static bool processedJobMode(pxConfig *config) 934 684 { 935 bool status; 936 937 PS_ASSERT_PTR_NON_NULL(config, false); 938 939 psString job_id = psMetadataLookupStr(&status, config->args, "-job_id"); 940 if (!status) { 941 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -job_id"); 942 return false; 943 } 944 if (!job_id) { 945 psError(PS_ERR_UNKNOWN, true, "-job_id is required"); 946 return false; 947 } 948 psString state = psMetadataLookupStr(&status, config->args, "-state"); 949 if (!status) { 950 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state"); 951 return false; 952 } 953 if (!state) { 954 psError(PS_ERR_UNKNOWN, true, "-state is required"); 955 return false; 956 } 957 psString fault = psMetadataLookupStr(&status, config->args, "-fault"); 958 if (!status) { 959 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fault"); 960 return false; 961 } 685 PS_ASSERT_PTR_NON_NULL(config, false); 686 687 PXOPT_LOOKUP_STR(job_id, config->args, "-job_id", true, false); 688 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 689 PXOPT_LOOKUP_STR(fault, config->args, "-fault", false, false); 962 690 963 691 psString faultStr = NULL; … … 967 695 psStringAppend(&faultStr, ", fault = '%s'", fault); 968 696 } 969 697 970 698 char *query ="UPDATE pstampJob" 971 " SET state = '%s' %s"972 " WHERE job_id = '%s'";973 699 " SET state = '%s' %s" 700 " WHERE job_id = '%s'"; 701 974 702 if (!p_psDBRunQuery(config->dbh, query, state, faultStr, job_id)) { 975 703 psError(PS_ERR_UNKNOWN, false, "database error");
Note:
See TracChangeset
for help on using the changeset viewer.
