Changeset 28003 for branches/pap/ippTools/src/pstamptool.c
- Timestamp:
- May 18, 2010, 12:49:05 PM (16 years ago)
- Location:
- branches/pap
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippTools/src/pstamptool.c (modified) (30 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/ippTools/src/pstamptool.c
r27282 r28003 40 40 static bool updatereqMode(pxConfig *config); 41 41 static bool revertreqMode(pxConfig *config); 42 static bool pendingcleanupMode(pxConfig *config); 42 43 static bool addjobMode(pxConfig *config); 43 44 static bool listjobMode(pxConfig *config); … … 51 52 static bool pendingdependentMode(pxConfig *config); 52 53 static bool updatedependentMode(pxConfig *config); 54 static bool revertdependentMode(pxConfig *config); 53 55 54 56 # define MODECASE(caseName, func) \ … … 80 82 MODECASE(PSTAMPTOOL_MODE_UPDATEREQ, updatereqMode); 81 83 MODECASE(PSTAMPTOOL_MODE_REVERTREQ, revertreqMode); 84 MODECASE(PSTAMPTOOL_MODE_PENDINGCLEANUP, pendingcleanupMode); 82 85 MODECASE(PSTAMPTOOL_MODE_ADDJOB, addjobMode); 83 86 MODECASE(PSTAMPTOOL_MODE_LISTJOB, listjobMode); … … 91 94 MODECASE(PSTAMPTOOL_MODE_PENDINGDEPENDENT, pendingdependentMode); 92 95 MODECASE(PSTAMPTOOL_MODE_UPDATEDEPENDENT, updatedependentMode); 96 MODECASE(PSTAMPTOOL_MODE_REVERTDEPENDENT, revertdependentMode); 93 97 default: 94 98 psAbort("invalid option (this should not happen)"); … … 263 267 NULL, // outProduct 264 268 uri, 269 NULL, // outdir 265 270 0 // fault 266 271 )) { … … 299 304 } 300 305 psFree(where); 306 307 psStringAppend(&query, " ORDER BY priority DESC, req_id"); 301 308 302 309 // treat limit == 0 as "no limit" … … 337 344 } 338 345 339 static bool listreqMode(pxConfig *config)346 static bool pendingcleanupMode(pxConfig *config) 340 347 { 341 348 PS_ASSERT_PTR_NON_NULL(config, false); … … 343 350 psMetadata *where = psMetadataAlloc(); 344 351 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 345 PXOPT_COPY_S64(config->args, where, "-not_req_id", "req_id", "!="); 346 PXOPT_COPY_STR(config->args, where, "-name", "name", "=="); 347 348 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 352 pxAddLabelSearchArgs(config, where, "-label", "label", "LIKE"); 353 354 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 349 355 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 350 356 351 if (!psListLength(where->list)) { 352 psError(PS_ERR_UNKNOWN, true, "-req_id or -name must be supplied"); 353 return false; 354 } 355 356 psString query = psStringCopy("SELECT * from pstampRequest"); 357 358 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 359 psStringAppend(&query, " WHERE %s", whereClause); 360 psFree(whereClause); 361 psFree(where); 357 psString query = pxDataGet("pstamptool_pendingcleanup.sql"); 358 if (!query) { 359 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 360 return false; 361 } 362 363 if (psListLength(where->list)) { 364 psString whereClause = psDBGenerateWhereConditionSQL(where, "pstampRequest"); 365 psStringAppend(&query, " AND %s", whereClause); 366 psFree(whereClause); 367 } 368 psFree(where); 369 370 psStringAppend(&query, " ORDER BY priority DESC, req_id"); 362 371 363 372 // treat limit == 0 as "no limit" … … 381 390 } 382 391 if (!psArrayLength(output)) { 383 psTrace("pstamptool", PS_LOG_INFO, "request not found"); 384 // This causes main to exit with PS_EXIT_DATA_ERROR which the script is looking for 385 psError(PXTOOLS_ERR_CONFIG, true, "request not found"); 386 psFree(output); 387 // we return false so that the caller can determine that a request does not exist 388 return false; 392 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 393 psFree(output); 394 return true; 389 395 } 390 396 … … 401 407 } 402 408 403 static bool completedreqMode(pxConfig *config) 404 { 405 PS_ASSERT_PTR_NON_NULL(config, false); 406 407 psMetadata *where = psMetadataAlloc(); 408 pxAddLabelSearchArgs(config, where, "-label", "label", "LIKE"); 409 410 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 409 static bool listreqMode(pxConfig *config) 410 { 411 PS_ASSERT_PTR_NON_NULL(config, false); 412 413 psMetadata *where = psMetadataAlloc(); 414 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 415 PXOPT_COPY_S64(config->args, where, "-not_req_id", "req_id", "!="); 416 PXOPT_COPY_STR(config->args, where, "-name", "name", "=="); 417 418 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 411 419 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 412 420 413 psString query = pxDataGet("pstamptool_completedreq.sql"); 414 415 if (psListLength(where->list)) { 416 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 417 psStringAppend(&query, " AND %s", whereClause); 418 psFree(whereClause); 419 } 421 if (!psListLength(where->list)) { 422 psError(PS_ERR_UNKNOWN, true, "-req_id or -name must be supplied"); 423 return false; 424 } 425 426 psString query = psStringCopy("SELECT * from pstampRequest"); 427 428 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 429 psStringAppend(&query, " WHERE %s", whereClause); 430 psFree(whereClause); 420 431 psFree(where); 421 432 … … 432 443 return false; 433 444 } 445 psFree(query); 434 446 435 447 psArray *output = p_psDBFetchResult(config->dbh); … … 438 450 return false; 439 451 } 440 441 452 if (!psArrayLength(output)) { 442 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 443 psFree(output); 444 return true; 453 psTrace("pstamptool", PS_LOG_INFO, "request not found"); 454 // This causes main to exit with PS_EXIT_DATA_ERROR which the script is looking for 455 psError(PXTOOLS_ERR_CONFIG, true, "request not found"); 456 psFree(output); 457 // we return false so that the caller can determine that a request does not exist 458 return false; 445 459 } 446 460 … … 457 471 } 458 472 473 static bool completedreqMode(pxConfig *config) 474 { 475 PS_ASSERT_PTR_NON_NULL(config, false); 476 477 psMetadata *where = psMetadataAlloc(); 478 pxAddLabelSearchArgs(config, where, "-label", "label", "LIKE"); 479 480 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 481 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 482 483 psString query = pxDataGet("pstamptool_completedreq.sql"); 484 485 if (psListLength(where->list)) { 486 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 487 psStringAppend(&query, " AND %s", whereClause); 488 psFree(whereClause); 489 } 490 psFree(where); 491 492 psStringAppend(&query, " ORDER BY priority DESC, req_id"); 493 494 // treat limit == 0 as "no limit" 495 if (limit) { 496 psString limitString = psDBGenerateLimitSQL(limit); 497 psStringAppend(&query, " %s", limitString); 498 psFree(limitString); 499 } 500 501 if (!p_psDBRunQuery(config->dbh, query)) { 502 psError(PS_ERR_UNKNOWN, false, "database error"); 503 psFree(query); 504 return false; 505 } 506 507 psArray *output = p_psDBFetchResult(config->dbh); 508 if (!output) { 509 psError(PS_ERR_UNKNOWN, false, "database error"); 510 return false; 511 } 512 513 if (!psArrayLength(output)) { 514 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 515 psFree(output); 516 return true; 517 } 518 519 // negative simple so the default is true 520 if (!ippdbPrintMetadatas(stdout, output, "pstampRequest", !simple)) { 521 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 522 psFree(output); 523 return false; 524 } 525 526 psFree(output); 527 528 return true; 529 } 530 459 531 static bool updatereqMode(pxConfig *config) 460 532 { 461 533 PS_ASSERT_PTR_NON_NULL(config, false); 462 534 463 PXOPT_LOOKUP_S64(req_id, config->args, "-req_id", true, false); 464 PXOPT_LOOKUP_STR(state, config->args, "-state", false, false); 465 PXOPT_LOOKUP_STR(outProduct, config->args, "-outProduct", false, false); 466 PXOPT_LOOKUP_STR(fault, config->args, "-fault", false, false); 467 PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false); 468 PXOPT_LOOKUP_STR(name, config->args, "-name", false, false); 469 PXOPT_LOOKUP_STR(reqType, config->args, "-reqType", false, false); 470 471 psString query = NULL; 472 psStringAppend(&query, "UPDATE pstampRequest SET"); 473 535 // PXOPT_LOOKUP_S64(req_id, config->args, "-req_id", true, false); 536 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 537 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 538 PXOPT_LOOKUP_STR(outProduct, config->args, "-set_outProduct", false, false); 539 PXOPT_LOOKUP_S16(fault, config->args, "-set_fault", false, false); 540 PXOPT_LOOKUP_STR(uri, config->args, "-set_uri", false, false); 541 PXOPT_LOOKUP_STR(outdir, config->args, "-set_outdir", false, false); 542 PXOPT_LOOKUP_STR(name, config->args, "-set_name", false, false); 543 PXOPT_LOOKUP_STR(reqType, config->args, "-set_reqType", false, false); 544 PXOPT_LOOKUP_BOOL(clearfault,config->args, "-clearfault", false); 545 546 psMetadata *where = psMetadataAlloc(); 547 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 548 PXOPT_COPY_S64(config->args, where, "-req_id_max", "req_id", "<="); 549 PXOPT_COPY_S32(config->args, where, "-fault", "fault", "=="); 550 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 551 pxAddLabelSearchArgs(config, where, "-label", "pstampRequest.label", "LIKE"); 552 if (!psListLength(where->list)) { 553 psFree(where); 554 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 555 return false; 556 } 557 558 psString query = psStringCopy("UPDATE pstampRequest SET"); 559 560 psString stateCheck = NULL; 474 561 char c = ' '; 475 562 if (state) { 476 563 psStringAppend(&query, "%c state = '%s'", c, state); 477 564 c = ','; 565 if (!strcmp(state, "goto_cleaned")) { 566 psStringAppend(&stateCheck, " AND state != 'cleaned'"); 567 } 568 } 569 if (label) { 570 psStringAppend(&query, "%c label = '%s'", c, label); 571 c = ','; 478 572 } 479 573 if (outProduct) { … … 481 575 c = ','; 482 576 } 483 if (fault) { 484 psStringAppend(&query, "%c fault = %s", c, fault); 577 if (outdir) { 578 psStringAppend(&query, "%c outdir = '%s'", c, outdir); 579 c = ','; 580 } 581 if (clearfault) { 582 if (fault) { 583 psError(PXTOOLS_ERR_CONFIG, true, "only one of -fault and -clearfault is allowed"); 584 return false; 585 } 586 psStringAppend(&query, "%c fault = 0", c); 587 c = ','; 588 } else if (fault) { 589 psStringAppend(&query, "%c fault = %d", c, fault); 485 590 c = ','; 486 591 } … … 497 602 c = ','; 498 603 } 499 if (!state && !outProduct && !fault && !uri && !name && !reqType) { 500 psError(PS_ERR_UNKNOWN, true, "at least one of state, outProduct, fault, uri, name, and reqType must be specified"); 501 return false; 502 } 503 504 psStringAppend(&query, " WHERE req_id = %" PRId64, req_id); 604 if (c != ',') { 605 psError(PS_ERR_UNKNOWN, true, "at least one set option is required"); 606 return false; 607 } 608 609 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 610 psStringAppend(&query, "\nWHERE %s", whereClause); 611 psFree(whereClause); 612 psFree(where); 613 614 if (stateCheck) { 615 psStringAppend(&query, "%s", stateCheck); 616 } 505 617 506 618 if (!p_psDBRunQuery(config->dbh, query)) { … … 510 622 } 511 623 512 psU64 affected = psDBAffectedRows(config->dbh); 513 // note zero is not an error 514 if (affected > 1) { 515 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 516 PRIu64 " rows were modified", affected); 517 return false; 518 } 624 // psU64 affected = psDBAffectedRows(config->dbh); 625 // psLogMsg("pstamptool", PS_LOG_INFO, "Updated %" PRIu64 " pstampRequests", affected); 519 626 520 627 return true; … … 528 635 529 636 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 530 PXOPT_COPY_S64(config->args, where, "-fault", " req_id", "==");637 PXOPT_COPY_S64(config->args, where, "-fault", "fault", "=="); 531 638 PXOPT_COPY_STR(config->args, where, "-state", "pstampRequest.state", "=="); 532 639 pxAddLabelSearchArgs(config, where, "-label", "pstampRequest.label", "LIKE"); … … 703 810 PXOPT_COPY_S64(config->args, where, "-job_id", "job_id", "=="); 704 811 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 705 pxAddLabelSearchArgs(config, where, "-label", " label", "LIKE");812 pxAddLabelSearchArgs(config, where, "-label", "pstampRequest.label", "LIKE"); 706 813 707 814 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); … … 722 829 psFree(where); 723 830 831 psStringAppend(&query, " ORDER BY priority DESC, req_id"); 832 724 833 // treat limit == 0 as "no limit" 725 834 if (limit) { … … 763 872 PS_ASSERT_PTR_NON_NULL(config, false); 764 873 765 PXOPT_LOOKUP_S64(job_id, config->args, "-job_id", true, false); 766 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 767 PXOPT_LOOKUP_STR(fault, config->args, "-fault", false, false); 768 769 psString faultStr = NULL; 770 if (!fault) { 771 faultStr = psStringCopy(""); 772 } else { 773 psStringAppend(&faultStr, ", fault = '%s'", fault); 774 } 775 776 char *query ="UPDATE pstampJob" 777 " SET state = '%s' %s" 778 " WHERE job_id = %" PRId64; 779 780 if (!p_psDBRunQueryF(config->dbh, query, state, faultStr, job_id)) { 874 PXOPT_LOOKUP_S64(job_id, config->args, "-job_id", false, false); 875 PXOPT_LOOKUP_S64(dep_id, config->args, "-dep_id", false, false); 876 877 if (!job_id && !dep_id) { 878 psError(PS_ERR_UNKNOWN, true, "at least -job_id or -dep_id is required"); 879 return false; 880 } 881 882 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 883 PXOPT_LOOKUP_S32(fault, config->args, "-set_fault", false, false); 884 885 if (!state && !fault) { 886 psError(PS_ERR_UNKNOWN, true, "at least one of -set_state and -set_fault is required"); 887 return false; 888 } 889 890 psMetadata *where = psMetadataAlloc(); 891 892 PXOPT_COPY_S64(config->args, where, "-job_id", "job_id", "=="); 893 PXOPT_COPY_S64(config->args, where, "-dep_id", "dep_id", "=="); 894 895 psString query = pxDataGet("pstamptool_updatejob.sql"); 896 897 char c = ' '; 898 if (state) { 899 psStringAppend(&query, "\n %c pstampJob.state = '%s'", c, state); 900 c = ','; 901 } 902 if (fault) { 903 psStringAppend(&query, "\n %c pstampJob.fault = %d", c, fault); 904 c = ','; 905 } 906 907 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 908 psStringAppend(&query, " WHERE %s", whereClause); 909 psFree(whereClause); 910 psFree(where); 911 912 if (!p_psDBRunQuery(config->dbh, query)) { 781 913 psError(PS_ERR_UNKNOWN, false, "database error"); 782 914 psFree(query); 783 915 return false; 784 916 } 785 psFree( faultStr);917 psFree(query); 786 918 787 919 psU64 affected = psDBAffectedRows(config->dbh); 788 if (affected != 1) { 789 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 790 PRIu64 " rows were modified", affected); 791 return false; 792 } 920 psLogMsg("pstamptool", PS_LOG_INFO, "Updated %" PRIu64 " pstampJobs", affected); 793 921 794 922 return true; … … 952 1080 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 953 1081 PXOPT_LOOKUP_S64(stage_id, config->args, "-stage_id", true, false); 1082 PXOPT_LOOKUP_STR(component, config->args, "-component", true, false); 954 1083 PXOPT_LOOKUP_STR(imagedb, config->args, "-imagedb", true, false); 955 PXOPT_LOOKUP_STR(rlabel, config->args, "-rlabel", false, false); 956 PXOPT_LOOKUP_BOOL(no_magic, config->args, "-no_magic", false); 1084 PXOPT_LOOKUP_STR(rlabel, config->args, "-rlabel", true, false); 1085 PXOPT_LOOKUP_STR(outdir, config->args, "-outdir", true, false); 1086 PXOPT_LOOKUP_BOOL(need_magic, config->args, "-need_magic", false); 957 1087 PXOPT_LOOKUP_BOOL(no_create, config->args, "-no_create", false); 958 1088 … … 961 1091 PXOPT_COPY_STR(config->args, where, "-imagedb", "imagedb", "=="); 962 1092 PXOPT_COPY_S64(config->args, where, "-stage_id", "stage_id", "=="); 1093 PXOPT_COPY_STR(config->args, where, "-component", "component", "=="); 963 1094 964 1095 // start a transaction eraly so it will contain any row level locks … … 968 1099 } 969 1100 970 psString query = pxDataGet("pstamptool_ pendingdependent.sql");1101 psString query = pxDataGet("pstamptool_getdependent.sql"); 971 1102 if (!query) { 972 1103 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 973 1104 return false; 974 1105 } 975 psString whereClause = psDBGenerateWhere SQL(where, "WHERE");1106 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 976 1107 if (!no_create) { 977 1108 // This will lock the row until the transaction is committed 978 psStringAppend(&query, " %s FOR UPDATE", whereClause);1109 psStringAppend(&query, " AND %s FOR UPDATE", whereClause); 979 1110 } else { 980 psStringAppend(&query, " %s", whereClause);1111 psStringAppend(&query, " AND %s", whereClause); 981 1112 } 982 1113 psFree(whereClause); … … 1027 1158 stage, 1028 1159 stage_id, 1160 component, 1029 1161 imagedb, 1030 1162 rlabel, 1031 no_magic 1163 need_magic, 1164 outdir, 1165 0 // fault 1032 1166 )) { 1033 1167 if (!psDBRollback(config->dbh)) { … … 1038 1172 } 1039 1173 1174 // if we try and get this after commit zero is returned 1175 psS64 dep_id = psDBLastInsertID(config->dbh); 1176 if (!dep_id) { 1177 psError(PS_ERR_UNKNOWN, false, "psDBLastInsertID returned NULL"); 1178 if (!psDBRollback(config->dbh)) { 1179 psError(PS_ERR_UNKNOWN, false, "database error"); 1180 } 1181 return false; 1182 } 1183 1040 1184 if (!psDBCommit(config->dbh)) { 1041 1185 // rollback … … 1047 1191 } 1048 1192 1049 psS64 dep_id = psDBLastInsertID(config->dbh);1050 1193 printf("%" PRId64 "\n", dep_id); 1051 1194 … … 1058 1201 1059 1202 psMetadata *where = psMetadataAlloc(); 1203 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); 1204 PXOPT_COPY_STR(config->args, where, "-imagedb", "imagedb", "=="); 1205 PXOPT_COPY_S64(config->args, where, "-stage_id", "stage_id", "=="); 1206 PXOPT_COPY_S64(config->args, where, "-dep_id", "dep_id", "=="); 1207 PXOPT_COPY_STR(config->args, where, "-rlabel", "rlabel", "=="); 1208 pxAddLabelSearchArgs(config, where, "-label", "pstampRequest.label", "=="); 1060 1209 1061 1210 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); … … 1069 1218 1070 1219 if (psListLength(where->list)) { 1071 psString whereClause = psDBGenerateWhereConditionSQL(where, "pstampDependent");1220 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1072 1221 psStringAppend(&query, " AND %s", whereClause); 1073 1222 psFree(whereClause); 1074 1223 } 1075 1224 psFree(where); 1225 1226 psStringAppend(&query, " ORDER BY priority DESC, req_id"); 1076 1227 1077 1228 // treat limit == 0 as "no limit" … … 1116 1267 1117 1268 PXOPT_LOOKUP_S64(dep_id, config->args, "-dep_id", true, false); 1118 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 1119 1120 char *query ="UPDATE pstampDependent" 1121 " SET state = '%s'" 1122 " WHERE dep_id = %" PRId64; 1123 1124 if (!p_psDBRunQueryF(config->dbh, query, state, dep_id)) { 1269 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 1270 PXOPT_LOOKUP_S16(fault, config->args, "-set_fault", false, false); 1271 1272 if (!fault && !state) { 1273 psError(PS_ERR_UNKNOWN, true, "at least one of -set_state or fault is required"); 1274 return false; 1275 } 1276 psString query = psStringCopy("UPDATE pstampDependent SET"); 1277 bool needComma = false; 1278 if (state) { 1279 psStringAppend(&query, " state = '%s'", state); 1280 needComma = true; 1281 } 1282 if (fault) { 1283 psStringAppend(&query, "%s fault = %d", needComma ? ", " : "", fault); 1284 needComma = true; 1285 } 1286 psStringAppend(&query, " WHERE dep_id = %" PRId64, dep_id); 1287 1288 if (!p_psDBRunQuery(config->dbh, query)) { 1125 1289 psError(PS_ERR_UNKNOWN, false, "database error"); 1126 1290 psFree(query); … … 1137 1301 return true; 1138 1302 } 1303 static bool revertdependentMode(pxConfig *config) 1304 { 1305 PS_ASSERT_PTR_NON_NULL(config, false); 1306 1307 psMetadata *where = psMetadataAlloc(); 1308 PXOPT_COPY_S64(config->args, where, "-fault", "pstampDependent.fault", "=="); 1309 PXOPT_COPY_S64(config->args, where, "-dep_id", "dep_id", "=="); 1310 pxAddLabelSearchArgs(config, where, "-label", "pstampRequest.label", "=="); 1311 1312 if (!psListLength(where->list)) { 1313 psFree(where); 1314 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 1315 return false; 1316 } 1317 psString query = pxDataGet("pstamptool_revertdependent.sql"); 1318 if (!query) { 1319 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1320 return false; 1321 } 1322 1323 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1324 psStringAppend(&query, " AND %s", whereClause); 1325 psFree(whereClause); 1326 psFree(where); 1327 1328 if (!p_psDBRunQuery(config->dbh, query)) { 1329 psError(PS_ERR_UNKNOWN, false, "database error"); 1330 psFree(query); 1331 return false; 1332 } 1333 1334 return true; 1335 }
Note:
See TracChangeset
for help on using the changeset viewer.
