Changeset 25199 for trunk/ippTools/src/pstamptool.c
- Timestamp:
- Aug 25, 2009, 3:30:28 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pstamptool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pstamptool.c
r25109 r25199 44 44 static bool pendingjobMode(pxConfig *config); 45 45 static bool updatejobMode(pxConfig *config); 46 static bool revertjobMode(pxConfig *config); 46 47 static bool addprojectMode(pxConfig *config); 47 48 static bool projectMode(pxConfig *config); … … 80 81 MODECASE(PSTAMPTOOL_MODE_PENDINGJOB, pendingjobMode); 81 82 MODECASE(PSTAMPTOOL_MODE_UPDATEJOB, updatejobMode); 83 MODECASE(PSTAMPTOOL_MODE_REVERTJOB, revertjobMode); 82 84 MODECASE(PSTAMPTOOL_MODE_ADDPROJECT, addprojectMode); 83 85 MODECASE(PSTAMPTOOL_MODE_MODPROJECT, modprojectMode); … … 491 493 PS_ASSERT_PTR_NON_NULL(config, false); 492 494 493 PXOPT_LOOKUP_S64(req_id, config->args, "-req_id", true, false); 494 495 // printf("Revert request %" PRId64 "\n", req_id); 495 psMetadata *where = psMetadataAlloc(); 496 497 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 498 PXOPT_COPY_S64(config->args, where, "-fault", "req_id", "=="); 499 PXOPT_COPY_STR(config->args, where, "-state", "pstampRequest.state", "=="); 500 501 if (!psListLength(where->list)) { 502 psFree(where); 503 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 504 return false; 505 } 506 507 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 508 psFree(where); 509 510 // delete any jobs that were queued by requests that didn't complete parsing (pstampRequest.state = 'new' 511 // If state = 'run' was supplied this will be a no-op 512 psString query = pxDataGet("pstamptool_revertreq_deletejobs.sql"); 513 psStringAppend(&query, " AND %s", whereClause); 514 if (!p_psDBRunQuery(config->dbh, query)) { 515 psError(PS_ERR_UNKNOWN, false, "database error"); 516 return false; 517 } 518 psFree(query); 519 520 // clear fault for requests 521 query = pxDataGet("pstamptool_revertreq.sql"); 522 psStringAppend(&query, " AND %s", whereClause); 496 523 497 if (!p_psDBRunQueryF(config->dbh, "DELETE FROM pstampJob where req_id = %" PRId64, req_id)) { 498 psError(PS_ERR_UNKNOWN, false, "database error"); 499 return false; 500 } 501 if (!p_psDBRunQueryF(config->dbh, 502 "UPDATE pstampRequest set state ='new', name=NULL, reqType=NULL, fault=0 where req_id = %" PRId64, req_id)) { 503 psError(PS_ERR_UNKNOWN, false, "database error"); 504 return false; 505 } 524 psFree(whereClause); 525 526 if (!p_psDBRunQuery(config->dbh, query)) { 527 psError(PS_ERR_UNKNOWN, false, "database error"); 528 return false; 529 } 530 psFree(query); 506 531 507 532 return true; … … 734 759 return true; 735 760 } 761 762 static bool revertjobMode(pxConfig *config) 763 { 764 PS_ASSERT_PTR_NON_NULL(config, false); 765 766 psMetadata *where = psMetadataAlloc(); 767 768 PXOPT_COPY_S64(config->args, where, "-job_id", "job_id", "=="); 769 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 770 PXOPT_COPY_S64(config->args, where, "-fault", "fault", "=="); 771 772 if (!psListLength(where->list)) { 773 psFree(where); 774 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 775 return false; 776 } 777 778 psString query = pxDataGet("pstamptool_revertjob.sql"); 779 psString whereClause = psDBGenerateWhereConditionSQL(where, "pstampJob"); 780 psStringAppend(&query, " AND %s", whereClause); 781 psFree(whereClause); 782 psFree(where); 783 784 if (!p_psDBRunQuery(config->dbh, query)) { 785 psError(PS_ERR_UNKNOWN, false, "database error"); 786 return false; 787 } 788 789 return true; 790 } 736 791 static bool addprojectMode(pxConfig *config) 737 792 {
Note:
See TracChangeset
for help on using the changeset viewer.
