IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 3, 2006, 6:18:57 PM (20 years ago)
Author:
jhoblitt
Message:

large database schema change -> add airmass, ra, decl, exp_time, & background to exps
several memory leaks
add some transactions to p0search & p2search
fix p2search -done's handling of p2Done* tables

File:
1 edited

Legend:

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

    r8073 r8120  
    241241    psFree(pendingImfiles);
    242242
    243     // point of no return for p2PendingImfile -> p2DoneImfile
    244     if (!psDBCommit(config->dbh)) {
    245         psError(PS_ERR_UNKNOWN, false, "database error");
    246         return false;
    247     }
    248 
    249     // XXX make exposure state transition transactional
     243    // XXX I've decided to make the transaction cover the Exp migration as
     244    // well.  Otherwise, if the last imfile in an exp is moved and the exp
     245    // migration fails then the data base is left in a satuation where the exp
     246    // migration can't happen.
    250247
    251248    // look for pending exposures
    252249    psArray *pendingExps = p2searchPendingExp(config);
    253250    if (!pendingExps) {
     251        // rollback
     252        if (!psDBRollback(config->dbh)) {
     253            psError(PS_ERR_UNKNOWN, false, "database error");
     254        }
    254255        psError(PS_ERR_UNKNOWN, false, "no p2PendingExps found");
    255256        return false;
     
    265266        if (!pendingImfiles) {
    266267            // exp has no coresponding imfiles
    267             psArray *nukeMe = psArrayAlloc(1);
    268             nukeMe->n = 0;
    269             psArrayAdd(nukeMe, 0, pendingExp);
    270             bool status = p2PendingExpDeleteRowObjects(config->dbh, nukeMe, MAX_ROWS);
    271             psFree(nukeMe);
    272             if (!status) {
     268            psMetadata *where = psMetadataAlloc();
     269            psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", pendingExp->exp_id);
     270            long long count = p2PendingExpDelete(config->dbh, where, MAX_ROWS);
     271            psFree(where);
     272            if (count != 0) {
     273                // rollback
     274                if (!psDBRollback(config->dbh)) {
     275                    psError(PS_ERR_UNKNOWN, false, "database error");
     276                }
    273277                psError(PS_ERR_UNKNOWN, false, "dbh access failed");
     278                psFree(pendingExps);
    274279                return false;
    275280            }
    276             // XXX need a func to convert from p2PendingExp -> p2DoneExp
    277281
    278282            p2DoneExpRow *doneExp = p2pendingToDoneExp(pendingExp);
    279283            if (!doneExp) {
     284                // rollback
     285                if (!psDBRollback(config->dbh)) {
     286                    psError(PS_ERR_UNKNOWN, false, "database error");
     287                }
    280288                psError(PS_ERR_UNKNOWN, false, "p2PendingExp -> p2DoneExp failed");
     289                psFree(pendingExps);
    281290                return false;
    282291            }
    283292            if (!p2DoneExpInsertObject(config->dbh, doneExp)) {
     293                // rollback
     294                if (!psDBRollback(config->dbh)) {
     295                    psError(PS_ERR_UNKNOWN, false, "database error");
     296                }
    284297                psError(PS_ERR_UNKNOWN, false, "dbh access failed");
     298                psFree(doneExp);
     299                psFree(pendingExps);
    285300                return false;
    286301            }
    287         }
    288         // skip phase 3 for the time being
     302            psFree(doneExp);
     303        }
     304        // XXX skip phase 3 for the time being
    289305        psFree(pendingImfiles);
    290306    }
    291307
     308    psFree(pendingExps);
     309
     310    // point of no return for p2PendingImfile -> p2DoneImfile
     311    // point of no return for p2PendingExp -> p2DoneExp
     312    if (!psDBCommit(config->dbh)) {
     313        psError(PS_ERR_UNKNOWN, false, "database error");
     314        return false;
     315    }
    292316    /*
    293317    psArray *doneFrames = p2pendingToDone(config, pendingFrames);
     
    328352        uri,
    329353        "my recipe", // recipe
    330         "my stats", // stats
    331354        imfile->p1_version,
    332355        imfile->p2_version
Note: See TracChangeset for help on using the changeset viewer.