Changeset 18561 for trunk/ippTools/src/pztool.c
- Timestamp:
- Jul 15, 2008, 10:30:59 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pztool.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pztool.c
r18314 r18561 162 162 PS_ASSERT_PTR_NON_NULL(config, false); 163 163 164 psMetadata *where = psMetadataAlloc(); 165 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 166 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 167 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 168 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 169 164 170 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 165 171 166 172 psString query = psStringCopy("SELECT * FROM summitExp"); 167 173 168 if ( config->where) {169 psString whereClause = psDBGenerateWhereConditionSQL( config->where, "summitExp");174 if (psListLength(where->list)) { 175 psString whereClause = psDBGenerateWhereConditionSQL(where, "summitExp"); 170 176 psStringAppend(&query, " AND %s", whereClause); 171 177 psFree(whereClause); 172 178 } 179 psFree(where); 173 180 174 181 if (!p_psDBRunQuery(config->dbh, query)) { … … 206 213 PS_ASSERT_PTR_NON_NULL(config, false); 207 214 215 psMetadata *where = psMetadataAlloc(); 216 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 217 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 218 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 219 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 220 208 221 PXOPT_LOOKUP_BOOL(desc, config->args, "-desc", false); 209 222 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 210 223 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 211 224 225 // XXX leave this query here ? 212 226 psString query = psStringCopy( 213 227 "SELECT" … … 223 237 ); 224 238 225 if ( config->where) {226 psString whereClause = psDBGenerateWhereConditionSQL( config->where, "pzDownloadExp");239 if (psListLength(where->list)) { 240 psString whereClause = psDBGenerateWhereConditionSQL(where, "pzDownloadExp"); 227 241 psStringAppend(&query, " AND %s", whereClause); 228 242 psFree(whereClause); 229 243 } 244 psFree(where); 230 245 231 246 psStringAppend(&query, " ORDER BY summitExp.dateobs"); … … 274 289 { 275 290 PS_ASSERT_PTR_NON_NULL(config, false); 291 292 psMetadata *where = psMetadataAlloc(); 293 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 294 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 295 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 296 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 276 297 277 298 PXOPT_LOOKUP_BOOL(desc, config->args, "-desc", false); … … 300 321 psStringAppend(&query, " WHERE camera = \"%s\"", camera); 301 322 302 if ( config->where) {303 psString whereClause = psDBGenerateWhereConditionSQL( config->where, "pzDownloadImfile");323 if (psListLength(where->list)) { 324 psString whereClause = psDBGenerateWhereConditionSQL(where, "pzDownloadImfile"); 304 325 psStringAppend(&query, " AND %s", whereClause); 305 326 psFree(whereClause); … … 347 368 psFree(result); 348 369 } 370 psFree(where); 349 371 350 372 // stitch the arrays of imfiles together … … 378 400 // default values 379 401 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 402 403 // NOTE : the rest of the command-line args are parsed in copydoneCompleteExp 380 404 381 405 if (!pzDownloadImfileInsert(config->dbh, … … 447 471 } 448 472 473 // XXX this is a bit ugly : could just use the PXOPT_COPY_* methods 474 // and not pass exp_name, camera, or telescope as additional args 449 475 psMetadata *where = psMetadataAlloc(); 450 476 if (exp_name) { … … 472 498 } 473 499 474 if ( config->where) {500 if (psListLength(where->list)) { 475 501 psString whereClause = psDBGenerateWhereSQL(where, NULL); 476 502 psStringAppend(&query, " %s", whereClause); … … 720 746 PS_ASSERT_PTR_NON_NULL(config, false); 721 747 748 psMetadata *where = psMetadataAlloc(); 749 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 750 PXOPT_COPY_STR(config->args, where, "-inst", "inst", "=="); 751 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 752 PXOPT_COPY_STR(config->args, where, "-class", "class", "=="); 753 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 754 722 755 PXOPT_LOOKUP_S16(code, config->args, "-code", true, false); 723 756 724 if (!pxSetFaultCode(config->dbh, "pzDownloadImfile", config->where, code)) {757 if (!pxSetFaultCode(config->dbh, "pzDownloadImfile", where, code)) { 725 758 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 726 return false; 727 } 759 psFree (where); 760 return false; 761 } 762 psFree(where); 728 763 729 764 return true; … … 734 769 { 735 770 PS_ASSERT_PTR_NON_NULL(config, false); 771 772 psMetadata *where = psMetadataAlloc(); 773 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 774 PXOPT_COPY_STR(config->args, where, "-inst", "inst", "=="); 775 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 776 PXOPT_COPY_STR(config->args, where, "-class", "class", "=="); 777 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 736 778 737 779 psString query = pxDataGet("pztool_revertcopied.sql"); … … 741 783 } 742 784 743 if ( config->where) {744 psString whereClause = psDBGenerateWhereConditionSQL( config->where, "pzDownloadImfile");785 if (psListLength(where->list)) { 786 psString whereClause = psDBGenerateWhereConditionSQL(where, "pzDownloadImfile"); 745 787 psStringAppend(&query, " AND %s", whereClause); 746 788 psFree(whereClause); 747 789 } 790 psFree(where); 748 791 749 792 if (!p_psDBRunQuery(config->dbh, query)) { … … 803 846 { 804 847 PS_ASSERT_PTR_NON_NULL(config, false); 848 849 // NOTE : the command-line args are parsed in copydoneCompleteExp 805 850 806 851 // start a transaction so it's all rows or nothing
Note:
See TracChangeset
for help on using the changeset viewer.
