IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25015


Ignore:
Timestamp:
Aug 7, 2009, 10:53:23 AM (17 years ago)
Author:
bills
Message:

handle bothways diffs separately from !bothways

File:
1 edited

Legend:

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

    r24937 r25015  
    160160        return false;
    161161    }
    162 
    163     if (psListLength(where->list)) {
    164         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    165         psStringAppend(&query, "\n AND %s", whereClause);
    166         psFree(whereClause);
    167     }
    168     psFree(where);
    169 
    170     // treat limit == 0 as "no limit"
    171     if (limit) {
    172         psString limitString = psDBGenerateLimitSQL(limit);
    173         psStringAppend(&query, " %s", limitString);
    174         psFree(limitString);
    175     }
    176 
    177     if (!p_psDBRunQueryF(config->dbh, query, rerun ? "\n1 " : "\n0 ")) {
    178         psError(PS_ERR_UNKNOWN, false, "database error");
    179         psFree(query);
    180         return false;
     162    char *rerun_flag =  rerun ? "\n1 " : "\n0" ;
     163
     164    if (stageNum != IPP_STAGE_DIFF) {
     165        if (psListLength(where->list)) {
     166            psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     167            psStringAppend(&query, "\nAND %s", whereClause);
     168            psFree(whereClause);
     169        }
     170        psFree(where);
     171
     172        // treat limit == 0 as "no limit"
     173        if (limit) {
     174            psString limitString = psDBGenerateLimitSQL(limit);
     175            psStringAppend(&query, " %s", limitString);
     176            psFree(limitString);
     177        }
     178        if (!p_psDBRunQueryF(config->dbh, query, rerun_flag)) {
     179            psError(PS_ERR_UNKNOWN, false, "database error");
     180            psFree(query);
     181            return false;
     182        }
     183    } else {
     184        // diff stage query has two types bothways and !bothways
     185        // so we need to send the rerun flag and the where data twice
     186        psString whereString = psStringCopy("");
     187        if (psListLength(where->list)) {
     188            psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     189            psStringAppend(&whereString, "\nAND %s", whereClause);
     190            psFree(whereClause);
     191        }
     192        psFree(where);
     193
     194        // treat limit == 0 as "no limit"
     195        if (limit) {
     196            psString limitString = psDBGenerateLimitSQL(limit);
     197            psStringAppend(&query, " %s", limitString);
     198            psFree(limitString);
     199        }
     200
     201        if (!p_psDBRunQueryF(config->dbh, query, rerun_flag, whereString, rerun_flag, whereString)) {
     202            psError(PS_ERR_UNKNOWN, false, "database error");
     203            psFree(whereString);
     204            psFree(query);
     205            return false;
     206        }
     207        psFree(whereString);
    181208    }
    182209    psFree(query);
     
    215242        psS64 exp_id = psMetadataLookupS64(NULL, row, "exp_id");
    216243        psS64 magic_id = psMetadataLookupS64(NULL, row, "magic_id");
     244        psS64 inv_magic_id = psMetadataLookupS64(NULL, row, "inv_magic_id");
    217245        psS64 cam_id = psMetadataLookupS64(NULL, row, "cam_id");
    218246        psString magicRunLabel = psMetadataLookupStr(NULL, row, "label");
     
    232260                0, // magic_ds_id
    233261                magic_id,
     262                inv_magic_id,
    234263                "new",
    235264                stage,
     
    309338            0,          // ID
    310339            magic_id,
     340            0,          // inv_magic_id
    311341            "new",      // state
    312342            stage,
Note: See TracChangeset for help on using the changeset viewer.