IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 15, 2008, 2:41:41 PM (18 years ago)
Author:
Paul Price
Message:

Converting to use of psS64 for magic_id, diff_id. Cleaning up magictoolConfig.c. Adding error code into inputtree.

File:
1 edited

Legend:

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

    r18561 r18571  
    111111    // create warped skycells temp table
    112112    {
    113         psString query = pxDataGet("magictool_create_tmp_warpcomplete.sql");
    114         if (!query) {
    115             psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    116             return false;
    117         }
    118 
    119         if (!p_psDBRunQuery(config->dbh, query)) {
    120             psError(PS_ERR_UNKNOWN, false, "database error");
    121             return false;
    122         }
     113        psString query = pxDataGet("magictool_create_tmp_warpcomplete.sql");
     114        if (!query) {
     115            psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     116            return false;
     117        }
     118
     119        if (!p_psDBRunQuery(config->dbh, query)) {
     120            psError(PS_ERR_UNKNOWN, false, "database error");
     121            return false;
     122        }
    123123    }
    124124
    125125    // find warped skycells
    126126    {
    127         psString query = pxDataGet("magictool_find_complete_warpruns.sql");
    128         if (!query) {
    129             psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    130             return false;
    131         }
    132 
    133         if (!p_psDBRunQuery(config->dbh, query)) {
    134             psError(PS_ERR_UNKNOWN, false, "database error");
    135             psFree(query);
    136             return false;
    137         }
    138         psFree(query);
     127        psString query = pxDataGet("magictool_find_complete_warpruns.sql");
     128        if (!query) {
     129            psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     130            return false;
     131        }
     132
     133        if (!p_psDBRunQuery(config->dbh, query)) {
     134            psError(PS_ERR_UNKNOWN, false, "database error");
     135            psFree(query);
     136            return false;
     137        }
     138        psFree(query);
    139139    }
    140140
    141141    // find the diff_id's of the warped skycells
    142142    {
    143         psString query = pxDataGet("magictool_find_complete_diffed_exposures.sql");
    144         if (!query) {
    145             psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    146             return false;
    147         }
    148 
    149         if (!p_psDBRunQuery(config->dbh, query)) {
    150             psError(PS_ERR_UNKNOWN, false, "database error");
    151             psFree(query);
    152             return false;
    153         }
    154         psFree(query);
     143        psString query = pxDataGet("magictool_find_complete_diffed_exposures.sql");
     144        if (!query) {
     145            psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     146            return false;
     147        }
     148
     149        if (!p_psDBRunQuery(config->dbh, query)) {
     150            psError(PS_ERR_UNKNOWN, false, "database error");
     151            psFree(query);
     152            return false;
     153        }
     154        psFree(query);
    155155    }
    156156    psArray *output = p_psDBFetchResult(config->dbh);
     
    158158        psErrorCode err = psErrorCodeLast();
    159159        switch (err) {
    160           case PS_ERR_DB_CLIENT:
    161             psError(PXTOOLS_ERR_SYS, false, "database error");
    162           case PS_ERR_DB_SERVER:
    163             psError(PXTOOLS_ERR_PROG, false, "database error");
    164           default:
    165             psError(PXTOOLS_ERR_PROG, false, "unknown error");
     160          case PS_ERR_DB_CLIENT:
     161            psError(PXTOOLS_ERR_SYS, false, "database error");
     162          case PS_ERR_DB_SERVER:
     163            psError(PXTOOLS_ERR_PROG, false, "database error");
     164          default:
     165            psError(PXTOOLS_ERR_PROG, false, "unknown error");
    166166        }
    167167
     
    211211        // create a new magicRun for this group
    212212        magicRunRow *run = magicRunRowAlloc(
    213             0,                          // ID
    214             "reg",                      // state
    215             workdir,                    // workdir
    216             "dirty",                    // workdir_state
    217             label,                      // label
    218             dvodb,                      // dvodb
    219             registered,                 // registered
    220             0                           // fault
    221             );
     213            0,                          // ID
     214            "reg",                      // state
     215            workdir,                    // workdir
     216            "dirty",                    // workdir_state
     217            label,                      // label
     218            dvodb,                      // dvodb
     219            registered,                 // registered
     220            0                           // fault
     221            );
    222222        if (!run) {
    223223            psAbort("failed to alloc magicRun object");
     
    248248
    249249            if (!magicInputSkyfileInsert(config->dbh,
    250                                         magic_id,
    251                                         diff_id,
    252                                         node)) {
     250                                        magic_id,
     251                                        diff_id,
     252                                        node)) {
    253253                psError(PS_ERR_UNKNOWN, false, "database error");
    254254                psFree(grouped);
     
    320320
    321321    // required
    322     PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false);
     322    PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false);
    323323    PXOPT_LOOKUP_STR(state, config->args, "-state", true, false);
    324324
    325325    if (state) {
    326326        // set detRun.state to state
    327         return setmagicRunState(config, (psS64)atoll(magic_id), state);
     327        return setmagicRunState(config, magic_id, state);
    328328    }
    329329
     
    337337
    338338    // required
    339     PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false);
    340     PXOPT_LOOKUP_STR(diff_id, config->args, "-diff_id", true, false);
     339    PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false);
     340    PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false);
    341341    PXOPT_LOOKUP_STR(node, config->args, "-node", true, false);
    342342
    343343    magicInputSkyfileInsert(
    344344            config->dbh,
    345             (psS64)atoll(magic_id),
    346             (psS64)atoll(diff_id),
     345            magic_id,
     346            diff_id,
    347347            node
    348348    );
     
    357357
    358358    psMetadata *where = psMetadataAlloc();
    359     PXOPT_COPY_STR(config->args, where, "-magic_id", "magic_id", "==");
    360     PXOPT_COPY_STR(config->args, where, "-diff_id", "diff_id", "==");
     359    PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
     360    PXOPT_COPY_S64(config->args, where, "-diff_id", "diff_id", "==");
    361361    PXOPT_COPY_STR(config->args, where, "-node", "node", "==");
    362362
     
    431431
    432432    psMetadata *where = psMetadataAlloc();
    433     PXOPT_COPY_STR(config->args, where, "-magic_id", "magicRun.magic_id", "==");
     433    PXOPT_COPY_S64(config->args, where, "-magic_id", "magicRun.magic_id", "==");
    434434
    435435    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     
    503503
    504504    // required
    505     PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false);
    506     PXOPT_LOOKUP_STR(dep_file, config->args, "-dep_file", true, false);
    507 
    508     if (!parseAndInsertNodeDeps(config, (psS64)atoll(magic_id), dep_file)) {
     505    PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false);
     506
     507    // Optional values
     508    PXOPT_LOOKUP_STR(dep_file, config->args, "-dep_file", false, false);
     509
     510    // default values
     511    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
     512
     513    if (code > 0) {
     514        char *query = "UPDATE magicRun SET fault = %d WHERE magic_id = %" PRId64;
     515        if (!p_psDBRunQuery(config->dbh, query, code, magic_id)) {
     516            psError(PS_ERR_UNKNOWN, false,
     517                    "failed to set fault for magic_id %" PRId64, magic_id);
     518            return false;
     519        }
     520        return true;
     521    }
     522
     523    if (!parseAndInsertNodeDeps(config, magic_id, dep_file)) {
    509524        psError(PS_ERR_UNKNOWN, false, "failed to parse file");
    510525        return false;
     
    519534
    520535    psMetadata *where = psMetadataAlloc();
    521     PXOPT_COPY_STR(config->args, where, "-magic_id", "magic_id", "==");
     536    PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
    522537    PXOPT_COPY_STR(config->args, where, "-node", "node", "==");
    523538
     
    663678
    664679    psMetadata *where = psMetadataAlloc();
    665     PXOPT_COPY_STR(config->args, where, "-magic_id", "magic_id", "==");
     680    PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
    666681
    667682    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     
    678693        whereClause = psDBGenerateWhereSQL(where, NULL);
    679694        psStringAppend(&query, " %s", whereClause);
    680         psFree(whereClause);
     695        psFree(whereClause);
    681696    }
    682697    psFree(where);
     
    705720    if (!psArrayLength(output)) {
    706721        psTrace("magictool", PS_LOG_INFO, "no rows found");
    707         // psFree(output);
     722        // psFree(output);
    708723        // return true;
    709724    }
     
    798813
    799814    // required
    800     PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false);
     815    PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false);
    801816    PXOPT_LOOKUP_STR(node, config->args, "-node", true, false);
    802817
     
    808823
    809824    if (!magicNodeResultInsert(config->dbh,
    810                                (psS64)atoll(magic_id),
     825                               magic_id,
    811826                               node,
    812827                               uri,
     
    888903
    889904    // required
    890     PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false);
     905    PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false);
    891906
    892907    // optional
     
    903918
    904919    if (!magicMaskInsert(config->dbh,
    905                          (psS64)atoll(magic_id),
     920                         magic_id,
    906921                         uri,
    907922                         streaks,
     
    920935
    921936    // manually add constraint
    922     psStringAppend(&query, " AND magic_id = %s", magic_id);
     937    psStringAppend(&query, " AND magic_id = %" PRId64, magic_id);
    923938
    924939    if (!p_psDBRunQuery(config->dbh, query)) {
     
    943958
    944959    psMetadata *where = psMetadataAlloc();
    945     PXOPT_COPY_STR(config->args, where, "-magic_id", "magicRun.magic_id", "==");
     960    PXOPT_COPY_S64(config->args, where, "-magic_id", "magicRun.magic_id", "==");
    946961
    947962    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
Note: See TracChangeset for help on using the changeset viewer.