Changeset 27794 for trunk/ippTools/src/difftool.c
- Timestamp:
- Apr 28, 2010, 2:16:57 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/difftool.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/difftool.c
r27743 r27794 58 58 static bool tofullskyfileMode(pxConfig *config); 59 59 static bool listrunMode(pxConfig *config); 60 static bool setskyfiletoupdateMode(pxConfig *config); 60 61 61 62 … … 103 104 MODECASE(DIFFTOOL_MODE_TOFULLSKYFILE, tofullskyfileMode); 104 105 MODECASE(DIFFTOOL_MODE_LISTRUN, listrunMode); 106 MODECASE(DIFFTOOL_MODE_SETSKYFILETOUPDATE, setskyfiletoupdateMode); 105 107 106 108 default: … … 822 824 } 823 825 824 if (!psDBTransaction(config->dbh)) {825 psError(PS_ERR_UNKNOWN, false, "database error");826 psFree(where);827 return false;828 }829 830 // Update state to 'new'831 {832 psString query = pxDataGet("difftool_revertdiffskyfile_update.sql");833 if (!query) {834 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");835 if (!psDBRollback(config->dbh)) {836 psError(PS_ERR_UNKNOWN, false, "database error");837 }838 return false;839 }840 841 if (psListLength(where->list)) {842 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);843 psStringAppend(&query, " AND %s", whereClause);844 psFree(whereClause);845 }846 847 if (!p_psDBRunQuery(config->dbh, query)) {848 psError(PS_ERR_UNKNOWN, false, "database error");849 psFree(query);850 if (!psDBRollback(config->dbh)) {851 psError(PS_ERR_UNKNOWN, false, "database error");852 }853 return false;854 }855 psFree(query);856 857 psLogMsg("difftool", PS_LOG_INFO, "Updated %" PRIu64 " rows", psDBAffectedRows(config->dbh));858 }859 860 // Delete product861 826 { 862 827 psString query = pxDataGet("difftool_revertdiffskyfile_delete.sql"); 863 828 if (!query) { 864 829 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 865 if (!psDBRollback(config->dbh)) { 866 psError(PS_ERR_UNKNOWN, false, "database error"); 867 } 830 return false; 831 } 832 psString query_updated = pxDataGet("difftool_revertdiffskyfile_updated.sql"); 833 if (!query_updated) { 834 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 868 835 return false; 869 836 } … … 872 839 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 873 840 psStringAppend(&query, " AND %s", whereClause); 841 psStringAppend(&query_updated, " AND %s", whereClause); 874 842 psFree(whereClause); 875 843 } … … 878 846 psError(PS_ERR_UNKNOWN, false, "database error"); 879 847 psFree(query); 880 if (!psDBRollback(config->dbh)) {881 psError(PS_ERR_UNKNOWN, false, "database error");882 }883 848 return false; 884 849 } 885 850 psFree(query); 886 887 851 psLogMsg("difftool", PS_LOG_INFO, "Deleted %" PRIu64 " rows", psDBAffectedRows(config->dbh)); 852 853 if (!p_psDBRunQuery(config->dbh, query_updated)) { 854 psError(PS_ERR_UNKNOWN, false, "database error"); 855 psFree(query_updated); 856 return false; 857 } 858 psFree(query_updated); 859 860 psLogMsg("difftool", PS_LOG_INFO, "Updated %" PRIu64 " rows", psDBAffectedRows(config->dbh)); 888 861 } 889 862 890 863 psFree(where); 891 864 892 if (!psDBCommit(config->dbh)) {893 psError(PS_ERR_UNKNOWN, false, "database error");894 return false;895 }896 865 897 866 return true; … … 2370 2339 psMetadata *where = psMetadataAlloc(); 2371 2340 PXOPT_COPY_S64(config->args, where, "-diff_id", "diff_id", "=="); 2341 PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "=="); 2372 2342 2373 2343 if (!pxSetFaultCode(config->dbh, "diffSkyfile", where, fault)) { … … 2750 2720 return true; 2751 2721 } 2722 // a very specfic function to queue a cleaned warpSkyfile to be updated 2723 static bool setskyfiletoupdateMode(pxConfig *config) 2724 { 2725 PS_ASSERT_PTR_NON_NULL(config, NULL); 2726 2727 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false); 2728 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", false, false); 2729 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 2730 2731 psString query = pxDataGet("difftool_setskyfiletoupdate.sql"); 2732 if (!query) { 2733 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 2734 return false; 2735 } 2736 2737 psString setHook = psStringCopy(""); 2738 if (label) { 2739 psStringAppend(&setHook, "\n , diffRun.label = '%s'", label); 2740 } 2741 2742 if (skycell_id) { 2743 psStringAppend(&query, " AND (diffSkyfile.skycell_id = '%s')", skycell_id); 2744 } 2745 2746 if (!p_psDBRunQueryF(config->dbh, query, setHook, diff_id)) { 2747 psError(PS_ERR_UNKNOWN, false, "database error"); 2748 return false; 2749 } 2750 2751 psFree(setHook); 2752 psFree(query); 2753 2754 return true; 2755 }
Note:
See TracChangeset
for help on using the changeset viewer.
