IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 13, 2007, 12:22:23 PM (19 years ago)
Author:
jhoblitt
Message:

add p4tool -warped

File:
1 edited

Legend:

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

    r11776 r11777  
    945945    PS_ASSERT_PTR_NON_NULL(config, false);
    946946
    947     psString query = psStringCopy(
    948         " SELECT DISTINCT"
    949         "   p4Scfile.*"
    950         " FROM p4Run"
    951         " JOIN p4Scfile"
    952         "   USING(p4_id)"
    953         " WHERE"
    954         "   p4Run.state = 'run'"
     947    bool status = false;
     948    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     949    if (!status) {
     950        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
     951        return false;
     952    }
     953
     954    // find all rawImfiles matching the default query
     955    psString query = psStringCopy(
     956        "SELECT\n"
     957        "   p4Scfile.*\n"
     958        " FROM p4Run\n"
     959        " JOIN p4Scfile\n"
     960        "   USING(p4_id)\n"
     961        " WHERE\n"
     962        "   p4Run.state = 'run'\n"
    955963    );
    956964
     
    961969    }
    962970
     971    // treat limit == 0 as "no limit"
     972    if (limit) {
     973        psString limitString = psDBGenerateLimitSQL(limit);
     974        psStringAppend(&query, " %s", limitString);
     975        psFree(limitString);
     976    }
     977
    963978    if (!p_psDBRunQuery(config->dbh, query)) {
    964979        psError(PS_ERR_UNKNOWN, false, "database error");
     
    970985    psArray *output = p_psDBFetchResult(config->dbh);
    971986    if (!output) {
    972         psError(PS_ERR_UNKNOWN, false, "database error");
     987        psErrorCode err = psErrorCodeLast();
     988        switch (err) {
     989            case PS_ERR_DB_CLIENT:
     990                psError(PXTOOLS_ERR_SYS, false, "database error");
     991            case PS_ERR_DB_SERVER:
     992                psError(PXTOOLS_ERR_PROG, false, "database error");
     993            default:
     994                psError(PXTOOLS_ERR_PROG, false, "unknown error");
     995        }
     996
    973997        return false;
    974998    }
     
    9891013    }
    9901014
    991     // negative simple so the default is true
    992     if (!ippdbPrintMetadatas(stdout, output, "p4Scfile", !simple)) {
    993         psError(PS_ERR_UNKNOWN, false, "failed to print array");
    994         psFree(output);
    995         return false;
     1015    if (psArrayLength(output)) {
     1016        // negative simple so the default is true
     1017        if (!ippdbPrintMetadatas(stdout, output, "p4Scfile", !simple)) {
     1018            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1019            psFree(output);
     1020            return false;
     1021        }
    9961022    }
    9971023
Note: See TracChangeset for help on using the changeset viewer.