IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42412 for trunk/ippTools/src


Ignore:
Timestamp:
Mar 14, 2023, 3:31:02 PM (3 years ago)
Author:
eugene
Message:

add option to ignore summitcopy errors

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

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

    r42387 r42412  
    7777    PXOPT_LOOKUP_S32(timeout, config->args, "-timeout", false, false);
    7878    PXOPT_LOOKUP_BOOL(all, config->args, "-all", false);
     79    PXOPT_LOOKUP_BOOL(ignore_errors, config->args, "-ignore-errors", false);
    7980
    8081    // find last fileset/exp_name (if we have one)
     
    180181    }
    181182
     183    // XXX for test, make this not a temporary table:
    182184    // create a temporry table
    183185    {
     
    197199
    198200    {
    199         char *query = "INSERT INTO incoming (exp_name, camera, telescope, dateobs, exp_type, uri) VALUES (?, ?, ?, ?, ?, ?)";
     201      char *query_notice = "INSERT INTO incoming (exp_name, camera, telescope, dateobs, exp_type, uri) VALUES (?, ?, ?, ?, ?, ?)";
     202      char *query_ignore = "INSERT IGNORE INTO incoming (exp_name, camera, telescope, dateobs, exp_type, uri) VALUES (?, ?, ?, ?, ?, ?)";
     203
     204      char *query = ignore_errors ? query_ignore : query_notice;
    200205
    201206        long inserted = p_psDBRunQueryPrepared(config->dbh, newSummitExps, query);
     
    209214            return false;
    210215        }
     216        fprintf (stderr, "inserted: %d\n", (int) inserted);
    211217        // sanity check that we actually inserted something
    212218        if (inserted == 0) {
     
    222228
    223229    psFree(newSummitExps);
     230
     231    // TEST
     232    if (0) {
     233        char *query = "select * from incomingTest";
     234        p_psDBRunQuery(config->dbh, query);
     235        psArray *output = p_psDBFetchResult(config->dbh);
     236        if (!output) {
     237            psError(PS_ERR_UNKNOWN, false, "database error");
     238            return false;
     239        }
     240       
     241        // negative simple so the default is true
     242        if (!ippdbPrintMetadatas(stdout, output, "test", TRUE)) {
     243            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     244            psFree(output);
     245            return false;
     246        }
     247        psFree(output);
     248        exit (2);
     249    }
     250
     251    // debug this query
     252    if (0) {
     253        char *query =
     254            "DESCRIBE INSERT INTO summitExp"
     255            "   SELECT"
     256            "       NULL," // summit_id
     257            "       incomingTest.*,"
     258            "       NULL,"  // imfiles
     259            "       0,"     // fault
     260            "       NULL"   // epoch
     261            "   FROM incomingTest"
     262            "   LEFT JOIN summitExp"
     263            "       USING(exp_name, camera, telescope)"
     264            "   WHERE"
     265            "       summitExp.exp_name is NULL"
     266            "       AND summitExp.camera is NULL"
     267            "       AND summitExp.telescope is NULL";
     268
     269        if (!p_psDBRunQuery(config->dbh, query)) {
     270            // rollback
     271            if (!psDBRollback(config->dbh)) {
     272                psError(PS_ERR_UNKNOWN, false, "database error");
     273            }
     274            psError(PS_ERR_UNKNOWN, false, "database error");
     275            return false;
     276        }
     277        psArray *output = p_psDBFetchResult(config->dbh);
     278        if (!output) {
     279            psError(PS_ERR_UNKNOWN, false, "database error");
     280            return false;
     281        }
     282       
     283        // negative simple so the default is true
     284        if (!ippdbPrintMetadatas(stdout, output, "test", TRUE)) {
     285            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     286            psFree(output);
     287            return false;
     288        }
     289        psFree(output);
     290    }
     291
     292    // exit  (1);
    224293
    225294    // add new exps to summitExp
     
    239308            "       summitExp.exp_name is NULL"
    240309            "       AND summitExp.camera is NULL"
    241             "       AND summitExp.telescope is NULL";
     310            "       AND summitExp.telescope is NULL";
     311
     312        // MAJOR hack to avoid excess long inserts
     313        // include this line to limit the incomping entries
     314        // "       AND incoming.dateobs > '2023-01-01'";
    242315
    243316        if (!p_psDBRunQuery(config->dbh, query)) {
  • trunk/ippTools/src/pzgetexpConfig.c

    r18919 r42412  
    5555    psMetadataAddBool(args, PS_LIST_TAIL, "-all",  0,
    5656        "download ALL filesets", 0);
     57    psMetadataAddBool(args, PS_LIST_TAIL, "-ignore-errors",  0,
     58        "do not fail if one of the entries raises a database error", 0);
    5759
    5860
Note: See TracChangeset for help on using the changeset viewer.