IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 15, 2008, 10:30:59 AM (18 years ago)
Author:
eugene
Message:

completely deprecate config->where; make all command-line handling consistent; move nearly all sql into share/*.sql; ensure consistency between args supplied and used

File:
1 edited

Legend:

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

    r18314 r18561  
    162162    PS_ASSERT_PTR_NON_NULL(config, false);
    163163
     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
    164170    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    165171
    166172    psString query = psStringCopy("SELECT * FROM summitExp");
    167173
    168     if (config->where) {
    169         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "summitExp");
     174    if (psListLength(where->list)) {
     175        psString whereClause = psDBGenerateWhereConditionSQL(where, "summitExp");
    170176        psStringAppend(&query, " AND %s", whereClause);
    171177        psFree(whereClause);
    172178    }
     179    psFree(where);
    173180
    174181    if (!p_psDBRunQuery(config->dbh, query)) {
     
    206213    PS_ASSERT_PTR_NON_NULL(config, false);
    207214
     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
    208221    PXOPT_LOOKUP_BOOL(desc, config->args, "-desc", false);
    209222    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    210223    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    211224
     225    // XXX leave this query here ?
    212226    psString query = psStringCopy(
    213227            "SELECT"
     
    223237        );
    224238
    225     if (config->where) {
    226         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "pzDownloadExp");
     239    if (psListLength(where->list)) {
     240        psString whereClause = psDBGenerateWhereConditionSQL(where, "pzDownloadExp");
    227241        psStringAppend(&query, " AND %s", whereClause);
    228242        psFree(whereClause);
    229243    }
     244    psFree(where);
    230245
    231246    psStringAppend(&query, " ORDER BY summitExp.dateobs");
     
    274289{
    275290    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", "==");
    276297
    277298    PXOPT_LOOKUP_BOOL(desc, config->args, "-desc", false);
     
    300321        psStringAppend(&query, " WHERE camera = \"%s\"", camera);
    301322
    302         if (config->where) {
    303             psString whereClause = psDBGenerateWhereConditionSQL(config->where, "pzDownloadImfile");
     323        if (psListLength(where->list)) {
     324            psString whereClause = psDBGenerateWhereConditionSQL(where, "pzDownloadImfile");
    304325            psStringAppend(&query, " AND %s", whereClause);
    305326            psFree(whereClause);
     
    347368        psFree(result);
    348369    }
     370    psFree(where);
    349371
    350372    // stitch the arrays of imfiles together
     
    378400    // default values
    379401    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
     402
     403    // NOTE : the rest of the command-line args are parsed in copydoneCompleteExp
    380404
    381405    if (!pzDownloadImfileInsert(config->dbh,
     
    447471    }
    448472
     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
    449475    psMetadata *where = psMetadataAlloc();
    450476    if (exp_name) {
     
    472498    }
    473499
    474     if (config->where) {
     500    if (psListLength(where->list)) {
    475501        psString whereClause = psDBGenerateWhereSQL(where, NULL);
    476502        psStringAppend(&query, " %s", whereClause);
     
    720746    PS_ASSERT_PTR_NON_NULL(config, false);
    721747
     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
    722755    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
    723756
    724     if (!pxSetFaultCode(config->dbh, "pzDownloadImfile", config->where, code)) {
     757    if (!pxSetFaultCode(config->dbh, "pzDownloadImfile", where, code)) {
    725758        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);
    728763
    729764    return true;
     
    734769{
    735770    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", "==");
    736778
    737779    psString query = pxDataGet("pztool_revertcopied.sql");
     
    741783    }
    742784
    743     if (config->where) {
    744         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "pzDownloadImfile");
     785    if (psListLength(where->list)) {
     786        psString whereClause = psDBGenerateWhereConditionSQL(where, "pzDownloadImfile");
    745787        psStringAppend(&query, " AND %s", whereClause);
    746788        psFree(whereClause);
    747789    }
     790    psFree(where);
    748791
    749792    if (!p_psDBRunQuery(config->dbh, query)) {
     
    803846{
    804847    PS_ASSERT_PTR_NON_NULL(config, false);
     848
     849    // NOTE : the command-line args are parsed in copydoneCompleteExp
    805850
    806851    // start a transaction so it's all rows or nothing
Note: See TracChangeset for help on using the changeset viewer.