IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19249


Ignore:
Timestamp:
Aug 27, 2008, 3:37:35 PM (18 years ago)
Author:
Paul Price
Message:

stacktool wasn't applying the restrictions specified on the command-line when inserting warps into stackInputSkyfile. Needed to split share/stacktool_definebyquery_insert_random.sql into two parts to make it work with the restrictions.

Location:
trunk/ippTools
Files:
2 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/share/Makefile.am

    r19160 r19249  
    132132     regtool_revertprocessedimfile.sql \
    133133     stacktool_definebyquery_insert.sql \
    134      stacktool_definebyquery_insert_random.sql \
     134     stacktool_definebyquery_insert_random_part1.sql \
     135     stacktool_definebyquery_insert_random_part2.sql \
    135136     stacktool_definebyquery_part1.sql \
    136137     stacktool_definebyquery_part2.sql \
  • trunk/ippTools/src/stacktool.c

    r19159 r19249  
    141141    PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
    142142
    143     if (!psListLength(where->list) && 
    144         !psMetadataLookupBool(NULL, config->args, "-all")) {
     143    if (!psListLength(where->list) &&
     144        !psMetadataLookupBool(NULL, config->args, "-all")) {
    145145        psFree(where);
    146146        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     
    159159        psFree(whereClause);
    160160    }
    161     psFree(where);
    162161
    163162    psString groupby = pxDataGet("stacktool_definebyquery_part2.sql");
    164163    if (!groupby) {
    165164        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     165        psFree(where);
    166166        return false;
    167167    }
     
    202202        psError(PS_ERR_UNKNOWN, false, "database error");
    203203        psFree(select);
     204        psFree(where);
    204205        return false;
    205206    }
     
    217218                psError(PXTOOLS_ERR_PROG, false, "unknown error");
    218219        }
    219 
     220        psFree(where);
    220221        return false;
    221222    }
     
    223224        psTrace("stacktool", PS_LOG_INFO, "no rows found");
    224225        psFree(output);
     226        psFree(where);
    225227        return true;
    226228    }
     
    228230    psString insert = NULL;             // Insertion query
    229231    if (randomLimit > 0) {
    230         insert = pxDataGet("stacktool_definebyquery_insert_random.sql");
     232        insert = pxDataGet("stacktool_definebyquery_insert_random_part1.sql");
    231233    } else {
    232234        insert = pxDataGet("stacktool_definebyquery_insert.sql");
     
    234236    if (!insert) {
    235237        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    236         return false;
     238        psFree(where);
     239        return false;
     240    }
     241
     242    if (psListLength(where->list)) {
     243        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     244        psStringAppend(&select, " AND %s", whereClause);
     245        psFree(whereClause);
     246    }
     247    psFree(where);
     248
     249    if (randomLimit > 0) {
     250        psString part2 = pxDataGet("stacktool_definebyquery_insert_random_part2.sql");
     251        if (!part2) {
     252            psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     253            psFree(insert);
     254            return false;
     255        }
     256        psStringAppend(&insert, "%s", part2);
     257        psFree(part2);
    237258    }
    238259
    239260    if (!psDBTransaction(config->dbh)) {
    240261        psError(PS_ERR_UNKNOWN, false, "database error");
     262        psFree(where);
    241263        return false;
    242264    }
     
    288310            0,                          // ID
    289311            "new",                      // state
    290             workdir, 
     312            workdir,
    291313            NULL,                       // workdir_state
    292             registered, 
    293             skycell_id, 
    294             tess_id, 
     314            registered,
     315            skycell_id,
     316            tess_id,
    295317            filter);
    296318
     
    324346        psFree(idString);
    325347
    326         // XXX this insert uses a select to generate the list of warp_ids for the stack,
    327         // we have applied a set of criteria above (WHERE) to select the relevant warps
    328         // this insert needs to use exactly the same restrictions (race condition is probably not critical)
    329         // the insert below seems to only restrict matches to the skycell, tess, and filter
     348        // XXX this insert uses a select to generate the list of warp_ids for the stack,
     349        // we have applied a set of criteria above (WHERE) to select the relevant warps
     350        // this insert needs to use exactly the same restrictions (race condition is probably not critical)
     351        // the insert below seems to only restrict matches to the skycell, tess, and filter
    330352        if ((randomLimit > 0 && !p_psDBRunQuery(config->dbh, thisInsert, skycell_id, tess_id, filter,
    331353                                                randomLimit)) ||
     
    384406
    385407    stackRunRow *run = stackRunRowAlloc(
    386         0,                              // ID
    387         "new",                          // state
    388         workdir,
    389         NULL,                           // workdir_state
    390         registered,
    391         skycell_id,
    392         tess_id,
    393         filter);
     408        0,                              // ID
     409        "new",                          // state
     410        workdir,
     411        NULL,                           // workdir_state
     412        registered,
     413        skycell_id,
     414        tess_id,
     415        filter);
    394416
    395417    if (!run) {
Note: See TracChangeset for help on using the changeset viewer.