Changeset 24427 for branches/pap_mops/ippTools/src/pubtool.c
- Timestamp:
- Jun 15, 2009, 5:28:09 PM (17 years ago)
- File:
-
- 1 edited
-
branches/pap_mops/ippTools/src/pubtool.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_mops/ippTools/src/pubtool.c
r24413 r24427 36 36 static bool addMode(pxConfig *config); 37 37 static bool revertMode(pxConfig *config); 38 static bool advanceMode(pxConfig *config);39 38 40 39 # define MODECASE(caseName, func) \ … … 62 61 MODECASE(PUBTOOL_MODE_ADD, addMode); 63 62 MODECASE(PUBTOOL_MODE_REVERT, revertMode); 64 MODECASE(PUBTOOL_MODE_ADVANCE, advanceMode);65 63 default: 66 64 psAbort("invalid option (this should not happen)"); … … 89 87 90 88 // required 89 PXOPT_LOOKUP_STR(product, config->args, "-product", true, false); 91 90 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 92 PXOPT_LOOKUP_STR(destination, config->args, "-destination", true, false);93 91 94 92 // optional 95 PXOPT_LOOKUP_STR(format, config->args, "-format", false, false);96 93 PXOPT_LOOKUP_STR(comment, config->args, "-comment", false, false); 97 94 98 if (!publishClientInsert(config->dbh, 0, stage, destination, format, comment)) {95 if (!publishClientInsert(config->dbh, 0, product, stage, comment)) { 99 96 psError(PS_ERR_UNKNOWN, false, "Database error"); 100 97 return false; … … 109 106 110 107 psMetadata *where = psMetadataAlloc(); // WHERE conditions 108 109 // required 110 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 111 111 112 112 // optional … … 141 141 psFree(query); 142 142 psFree(whereClause); 143 if (!psDB Transaction(config->dbh)) {143 if (!psDBRollback(config->dbh)) { 144 144 psError(PS_ERR_UNKNOWN, false, "Database error"); 145 145 } … … 152 152 if (!output) { 153 153 psError(PS_ERR_UNKNOWN, false, "Database error"); 154 if (!psDB Transaction(config->dbh)) {154 if (!psDBRollback(config->dbh)) { 155 155 psError(PS_ERR_UNKNOWN, false, "Database error"); 156 156 } … … 160 160 psTrace("pubtool", PS_LOG_INFO, "No rows found"); 161 161 psFree(output); 162 if (!psDB Transaction(config->dbh)) {162 if (!psDBRollback(config->dbh)) { 163 163 psError(PS_ERR_UNKNOWN, false, "Database error"); 164 164 } … … 171 171 psS64 stage = psMetadataLookupS64(NULL, row, "stage_id"); // Stage identifier 172 172 173 if (!publishRunInsert(config->dbh, 0, client, stage, set_label, "new")) {173 if (!publishRunInsert(config->dbh, 0, client, stage, workdir, set_label, "new")) { 174 174 psError(PS_ERR_UNKNOWN, false, "Unable to add fileset"); 175 175 psFree(output); 176 if (!psDB Transaction(config->dbh)) {176 if (!psDBRollback(config->dbh)) { 177 177 psError(PS_ERR_UNKNOWN, false, "Database error"); 178 178 } … … 182 182 psFree(output); 183 183 184 if (!psDB Transaction(config->dbh)) {184 if (!psDBCommit(config->dbh)) { 185 185 psError(PS_ERR_UNKNOWN, false, "Database error"); 186 186 return false; … … 259 259 // required 260 260 PXOPT_LOOKUP_S64(pub_id, config->args, "-pub_id", true, false); 261 PXOPT_LOOKUP_STR( component, config->args, "-component",true, false);261 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false); 262 262 263 263 // optional 264 264 PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false); 265 265 266 if (!publishFileInsert(config->dbh, pub_id, component, fault)) { 266 if (!psDBTransaction(config->dbh)) { 267 psError(PS_ERR_UNKNOWN, false, "Database error"); 268 return false; 269 } 270 271 if (!publishDoneInsert(config->dbh, pub_id, path_base, fault)) { 267 272 psError(PS_ERR_UNKNOWN, false, "Unable to add file"); 273 if (!psDBRollback(config->dbh)) { 274 psError(PS_ERR_UNKNOWN, false, "Database error"); 275 } 276 return false; 277 } 278 279 if (!p_psDBRunQueryF(config->dbh, 280 "UPDATE publishRun SET state = 'full' WHERE pub_id = %" PRId64, 281 pub_id)) { 282 psError(PS_ERR_UNKNOWN, false, "Database error"); 283 if (!psDBRollback(config->dbh)) { 284 psError(PS_ERR_UNKNOWN, false, "Database error"); 285 } 286 return false; 287 } 288 289 if (!psDBCommit(config->dbh)) { 290 psError(PS_ERR_UNKNOWN, false, "Database error"); 268 291 return false; 269 292 } … … 283 306 PXOPT_COPY_S32(config->args, where, "-fault", "fault", "=="); 284 307 PXOPT_COPY_STR(config->args, where, "-client_id", "client_id", "=="); 285 PXOPT_COPY_STR(config->args, where, "-component", "component", "==");286 308 PXOPT_COPY_STR(config->args, where, "-comment", "comment", "LIKE"); 287 309 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); … … 310 332 return true; 311 333 } 312 static bool advanceMode(pxConfig *config) 313 { 314 PS_ASSERT_PTR_NON_NULL(config, false); 315 316 psString query = pxDataGet("pubtool_advance.sql"); 317 if (!query) { 318 psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement"); 319 return false; 320 } 321 322 if (!p_psDBRunQuery(config->dbh, query)) { 323 psError(PS_ERR_UNKNOWN, false, "Database error"); 324 psFree(query); 325 return false; 326 } 327 psFree(query); 328 329 return true; 330 } 334
Note:
See TracChangeset
for help on using the changeset viewer.
