Changeset 18357 for branches/cleanup/ippTools/src/regtool.c
- Timestamp:
- Jun 29, 2008, 2:44:04 PM (18 years ago)
- File:
-
- 1 edited
-
branches/cleanup/ippTools/src/regtool.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cleanup/ippTools/src/regtool.c
r18076 r18357 43 43 static bool revertprocessedexpMode(pxConfig *config); 44 44 static bool updateprocessedexpMode(pxConfig *config); 45 static bool cleardupexpMode(pxConfig *config); 45 46 46 47 # define MODECASE(caseName, func) \ … … 74 75 MODECASE(REGTOOL_MODE_REVERTPROCESSEDEXP, revertprocessedexpMode); 75 76 MODECASE(REGTOOL_MODE_UPDATEPROCESSEDEXP, updateprocessedexpMode); 77 MODECASE(REGTOOL_MODE_CLEARDUPEXP, cleardupexpMode); 76 78 default: 77 79 psAbort("invalid option (this should not happen)"); … … 168 170 169 171 // required 170 PXOPT_LOOKUP_S TR(exp_id, config->args, "-exp_id", true, false);172 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false); 171 173 PXOPT_LOOKUP_STR(exp_name, config->args, "-exp_name", true, false); 172 174 PXOPT_LOOKUP_STR(camera, config->args, "-inst", true, false); … … 228 230 if (!rawImfileInsert( 229 231 config->dbh, 230 (psS64)atoll(exp_id),232 exp_id, 231 233 exp_name, 232 234 camera, … … 494 496 495 497 // required 496 PXOPT_LOOKUP_S TR(exp_id, config->args, "-exp_id", true, false);498 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false); 497 499 PXOPT_LOOKUP_STR(exp_name, config->args, "-exp_name", true, false); 498 500 PXOPT_LOOKUP_STR(camera, config->args, "-inst", true, false); … … 567 569 // build a query to search by exp_id 568 570 psMetadata *where = psMetadataAlloc(); 569 if (!psMetadataAddS tr(where, PS_LIST_TAIL, "newExp.exp_id", 0, "==", exp_id)) {571 if (!psMetadataAddS64(where, PS_LIST_TAIL, "newExp.exp_id", 0, "==", exp_id)) { 570 572 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 571 573 psFree(where); … … 650 652 651 653 if (!rawExpInsert(config->dbh, 652 (psS64)atoll(exp_id),654 exp_id, 653 655 exp_name, 654 656 camera, … … 724 726 psError(PS_ERR_UNKNOWN, false, "database error"); 725 727 } 726 psError(PS_ERR_UNKNOWN, false, "failed to change newExp.state for exp_id: % s", exp_id);728 psError(PS_ERR_UNKNOWN, false, "failed to change newExp.state for exp_id: %"PRId64, exp_id); 727 729 psFree(newExp); 728 730 return false; … … 747 749 // this can only be run as the newExp's state has been set to stop 748 750 if (!pxchipQueueByExpTag(config, 749 (psS64)atoll(exp_id),751 exp_id, 750 752 workdir, 751 753 label, … … 795 797 796 798 // XX test this out; need to make this consistent with the list in regtoolConfig.c 797 PXOPT_COPY_S TR(config->args, config->where, "-exp_id", "exp_id", "==");799 PXOPT_COPY_S64(config->args, config->where, "-exp_id", "exp_id", "=="); 798 800 PXOPT_COPY_STR(config->args, config->where, "-exp_name", "exp_name", "=="); 799 801 PXOPT_COPY_STR(config->args, config->where, "-inst", "camera", "=="); … … 941 943 return true; 942 944 } 945 946 947 static bool cleardupexpMode(pxConfig *config) 948 { 949 PS_ASSERT_PTR_NON_NULL(config, false); 950 951 if (!psDBTransaction(config->dbh)) { 952 psError(PS_ERR_UNKNOWN, false, "database error"); 953 return false; 954 } 955 956 // create temp table of exp_ids to be removed 957 { 958 psString query = pxDataGet("regtool_create_dup_table.sql"); 959 if (!query) { 960 // rollback 961 if (!psDBRollback(config->dbh)) { 962 psError(PS_ERR_UNKNOWN, false, "database error"); 963 } 964 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 965 return false; 966 } 967 968 if (!p_psDBRunQuery(config->dbh, query)) { 969 // rollback 970 if (!psDBRollback(config->dbh)) { 971 psError(PS_ERR_UNKNOWN, false, "database error"); 972 } 973 psError(PS_ERR_UNKNOWN, false, "database error"); 974 psFree(query); 975 return false; 976 } 977 psFree(query); 978 } 979 980 // populate that table 981 // XXX note that this query currently doesn't not correctly handle the case 982 // where there is more than one duplicate 983 { 984 psString query = pxDataGet("regtool_populate_dup_table.sql"); 985 if (!query) { 986 // rollback 987 if (!psDBRollback(config->dbh)) { 988 psError(PS_ERR_UNKNOWN, false, "database error"); 989 } 990 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 991 return false; 992 } 993 994 if (!p_psDBRunQuery(config->dbh, query)) { 995 // rollback 996 if (!psDBRollback(config->dbh)) { 997 psError(PS_ERR_UNKNOWN, false, "database error"); 998 } 999 psError(PS_ERR_UNKNOWN, false, "database error"); 1000 psFree(query); 1001 return false; 1002 } 1003 psFree(query); 1004 } 1005 1006 if (!p_psDBRunQuery(config->dbh, "DELETE FROM rawImfile USING rawImfile, duplicate WHERE duplicate.exp_id = rawImfile.exp_id")) { 1007 // rollback 1008 if (!psDBRollback(config->dbh)) { 1009 psError(PS_ERR_UNKNOWN, false, "database error"); 1010 } 1011 psError(PS_ERR_UNKNOWN, false, "database error"); 1012 return false; 1013 } 1014 1015 if (!p_psDBRunQuery(config->dbh, "DELETE FROM rawExp USING rawExp, duplicate WHERE duplicate.exp_id = rawExp.exp_id")) { 1016 // rollback 1017 if (!psDBRollback(config->dbh)) { 1018 psError(PS_ERR_UNKNOWN, false, "database error"); 1019 } 1020 psError(PS_ERR_UNKNOWN, false, "database error"); 1021 return false; 1022 } 1023 1024 if (!p_psDBRunQuery(config->dbh, "DELETE FROM newImfile USING newImfile, duplicate WHERE duplicate.exp_id = newImfile.exp_id")) { 1025 // rollback 1026 if (!psDBRollback(config->dbh)) { 1027 psError(PS_ERR_UNKNOWN, false, "database error"); 1028 } 1029 psError(PS_ERR_UNKNOWN, false, "database error"); 1030 return false; 1031 } 1032 1033 if (!p_psDBRunQuery(config->dbh, "DELETE FROM newExp USING newExp, duplicate WHERE duplicate.exp_id = newExp.exp_id")) { 1034 // rollback 1035 if (!psDBRollback(config->dbh)) { 1036 psError(PS_ERR_UNKNOWN, false, "database error"); 1037 } 1038 psError(PS_ERR_UNKNOWN, false, "database error"); 1039 return false; 1040 } 1041 1042 if (!psDBCommit(config->dbh)) { 1043 psError(PS_ERR_UNKNOWN, false, "database error"); 1044 return false; 1045 } 1046 1047 return true; 1048 }
Note:
See TracChangeset
for help on using the changeset viewer.
