Changeset 12024 for trunk/ippTools/src/stacktool.c
- Timestamp:
- Feb 23, 2007, 3:41:56 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/stacktool.c (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/stacktool.c
r11997 r12024 39 39 static bool sumskyfileMode(pxConfig *config); 40 40 41 static bool set p6RunState(pxConfig *config, const char *p6_id, const char *state);41 static bool setstackRunState(pxConfig *config, const char *stack_id, const char *state); 42 42 43 43 # define MODECASE(caseName, func) \ … … 125 125 126 126 // we have to support multipe exp_tags 127 psMetadataItem * p4_ids = psMetadataLookup(config->args, "-p4_id");128 if (! p4_ids) {127 psMetadataItem *warp_ids = psMetadataLookup(config->args, "-warp_id"); 128 if (!warp_ids) { 129 129 // this shouldn't actually happen when using psArgs 130 psError(PS_ERR_UNKNOWN, true, "- p4_id is required");130 psError(PS_ERR_UNKNOWN, true, "-warp_id is required"); 131 131 return false; 132 132 } … … 147 147 } 148 148 149 p6RunRow *run = p6RunRowAlloc(149 stackRunRow *run = stackRunRowAlloc( 150 150 0, // ID 151 151 "run", // state … … 158 158 psFree(registered); 159 159 if (!run) { 160 psError(PS_ERR_UNKNOWN, false, "failed to alloc p6Run object");160 psError(PS_ERR_UNKNOWN, false, "failed to alloc stackRun object"); 161 161 return true; 162 162 } … … 167 167 } 168 168 169 if (! p6RunInsertObject(config->dbh, run)) {169 if (!stackRunInsertObject(config->dbh, run)) { 170 170 if (!psDBRollback(config->dbh)) { 171 171 psError(PS_ERR_UNKNOWN, false, "database error"); … … 176 176 } 177 177 178 // get the assigned p4_id179 run-> p6_id = psDBLastInsertID(config->dbh);180 181 // insert the p6InputSkyfile rows182 psListIterator *iter = psListIteratorAlloc( p4_ids->data.list, 0, false);178 // get the assigned warp_id 179 run->stack_id = psDBLastInsertID(config->dbh); 180 181 // insert the stackInputSkyfile rows 182 psListIterator *iter = psListIteratorAlloc(warp_ids->data.list, 0, false); 183 183 psMetadataItem *item = NULL; 184 184 while ((item = psListGetAndIncrement(iter))) { 185 if (! p6InputSkyfileInsert(config->dbh, run->p6_id, atoi((char *)item->data.V))) {185 if (!stackInputSkyfileInsert(config->dbh, run->stack_id, atoi((char *)item->data.V))) { 186 186 if (!psDBRollback(config->dbh)) { 187 187 psError(PS_ERR_UNKNOWN, false, "database error"); 188 188 } 189 psError(PS_ERR_UNKNOWN, false, "failed to insert p6InputSkyfile rows");189 psError(PS_ERR_UNKNOWN, false, "failed to insert stackInputSkyfile rows"); 190 190 return false; 191 191 } … … 210 210 } 211 211 212 if (! p6RunPrintObject(stdout, run, !simple)) {212 if (!stackRunPrintObject(stdout, run, !simple)) { 213 213 psError(PS_ERR_UNKNOWN, false, "failed to print object"); 214 214 psFree(run); … … 227 227 228 228 bool status = false; 229 psString p6_id = psMetadataLookupStr(&status, config->args, "-p6_id");230 if (!status) { 231 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for - p6_id");232 return false; 233 } 234 if (! p6_id) {235 psError(PS_ERR_UNKNOWN, true, "- p6_id is required");229 psString stack_id = psMetadataLookupStr(&status, config->args, "-stack_id"); 230 if (!status) { 231 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stack_id"); 232 return false; 233 } 234 if (!stack_id) { 235 psError(PS_ERR_UNKNOWN, true, "-stack_id is required"); 236 236 return false; 237 237 } … … 249 249 if (state) { 250 250 // set detRun.state to state 251 return set p6RunState(config, p6_id, state);251 return setstackRunState(config, stack_id, state); 252 252 } 253 253 … … 261 261 262 262 bool status = false; 263 psString p6_id = psMetadataLookupStr(&status, config->args, "-p6_id");264 if (!status) { 265 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for - p6_id");266 return false; 267 } 268 if (! p6_id) {269 psError(PS_ERR_UNKNOWN, true, "- p6_id is required");270 return false; 271 272 } 273 274 psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id");275 if (!status) { 276 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for - p4_id");277 return false; 278 } 279 if (! p4_id) {280 psError(PS_ERR_UNKNOWN, true, "- p4_id is required");281 return false; 282 } 283 284 285 // XXX need to validate the p4_id here263 psString stack_id = psMetadataLookupStr(&status, config->args, "-stack_id"); 264 if (!status) { 265 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stack_id"); 266 return false; 267 } 268 if (!stack_id) { 269 psError(PS_ERR_UNKNOWN, true, "-stack_id is required"); 270 return false; 271 272 } 273 274 psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id"); 275 if (!status) { 276 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warp_id"); 277 return false; 278 } 279 if (!warp_id) { 280 psError(PS_ERR_UNKNOWN, true, "-warp_id is required"); 281 return false; 282 } 283 284 285 // XXX need to validate the warp_id here 286 286 // XXX instead of validiting it here we should just use forgein key 287 287 // constrants 288 if (! p6InputSkyfileInsert(config->dbh,289 (psS32)atoi( p6_id),290 (psS32)atoi( p4_id)288 if (!stackInputSkyfileInsert(config->dbh, 289 (psS32)atoi(stack_id), 290 (psS32)atoi(warp_id) 291 291 )) { 292 292 psError(PS_ERR_UNKNOWN, false, "database error"); … … 312 312 psString query = psStringCopy( 313 313 "SELECT\n" 314 " p4Skyfile.*\n"315 " FROM p6Run\n"316 " JOIN p6InputSkyfile\n"317 " USING( p6_id)\n"318 " JOIN p4Skyfile\n"319 " ON p6InputSkyfile.p4_id = p4Skyfile.p4_id\n"320 " AND p6Run.skycell_id = p4Skyfile.skycell_id\n"321 " AND p6Run.tess_id = p4Skyfile.tess_id\n"314 " warpSkyfile.*\n" 315 " FROM stackRun\n" 316 " JOIN stackInputSkyfile\n" 317 " USING(stack_id)\n" 318 " JOIN warpSkyfile\n" 319 " ON stackInputSkyfile.warp_id = warpSkyfile.warp_id\n" 320 " AND stackRun.skycell_id = warpSkyfile.skycell_id\n" 321 " AND stackRun.tess_id = warpSkyfile.tess_id\n" 322 322 " WHERE\n" 323 " p6Run.state = 'run'\n"323 " stackRun.state = 'run'\n" 324 324 ); 325 325 if (config->where) { 326 psString whereClause = psDBGenerateWhereConditionSQL(config->where, " p6InputSkyfile");326 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "stackInputSkyfile"); 327 327 psStringAppend(&query, " AND %s", whereClause); 328 328 psFree(whereClause); … … 358 358 } 359 359 if (!psArrayLength(output)) { 360 psError(PS_ERR_UNKNOWN, false, "no p6InputSkyfile rows found");360 psError(PS_ERR_UNKNOWN, false, "no stackInputSkyfile rows found"); 361 361 psFree(output); 362 362 return true; … … 375 375 if (psArrayLength(output)) { 376 376 // negative simple so the default is true 377 if (!ippdbPrintMetadatas(stdout, output, " p6InputSkyfile", !simple)) {377 if (!ippdbPrintMetadatas(stdout, output, "stackInputSkyfile", !simple)) { 378 378 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 379 379 psFree(output); … … 402 402 psString query = psStringCopy( 403 403 "SELECT\n" 404 " p6Run.p6_id\n"405 " FROM p6Run\n"406 " LEFT JOIN p6SumSkyfile\n"407 " USING( p6_id)\n"404 " stackRun.stack_id\n" 405 " FROM stackRun\n" 406 " LEFT JOIN stackSumSkyfile\n" 407 " USING(stack_id)\n" 408 408 " WHERE\n" 409 " p6Run.state = 'run'\n"410 " AND p6SumSkyfile.p6_id IS NULL\n"409 " stackRun.state = 'run'\n" 410 " AND stackSumSkyfile.stack_id IS NULL\n" 411 411 ); 412 412 413 413 if (config->where) { 414 psString whereClause = psDBGenerateWhereConditionSQL(config->where, " p6SumSkyfile");414 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "stackSumSkyfile"); 415 415 psStringAppend(&query, " AND %s", whereClause); 416 416 psFree(whereClause); … … 446 446 } 447 447 if (!psArrayLength(output)) { 448 psError(PS_ERR_UNKNOWN, false, "no p6SumSkyfile rows found");448 psError(PS_ERR_UNKNOWN, false, "no stackSumSkyfile rows found"); 449 449 psFree(output); 450 450 return true; … … 463 463 if (psArrayLength(output)) { 464 464 // negative simple so the default is true 465 if (!ippdbPrintMetadatas(stdout, output, " p6SumSkyfile", !simple)) {465 if (!ippdbPrintMetadatas(stdout, output, "stackSumSkyfile", !simple)) { 466 466 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 467 467 psFree(output); … … 481 481 482 482 bool status = false; 483 psString p6_id = psMetadataLookupStr(&status, config->args, "-p6_id");484 if (!status) { 485 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for - p6_id");486 return false; 487 } 488 if (! p6_id) {489 psError(PS_ERR_UNKNOWN, true, "- p6_id is required");483 psString stack_id = psMetadataLookupStr(&status, config->args, "-stack_id"); 484 if (!status) { 485 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stack_id"); 486 return false; 487 } 488 if (!stack_id) { 489 psError(PS_ERR_UNKNOWN, true, "-stack_id is required"); 490 490 return false; 491 491 … … 520 520 } 521 521 522 // XXX need to validate the p6_id here522 // XXX need to validate the stack_id here 523 523 // XXX instead of validiting it here we should just use forgein key 524 524 // constrants 525 if (! p6SumSkyfileInsert(config->dbh,526 (psS32)atoi( p6_id),525 if (!stackSumSkyfileInsert(config->dbh, 526 (psS32)atoi(stack_id), 527 527 uri, 528 528 bg, … … 536 536 } 537 537 538 if (set p6RunState(config, p6_id, "stop")) {538 if (setstackRunState(config, stack_id, "stop")) { 539 539 if (!psDBRollback(config->dbh)) { 540 540 psError(PS_ERR_UNKNOWN, false, "database error"); 541 541 } 542 psError(PS_ERR_UNKNOWN, false, "failed to change p6Run's state");542 psError(PS_ERR_UNKNOWN, false, "failed to change stackRun's state"); 543 543 return false; 544 544 } … … 568 568 psString query = psStringCopy( 569 569 "SELECT\n" 570 " p6SumSkyfile.*\n"571 " FROM p6Run\n"572 " JOIN p6SumSkyfile\n"573 " USING( p6_id)\n"570 " stackSumSkyfile.*\n" 571 " FROM stackRun\n" 572 " JOIN stackSumSkyfile\n" 573 " USING(stack_id)\n" 574 574 " WHERE\n" 575 " p6Run.state = 'run'\n"575 " stackRun.state = 'run'\n" 576 576 ); 577 577 578 578 if (config->where) { 579 psString whereClause = psDBGenerateWhereConditionSQL(config->where, " p6SumSkyfile");579 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "stackSumSkyfile"); 580 580 psStringAppend(&query, " AND %s", whereClause); 581 581 psFree(whereClause); … … 611 611 } 612 612 if (!psArrayLength(output)) { 613 psError(PS_ERR_UNKNOWN, false, "no p4Skyfile rows found");613 psError(PS_ERR_UNKNOWN, false, "no warpSkyfile rows found"); 614 614 psFree(output); 615 615 return true; … … 627 627 628 628 if (psArrayLength(output)) { 629 if (!ippdbPrintMetadatas(stdout, output, " p6SumSkyfile", !simple)) {629 if (!ippdbPrintMetadatas(stdout, output, "stackSumSkyfile", !simple)) { 630 630 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 631 631 psFree(output); … … 640 640 641 641 642 static bool set p6RunState(pxConfig *config, const char *p6_id, const char *state)643 { 644 PS_ASSERT_PTR_NON_NULL( p6_id, false);642 static bool setstackRunState(pxConfig *config, const char *stack_id, const char *state) 643 { 644 PS_ASSERT_PTR_NON_NULL(stack_id, false); 645 645 PS_ASSERT_PTR_NON_NULL(state, false); 646 646 … … 653 653 ) { 654 654 psError(PS_ERR_UNKNOWN, false, 655 "invalid p4Run state: %s", state);656 return false; 657 } 658 659 char *query = "UPDATE p6Run SET state = '%s' WHERE p6_id = '%s'";660 if (!p_psDBRunQuery(config->dbh, query, state, p6_id)) {655 "invalid warpRun state: %s", state); 656 return false; 657 } 658 659 char *query = "UPDATE stackRun SET state = '%s' WHERE stack_id = '%s'"; 660 if (!p_psDBRunQuery(config->dbh, query, state, stack_id)) { 661 661 psError(PS_ERR_UNKNOWN, false, 662 "failed to change state for p6_id %s", p6_id);663 return false; 664 } 665 666 return true; 667 } 662 "failed to change state for stack_id %s", stack_id); 663 return false; 664 } 665 666 return true; 667 }
Note:
See TracChangeset
for help on using the changeset viewer.
