IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 17, 2010, 4:40:03 PM (16 years ago)
Author:
Paul Price
Message:

Reworked all ippTools to put fault=2 (SYS_ERROR) when can't find SQL file (presumably due to NFS problems). Removed DATA_ERROR because ippTools don't work on data (astronomical images or catalogues). This should allow us to turn on revert for fault=2 only.

File:
1 edited

Legend:

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

    r26565 r26981  
    146146    psString query = pxDataGet("pstamptool_datastore.sql");
    147147    if (!query) {
    148         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     148        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    149149        return false;
    150150    }
     
    199199    char *query = psStringCopy ("UPDATE pstampDataStore SET");
    200200    bool needComma = false;
    201    
     201
    202202    if (lastFileset) {
    203203        psStringAppend(&query, " lastFileset = '%s'", lastFileset);
     
    209209        needComma = true; // be ready in case we add another field
    210210    }
    211                
     211
    212212    psStringAppend(&query, " WHERE ds_id = %" PRId64, ds_id);
    213213
     
    220220    psU64 affected = psDBAffectedRows(config->dbh);
    221221    if (affected != 1) {
    222         psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 
     222        psError(PS_ERR_UNKNOWN, false, "should have affected one row but %"
    223223                                        PRIu64 " rows were modified", affected);
    224224        return false;
     
    245245        label,
    246246        NULL,   // outProduct
    247         uri,   
    248         0       // fault 
     247        uri,
     248        0       // fault
    249249        )) {
    250250        psError(PS_ERR_UNKNOWN, false, "failed to insert request");
     
    271271    psString query = pxDataGet("pstamptool_pendingreq.sql");
    272272    if (!query) {
    273         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     273        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    274274        return false;
    275275    }
     
    342342    psFree(whereClause);
    343343    psFree(where);
    344    
     344
    345345    // treat limit == 0 as "no limit"
    346346    if (limit) {
     
    365365        psTrace("pstamptool", PS_LOG_INFO, "request not found");
    366366        // This causes main to exit with PS_EXIT_DATA_ERROR which the script is looking for
    367         psError(PXTOOLS_ERR_DATA, true, "request not found");
     367        psError(PXTOOLS_ERR_CONFIG, true, "request not found");
    368368        psFree(output);
    369369        // we return false so that the caller can determine that a request does not exist
     
    436436    PXOPT_LOOKUP_STR(state,      config->args, "-state",      false, false);
    437437    PXOPT_LOOKUP_STR(outProduct, config->args, "-outProduct", false, false);
    438     PXOPT_LOOKUP_STR(fault,     config->args, "-fault",      false, false);
    439     PXOPT_LOOKUP_STR(uri,       config->args, "-uri",        false, false);
    440     PXOPT_LOOKUP_STR(name,      config->args, "-name",       false, false);
     438    PXOPT_LOOKUP_STR(fault,     config->args, "-fault",      false, false);
     439    PXOPT_LOOKUP_STR(uri,       config->args, "-uri",        false, false);
     440    PXOPT_LOOKUP_STR(name,      config->args, "-name",       false, false);
    441441    PXOPT_LOOKUP_STR(reqType,    config->args, "-reqType",    false, false);
    442442
     
    485485    // note zero is not an error
    486486    if (affected > 1) {
    487         psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 
     487        psError(PS_ERR_UNKNOWN, false, "should have affected one row but %"
    488488                                        PRIu64 " rows were modified", affected);
    489489        return false;
     
    505505    if (!psListLength(where->list)) {
    506506        psFree(where);
    507         psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     507        psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
    508508        return false;
    509509    }
     
    525525    query = pxDataGet("pstamptool_revertreq.sql");
    526526    psStringAppend(&query, " AND %s", whereClause);
    527    
     527
    528528    psFree(whereClause);
    529529
     
    555555    // unless the job is being inserted with stop state require outputBase
    556556    if (strcmp(stateString, "stop") && !outputBase) {
    557         psError(PS_ERR_UNKNOWN, true, "-outputBase is required");
    558         return false;
     557        psError(PS_ERR_UNKNOWN, true, "-outputBase is required");
     558        return false;
    559559    }
    560560
    561561    // default value for job_type is defined in pstamptoolConfig.c
    562562    if (!strcmp(job_type, "get_image") || !strcmp(job_type, "detect_query") || !strcmp(job_type, "none")) {
    563         stampJob = false;
     563        stampJob = false;
    564564    } else if (!strcmp(job_type, "stamp")) {
    565         stampJob = true;
     565        stampJob = true;
    566566    } else {
    567         psError(PS_ERR_UNKNOWN, false, "unknown value for -job_type: %s", job_type);
    568         return false;
    569     }
    570     if (!pstampJobInsert(config->dbh, 
     567        psError(PS_ERR_UNKNOWN, false, "unknown value for -job_type: %s", job_type);
     568        return false;
     569    }
     570    if (!pstampJobInsert(config->dbh,
    571571            0, // job_id
    572572            req_id,
    573             rownum, 
    574             stateString, 
    575             job_type, 
    576             fault, 
    577             exp_id, 
     573            rownum,
     574            stateString,
     575            job_type,
     576            fault,
     577            exp_id,
    578578            outputBase,
    579579            options,
     
    586586    psU64 affected = psDBAffectedRows(config->dbh);
    587587    if (affected != 1) {
    588         psError(PS_ERR_UNKNOWN, false, 
     588        psError(PS_ERR_UNKNOWN, false,
    589589            "should have affected one row but %" PRIu64 " rows were modified",
    590590            affected);
     
    617617    psString query = pxDataGet("pstamptool_listjob.sql");
    618618    if (!query) {
    619         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     619        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    620620        return false;
    621621    }
     
    679679    psString query = pxDataGet("pstamptool_pendingjob.sql");
    680680    if (!query) {
    681         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     681        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    682682        return false;
    683683    }
     
    744744
    745745    char *query ="UPDATE pstampJob"
    746         " SET state = '%s' %s"
    747         " WHERE job_id = %" PRId64;
    748    
     746        " SET state = '%s' %s"
     747        " WHERE job_id = %" PRId64;
     748
    749749    if (!p_psDBRunQueryF(config->dbh, query, state, faultStr, job_id)) {
    750750        psError(PS_ERR_UNKNOWN, false, "database error");
     
    756756    psU64 affected = psDBAffectedRows(config->dbh);
    757757    if (affected != 1) {
    758         psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 
     758        psError(PS_ERR_UNKNOWN, false, "should have affected one row but %"
    759759                                        PRIu64 " rows were modified", affected);
    760760        return false;
     
    790790    if (!psListLength(where->list) && !all) {
    791791        psFree(where);
    792         psError(PXTOOLS_ERR_DATA, false, "search parameters or -all are required");
     792        psError(PXTOOLS_ERR_CONFIG, false, "search parameters or -all are required");
    793793        return false;
    794794    }
     
    799799    }
    800800    psFree(where);
    801    
     801
    802802    if (!p_psDBRunQueryF(config->dbh, query, faultClause)) {
    803803        psError(PS_ERR_UNKNOWN, false, "database error");
     
    847847    psString query = pxDataGet("pstamptool_project.sql");
    848848    if (!query) {
    849         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     849        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    850850        return false;
    851851    }
     
    893893
    894894    char *query = psStringCopy ("UPDATE pstampProject SET");
    895    
     895
    896896    psStringAppend(&query, " state = '%s'", state);
    897                
     897
    898898    psStringAppend(&query, " WHERE proj_id = %" PRId64, proj_id);
    899899
     
    906906    psU64 affected = psDBAffectedRows(config->dbh);
    907907    if (affected != 1) {
    908         psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 
     908        psError(PS_ERR_UNKNOWN, false, "should have affected one row but %"
    909909                                        PRIu64 " rows were modified", affected);
    910910        return false;
     
    938938    psString query = pxDataGet("pstamptool_pendingdependent.sql");
    939939    if (!query) {
    940         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     940        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    941941        return false;
    942942    }
     
    986986    }
    987987    // no existing dependent that matches, insert one
    988     // Since we have multiple processes running jobs we have a 
     988    // Since we have multiple processes running jobs we have a
    989989    // race condition here so that's why we need to lock the table
    990990
     
    10321032    psString query = pxDataGet("pstamptool_pendingdependent.sql");
    10331033    if (!query) {
    1034         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1034        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    10351035        return false;
    10361036    }
     
    10871087
    10881088    char *query ="UPDATE pstampDependent"
    1089         " SET state = '%s'"
    1090         " WHERE dep_id = %" PRId64;
    1091    
     1089        " SET state = '%s'"
     1090        " WHERE dep_id = %" PRId64;
     1091
    10921092    if (!p_psDBRunQueryF(config->dbh, query, state, dep_id)) {
    10931093        psError(PS_ERR_UNKNOWN, false, "database error");
     
    10981098    psU64 affected = psDBAffectedRows(config->dbh);
    10991099    if (affected != 1) {
    1100         psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 
     1100        psError(PS_ERR_UNKNOWN, false, "should have affected one row but %"
    11011101                                        PRIu64 " rows were modified", affected);
    11021102        return false;
Note: See TracChangeset for help on using the changeset viewer.