Changeset 14079 for trunk/ippTools/src/dettool.c
- Timestamp:
- Jul 9, 2007, 10:52:11 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool.c
r14078 r14079 82 82 static detInputExpRow *rawDetrenTodetInputExpRow(rawExpRow *rawExp, psS64 det_id, psS32 iteration); 83 83 static psArray *searchRawImfiles(pxConfig *config, psMetadata *where); 84 static psS32 incrementIteration(pxConfig *config, const char *det_id); 85 static bool setDetRunState(pxConfig *config, const char *det_id, const char *state); 84 static bool startNewIteration(pxConfig *config, psS64 det_id); 85 static psS32 incrementIteration(pxConfig *config, psS64 det_id); 86 static bool setDetRunState(pxConfig *config, psS64 det_id, const char *state); 86 87 static bool isValidMode(pxConfig *config, const char *mode); 87 88 … … 5804 5805 if (state) { 5805 5806 // set detRun.state to state 5806 return setDetRunState(config, det_id, state);5807 return setDetRunState(config, (psS64)atoll(det_id), state); 5807 5808 } 5808 5809 5809 5810 // else 5810 5811 // -again 5811 5812 // select detRun.det_id 5813 // select detRun.iteration 5814 // select detInputExp.exp_id 5815 // select detResidExp.accept 5816 // by: 5817 // find the current iteration bassed on det_id 5818 // find all exp_ids in the current det_id/iteration from detInputExp 5819 // find all exp_ids in the current det_id/iteration from detResidExp 5820 // compare the counts of exp_ids 5821 5822 psString query = psStringCopy( 5823 "SELECT DISTINCT" 5824 " detRun.det_id AS det_id," 5825 " detRun.iteration," 5826 " detInputExp.exp_id," 5827 " detResidExp.accept" 5828 " FROM detRun" 5829 " JOIN detInputExp" 5830 " ON detRun.det_id = detInputExp.det_id" 5831 " AND detRun.iteration = detInputExp.iteration" 5832 " JOIN detResidExp" 5833 " ON detRun.det_id = detResidExp.det_id" 5834 " AND detRun.iteration = detResidExp.iteration" 5835 " AND detInputExp.exp_id = detResidExp.exp_id" 5836 " WHERE" 5837 " detRun.state = 'run'" 5838 " AND detRun.mode = 'master'" 5839 ); 5812 if (!startNewIteration(config, (psS64)atoll(det_id))) { 5813 psError(PS_ERR_UNKNOWN, false, "failed to start new iteration"); 5814 return false; 5815 } 5816 5817 return true; 5818 } 5819 5820 static bool startNewIteration(pxConfig *config, psS64 det_id) 5821 { 5822 PS_ASSERT_PTR_NON_NULL(config, false); 5823 5824 psString query = pxDataGet("dettool_start_new_iteration.sql"); 5825 if (!query) { 5826 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 5827 return false; 5828 } 5840 5829 5841 5830 // XXX this query was not restricted by det_id, resulting 5842 5831 // in an inconsistent UPDATE below. I added this AND clause 5843 5832 // though there may be a cleaner method (EAM 2006.10.08) 5844 psStringAppend ( 5845 &query, 5846 " AND detRun.det_id = '%s'", det_id); 5847 5848 psStringAppend ( 5849 &query, 5850 " GROUP BY" 5851 " detRun.det_id," 5852 " detRun.iteration," 5853 " detInputExp.exp_id" 5854 " HAVING" 5855 " COUNT(detResidExp.exp_id) = COUNT(detInputExp.exp_id)" 5856 ); 5833 psStringAppend(&query, " WHERE detRun.det_id = %" PRId64 , det_id); 5857 5834 5858 5835 if (!p_psDBRunQuery(config->dbh, query)) { … … 5869 5846 } 5870 5847 if (!psArrayLength(output)) { 5871 ps Trace("dettool", PS_LOG_INFO, "no rows found");5848 psError(PS_ERR_UNKNOWN, false, "det_id %" PRId64 " not found", det_id); 5872 5849 psFree(output); 5873 return true;5850 return false; 5874 5851 } 5875 5852 … … 5898 5875 for (long i = 0; i < psArrayLength(output); i++) { 5899 5876 psMetadata *row = output->data[i]; 5877 bool status = false; 5900 5878 psS64 exp_id = psMetadataLookupS64(&status, row, "exp_id"); 5901 5879 if (!status) { … … 5922 5900 if (!detInputExpInsert( 5923 5901 config->dbh, 5924 (psS64)atoll(det_id),5902 det_id, 5925 5903 newIteration, 5926 5904 exp_id, … … 6046 6024 6047 6025 // up the detRuns iteration count 6048 psS32 newIteration = incrementIteration(config, det_id);6026 psS32 newIteration = incrementIteration(config, (psS64)atoll(det_id)); 6049 6027 if (!newIteration) { 6050 6028 // rollback … … 6575 6553 } 6576 6554 6577 static psS32 incrementIteration(pxConfig *config, const char *det_id)6555 static psS32 incrementIteration(pxConfig *config, psS64 det_id) 6578 6556 { 6579 6557 // this function returns zero on error 6580 6558 PS_ASSERT_PTR_NON_NULL(config, 0); 6581 PS_ASSERT_PTR_NON_NULL(det_id, 0); 6582 6583 char *query = "UPDATE detRun SET iteration = iteration + 1 WHERE det_id = '%s'"; 6559 6560 char *query = "UPDATE detRun SET iteration = iteration + 1 WHERE det_id = %" PRId64; 6584 6561 if (!p_psDBRunQuery(config->dbh, query, det_id)) { 6585 6562 psError(PS_ERR_UNKNOWN, false, 6586 "failed to increment iteration for det_id % s", det_id);6563 "failed to increment iteration for det_id %" PRId64, det_id); 6587 6564 return 0; 6588 6565 } 6589 6566 6590 6567 psMetadata *where = psMetadataAlloc(); 6591 if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==", 6592 (psS32)atoll(det_id))) { 6568 if (!psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", det_id)) { 6593 6569 psError(PS_ERR_UNKNOWN, false, "failed to add item det_id"); 6594 6570 psFree(where); … … 6615 6591 } 6616 6592 6617 static bool setDetRunState(pxConfig *config, const char *det_id, const char *state)6593 static bool setDetRunState(pxConfig *config, psS64 det_id, const char *state) 6618 6594 { 6619 PS_ASSERT_PTR_NON_NULL( det_id, false);6595 PS_ASSERT_PTR_NON_NULL(config, false); 6620 6596 PS_ASSERT_PTR_NON_NULL(state, false); 6621 6597 … … 6633 6609 } 6634 6610 6635 char *query = "UPDATE detRun SET state = '%s' WHERE det_id = '%s'";6611 char *query = "UPDATE detRun SET state = '%s' WHERE det_id = %" PRId64; 6636 6612 if (!p_psDBRunQuery(config->dbh, query, state, det_id)) { 6637 6613 psError(PS_ERR_UNKNOWN, false, 6638 "failed to change state for det_id % s", det_id);6614 "failed to change state for det_id %" PRId64, det_id); 6639 6615 return false; 6640 6616 }
Note:
See TracChangeset
for help on using the changeset viewer.
