IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10110


Ignore:
Timestamp:
Nov 20, 2006, 1:58:03 PM (20 years ago)
Author:
jhoblitt
Message:

VERSION 0.0.57

Location:
trunk/ippdb
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippdb/Makefile.am

    r10060 r10110  
    1010man_MANS = \
    1111    $(top_builddir)/docs/man/man3/ippdb.3 \
     12    $(top_builddir)/docs/man/man3/expTagCounterRow.3 \
    1213    $(top_builddir)/docs/man/man3/summitExpRow.3 \
    1314    $(top_builddir)/docs/man/man3/summitImfileRow.3 \
     
    4546
    4647
    47 docs/man/man3/ippdb.3 docs/man/man3/summitExpRow.3 docs/man/man3/summitImfileRow.3 docs/man/man3/pzPendingExpRow.3 docs/man/man3/pzPendingImfileRow.3 docs/man/man3/pzDoneExpRow.3 docs/man/man3/pzDoneImfileRow.3 docs/man/man3/newExpRow.3 docs/man/man3/newImfileRow.3 docs/man/man3/rawDetrendExpRow.3 docs/man/man3/rawScienceExpRow.3 docs/man/man3/rawImfileRow.3 docs/man/man3/p1PendingExpRow.3 docs/man/man3/p2PendingExpRow.3 docs/man/man3/p2PendingImfileRow.3 docs/man/man3/p2ProcessedExpRow.3 docs/man/man3/p2MaskRow.3 docs/man/man3/p2ProcessedImfileRow.3 docs/man/man3/p3PendingExpRow.3 docs/man/man3/p3ProcessedExpRow.3 docs/man/man3/p3MaskRow.3 docs/man/man3/detRunRow.3 docs/man/man3/detInputExpRow.3 docs/man/man3/detProcessedImfileRow.3 docs/man/man3/detProcessedExpRow.3 docs/man/man3/detStackedImfileRow.3 docs/man/man3/detNormalizedStatImfileRow.3 docs/man/man3/detNormalizedImfileRow.3 docs/man/man3/detNormalizedExpRow.3 docs/man/man3/detMasterFrameRow.3 docs/man/man3/detMasterImfileRow.3 docs/man/man3/detResidImfileRow.3 docs/man/man3/detResidExpRow.3 docs/man/man3/detRunSummaryRow.3:
     48docs/man/man3/ippdb.3 docs/man/man3/expTagCounterRow.3 docs/man/man3/summitExpRow.3 docs/man/man3/summitImfileRow.3 docs/man/man3/pzPendingExpRow.3 docs/man/man3/pzPendingImfileRow.3 docs/man/man3/pzDoneExpRow.3 docs/man/man3/pzDoneImfileRow.3 docs/man/man3/newExpRow.3 docs/man/man3/newImfileRow.3 docs/man/man3/rawDetrendExpRow.3 docs/man/man3/rawScienceExpRow.3 docs/man/man3/rawImfileRow.3 docs/man/man3/p1PendingExpRow.3 docs/man/man3/p2PendingExpRow.3 docs/man/man3/p2PendingImfileRow.3 docs/man/man3/p2ProcessedExpRow.3 docs/man/man3/p2MaskRow.3 docs/man/man3/p2ProcessedImfileRow.3 docs/man/man3/p3PendingExpRow.3 docs/man/man3/p3ProcessedExpRow.3 docs/man/man3/p3MaskRow.3 docs/man/man3/detRunRow.3 docs/man/man3/detInputExpRow.3 docs/man/man3/detProcessedImfileRow.3 docs/man/man3/detProcessedExpRow.3 docs/man/man3/detStackedImfileRow.3 docs/man/man3/detNormalizedStatImfileRow.3 docs/man/man3/detNormalizedImfileRow.3 docs/man/man3/detNormalizedExpRow.3 docs/man/man3/detMasterFrameRow.3 docs/man/man3/detMasterImfileRow.3 docs/man/man3/detResidImfileRow.3 docs/man/man3/detResidExpRow.3 docs/man/man3/detRunSummaryRow.3:
    4849        $(DOXYGEN)
    4950
  • trunk/ippdb/configure.ac

    r10060 r10110  
    77AC_PREREQ(2.59)
    88
    9 AC_INIT([ippdb], [0.0.56], [pan-starrs.ifa.hawaii.edu])
     9AC_INIT([ippdb], [0.0.57], [pan-starrs.ifa.hawaii.edu])
    1010AC_CONFIG_SRCDIR([ippdb.pc.in])
    1111
  • trunk/ippdb/src/ippdb.c

    r10060 r10110  
    3131#include "ippdb.h"
    3232
     33#define EXPTAGCOUNTER_TABLE_NAME "expTagCounter"
    3334#define SUMMITEXP_TABLE_NAME "summitExp"
    3435#define SUMMITIMFILE_TABLE_NAME "summitImfile"
     
    235236}
    236237
     238static void expTagCounterRowFree(expTagCounterRow *object);
     239
     240expTagCounterRow *expTagCounterRowAlloc(psU64 counter)
     241{
     242    expTagCounterRow *_object;
     243
     244    _object = psAlloc(sizeof(expTagCounterRow));
     245    psMemSetDeallocator(_object, (psFreeFunc)expTagCounterRowFree);
     246
     247    _object->counter = counter;
     248
     249    return _object;
     250}
     251
     252static void expTagCounterRowFree(expTagCounterRow *object)
     253{
     254}
     255
     256bool expTagCounterCreateTable(psDB *dbh)
     257{
     258    psMetadata *md = psMetadataAlloc();
     259    if (!psMetadataAdd(md, PS_LIST_TAIL, "counter", PS_DATA_U64, NULL, 0)) {
     260        psError(PS_ERR_UNKNOWN, false, "failed to add item counter");
     261        psFree(md);
     262        return false;
     263    }
     264
     265    bool status = psDBCreateTable(dbh, EXPTAGCOUNTER_TABLE_NAME, md);
     266
     267    psFree(md);
     268
     269    return status;
     270}
     271
     272bool expTagCounterDropTable(psDB *dbh)
     273{
     274    return psDBDropTable(dbh, EXPTAGCOUNTER_TABLE_NAME);
     275}
     276
     277bool expTagCounterInsert(psDB * dbh, psU64 counter)
     278{
     279    psMetadata *md = psMetadataAlloc();
     280    if (!psMetadataAdd(md, PS_LIST_TAIL, "counter", PS_DATA_U64, NULL, counter)) {
     281        psError(PS_ERR_UNKNOWN, false, "failed to add item counter");
     282        psFree(md);
     283        return false;
     284    }
     285
     286    bool status = psDBInsertOneRow(dbh, EXPTAGCOUNTER_TABLE_NAME, md);
     287    psFree(md);
     288
     289    return status;
     290}
     291
     292long long expTagCounterDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
     293{
     294    long long       deleted = 0;
     295
     296    long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);
     297    if (count < 0) {
     298        psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter");
     299        return count;
     300
     301        deleted += count;
     302    }
     303
     304    return deleted;
     305}
     306bool expTagCounterInsertObject(psDB *dbh, expTagCounterRow *object)
     307{
     308    return expTagCounterInsert(dbh, object->counter);
     309}
     310
     311bool expTagCounterInsertObjects(psDB *dbh, psArray *objects)
     312{
     313    for (long i = 0; i < psArrayLength(objects); i++) {
     314        if (!expTagCounterInsertObject(dbh, objects->data[i])) {
     315            return false;
     316        }
     317    }
     318
     319    return true;
     320}
     321
     322bool expTagCounterInsertFits(psDB *dbh, const psFits *fits)
     323{
     324    psArray         *rowSet;
     325
     326    // move to (the first?) extension named  EXPTAGCOUNTER_TABLE_NAME
     327    if (!psFitsMoveExtName(fits, EXPTAGCOUNTER_TABLE_NAME)) {
     328        psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", EXPTAGCOUNTER_TABLE_NAME);
     329        return false;
     330    }
     331
     332    // check HDU type
     333    if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE)  {
     334        psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE");
     335        return false;
     336    }
     337
     338    // read fits table
     339    rowSet = psFitsReadTable(fits);
     340    if (!rowSet) {
     341        psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty");
     342        psFree(rowSet);
     343        return false;
     344    }
     345
     346    if (!psDBInsertRows(dbh, EXPTAGCOUNTER_TABLE_NAME, rowSet)) {
     347        psError(PS_ERR_UNKNOWN, false, "databse insert failed");
     348        psFree(rowSet);
     349        return false;
     350    }
     351
     352    psFree(rowSet);
     353
     354    return true;
     355}
     356
     357bool expTagCounterSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
     358{
     359    psArray         *rowSet;
     360
     361    rowSet = psDBSelectRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);
     362    if (!rowSet) {
     363        return false;
     364    }
     365
     366    // output to fits
     367    if (!psFitsWriteTable(fits, NULL, rowSet, EXPTAGCOUNTER_TABLE_NAME)) {
     368        psError(PS_ERR_UNKNOWN, false, "FITS table write failed");
     369        psFree(rowSet);
     370        return false;
     371    }
     372
     373    psFree(rowSet);
     374
     375    return true;
     376}
     377
     378psMetadata *expTagCounterMetadataFromObject(const expTagCounterRow *object)
     379{
     380    psMetadata *md = psMetadataAlloc();
     381    if (!psMetadataAdd(md, PS_LIST_TAIL, "counter", PS_DATA_U64, NULL, object->counter)) {
     382        psError(PS_ERR_UNKNOWN, false, "failed to add item counter");
     383        psFree(md);
     384        return false;
     385    }
     386
     387
     388    return md;
     389}
     390
     391expTagCounterRow *expTagCounterObjectFromMetadata(psMetadata *md)
     392{
     393
     394bool status = false;
     395    psU64 counter = psMetadataLookupU64(&status, md, "counter");
     396    if (!status) {
     397        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item counter");
     398        return false;
     399    }
     400
     401    return expTagCounterRowAlloc(counter);
     402}
     403psArray *expTagCounterSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
     404{
     405    psArray         *rowSet;
     406    psArray         *returnSet;
     407    psU64           i;
     408
     409    rowSet = psDBSelectRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);
     410    if (!rowSet) {
     411        return NULL;
     412    }
     413
     414    // convert psMetadata rows to row objects
     415
     416    returnSet = psArrayAllocEmpty(rowSet->n);
     417
     418    for (i = 0; i < rowSet->n; i++) {
     419        expTagCounterRow *object = expTagCounterObjectFromMetadata(rowSet->data[i]);
     420        psArrayAdd(returnSet, 0, object);
     421        psFree(object);
     422    }
     423
     424    psFree(rowSet);
     425
     426    return returnSet;
     427}
     428bool expTagCounterDeleteObject(psDB *dbh, const expTagCounterRow *object)
     429{
     430    psMetadata *where = expTagCounterMetadataFromObject(object);
     431    long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, 0);
     432    psFree(where)
     433    if (count < 0) {
     434        psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter");
     435        return false;
     436    }
     437    if (count > 1) {
     438        // XXX should this be a psAbort() instead?  It is possible that
     439        // having an object match multiple rows was by design.
     440        psError(PS_ERR_UNKNOWN, true, "expTagCounterRow object matched more then one row.  Check your database schema");
     441        return false;
     442    }
     443
     444    return true;
     445}
     446long long expTagCounterDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)
     447{
     448    long long       deleted = 0;
     449
     450    for (long long i = 0; i < objects->n; i++) {
     451        expTagCounterRow *object = objects->data[i];
     452        psMetadata *where = expTagCounterMetadataFromObject(object);
     453        long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);
     454        psFree(where)
     455        if (count < 0) {
     456            psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter");
     457            return count;
     458        }
     459
     460        deleted += count;
     461    }
     462
     463    return deleted;
     464}
     465bool expTagCounterPrintObjects(FILE *stream, psArray *objects, bool mdcf)
     466{
     467    PS_ASSERT_PTR_NON_NULL(objects, false);
     468
     469    psMetadata *output = psMetadataAlloc();
     470    for (long i = 0; i < psArrayLength(objects); i++) {
     471        psMetadata *md = expTagCounterMetadataFromObject(objects->data[i]);
     472        if (!psMetadataAddMetadata(
     473            output,
     474            PS_LIST_TAIL,
     475            EXPTAGCOUNTER_TABLE_NAME,
     476            PS_META_DUPLICATE_OK,
     477            NULL,
     478            md
     479        )) {
     480            psError(PS_ERR_UNKNOWN, false, "failed to add metadata");
     481            psFree(md);
     482            psFree(output);
     483            return false;
     484        }
     485        psFree(md);
     486    }
     487
     488    if (!ippdbPrintMetadataRaw(stream, output, mdcf)) {
     489        psError(PS_ERR_UNKNOWN, false, "failed to print metadata");
     490        psFree(output);
     491    }
     492    psFree(output);
     493
     494    return true;
     495}
    237496static void summitExpRowFree(summitExpRow *object);
    238497
     
    24082667static void newExpRowFree(newExpRow *object);
    24092668
    2410 newExpRow *newExpRowAlloc(psU64 exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles)
     2669newExpRow *newExpRowAlloc(const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles)
    24112670{
    24122671    newExpRow       *_object;
     
    24152674    psMemSetDeallocator(_object, (psFreeFunc)newExpRowFree);
    24162675
    2417     _object->exp_tag = exp_tag;
     2676    _object->exp_tag = psStringCopy(exp_tag);
    24182677    _object->exp_id = psStringCopy(exp_id);
    24192678    _object->camera = psStringCopy(camera);
     
    24282687static void newExpRowFree(newExpRow *object)
    24292688{
     2689    psFree(object->exp_tag);
    24302690    psFree(object->exp_id);
    24312691    psFree(object->camera);
     
    24382698{
    24392699    psMetadata *md = psMetadataAlloc();
    2440     if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_U64, "Primary Key AUTO_INCREMENT", 0)) {
     2700    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, "Primary Key", "64")) {
    24412701        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    24422702        psFree(md);
     
    24892749}
    24902750
    2491 bool newExpInsert(psDB * dbh, psU64 exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles)
     2751bool newExpInsert(psDB * dbh, const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles)
    24922752{
    24932753    psMetadata *md = psMetadataAlloc();
    2494     if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_U64, NULL, exp_tag)) {
     2754    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, exp_tag)) {
    24952755        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    24962756        psFree(md);
     
    26232883{
    26242884    psMetadata *md = psMetadataAlloc();
    2625     if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_U64, NULL, object->exp_tag)) {
     2885    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, object->exp_tag)) {
    26262886        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
    26272887        psFree(md);
     
    26672927
    26682928bool status = false;
    2669     psU64 exp_tag = psMetadataLookupU64(&status, md, "exp_tag");
     2929    char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag");
    26702930    if (!status) {
    26712931        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag");
  • trunk/ippdb/src/ippdb.h

    r10060 r10110  
    125125);
    126126
     127/** expTagCounterRow data structure
     128 *
     129 * Structure for representing a single row of expTagCounter table data.
     130 */
     131
     132typedef struct {
     133    psU64           counter;
     134} expTagCounterRow;
     135
     136/** Creates a new expTagCounterRow object
     137 *
     138 *  @return A new expTagCounterRow object or NULL on failure.
     139 */
     140
     141expTagCounterRow *expTagCounterRowAlloc(
     142    psU64           counter
     143);
     144
     145/** Creates a new expTagCounter table
     146 *
     147 * @return true on success
     148 */
     149
     150bool expTagCounterCreateTable(
     151    psDB            *dbh                ///< Database handle
     152);
     153
     154/** Deletes a expTagCounter table
     155 *
     156 * @return true on success
     157 */
     158
     159bool expTagCounterDropTable(
     160    psDB            *dbh                ///< Database handle
     161);
     162
     163/** Insert a single row into a table
     164 *
     165 * This function constructs and inserts a single row based on it's parameters.
     166 *
     167 * @return true on success
     168 */
     169
     170bool expTagCounterInsert(
     171    psDB            *dbh,               ///< Database handle
     172    psU64           counter
     173);
     174
     175/** Deletes up to limit rows from the database and returns the number of rows actually deleted.
     176 *
     177 * @return A The number of rows removed or a negative value on error
     178 */
     179
     180long long expTagCounterDelete(
     181    psDB            *dbh,               ///< Database handle
     182    const psMetadata *where,            ///< Row match criteria
     183    unsigned long long limit            ///< Maximum number of elements to delete
     184);
     185
     186/** Insert a single expTagCounterRow object into a table
     187 *
     188 * This function constructs and inserts a single row based on it's parameters.
     189 *
     190 * @return true on success
     191 */
     192
     193bool expTagCounterInsertObject(
     194    psDB            *dbh,               ///< Database handle
     195    expTagCounterRow *object             ///< expTagCounterRow object
     196);
     197
     198/** Insert an array of expTagCounterRow object into a table
     199 *
     200 * This function constructs and inserts multiple rows based on it's parameters.
     201 *
     202 * @return true on success
     203 */
     204
     205bool expTagCounterInsertObjects(
     206    psDB            *dbh,               ///< Database handle
     207    psArray         *objects            ///< array of expTagCounterRow objects
     208);
     209
     210/** Insert data from a binary FITS table expTagCounterRow into the database
     211 *
     212 * This function expects a psFits object with a FITS table as the first
     213 * extension.  The table must have at least one row of data in it, that is of
     214 * the appropriate format (number of columns and their type).  All other
     215 * extensions are ignored.
     216 *
     217 * @return true on success
     218 */
     219
     220bool expTagCounterInsertFits(
     221    psDB            *dbh,               ///< Database handle
     222    const psFits    *fits               ///< psFits object
     223);
     224
     225/** Selects up to limit from the database and returns them in a binary FITS table
     226 *
     227 * This function assumes an empty psFits object and will create a FITS table
     228 * as the first extension.
     229 *
     230 *  See psDBSelectRows() for documentation on the format of where.
     231 *
     232 * @return true on success
     233 */
     234
     235bool expTagCounterSelectRowsFits(
     236    psDB            *dbh,               ///< Database handle
     237    psFits          *fits,              ///< psFits object
     238    const psMetadata *where,            ///< Row match criteria
     239    unsigned long long limit            ///< Maximum number of elements to return
     240);
     241
     242/** Convert a expTagCounterRow into an equivalent psMetadata
     243 *
     244 * @return A psMetadata pointer or NULL on error
     245 */
     246
     247psMetadata *expTagCounterMetadataFromObject(
     248    const expTagCounterRow *object             ///< fooRow to convert into a psMetadata
     249);
     250
     251/** Convert a psMetadata into an equivalent fooRow
     252 *
     253 * @return A expTagCounterRow pointer or NULL on error
     254 */
     255
     256expTagCounterRow *expTagCounterObjectFromMetadata(
     257    psMetadata      *md                 ///< psMetadata to convert into a fooRow
     258);
     259/** Selects up to limit rows from the database and returns as expTagCounterRow objects in a psArray
     260 *
     261 *  See psDBSelectRows() for documentation on the format of where.
     262 *
     263 * @return A psArray pointer or NULL on error
     264 */
     265
     266psArray *expTagCounterSelectRowObjects(
     267    psDB            *dbh,               ///< Database handle
     268    const psMetadata *where,            ///< Row match criteria
     269    unsigned long long limit            ///< Maximum number of elements to return
     270);
     271/** Deletes a row from the database coresponding to an expTagCounter
     272 *
     273 *  Note that a 'where' search psMetadata is constructed from each object and
     274 *  used to find rows to delete.
     275 *
     276 * @return A The number of rows removed or a negative value on error
     277 */
     278
     279bool expTagCounterDeleteObject(
     280    psDB            *dbh,               ///< Database handle
     281    const expTagCounterRow *object    ///< Object to delete
     282);
     283/** Deletes up to limit rows from the database and returns the number of rows actually deleted.
     284 *
     285 *  Note that a 'where' search psMetadata is constructed from each object and
     286 *  used to find rows to delete.
     287 *
     288 * @return A The number of rows removed or a negative value on error
     289 */
     290
     291long long expTagCounterDeleteRowObjects(
     292    psDB            *dbh,               ///< Database handle
     293    const psArray   *objects,           ///< Array of objects to delete
     294    unsigned long long limit            ///< Maximum number of elements to delete
     295);
     296/** Formats and prints an array of expTagCounterRow objects
     297 *
     298 * When mdcf is set the formated output is in psMetadataConfig
     299 * format, otherwise it is in a simple tabular format.
     300 *
     301 * @return true on success
     302 */
     303
     304bool expTagCounterPrintObjects(
     305    FILE            *stream,            ///< a stream
     306    psArray         *objects,           ///< An array of expTagCounterRow objects
     307    bool            mdcf                ///< format as mdconfig or simple
     308);
    127309/** summitExpRow data structure
    128310 *
     
    13071489
    13081490typedef struct {
    1309     psU64           exp_tag;
     1491    char            *exp_tag;
    13101492    char            *exp_id;
    13111493    char            *camera;
     
    13221504
    13231505newExpRow *newExpRowAlloc(
    1324     psU64           exp_tag,
     1506    const char      *exp_tag,
    13251507    const char      *exp_id,
    13261508    const char      *camera,
     
    13581540bool newExpInsert(
    13591541    psDB            *dbh,               ///< Database handle
    1360     psU64           exp_tag,
     1542    const char      *exp_tag,
    13611543    const char      *exp_id,
    13621544    const char      *camera,
  • trunk/ippdb/tests/alloc.c

    r10060 r10110  
    99{
    1010    {
     11        expTagCounterRow *object;
     12
     13        object = expTagCounterRowAlloc(64    );
     14
     15        if (!object) {
     16            exit(EXIT_FAILURE);
     17        }
     18
     19            psFree(object);
     20            exit(EXIT_FAILURE);
     21        }
     22
     23        psFree(object);
     24    }
     25
     26    {
    1127        summitExpRow    *object;
    1228
     
    224240        newExpRow       *object;
    225241
    226         object = newExpRowAlloc(64, "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32    );
    227 
    228         if (!object) {
    229             exit(EXIT_FAILURE);
    230         }
    231 
     242        object = newExpRowAlloc("a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32    );
     243
     244        if (!object) {
     245            exit(EXIT_FAILURE);
     246        }
     247
     248        if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) {
    232249            psFree(object);
    233250            exit(EXIT_FAILURE);
  • trunk/ippdb/tests/createtable.c

    r10060 r10110  
    1313        }
    1414
     15        if(!expTagCounterCreateTable(dbh)) {
     16            exit(EXIT_FAILURE);
     17        }
     18
     19        psDBCleanup(dbh);
     20    }
     21
     22    {
     23        psDB            *dbh;
     24
     25        dbh = psDBInit("localhost", "test", NULL, "test");
     26        if (!dbh) {
     27            exit(EXIT_FAILURE);
     28        }
     29
    1530        if(!summitExpCreateTable(dbh)) {
    1631            exit(EXIT_FAILURE);
  • trunk/ippdb/tests/dbcleanup.c

    r10060 r10110  
    1111    }
    1212
     13    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS expTagCounter");
    1314    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS summitExp");
    1415    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS summitImfile");
  • trunk/ippdb/tests/dbsetup.c

    r10060 r10110  
    1313
    1414    // remove the table if it already exists
     15    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS expTagCounter");
     16    expTagCounterCreateTable(dbh);
     17
    1518    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS summitExp");
    1619    summitExpCreateTable(dbh);
  • trunk/ippdb/tests/droptable.c

    r10060 r10110  
    1313        }
    1414
     15        if (!expTagCounterDropTable(dbh)) {
     16            exit(EXIT_FAILURE);
     17        }
     18
     19        psDBCleanup(dbh);
     20    }
     21
     22    {
     23        psDB            *dbh;
     24
     25        dbh = psDBInit("localhost", "test", NULL, "test");
     26        if (!dbh) {
     27            exit(EXIT_FAILURE);
     28        }
     29
    1530        if (!summitExpDropTable(dbh)) {
    1631            exit(EXIT_FAILURE);
  • trunk/ippdb/tests/insert.c

    r10060 r10110  
    1313        }
    1414
     15        if (!expTagCounterInsert(dbh, 64)) {
     16            exit(EXIT_FAILURE);
     17        }
     18
     19        psDBCleanup(dbh);
     20    }
     21
     22    {
     23        psDB            *dbh;
     24
     25        dbh = psDBInit("localhost", "test", NULL, "test");
     26        if (!dbh) {
     27            exit(EXIT_FAILURE);
     28        }
     29
    1530        if (!summitExpInsert(dbh, "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", "a string", -32)) {
    1631            exit(EXIT_FAILURE);
     
    103118        }
    104119
    105         if (!newExpInsert(dbh, 64, "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32)) {
     120        if (!newExpInsert(dbh, "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32)) {
    106121            exit(EXIT_FAILURE);
    107122        }
  • trunk/ippdb/tests/insertfits.c

    r10060 r10110  
    2424        }
    2525
     26        if (!expTagCounterInsertFits(dbh, fits)) {
     27            exit(EXIT_FAILURE);
     28        }
     29
     30        if (!psFitsClose(fits)) {
     31            exit(EXIT_FAILURE);
     32        }
     33
     34        psDBCleanup(dbh);
     35    }
     36
     37    {
     38        psDB            *dbh;
     39        psFits          *fits;
     40
     41        dbh = psDBInit("localhost", "test", NULL, "test");
     42        if (!dbh) {
     43            exit(EXIT_FAILURE);
     44        }
     45
     46        // open a temp
     47        fits = psFitsOpen(TMP_FILENAME, "r");
     48        if (!fits) {
     49            exit(EXIT_FAILURE);
     50        }
     51
    2652        if (!summitExpInsertFits(dbh, fits)) {
    2753            exit(EXIT_FAILURE);
  • trunk/ippdb/tests/insertobject.c

    r10060 r10110  
    77    {
    88        psDB            *dbh;
     9        expTagCounterRow *object;
     10
     11        dbh = psDBInit("localhost", "test", NULL, "test");
     12        if (!dbh) {
     13            exit(EXIT_FAILURE);
     14        }
     15
     16        object = expTagCounterRowAlloc(64);
     17        if (!object) {
     18            exit(EXIT_FAILURE);
     19        }
     20
     21        if (!expTagCounterInsertObject(dbh, object)) {
     22            exit(EXIT_FAILURE);
     23        }
     24
     25        psFree(object);
     26        psDBCleanup(dbh);
     27    }
     28
     29    {
     30        psDB            *dbh;
    931        summitExpRow    *object;
    1032
     
    146168        }
    147169
    148         object = newExpRowAlloc(64, "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32);
     170        object = newExpRowAlloc("a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32);
    149171        if (!object) {
    150172            exit(EXIT_FAILURE);
  • trunk/ippdb/tests/metadatafromobject.c

    r10060 r10110  
    1010    {
    1111        psMetadata      *md;
     12        expTagCounterRow *object;
     13        bool            status;
     14
     15        object = expTagCounterRowAlloc(64);
     16        if (!object) {
     17            exit(EXIT_FAILURE);
     18        }
     19
     20        md = expTagCounterMetadataFromObject(object);
     21        if (!md) {
     22            exit(EXIT_FAILURE);
     23        }
     24
     25        psFree(object);
     26
     27            psFree(md);
     28            exit(EXIT_FAILURE);
     29        }
     30
     31        psFree(md);
     32    }
     33
     34    {
     35        psMetadata      *md;
    1236        summitExpRow    *object;
    1337        bool            status;
     
    274298        bool            status;
    275299
    276         object = newExpRowAlloc(64, "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32);
     300        object = newExpRowAlloc("a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32);
    277301        if (!object) {
    278302            exit(EXIT_FAILURE);
     
    286310        psFree(object);
    287311
     312        if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) {
    288313            psFree(md);
    289314            exit(EXIT_FAILURE);
  • trunk/ippdb/tests/objectfrommetadata.c

    r10060 r10110  
    1010    {
    1111        psMetadata      *md;
     12        expTagCounterRow *object;
     13
     14        md = psMetadataAlloc();
     15            psFree(md);
     16            exit(EXIT_FAILURE);
     17        }
     18
     19        object = expTagCounterObjectFromMetadata(md);
     20        if (!object) {
     21            psFree(md);
     22            exit(EXIT_FAILURE);
     23        }
     24
     25        psFree(md);
     26
     27            psFree(object);
     28            exit(EXIT_FAILURE);
     29        }
     30
     31        psFree(object);
     32    }
     33
     34    {
     35        psMetadata      *md;
    1236        summitExpRow    *object;
    1337
     
    391415
    392416        md = psMetadataAlloc();
     417        if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_tag", 0, NULL, "a string")) {
    393418            psFree(md);
    394419            exit(EXIT_FAILURE);
     
    426451        psFree(md);
    427452
     453        if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) {
    428454            psFree(object);
    429455            exit(EXIT_FAILURE);
  • trunk/ippdb/tests/selectrowsfits.c

    r10060 r10110  
    2121        }
    2222
     23        if (!expTagCounterSelectRowsFits(dbh, fits, NULL, 1)) {
     24            exit(EXIT_FAILURE);
     25        }
     26
     27        psFree(fits);
     28        psDBCleanup(dbh);
     29    }
     30
     31    {
     32        psDB            *dbh;
     33        psFits          *fits;
     34
     35        dbh = psDBInit("localhost", "test", NULL, "test");
     36        if (!dbh) {
     37            exit(EXIT_FAILURE);
     38        }
     39
     40        fits = psFitsOpen(TMP_FILENAME, "w");
     41        if (!fits) {
     42            exit(EXIT_FAILURE);
     43        }
     44
    2345        if (!summitExpSelectRowsFits(dbh, fits, NULL, 1)) {
    2446            exit(EXIT_FAILURE);
Note: See TracChangeset for help on using the changeset viewer.