IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23616


Ignore:
Timestamp:
Mar 30, 2009, 2:55:03 PM (17 years ago)
Author:
eugene
Message:

fix pxcamGet/SetSearchArgs usage: need to be careful of queries that used nested subqueries to hide the table

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/camtool.c

    r23590 r23616  
    112112    PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "==");
    113113
    114     if (!psListLength(where->list)
    115         && !psMetadataLookupBool(NULL, config->args, "-all")) {
     114    if (!psListLength(where->list) &&
     115        !psMetadataLookupBool(NULL, config->args, "-all")) {
    116116        psFree(where);
    117117        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     
    137137    // use psDBGenerateWhereSQL because the SQL yields an intermediate table
    138138    if (where && psListLength(where->list)) {
    139         psString whereClause = psDBGenerateWhereSQL(where, NULL);
    140         psStringAppend(&query, "%s", whereClause);
     139        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     140        psStringAppend(&query, " AND %s", whereClause);
    141141        psFree(whereClause);
    142142    }
     
    289289    // use psDBGenerateWhereSQL because the SQL yields an intermediate table
    290290    if (psListLength(where->list)) {
    291         psString whereClause = psDBGenerateWhereSQL(where, NULL);
    292         psStringAppend(&query, "%s", whereClause);
     291        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     292        psStringAppend(&query, " AND %s", whereClause);
    293293        psFree(whereClause);
    294294    }
     
    344344    PXOPT_COPY_STR(config->args, where, "-class_id",  "chipProcessedImfile.class_id", "==");
    345345
    346     // XXX is this used? PXOPT_COPY_STR(config->args, where, "-class",    "class",         "==");
    347 
    348346    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    349347
     
    356354    // use psDBGenerateWhereSQL because the SQL yields an intermediate table
    357355    if (psListLength(where->list)) {
    358         psString whereClause = psDBGenerateWhereSQL(where, NULL);
    359         psStringAppend(&query, "%s", whereClause);
     356        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     357        psStringAppend(&query, " AND %s", whereClause);
    360358        psFree(whereClause);
    361359    }
     
    474472    // generate restrictions
    475473    psMetadata *where = psMetadataAlloc();
    476     PXOPT_COPY_S64(config->args, where, "-cam_id",   "cam_id",   "==");
     474    PXOPT_COPY_S64(config->args, where, "-cam_id",   "camRun.cam_id",   "==");
    477475
    478476    psString query = pxDataGet("camtool_find_pendingexp.sql");
     
    484482    // use psDBGenerateWhereSQL because the SQL yields an intermediate table
    485483    if (psListLength(where->list)) {
    486         psString whereClaus = psDBGenerateWhereSQL(where, NULL);
    487         psStringAppend(&query, "%s", whereClaus);
     484        psString whereClaus = psDBGenerateWhereConditionSQL(where, NULL);
     485        psStringAppend(&query, " AND %s", whereClaus);
    488486        psFree(whereClaus);
    489487    }
     
    659657    PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "==");
    660658
     659    if (!psListLength(where->list) &&
     660        !psMetadataLookupBool(NULL, config->args, "-all")) {
     661        psFree(where);
     662        psError(PXTOOLS_ERR_DATA, false, "search parameters (or -all) are required");
     663        return false;
     664    }
     665
    661666    psString query = pxDataGet("camtool_find_processedexp.sql");
    662667    if (!query) {
     
    669674        psStringAppend(&query, " WHERE %s", whereClause);
    670675        psFree(whereClause);
     676    }
     677
     678    // we either add AND (condition) or WHERE (condition):
     679    if (where->list && faulted) {
     680        // list only faulted rows
     681        psStringAppend(&query, " %s", " AND camProcessedExp.fault != 0");
     682    }
     683    if (where->list && !faulted) {
     684        // don't list faulted rows
     685        psStringAppend(&query, " %s", " AND camProcessedExp.fault = 0");
     686    }
     687    if (!where->list && faulted) {
     688        // list only faulted rows
     689        psStringAppend(&query, " %s", " WHERE camProcessedExp.fault != 0");
     690    }
     691    if (!where->list && !faulted) {
     692        // don't list faulted rows
     693        psStringAppend(&query, " %s", " WHERE camProcessedExp.fault = 0");
    671694    }
    672695    psFree(where);
    673 
    674     if (faulted) {
    675         // list only faulted rows
    676         psStringAppend(&query, " %s", "AND camProcessedExp.fault != 0");
    677     } else {
    678         // don't list faulted rows
    679         psStringAppend(&query, " %s", "AND camProcessedExp.fault = 0");
    680     }
    681696
    682697    // order by cam_id so that the postage stamp parser can easliy find the 'latest' astrometry
  • trunk/ippTools/src/camtoolConfig.c

    r23590 r23616  
    174174    psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-reduction",0,            "search by camRun reduction class", NULL);
    175175
    176     psMetadataAddU64(processedexpArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
    177     psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-simple", 0,            "use the simple output format", false);
    178     psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-faulted",  0,            "only return imfiles with a fault status set", false);
     176    psMetadataAddU64(processedexpArgs, PS_LIST_TAIL, "-limit",    0,            "limit result set to N items", 0);
     177    psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-all",     0,            "list everything without restriction", false);
     178    psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-simple",  0,            "use the simple output format", false);
     179    psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-faulted", 0,            "only return imfiles with a fault status set", false);
    179180
    180181    // -revertprocessedexp
Note: See TracChangeset for help on using the changeset viewer.