IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17618 for trunk/ippTools/src


Ignore:
Timestamp:
May 9, 2008, 11:48:09 AM (18 years ago)
Author:
jhoblitt
Message:

further attempts to optimize the use of the regtool_pendingexp.sql query

File:
1 edited

Legend:

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

    r17611 r17618  
    430430
    431431    // treat limit == 0 as "no limit"
     432    psString limitString = NULL;
    432433    if (limit) {
    433         psString limitString = psDBGenerateLimitSQL(limit);
    434         psStringAppend(&query, " %s", limitString);
    435         psFree(limitString);
    436     }
    437 
    438     // close subquery
    439     psStringAppend(&query, "\n    ) as Foo\n");
    440 
    441     if (!p_psDBRunQuery(config->dbh, query)) {
     434        limitString = psDBGenerateLimitSQL(limit);
     435        // skip past the "hook" comment
     436        psStringPrepend(&limitString, "\n");
     437    }
     438
     439    // 1st arg: where hook, 2nd arg: limit hook
     440    if (!p_psDBRunQuery(config->dbh, query, "", limitString ? limitString : "")) {
    442441        // XXX PS_EXIT_PROG_ERROR (incorrect SQL) or SYS_ERROR (database comms)
    443442        psError(PXTOOLS_ERR_PROG, false, "database error");
     443        psFree(limitString);
    444444        psFree(query);
    445445        return false;
    446446    }
     447    psFree(limitString);
    447448    psFree(query);
    448449
     
    558559    }
    559560
    560     // close subquery (left open for limit supplied to pendingexpMode (regtool.c:104)
    561     psStringAppend(&query, "\n    ) as Foo\n");
    562 
     561    psString whereClause = NULL;
    563562    {
    564563        // build a query to search by exp_id
     
    571570        }
    572571
    573         psString whereClause = psDBGenerateWhereSQL(where, NULL);
     572        whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    574573        psFree(where);
    575574        if (whereClause) {
    576         psStringAppend(&query, " %s", whereClause);
     575            // skip past comment "hook"
     576            psStringPrepend(&whereClause, "\n AND ");
     577        }
     578    }
     579
     580    // 1st arg: where hook, 2nd arg: limit hook
     581    if (!p_psDBRunQuery(config->dbh, query, whereClause ? whereClause : "", "")) {
     582        psError(PS_ERR_UNKNOWN, false, "database error");
    577583        psFree(whereClause);
    578         }
    579     }
    580 
    581     if (!p_psDBRunQuery(config->dbh, query)) {
    582         psError(PS_ERR_UNKNOWN, false, "database error");
    583584        psFree(query);
    584585        return false;
    585586    }
     587    psFree(whereClause);
    586588    psFree(query);
    587589
Note: See TracChangeset for help on using the changeset viewer.