IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24664


Ignore:
Timestamp:
Jul 3, 2009, 11:48:59 AM (17 years ago)
Author:
eugene
Message:

fix definebyquery insert sql so it can handle SQL wildcards; add -pretend mode to definebyquery

Location:
trunk/ippTools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/share/stacktool_definebyquery_insert.sql

    r23688 r24664  
    1212JOIN camRun
    1313    USING(cam_id)
     14JOIN camProcessedExp
     15    USING(cam_id)
    1416JOIN chipRun
    1517    USING(chip_id)
     
    1719    USING(exp_id)
    1820WHERE
    19     warpSkyfile.skycell_id = '%s'
     21    warpSkyfile.skycell_id = '@SKYCELL_ID@'
    2022    AND warpRun.state = 'full'
    21     AND rawExp.filter = '%s'
     23    AND rawExp.filter = '@FILTER@'
    2224    AND warpSkyfile.fault = 0
    2325    AND warpSkyfile.quality = 0
  • trunk/ippTools/share/stacktool_definebyquery_insert_random_part1.sql

    r23688 r24664  
    1919    JOIN camRun
    2020        USING(cam_id)
     21    JOIN camProcessedExp
     22        USING(cam_id)
    2123    JOIN chipRun
    2224        USING(chip_id)
     
    2426        USING(exp_id)
    2527    WHERE
    26         skycell_id = '%s'
     28        skycell_id = '@SKYCELL_ID@'
    2729        AND warpRun.state = 'full'
    28         AND rawExp.filter = '%s' -- the result of the query is grouped by filter and inserted for one at a time
     30        AND rawExp.filter = '@FILTER@' -- the result of the query is grouped by filter and inserted for one at a time
    2931        AND warpSkyfile.fault = 0
    3032        AND warpSkyfile.quality = 0
  • trunk/ippTools/share/stacktool_definebyquery_insert_random_part2.sql

    r19249 r24664  
    55    -- to get a random set of N.
    66    ORDER BY rnd_num
    7     LIMIT %d
     7    LIMIT @RANDOM_LIMIT@
    88) AS randomWarps
  • trunk/ippTools/src/stacktool.c

    r24661 r24664  
    153153
    154154    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     155    PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false);
    155156    PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
    156157
     
    236237    }
    237238    if (!psArrayLength(output)) {
    238         psTrace("stacktool", PS_LOG_INFO, "no rows found");
     239        psWarning("stacktool: no rows found");
     240        psFree(output);
     241        psFree(where);
     242        return true;
     243    }
     244    if (pretend) {
     245        // negative simple so the default is true
     246        if (!ippdbPrintMetadatas(stdout, output, "stackSkycells", !simple)) {
     247            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     248            psFree(output);
     249            psFree(where);
     250            return false;
     251        }
    239252        psFree(output);
    240253        psFree(where);
     
    362375        psFree(idString);
    363376
     377        // replace @FILTER@, @SKYCELL_ID@, @RANDOM_LIMIT@
     378        psStringSubstitute(&thisInsert, filter, "@FILTER@");
     379        psStringSubstitute(&thisInsert, skycell_id, "@SKYCELL_ID@");
     380
     381        if (randomLimit > 0) {
     382          psString limString = NULL;
     383          psStringAppend(&limString, "%d", randomLimit);
     384          psStringSubstitute(&thisInsert, limString, "@RANDOM_LIMIT@");
     385          psFree(limString);
     386        }
     387
    364388        // XXX this insert uses a select to generate the list of warp_ids for the stack,
    365389        // we have applied a set of criteria above (WHERE) to select the relevant warps
    366390        // this insert needs to use exactly the same restrictions (race condition is probably not critical)
    367391        // the insert below seems to only restrict matches to the skycell, tess, and filter
    368         if ((randomLimit > 0 && !p_psDBRunQueryF(config->dbh, thisInsert, skycell_id, filter, randomLimit)) ||
    369             (randomLimit <= 0 && !p_psDBRunQueryF(config->dbh, thisInsert, skycell_id, filter))) {
     392        if (!p_psDBRunQuery(config->dbh, thisInsert)) {
    370393            psError(PS_ERR_UNKNOWN, false, "database error");
    371394            psFree(thisInsert);
     
    379402        }
    380403        psFree(thisInsert);
     404
     405# if (0)
     406        {
     407          psArray *output = p_psDBFetchResult(config->dbh);
     408          if (!output) {
     409            psErrorCode err = psErrorCodeLast();
     410            switch (err) {
     411            case PS_ERR_DB_CLIENT:
     412              psError(PXTOOLS_ERR_SYS, false, "database error");
     413            case PS_ERR_DB_SERVER:
     414              psError(PXTOOLS_ERR_PROG, false, "database error");
     415            default:
     416              psError(PXTOOLS_ERR_PROG, false, "unknown error");
     417            }
     418            psFree(where);
     419            return false;
     420          }
     421          if (!psArrayLength(output)) {
     422            psWarning("stacktool (definebyquery, insert): no rows found");
     423            psFree(output);
     424            psFree(where);
     425            return true;
     426          }
     427          // negative simple so the default is true
     428          if (!ippdbPrintMetadatas(stdout, output, "stackSkycells", !simple)) {
     429            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     430            psFree(output);
     431            psFree(where);
     432            return false;
     433          }
     434          psFree(output);
     435          psFree(where);
     436          return true;
     437        }
     438# endif
     439
    381440    }
    382441    psFree(output);
  • trunk/ippTools/src/stacktoolConfig.c

    r24660 r24664  
    8282    psMetadataAddS32(definebyqueryArgs, PS_LIST_TAIL, "-min_new", 0, "minimum number of new inputs", 0);
    8383    psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-min_frac", 0, "minumum fraction of new inputs", NAN);
     84    psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-pretend",  0, "do not actually modify the database", false);
    8485    psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);
    8586
Note: See TracChangeset for help on using the changeset viewer.