IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15032


Ignore:
Timestamp:
Sep 26, 2007, 11:13:41 AM (19 years ago)
Author:
jhoblitt
Message:

fix -copydone to work with exp's with more than 1 imfile
add -pending[exp|imfile] -limit n options

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

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

    r14627 r15032  
    137137    PS_ASSERT_PTR_NON_NULL(config, false);
    138138
     139    bool status = false;
     140    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     141    if (!status) {
     142        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit");
     143        return false;
     144    }
     145
    139146    psString query = psStringCopy(
    140147            "SELECT"
     
    151158    }
    152159
     160    // treat limit == 0 as "no limit"
     161    if (limit) {
     162        psString limitString = psDBGenerateLimitSQL(limit);
     163        psStringAppend(&query, " %s", limitString);
     164        psFree(limitString);
     165    }
     166
    153167    if (!p_psDBRunQuery(config->dbh, query)) {
    154168        psError(PS_ERR_UNKNOWN, false, "database error");
     
    196210    PS_ASSERT_PTR_NON_NULL(config, false);
    197211
     212    bool status = false;
     213    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     214    if (!status) {
     215        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit");
     216        return false;
     217    }
     218
    198219    psString query = psStringCopy(
    199220            "SELECT"
     
    208229        psStringAppend(&query, " AND %s", whereClause);
    209230        psFree(whereClause);
     231    }
     232
     233    // treat limit == 0 as "no limit"
     234    if (limit) {
     235        psString limitString = psDBGenerateLimitSQL(limit);
     236        psStringAppend(&query, " %s", limitString);
     237        psFree(limitString);
    210238    }
    211239
     
    478506        psS64 exp_id = psDBLastInsertID(config->dbh);
    479507
    480         // insert new pzDoneImfile into newImfile
     508        // insert new all pzDoneImfile for the exp into newImfile
    481509        {
    482510            char *query =
     
    503531            }
    504532
    505             // sanity check: we should have inserted only one row
     533            // sanity check: we should have inserted at least one row
    506534            psU64 affected = psDBAffectedRows(config->dbh);
    507             if (psDBAffectedRows(config->dbh) != 1) {
     535            if (psDBAffectedRows(config->dbh) < 1) {
    508536                // rollback
    509537                if (!psDBRollback(config->dbh)) {
    510538                    psError(PS_ERR_UNKNOWN, false, "database error");
    511539                }
    512                 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row but %" PRIu64 " rows were modified", affected);
     540                psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row but %" PRIu64 " rows were modified", affected);
    513541                psFree(doneExp);
    514542                psFree(output);
  • trunk/ippTools/src/pztoolConfig.c

    r14600 r15032  
    6666    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-exp_type", 0,
    6767            "define exposure type", NULL);
     68    psMetadataAddU64(pendingexpArgs, PS_LIST_TAIL, "-limit",  0,
     69            "limit result set to N items", 0);
    6870    psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-simple", 0,
    6971            "use the simple output format", false);
     
    7981    psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-exp_type", 0,
    8082            "define exposure type", NULL);
     83    psMetadataAddU64(pendingimfileArgs, PS_LIST_TAIL, "-limit",  0,
     84            "limit result set to N items", 0);
    8185    psMetadataAddBool(pendingimfileArgs, PS_LIST_TAIL, "-simple", 0,
    8286            "use the simple output format", false);
     
    8589    psMetadata *copydoneArgs = psMetadataAlloc();
    8690    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-exp_name", 0,
    87             "define exposure ID", NULL);
     91            "define exposure ID (required)", NULL);
    8892    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-inst", 0,
    89             "define camera ID", NULL);
     93            "define camera ID (required)", NULL);
    9094    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-telescope", 0,
    91             "define telescope ID", NULL);
     95            "define telescope ID (required)", NULL);
    9296    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-class", 0,
    9397            "define class", NULL);
Note: See TracChangeset for help on using the changeset viewer.