IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14147


Ignore:
Timestamp:
Jul 11, 2007, 3:01:27 PM (19 years ago)
Author:
jhoblitt
Message:

properly constraint camtool -addprocessexp sanity checking SQL

Location:
trunk/ippTools
Files:
2 edited

Legend:

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

    r14027 r14147  
    22-- does a little more work then is necessary for -addprocessed but it seems
    33-- "cleaner" to use the same query for both cases
    4 SELECT
    5     camRun.*,
    6     rawExp.exp_tag,
    7     rawExp.exp_id,
    8     rawExp.exp_name,
    9     rawExp.camera,
    10     rawExp.telescope,
    11     rawExp.filelevel
    12 FROM camRun
    13 JOIN chipRun
    14     USING(chip_id)
    15 JOIN chipProcessedImfile
    16     USING(chip_id)
    17 JOIN rawExp
    18     ON chipProcessedImfile.exp_id = rawExp.exp_id
    19 LEFT JOIN camProcessedExp
    20     ON camRun.cam_id = camProcessedExp.cam_id
    21 LEFT JOIN camMask
    22     ON camRun.label = camMask.label
    23 WHERE
    24     chipRun.state = 'stop'
    25     AND camRun.state = 'run'
    26     AND camMask.label IS NULL
    27     AND camProcessedExp.cam_id IS NULL
     4SELECT * FROM
     5    (SELECT
     6        camRun.*,
     7        rawExp.exp_tag,
     8        rawExp.exp_id,
     9        rawExp.exp_name,
     10        rawExp.camera,
     11        rawExp.telescope,
     12        rawExp.filelevel
     13    FROM camRun
     14    JOIN chipRun
     15        USING(chip_id)
     16    JOIN chipProcessedImfile
     17        USING(chip_id)
     18    JOIN rawExp
     19        ON chipProcessedImfile.exp_id = rawExp.exp_id
     20    LEFT JOIN camProcessedExp
     21        ON camRun.cam_id = camProcessedExp.cam_id
     22    LEFT JOIN camMask
     23        ON camRun.label = camMask.label
     24    WHERE
     25        chipRun.state = 'stop'
     26        AND camRun.state = 'run'
     27        AND camMask.label IS NULL
     28        AND camProcessedExp.cam_id IS NULL
     29    ) as Foo
  • trunk/ippTools/src/camtool.c

    r14100 r14147  
    590590    }
    591591
    592     if (!p_psDBRunQuery(config->dbh, query, cam_id)) {
     592    {
     593        // build a query to search by cam_id
     594        psMetadata *where = psMetadataAlloc();
     595        if (cam_id) {
     596            if (!psMetadataAddS64(where, PS_LIST_TAIL, "cam_id", 0, "==", (psS64)atoll(cam_id))) {
     597                psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id");
     598                psFree(where);
     599                psFree(query);
     600                return false;
     601            }
     602        }
     603
     604        psString whereClaus = psDBGenerateWhereSQL(where, NULL);
     605        psFree(where);
     606        if (whereClaus) {
     607            psStringAppend(&query, " %s", whereClaus);
     608            psFree(whereClaus);
     609        }
     610
     611    }
     612
     613    if (!p_psDBRunQuery(config->dbh, query)) {
    593614        psError(PS_ERR_UNKNOWN, false, "database error");
    594615        psFree(query);
Note: See TracChangeset for help on using the changeset viewer.