IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 12, 2006, 3:52:24 PM (19 years ago)
Author:
jhoblitt
Message:

add a -limit option to -pendingexp & -pendingimfile

File:
1 edited

Legend:

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

    r10637 r10671  
    8282    PS_ASSERT_PTR_NON_NULL(config, false);
    8383
     84    bool status = false;
     85    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     86    if (!status) {
     87        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit");
     88        return false;
     89    }
     90
    8491    // return only exps that:
    8592    // are not in rawScienceExp
     
    8895    // and have no associated imfiles left in newImfile
    8996
    90     char *query =
     97    psString query = psStringCopy(
    9198        "SELECT"
    9299        "   newExp.*"
     
    105112        "   (SELECT COUNT(exp_tag) FROM rawImfile"
    106113        "       WHERE rawImfile.exp_tag = newExp.exp_tag)"
    107         ;
     114    );
     115
     116    // treat limit == 0 as "no limit"
     117    if (limit) {
     118        psString limitString = psDBGenerateLimitSQL(limit);
     119        psStringAppend(&query, " %s", limitString);
     120        psFree(limitString);
     121    }
    108122
    109123    if (!p_psDBRunQuery(config->dbh, query)) {
    110124        psError(PS_ERR_UNKNOWN, false, "database error");
    111         return false;
    112     }
     125        psFree(query);
     126        return false;
     127    }
     128    psFree(query);
    113129
    114130    psArray *output = p_psDBFetchResult(config->dbh);
     
    150166    PS_ASSERT_PTR_NON_NULL(config, false);
    151167
     168    bool status = false;
     169    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     170    if (!status) {
     171        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit");
     172        return false;
     173    }
     174
    152175    // select newImfiles that:
    153176    // exp_tag is in newExp
     
    156179    // XXX having the same exp_tag in newExp and raw*Exp is probably an error
    157180    // that should be checked for
    158     char *query =
     181
     182    psString query = psStringCopy(
    159183        "SELECT newImfile.* FROM newImfile"
    160184        " LEFT JOIN newExp USING(exp_tag)"
     
    163187        " WHERE newExp.exp_tag is NOT NULL"
    164188        " AND rawScienceExp.exp_tag IS NULL"
    165         " AND rawDetrendExp.exp_tag IS NULL";
     189        " AND rawDetrendExp.exp_tag IS NULL"
     190    );
     191
     192    // treat limit == 0 as "no limit"
     193    if (limit) {
     194        psString limitString = psDBGenerateLimitSQL(limit);
     195        psStringAppend(&query, " %s", limitString);
     196        psFree(limitString);
     197    }
    166198
    167199    if (!p_psDBRunQuery(config->dbh, query)) {
    168200        psError(PS_ERR_UNKNOWN, false, "database error");
    169         return false;
    170     }
     201        psFree(query);
     202        return false;
     203    }
     204    psFree(query);
    171205
    172206    psArray *output = p_psDBFetchResult(config->dbh);
Note: See TracChangeset for help on using the changeset viewer.