Changeset 25800 for trunk/ippTools/src/difftool.c
- Timestamp:
- Oct 7, 2009, 4:25:35 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/difftool.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/difftool.c
r25790 r25800 51 51 52 52 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state, psS64 magicked); 53 static bool setdiffRunStateByLabel(pxConfig *config, const char* label, const char *state); 54 static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state); 55 static bool tocleanedskyfileMode(pxConfig *config); 56 static bool topurgedskyfileMode(pxConfig *config); 57 static bool toscrubbedskyfileMode(pxConfig *config); 58 59 53 60 54 61 # define MODECASE(caseName, func) \ … … 88 95 MODECASE(DIFFTOOL_MODE_EXPORTRUN, exportrunMode); 89 96 MODECASE(DIFFTOOL_MODE_IMPORTRUN, importrunMode); 97 MODECASE(DIFFTOOL_MODE_TOCLEANEDSKYFILE, tocleanedskyfileMode); 98 MODECASE(DIFFTOOL_MODE_TOPURGEDSKYFILE, topurgedskyfileMode); 99 MODECASE(DIFFTOOL_MODE_TOSCRUBBEDSKYFILE, toscrubbedskyfileMode); 100 90 101 default: 91 102 psAbort("invalid option (this should not happen)"); … … 169 180 170 181 // required options 171 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false);182 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", false, false); 172 183 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 173 174 if (state) { 184 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 185 186 // Copy of my hacky work around from stacktool.c 187 if ((state)&&(diff_id)) { 175 188 // set detRun.state to state 176 189 return setdiffRunState(config, diff_id, state, false); 177 190 } 178 191 179 return true; 192 if ((state)&&(label)) { 193 return setdiffRunStateByLabel(config, label, state); 194 } 195 196 psError(PS_ERR_UNKNOWN, false, "Required options not found."); 197 198 return false; 180 199 } 181 200 … … 865 884 } 866 885 867 char *query = "UPDATE diffRun SET state = '%s', magicked = %" PRId64 " WHERE diff_id = %"PRId64; 868 869 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) { 886 if (magicked) { 887 char *query = "UPDATE diffRun SET state = '%s', magicked = %" PRId64 " WHERE diff_id = %"PRId64; 888 889 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) { 870 890 psError(PS_ERR_UNKNOWN, false, 871 891 "failed to change state for diff_id %"PRId64, diff_id); 872 892 return false; 873 } 874 893 } 894 } 895 else { 896 char *query = "UPDATE diffRun SET state = '%s' WHERE diff_id = %"PRId64; 897 898 if (!p_psDBRunQueryF(config->dbh, query, state, diff_id)) { 899 psError(PS_ERR_UNKNOWN, false, 900 "failed to change state for diff_id %"PRId64, diff_id); 901 return false; 902 } 903 } 904 875 905 return true; 906 } 907 908 909 static bool setdiffRunStateByLabel(pxConfig *config, const char *label, const char *state) { 910 PS_ASSERT_PTR_NON_NULL(state,false); 911 912 // check that state is a valid string value 913 if (!pxIsValidState(state)) { 914 psError(PS_ERR_UNKNOWN, false, "invalid diffRun state: %s", state); 915 return false; 916 } 917 918 char *query = "UPDATE diffRun SET state = '%s' WHERE label = '%s'"; 919 if (!p_psDBRunQueryF(config->dbh,query,state,label)) { 920 psError(PS_ERR_UNKNOWN, false, 921 "failed to change state for label %s", label); 922 return(false); 923 } 924 925 return true; 876 926 } 877 927 … … 1725 1775 1726 1776 psMetadata *where = psMetadataAlloc(); 1727 pxAddLabelSearchArgs (config, where, "-label", " diffRun.label", "==");1777 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 1728 1778 1729 1779 psString query = pxDataGet("difftool_pendingcleanuprun.sql"); … … 1747 1797 } 1748 1798 1799 // fprintf(stderr,"%s",query); 1749 1800 if (!p_psDBRunQuery(config->dbh, query)) { 1750 1801 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1918 1969 1919 1970 return true; 1971 } 1972 1973 static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state) { 1974 PS_ASSERT_PTR_NON_NULL(config, false); 1975 1976 // diff_id, skycell_id are required 1977 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false); 1978 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 1979 1980 psString query = pxDataGet("difftool_change_skyfile_data_state.sql"); 1981 1982 if (!psDBTransaction(config->dbh)) { 1983 psError(PS_ERR_UNKNOWN, false, "database error"); 1984 return(false); 1985 } 1986 1987 // Uses the unconstrained (diffRun.state [NEED NOT EQUAL] run_state) version from warptool.c 1988 1989 if (!p_psDBRunQueryF(config->dbh, query, data_state, diff_id, skycell_id)) { 1990 psError(PS_ERR_UNKNOWN, false, "database error"); 1991 // rollback 1992 if (!psDBRollback(config->dbh)) { 1993 psError(PS_ERR_UNKNOWN, false, "database error"); 1994 } 1995 psError(PS_ERR_UNKNOWN, false, "database error"); 1996 return(false); 1997 } 1998 psFree(query); 1999 2000 query = pxDataGet("difftool_change_run_state.sql"); 2001 if (!p_psDBRunQueryF(config->dbh, query, data_state, diff_id, data_state)) { 2002 // rollback 2003 if (!psDBRollback(config->dbh)) { 2004 psError(PS_ERR_UNKNOWN, false, "database error"); 2005 } 2006 psError(PS_ERR_UNKNOWN, false, "database error"); 2007 return(false); 2008 } 2009 2010 if (!psDBCommit(config->dbh)) { 2011 psError(PS_ERR_UNKNOWN, false, "database error"); 2012 return(false); 2013 } 2014 2015 return(true); 2016 } 2017 2018 static bool tocleanedskyfileMode(pxConfig *config) { 2019 return change_skyfile_data_state(config, "cleaned","goto_cleaned"); 2020 } 2021 static bool topurgedskyfileMode(pxConfig *config) { 2022 return change_skyfile_data_state(config, "purged", "goto_purged"); 2023 } 2024 static bool toscrubbedskyfileMode(pxConfig *config) { 2025 return change_skyfile_data_state(config, "scrubbed", "goto_scrubbed"); 1920 2026 } 1921 2027
Note:
See TracChangeset
for help on using the changeset viewer.
