Changeset 29625 for trunk/ippTools/src/magictool.c
- Timestamp:
- Nov 1, 2010, 12:51:37 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/magictool.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/magictool.c
r29553 r29625 1059 1059 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 1060 1060 1061 if (!psDBTransaction(config->dbh)) { 1062 psError(PS_ERR_UNKNOWN, false, "database error"); 1063 return false; 1064 } 1065 1061 1066 if (!magicNodeResultInsert(config->dbh, 1062 1067 magic_id, … … 1069 1074 } 1070 1075 1076 if (fault == 0 && !strcmp(node, "root")) { 1077 // Set the magicRun state 1078 psString query = pxDataGet("magictool_setfull.sql"); 1079 if (!query) { 1080 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1081 if (!psDBRollback(config->dbh)) { 1082 psError(PS_ERR_UNKNOWN, false, "database error"); 1083 } 1084 return false; 1085 } 1086 1087 // manually add constraint 1088 psStringAppend(&query, " AND magic_id = %" PRId64, magic_id); 1089 1090 if (!p_psDBRunQuery(config->dbh, query)) { 1091 psError(PS_ERR_UNKNOWN, false, "database error"); 1092 psFree(query); 1093 if (!psDBRollback(config->dbh)) { 1094 psError(PS_ERR_UNKNOWN, false, "database error"); 1095 } 1096 return false; 1097 } 1098 psFree(query); 1099 } 1100 if (!psDBCommit(config->dbh)) { 1101 psError(PS_ERR_UNKNOWN, false, "database error"); 1102 return false; 1103 } 1104 1071 1105 return true; 1072 1106 } … … 1082 1116 pxAddLabelSearchArgs (config, where, "-label", "magicRun.label", "=="); 1083 1117 1084 psString query = pxDataGet("magictool_revertnode.sql"); 1118 if (!psListLength(where->list)) { 1119 psError(PS_ERR_UNKNOWN, false, "search parameters are required"); 1120 psFree(where); 1121 return false; 1122 } 1123 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1124 psFree(where); 1125 1126 // don't need a transaction because it is ok if the first query succeeds 1127 // but the second query does not 1128 psString query = pxDataGet("magictool_deletemask.sql"); 1085 1129 if (!query) { 1086 1130 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1087 1131 return false; 1088 1132 } 1089 1090 if (psListLength(where->list)) { 1091 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1092 psStringAppend(&query, " AND %s", whereClause); 1133 psStringAppend(&query, " AND %s", whereClause); 1134 if (!p_psDBRunQuery(config->dbh, query)) { 1093 1135 psFree(whereClause); 1094 } else { 1095 psError(PS_ERR_UNKNOWN, false, "search parameters are required"); 1096 psFree(where); 1097 return false; 1098 } 1099 psFree(where); 1136 psFree(query); 1137 psError(PS_ERR_UNKNOWN, false, "failed to delete faulted masks"); 1138 return false; 1139 } 1140 psFree(query); 1141 1142 query = pxDataGet("magictool_revertnode.sql"); 1143 if (!query) { 1144 psFree(whereClause); 1145 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1146 return false; 1147 } 1148 psStringAppend(&query, " AND %s", whereClause); 1149 psFree(whereClause); 1100 1150 1101 1151 if (!p_psDBRunQuery(config->dbh, query)) { 1152 psFree(query); 1102 1153 psError(PS_ERR_UNKNOWN, false, "failed to revert"); 1103 1154 return false; 1104 1155 } 1156 psFree(query); 1105 1157 1106 1158 psS32 numUpdated = psDBAffectedRows(config->dbh); … … 1180 1232 // required 1181 1233 PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false); 1234 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false); 1182 1235 1183 1236 // optional 1184 // PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false);1185 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);1186 1237 PXOPT_LOOKUP_S32(streaks, config->args, "-streaks", false, false); 1187 1188 // default values1189 1238 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 1190 1191 if (!psDBTransaction(config->dbh)) {1192 psError(PS_ERR_UNKNOWN, false, "database error");1193 return false;1194 }1195 1239 1196 1240 if (!magicMaskInsert(config->dbh, … … 1205 1249 psError(PS_ERR_UNKNOWN, false, "database error"); 1206 1250 } 1207 return false;1208 }1209 1210 // Set the magicRun state1211 psString query = pxDataGet("magictool_addmask.sql");1212 if (!query) {1213 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");1214 if (!psDBRollback(config->dbh)) {1215 psError(PS_ERR_UNKNOWN, false, "database error");1216 }1217 return false;1218 }1219 1220 // manually add constraint1221 psStringAppend(&query, " AND magic_id = %" PRId64, magic_id);1222 1223 if (!p_psDBRunQuery(config->dbh, query)) {1224 psError(PS_ERR_UNKNOWN, false, "database error");1225 psFree(query);1226 if (!psDBRollback(config->dbh)) {1227 psError(PS_ERR_UNKNOWN, false, "database error");1228 }1229 return false;1230 }1231 psFree(query);1232 1233 if (!psDBCommit(config->dbh)) {1234 psError(PS_ERR_UNKNOWN, false, "database error");1235 1251 return false; 1236 1252 }
Note:
See TracChangeset
for help on using the changeset viewer.
