Changeset 18496 for branches/eam_branch_20080706/ippTools/src/magictool.c
- Timestamp:
- Jul 13, 2008, 11:21:45 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080706/ippTools/src/magictool.c
r18336 r18496 103 103 104 104 // create warped skycells temp table 105 { 106 char *query = 107 "CREATE TEMPORARY TABLE warpComplete\n" 108 " (warp_id BIGINT, skycell_id VARCHAR(64), tess_id VARCHAR(64),\n" 109 " PRIMARY KEY(warp_id, skycell_id, tess_id)) ENGINE=MEMORY\n"; 110 111 if (!p_psDBRunQuery(config->dbh, query)) { 112 psError(PS_ERR_UNKNOWN, false, "database error"); 113 return false; 114 } 115 } 105 { 106 psString query = pxDataGet("magictool_create_tmp_warpcomplete.sql"); 107 if (!query) { 108 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 109 return false; 110 } 111 112 if (!p_psDBRunQuery(config->dbh, query)) { 113 psError(PS_ERR_UNKNOWN, false, "database error"); 114 return false; 115 } 116 } 116 117 117 118 // find warped skycells 118 {119 psString query = pxDataGet("magictool_find_complete_warpruns.sql");120 if (!query) {121 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");122 return false;123 }124 125 if (!p_psDBRunQuery(config->dbh, query)) {126 psError(PS_ERR_UNKNOWN, false, "database error");127 psFree(query);128 return false;129 }130 psFree(query);131 }119 { 120 psString query = pxDataGet("magictool_find_complete_warpruns.sql"); 121 if (!query) { 122 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 123 return false; 124 } 125 126 if (!p_psDBRunQuery(config->dbh, query)) { 127 psError(PS_ERR_UNKNOWN, false, "database error"); 128 psFree(query); 129 return false; 130 } 131 psFree(query); 132 } 132 133 133 134 // find the diff_id's of the warped skycells 134 {135 psString query = pxDataGet("magictool_find_complete_diffed_exposures.sql");136 if (!query) {137 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");138 return false;139 }140 141 if (!p_psDBRunQuery(config->dbh, query)) {142 psError(PS_ERR_UNKNOWN, false, "database error");143 psFree(query);144 return false;145 }146 psFree(query);147 }135 { 136 psString query = pxDataGet("magictool_find_complete_diffed_exposures.sql"); 137 if (!query) { 138 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 139 return false; 140 } 141 142 if (!p_psDBRunQuery(config->dbh, query)) { 143 psError(PS_ERR_UNKNOWN, false, "database error"); 144 psFree(query); 145 return false; 146 } 147 psFree(query); 148 } 148 149 psArray *output = p_psDBFetchResult(config->dbh); 149 150 if (!output) { 150 151 psErrorCode err = psErrorCodeLast(); 151 152 switch (err) { 152 case PS_ERR_DB_CLIENT:153 psError(PXTOOLS_ERR_SYS, false, "database error");154 case PS_ERR_DB_SERVER:155 psError(PXTOOLS_ERR_PROG, false, "database error");156 default:157 psError(PXTOOLS_ERR_PROG, false, "unknown error");153 case PS_ERR_DB_CLIENT: 154 psError(PXTOOLS_ERR_SYS, false, "database error"); 155 case PS_ERR_DB_SERVER: 156 psError(PXTOOLS_ERR_PROG, false, "database error"); 157 default: 158 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 158 159 } 159 160 … … 205 206 206 207 magicRunRow *run = magicRunRowAlloc( 207 0, // ID208 "reg", // state209 NULL, // workdir210 "dirty", // workdir_state211 NULL, // label212 NULL, // dvodb213 NULL // registered214 );208 0, // ID 209 "reg", // state 210 NULL, // workdir 211 "dirty", // workdir_state 212 NULL, // label 213 NULL, // dvodb 214 NULL // registered 215 ); 215 216 if (!run) { 216 217 psAbort("failed to alloc magicRun object"); … … 241 242 242 243 if (!magicInputSkyfileInsert(config->dbh, 243 magic_id,244 diff_id,245 node)) {244 magic_id, 245 diff_id, 246 node)) { 246 247 psError(PS_ERR_UNKNOWN, false, "database error"); 247 248 psFree(grouped); … … 268 269 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 269 270 PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false); 271 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 270 272 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 271 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);272 273 273 274 magicRunRow *run = magicRunRowAlloc( … … 348 349 PS_ASSERT_PTR_NON_NULL(config, false); 349 350 351 psMetadata *where = psMetadataAlloc(); 352 PXOPT_COPY_STR(config->args, where, "-magic_id", "magic_id", "=="); 353 PXOPT_COPY_STR(config->args, where, "-diff_id", "diff_id", "=="); 354 PXOPT_COPY_STR(config->args, where, "-node", "node", "=="); 355 350 356 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 351 357 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); … … 358 364 } 359 365 360 if ( config->where) {361 psString whereClause = psDBGenerateWhereConditionSQL( config->where, "magicInputSkyfile");366 if (psListLength(where->list)) { 367 psString whereClause = psDBGenerateWhereConditionSQL(where, "magicInputSkyfile"); 362 368 psStringAppend(&query, " AND %s", whereClause); 363 369 psFree(whereClause); 364 370 } 371 psFree(where); 365 372 366 373 // treat limit == 0 as "no limit" … … 500 507 PS_ASSERT_PTR_NON_NULL(config, false); 501 508 502 PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", false, false); 509 psMetadata *where = psMetadataAlloc(); 510 PXOPT_COPY_STR(config->args, where, "-magic_id", "magic_id", "=="); 511 512 psString whereClause = NULL; 513 if (psListLength(where->list)) { 514 whereClause = psDBGenerateWhereSQL(where, NULL); 515 } 516 psFree(where); 517 503 518 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 504 519 … … 510 525 } 511 526 512 if (magic_id) { 513 psMetadata *where = psMetadataAlloc(); 514 psMetadataAddS64(where, PS_LIST_TAIL, "magic_id", 0, "==", (psS64)atoll(magic_id)); 515 psString whereClause = psDBGenerateWhereSQL(where, NULL); 516 psFree(where); 527 if (whereClause) { 517 528 psStringAppend(&query, " %s", whereClause); 518 psFree(whereClause);519 529 } 520 530 … … 542 552 if (!psArrayLength(output)) { 543 553 psTrace("magictool", PS_LOG_INFO, "no rows found"); 544 //psFree(output);545 //return true;554 // psFree(output); 555 // return true; 546 556 } 547 557 … … 553 563 } 554 564 555 556 if (magic_id) { 557 psMetadata *where = psMetadataAlloc(); 558 psMetadataAddS64(where, PS_LIST_TAIL, "magic_id", 0, "==", (psS64)atoll(magic_id)); 559 psString whereClause = psDBGenerateWhereSQL(where, NULL); 560 psFree(where); 565 if (whereClause) { 561 566 psStringAppend(&query, " %s", whereClause); 562 psFree(whereClause);563 567 } 564 568 … … 613 617 pxNode *root = psHashLookup(forest, "root"); 614 618 psFree(forest); 615 //pxTreePrint(stdout, root);619 // pxTreePrint(stdout, root); 616 620 617 621 // crawl through the tree and looking for nodes with children that are all … … 630 634 631 635 psFree(output); 636 psFree(whereClause); 632 637 633 638 return true; … … 744 749 PS_ASSERT_PTR_NON_NULL(config, false); 745 750 751 psMetadata *where = psMetadataAlloc(); 752 PXOPT_COPY_STR(config->args, where, "-magic_id", "magic_id", "=="); 753 746 754 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 747 755 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); … … 752 760 return false; 753 761 } 762 763 if (psListLength(where->list)) { 764 psString whereClause = psDBGenerateWhereConditionSQL(where, "magicRun"); 765 psStringAppend(&query, " AND %s", whereClause); 766 psFree(whereClause); 767 } 768 psFree(where); 754 769 755 770 // treat limit == 0 as "no limit"
Note:
See TracChangeset
for help on using the changeset viewer.
