Changeset 26981 for trunk/ippTools/src/pstamptool.c
- Timestamp:
- Feb 17, 2010, 4:40:03 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pstamptool.c (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pstamptool.c
r26565 r26981 146 146 psString query = pxDataGet("pstamptool_datastore.sql"); 147 147 if (!query) { 148 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");148 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 149 149 return false; 150 150 } … … 199 199 char *query = psStringCopy ("UPDATE pstampDataStore SET"); 200 200 bool needComma = false; 201 201 202 202 if (lastFileset) { 203 203 psStringAppend(&query, " lastFileset = '%s'", lastFileset); … … 209 209 needComma = true; // be ready in case we add another field 210 210 } 211 211 212 212 psStringAppend(&query, " WHERE ds_id = %" PRId64, ds_id); 213 213 … … 220 220 psU64 affected = psDBAffectedRows(config->dbh); 221 221 if (affected != 1) { 222 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 222 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 223 223 PRIu64 " rows were modified", affected); 224 224 return false; … … 245 245 label, 246 246 NULL, // outProduct 247 uri, 248 0 // fault 247 uri, 248 0 // fault 249 249 )) { 250 250 psError(PS_ERR_UNKNOWN, false, "failed to insert request"); … … 271 271 psString query = pxDataGet("pstamptool_pendingreq.sql"); 272 272 if (!query) { 273 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");273 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 274 274 return false; 275 275 } … … 342 342 psFree(whereClause); 343 343 psFree(where); 344 344 345 345 // treat limit == 0 as "no limit" 346 346 if (limit) { … … 365 365 psTrace("pstamptool", PS_LOG_INFO, "request not found"); 366 366 // This causes main to exit with PS_EXIT_DATA_ERROR which the script is looking for 367 psError(PXTOOLS_ERR_ DATA, true, "request not found");367 psError(PXTOOLS_ERR_CONFIG, true, "request not found"); 368 368 psFree(output); 369 369 // we return false so that the caller can determine that a request does not exist … … 436 436 PXOPT_LOOKUP_STR(state, config->args, "-state", false, false); 437 437 PXOPT_LOOKUP_STR(outProduct, config->args, "-outProduct", false, false); 438 PXOPT_LOOKUP_STR(fault, config->args, "-fault", false, false);439 PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false);440 PXOPT_LOOKUP_STR(name, config->args, "-name", false, false);438 PXOPT_LOOKUP_STR(fault, config->args, "-fault", false, false); 439 PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false); 440 PXOPT_LOOKUP_STR(name, config->args, "-name", false, false); 441 441 PXOPT_LOOKUP_STR(reqType, config->args, "-reqType", false, false); 442 442 … … 485 485 // note zero is not an error 486 486 if (affected > 1) { 487 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 487 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 488 488 PRIu64 " rows were modified", affected); 489 489 return false; … … 505 505 if (!psListLength(where->list)) { 506 506 psFree(where); 507 psError(PXTOOLS_ERR_ DATA, false, "search parameters are required");507 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 508 508 return false; 509 509 } … … 525 525 query = pxDataGet("pstamptool_revertreq.sql"); 526 526 psStringAppend(&query, " AND %s", whereClause); 527 527 528 528 psFree(whereClause); 529 529 … … 555 555 // unless the job is being inserted with stop state require outputBase 556 556 if (strcmp(stateString, "stop") && !outputBase) { 557 psError(PS_ERR_UNKNOWN, true, "-outputBase is required");558 return false;557 psError(PS_ERR_UNKNOWN, true, "-outputBase is required"); 558 return false; 559 559 } 560 560 561 561 // default value for job_type is defined in pstamptoolConfig.c 562 562 if (!strcmp(job_type, "get_image") || !strcmp(job_type, "detect_query") || !strcmp(job_type, "none")) { 563 stampJob = false;563 stampJob = false; 564 564 } else if (!strcmp(job_type, "stamp")) { 565 stampJob = true;565 stampJob = true; 566 566 } else { 567 psError(PS_ERR_UNKNOWN, false, "unknown value for -job_type: %s", job_type);568 return false;569 } 570 if (!pstampJobInsert(config->dbh, 567 psError(PS_ERR_UNKNOWN, false, "unknown value for -job_type: %s", job_type); 568 return false; 569 } 570 if (!pstampJobInsert(config->dbh, 571 571 0, // job_id 572 572 req_id, 573 rownum, 574 stateString, 575 job_type, 576 fault, 577 exp_id, 573 rownum, 574 stateString, 575 job_type, 576 fault, 577 exp_id, 578 578 outputBase, 579 579 options, … … 586 586 psU64 affected = psDBAffectedRows(config->dbh); 587 587 if (affected != 1) { 588 psError(PS_ERR_UNKNOWN, false, 588 psError(PS_ERR_UNKNOWN, false, 589 589 "should have affected one row but %" PRIu64 " rows were modified", 590 590 affected); … … 617 617 psString query = pxDataGet("pstamptool_listjob.sql"); 618 618 if (!query) { 619 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");619 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 620 620 return false; 621 621 } … … 679 679 psString query = pxDataGet("pstamptool_pendingjob.sql"); 680 680 if (!query) { 681 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");681 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 682 682 return false; 683 683 } … … 744 744 745 745 char *query ="UPDATE pstampJob" 746 " SET state = '%s' %s"747 " WHERE job_id = %" PRId64;748 746 " SET state = '%s' %s" 747 " WHERE job_id = %" PRId64; 748 749 749 if (!p_psDBRunQueryF(config->dbh, query, state, faultStr, job_id)) { 750 750 psError(PS_ERR_UNKNOWN, false, "database error"); … … 756 756 psU64 affected = psDBAffectedRows(config->dbh); 757 757 if (affected != 1) { 758 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 758 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 759 759 PRIu64 " rows were modified", affected); 760 760 return false; … … 790 790 if (!psListLength(where->list) && !all) { 791 791 psFree(where); 792 psError(PXTOOLS_ERR_ DATA, false, "search parameters or -all are required");792 psError(PXTOOLS_ERR_CONFIG, false, "search parameters or -all are required"); 793 793 return false; 794 794 } … … 799 799 } 800 800 psFree(where); 801 801 802 802 if (!p_psDBRunQueryF(config->dbh, query, faultClause)) { 803 803 psError(PS_ERR_UNKNOWN, false, "database error"); … … 847 847 psString query = pxDataGet("pstamptool_project.sql"); 848 848 if (!query) { 849 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");849 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 850 850 return false; 851 851 } … … 893 893 894 894 char *query = psStringCopy ("UPDATE pstampProject SET"); 895 895 896 896 psStringAppend(&query, " state = '%s'", state); 897 897 898 898 psStringAppend(&query, " WHERE proj_id = %" PRId64, proj_id); 899 899 … … 906 906 psU64 affected = psDBAffectedRows(config->dbh); 907 907 if (affected != 1) { 908 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 908 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 909 909 PRIu64 " rows were modified", affected); 910 910 return false; … … 938 938 psString query = pxDataGet("pstamptool_pendingdependent.sql"); 939 939 if (!query) { 940 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");940 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 941 941 return false; 942 942 } … … 986 986 } 987 987 // no existing dependent that matches, insert one 988 // Since we have multiple processes running jobs we have a 988 // Since we have multiple processes running jobs we have a 989 989 // race condition here so that's why we need to lock the table 990 990 … … 1032 1032 psString query = pxDataGet("pstamptool_pendingdependent.sql"); 1033 1033 if (!query) { 1034 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");1034 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1035 1035 return false; 1036 1036 } … … 1087 1087 1088 1088 char *query ="UPDATE pstampDependent" 1089 " SET state = '%s'"1090 " WHERE dep_id = %" PRId64;1091 1089 " SET state = '%s'" 1090 " WHERE dep_id = %" PRId64; 1091 1092 1092 if (!p_psDBRunQueryF(config->dbh, query, state, dep_id)) { 1093 1093 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1098 1098 psU64 affected = psDBAffectedRows(config->dbh); 1099 1099 if (affected != 1) { 1100 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 1100 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 1101 1101 PRIu64 " rows were modified", affected); 1102 1102 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
