Changeset 25509 for trunk/ippTools/src/difftool.c
- Timestamp:
- Sep 23, 2009, 1:41:56 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/difftool.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/difftool.c
r25074 r25509 37 37 static bool todiffskyfileMode(pxConfig *config); 38 38 static bool adddiffskyfileMode(pxConfig *config); 39 static bool advanceMode(pxConfig *config); 39 40 static bool diffskyfileMode(pxConfig *config); 40 41 static bool revertdiffskyfileMode(pxConfig *config); … … 50 51 51 52 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state, psS64 magicked); 52 static bool diffRunComplete(pxConfig *config);53 53 54 54 # define MODECASE(caseName, func) \ … … 76 76 MODECASE(DIFFTOOL_MODE_TODIFFSKYFILE, todiffskyfileMode); 77 77 MODECASE(DIFFTOOL_MODE_ADDDIFFSKYFILE, adddiffskyfileMode); 78 MODECASE(DIFFTOOL_MODE_ADVANCE, advanceMode); 78 79 MODECASE(DIFFTOOL_MODE_DIFFSKYFILE, diffskyfileMode); 79 80 MODECASE(DIFFTOOL_MODE_REVERTDIFFSKYFILE, revertdiffskyfileMode); 80 81 MODECASE(DIFFTOOL_MODE_DEFINEPOPRUN, definepoprunMode); 81 MODECASE(DIFFTOOL_MODE_DEFINEWARPSTACK, definewarpstackMode);82 MODECASE(DIFFTOOL_MODE_DEFINEWARPSTACK, definewarpstackMode); 82 83 MODECASE(DIFFTOOL_MODE_DEFINEWARPWARP, definewarpwarpMode); 83 84 MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); … … 555 556 } 556 557 557 if (!diffRunComplete(config)) {558 if (!psDBRollback(config->dbh)) {559 psError(PS_ERR_UNKNOWN, false, "database error");560 }561 psError(PS_ERR_UNKNOWN, false, "database error");562 return false;563 }564 565 558 // point of no return 566 559 if (!psDBCommit(config->dbh)) { … … 569 562 } 570 563 564 565 return true; 566 } 567 568 static bool advanceMode(pxConfig *config) 569 { 570 PS_ASSERT_PTR_NON_NULL(config, false); 571 572 psMetadata *where = psMetadataAlloc(); 573 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "=="); 574 PXOPT_COPY_STR(config->args, where, "-label", "diffRun.label", "=="); 575 576 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 577 578 // look for completed diffRuns 579 psString query = pxDataGet("difftool_completed_runs.sql"); 580 if (!query) { 581 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 582 return false; 583 } 584 585 if (psListLength(where->list)) { 586 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 587 psStringAppend(&query, " WHERE %s", whereClause); 588 psFree(whereClause); 589 } 590 psFree(where); 591 592 // treat limit == 0 as "no limit" 593 if (limit) { 594 psString limitString = psDBGenerateLimitSQL(limit); 595 psStringAppend(&query, " %s", limitString); 596 psFree(limitString); 597 } 598 599 if (!psDBTransaction(config->dbh)) { 600 psError(PS_ERR_UNKNOWN, false, "database error"); 601 return false; 602 } 603 604 if (!p_psDBRunQuery(config->dbh, query)) { 605 psError(PS_ERR_UNKNOWN, false, "database error"); 606 psFree(query); 607 if (!psDBRollback(config->dbh)) { 608 psError(PS_ERR_UNKNOWN, false, "database error"); 609 } 610 return false; 611 } 612 psFree(query); 613 614 psArray *output = p_psDBFetchResult(config->dbh); 615 if (!output) { 616 psError(PS_ERR_UNKNOWN, false, "database error"); 617 if (!psDBRollback(config->dbh)) { 618 psError(PS_ERR_UNKNOWN, false, "database error"); 619 } 620 return false; 621 } 622 if (!psArrayLength(output)) { 623 psTrace("difftool", PS_LOG_INFO, "no rows found"); 624 psFree(output); 625 return true; 626 } 627 628 for (long i = 0; i < psArrayLength(output); i++) { 629 psMetadata *row = output->data[i]; 630 631 psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id"); 632 psS64 magicked = psMetadataLookupS64(NULL, row, "magicked"); 633 634 // set diffRun.state to 'full' 635 if (!setdiffRunState(config, diff_id, "full", magicked)) { 636 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, 637 diff_id); 638 psFree(output); 639 if (!psDBRollback(config->dbh)) { 640 psError(PS_ERR_UNKNOWN, false, "database error"); 641 } 642 return false; 643 } 644 } 645 psFree(output); 646 647 if (!psDBCommit(config->dbh)) { 648 psError(PS_ERR_UNKNOWN, false, "database error"); 649 return false; 650 } 571 651 572 652 return true; … … 1810 1890 } 1811 1891 1812 static bool diffRunComplete(pxConfig *config)1813 {1814 PS_ASSERT_PTR_NON_NULL(config, false);1815 1816 // look for completed diffRuns1817 psString query = pxDataGet("difftool_completed_runs.sql");1818 if (!query) {1819 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");1820 return false;1821 }1822 1823 if (!p_psDBRunQuery(config->dbh, query)) {1824 psError(PS_ERR_UNKNOWN, false, "database error");1825 psFree(query);1826 return false;1827 }1828 psFree(query);1829 1830 psArray *output = p_psDBFetchResult(config->dbh);1831 if (!output) {1832 psError(PS_ERR_UNKNOWN, false, "database error");1833 return false;1834 }1835 if (!psArrayLength(output)) {1836 psTrace("difftool", PS_LOG_INFO, "no rows found");1837 psFree(output);1838 return true;1839 }1840 for (long i = 0; i < psArrayLength(output); i++) {1841 psMetadata *row = output->data[i];1842 1843 psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id");1844 psS64 magicked = psMetadataLookupS64(NULL, row, "magicked");1845 1846 // set diffRun.state to 'stop'1847 if (!setdiffRunState(config, diff_id, "full", magicked)) {1848 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64,1849 diff_id);1850 psFree(output);1851 return false;1852 }1853 }1854 1855 return true;1856 }1857 1892 1858 1893 bool exportrunMode(pxConfig *config)
Note:
See TracChangeset
for help on using the changeset viewer.
