Changeset 12024 for trunk/ippTools/src/difftool.c
- Timestamp:
- Feb 23, 2007, 3:41:56 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/difftool.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/difftool.c
r11997 r12024 39 39 static bool diffskyfileMode(pxConfig *config); 40 40 41 static bool set p5RunState(pxConfig *config, const char *p4_id, const char *state);41 static bool setdiffRunState(pxConfig *config, const char *warp_id, const char *state); 42 42 43 43 # define MODECASE(caseName, func) \ … … 139 139 } 140 140 141 p5RunRow *run = p5RunRowAlloc(141 diffRunRow *run = diffRunRowAlloc( 142 142 0, // ID 143 143 "reg", // state … … 150 150 psFree(registered); 151 151 if (!run) { 152 psError(PS_ERR_UNKNOWN, false, "failed to alloc p5Run object");152 psError(PS_ERR_UNKNOWN, false, "failed to alloc diffRun object"); 153 153 return true; 154 154 } 155 if (! p5RunInsertObject(config->dbh, run)) {155 if (!diffRunInsertObject(config->dbh, run)) { 156 156 psError(PS_ERR_UNKNOWN, false, "database error"); 157 157 psFree(run); … … 159 159 } 160 160 161 // get the assigned p5_id162 run-> p5_id = psDBLastInsertID(config->dbh);161 // get the assigned diff_id 162 run->diff_id = psDBLastInsertID(config->dbh); 163 163 164 164 bool simple = false; … … 173 173 } 174 174 175 if (! p5RunPrintObject(stdout, run, !simple)) {175 if (!diffRunPrintObject(stdout, run, !simple)) { 176 176 psError(PS_ERR_UNKNOWN, false, "failed to print object"); 177 177 psFree(run); … … 190 190 191 191 bool status = false; 192 psString p5_id = psMetadataLookupStr(&status, config->args, "-p5_id");193 if (!status) { 194 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for - p5_id");195 return false; 196 } 197 if (! p5_id) {198 psError(PS_ERR_UNKNOWN, true, "- p5_id is required");192 psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id"); 193 if (!status) { 194 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id"); 195 return false; 196 } 197 if (!diff_id) { 198 psError(PS_ERR_UNKNOWN, true, "-diff_id is required"); 199 199 return false; 200 200 } … … 212 212 if (state) { 213 213 // set detRun.state to state 214 return set p5RunState(config, p5_id, state);214 return setdiffRunState(config, diff_id, state); 215 215 } 216 216 … … 224 224 225 225 bool status = false; 226 psString p5_id = psMetadataLookupStr(&status, config->args, "-p5_id");227 if (!status) { 228 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for - p5_id");229 return false; 230 } 231 if (! p5_id) {232 psError(PS_ERR_UNKNOWN, true, "- p5_id is required");233 return false; 234 } 235 236 psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id");237 if (!status) { 238 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for - p4_id");239 return false; 240 } 241 if (! p5_id) {242 psError(PS_ERR_UNKNOWN, true, "- p5_id is required");226 psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id"); 227 if (!status) { 228 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id"); 229 return false; 230 } 231 if (!diff_id) { 232 psError(PS_ERR_UNKNOWN, true, "-diff_id is required"); 233 return false; 234 } 235 236 psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id"); 237 if (!status) { 238 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warp_id"); 239 return false; 240 } 241 if (!diff_id) { 242 psError(PS_ERR_UNKNOWN, true, "-diff_id is required"); 243 243 return false; 244 244 } … … 277 277 } 278 278 279 // XXX need to validate the p4_id here279 // XXX need to validate the warp_id here 280 280 // XXX instead of validiting it here we should just use forgein key 281 281 // constrants 282 if (! p5InputSkyfileInsert(config->dbh,283 (psS32)atoi( p5_id),284 (psS32)atoi( p4_id),282 if (!diffInputSkyfileInsert(config->dbh, 283 (psS32)atoi(diff_id), 284 (psS32)atoi(warp_id), 285 285 skycell_id, 286 286 tess_id, … … 310 310 psString query = psStringCopy( 311 311 "SELECT\n" 312 " p4Skyfile.*,\n"313 " p5InputSkyfile.template\n"314 " FROM p5Run\n"315 " JOIN p5InputSkyfile\n"316 " USING( p5_id)\n"317 " JOIN p4Skyfile\n"318 " ON p5InputSkyfile.p4_id = p4Skyfile.p4_id\n"319 " AND p5InputSkyfile.skycell_id = p4Skyfile.skycell_id\n"320 " AND p5InputSkyfile.tess_id = p4Skyfile.tess_id\n"312 " warpSkyfile.*,\n" 313 " diffInputSkyfile.template\n" 314 " FROM diffRun\n" 315 " JOIN diffInputSkyfile\n" 316 " USING(diff_id)\n" 317 " JOIN warpSkyfile\n" 318 " ON diffInputSkyfile.warp_id = warpSkyfile.warp_id\n" 319 " AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id\n" 320 " AND diffInputSkyfile.tess_id = warpSkyfile.tess_id\n" 321 321 " WHERE\n" 322 " p5Run.state = 'run'\n"322 " diffRun.state = 'run'\n" 323 323 ); 324 324 325 325 if (config->where) { 326 psString whereClause = psDBGenerateWhereConditionSQL(config->where, " p5InputSkyfile");326 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffInputSkyfile"); 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 p5InputSkyfile rows found");360 psError(PS_ERR_UNKNOWN, false, "no diffInputSkyfile 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, " p5InputSkyfile", !simple)) {377 if (!ippdbPrintMetadatas(stdout, output, "diffInputSkyfile", !simple)) { 378 378 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 379 379 psFree(output); … … 402 402 psString query = psStringCopy( 403 403 "SELECT DISTINCT\n" 404 " p5Run.p5_id\n"405 " FROM p5Run\n"406 " JOIN p5InputSkyfile\n"407 " USING( p5_id)\n"408 " JOIN p4Skyfile\n"409 " ON p5InputSkyfile.p4_id = p4Skyfile.p4_id\n"410 " AND p5InputSkyfile.skycell_id = p4Skyfile.skycell_id\n"411 " AND p5InputSkyfile.tess_id = p4Skyfile.tess_id\n"412 " LEFT JOIN p5DiffSkyfile\n"413 " ON p5InputSkyfile.p5_id = p5DiffSkyfile.p5_id\n"404 " diffRun.diff_id\n" 405 " FROM diffRun\n" 406 " JOIN diffInputSkyfile\n" 407 " USING(diff_id)\n" 408 " JOIN warpSkyfile\n" 409 " ON diffInputSkyfile.warp_id = warpSkyfile.warp_id\n" 410 " AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id\n" 411 " AND diffInputSkyfile.tess_id = warpSkyfile.tess_id\n" 412 " LEFT JOIN diffSkyfile\n" 413 " ON diffInputSkyfile.diff_id = diffSkyfile.diff_id\n" 414 414 " WHERE\n" 415 " p5Run.state = 'run'\n"416 " AND p5DiffSkyfile.p5_id IS NULL\n"415 " diffRun.state = 'run'\n" 416 " AND diffSkyfile.diff_id IS NULL\n" 417 417 ); 418 418 419 419 if (config->where) { 420 psString whereClause = psDBGenerateWhereConditionSQL(config->where, " p5Skyfile");420 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffSkyfile"); 421 421 psStringAppend(&query, " AND %s", whereClause); 422 422 psFree(whereClause); … … 452 452 } 453 453 if (!psArrayLength(output)) { 454 psError(PS_ERR_UNKNOWN, false, "no p5Skyfile rows found");454 psError(PS_ERR_UNKNOWN, false, "no diffSkyfile rows found"); 455 455 psFree(output); 456 456 return true; … … 469 469 if (psArrayLength(output)) { 470 470 // negative simple so the default is true 471 if (!ippdbPrintMetadatas(stdout, output, " p5Skyfile", !simple)) {471 if (!ippdbPrintMetadatas(stdout, output, "diffSkyfile", !simple)) { 472 472 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 473 473 psFree(output); … … 487 487 488 488 bool status = false; 489 psString p5_id = psMetadataLookupStr(&status, config->args, "-p5_id");490 if (!status) { 491 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for - p5_id");492 return false; 493 } 494 if (! p5_id) {495 psError(PS_ERR_UNKNOWN, true, "- p5_id is required");489 psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id"); 490 if (!status) { 491 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id"); 492 return false; 493 } 494 if (!diff_id) { 495 psError(PS_ERR_UNKNOWN, true, "-diff_id is required"); 496 496 return false; 497 497 } … … 525 525 } 526 526 527 if (! p5DiffSkyfileInsert(config->dbh,528 (psS32)atoi( p5_id),527 if (!diffSkyfileInsert(config->dbh, 528 (psS32)atoi(diff_id), 529 529 uri, 530 530 bg, … … 538 538 } 539 539 540 if (!set p5RunState(config, p5_id, "stop")) {540 if (!setdiffRunState(config, diff_id, "stop")) { 541 541 if (!psDBRollback(config->dbh)) { 542 542 psError(PS_ERR_UNKNOWN, false, "database error"); … … 570 570 psString query = psStringCopy( 571 571 "SELECT\n" 572 " p5Run.skycell_id,\n"573 " p5Run.tess_id,\n"574 " p5DiffSkyfile.*\n"575 " FROM p5Run\n"576 " JOIN p5DiffSkyfile\n"577 " USING( p5_id)\n"572 " diffRun.skycell_id,\n" 573 " diffRun.tess_id,\n" 574 " diffSkyfile.*\n" 575 " FROM diffRun\n" 576 " JOIN diffSkyfile\n" 577 " USING(diff_id)\n" 578 578 " WHERE\n" 579 " p5Run.state = 'run'\n"579 " diffRun.state = 'run'\n" 580 580 ); 581 581 582 582 if (config->where) { 583 psString whereClause = psDBGenerateWhereConditionSQL(config->where, " p5DiffSkyfile");583 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffSkyfile"); 584 584 psStringAppend(&query, " AND %s", whereClause); 585 585 psFree(whereClause); … … 615 615 } 616 616 if (!psArrayLength(output)) { 617 psError(PS_ERR_UNKNOWN, false, "no p5DiffSkyfile rows found");617 psError(PS_ERR_UNKNOWN, false, "no diffSkyfile rows found"); 618 618 psFree(output); 619 619 return true; … … 632 632 if (psArrayLength(output)) { 633 633 // negative simple so the default is true 634 if (!ippdbPrintMetadatas(stdout, output, " p5DiffSkyfile", !simple)) {634 if (!ippdbPrintMetadatas(stdout, output, "diffSkyfile", !simple)) { 635 635 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 636 636 psFree(output); … … 644 644 } 645 645 646 static bool set p5RunState(pxConfig *config, const char *p5_id, const char *state)647 { 648 PS_ASSERT_PTR_NON_NULL( p5_id, false);646 static bool setdiffRunState(pxConfig *config, const char *diff_id, const char *state) 647 { 648 PS_ASSERT_PTR_NON_NULL(diff_id, false); 649 649 PS_ASSERT_PTR_NON_NULL(state, false); 650 650 … … 657 657 ) { 658 658 psError(PS_ERR_UNKNOWN, false, 659 "invalid p5Run state: %s", state);660 return false; 661 } 662 663 char *query = "UPDATE p5Run SET state = '%s' WHERE p5_id = '%s'";664 if (!p_psDBRunQuery(config->dbh, query, state, p5_id)) {659 "invalid diffRun state: %s", state); 660 return false; 661 } 662 663 char *query = "UPDATE diffRun SET state = '%s' WHERE diff_id = '%s'"; 664 if (!p_psDBRunQuery(config->dbh, query, state, diff_id)) { 665 665 psError(PS_ERR_UNKNOWN, false, 666 "failed to change state for p5_id %s", p5_id);667 return false; 668 } 669 670 return true; 671 } 666 "failed to change state for diff_id %s", diff_id); 667 return false; 668 } 669 670 return true; 671 }
Note:
See TracChangeset
for help on using the changeset viewer.
