Changeset 10110
- Timestamp:
- Nov 20, 2006, 1:58:03 PM (20 years ago)
- Location:
- trunk/ippdb
- Files:
-
- 15 edited
-
Makefile.am (modified) (2 diffs)
-
configure.ac (modified) (1 diff)
-
src/ippdb.c (modified) (9 diffs)
-
src/ippdb.h (modified) (4 diffs)
-
tests/alloc.c (modified) (2 diffs)
-
tests/createtable.c (modified) (1 diff)
-
tests/dbcleanup.c (modified) (1 diff)
-
tests/dbsetup.c (modified) (1 diff)
-
tests/droptable.c (modified) (1 diff)
-
tests/insert.c (modified) (2 diffs)
-
tests/insertfits.c (modified) (1 diff)
-
tests/insertobject.c (modified) (2 diffs)
-
tests/metadatafromobject.c (modified) (3 diffs)
-
tests/objectfrommetadata.c (modified) (3 diffs)
-
tests/selectrowsfits.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippdb/Makefile.am
r10060 r10110 10 10 man_MANS = \ 11 11 $(top_builddir)/docs/man/man3/ippdb.3 \ 12 $(top_builddir)/docs/man/man3/expTagCounterRow.3 \ 12 13 $(top_builddir)/docs/man/man3/summitExpRow.3 \ 13 14 $(top_builddir)/docs/man/man3/summitImfileRow.3 \ … … 45 46 46 47 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:48 docs/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: 48 49 $(DOXYGEN) 49 50 -
trunk/ippdb/configure.ac
r10060 r10110 7 7 AC_PREREQ(2.59) 8 8 9 AC_INIT([ippdb], [0.0.5 6], [pan-starrs.ifa.hawaii.edu])9 AC_INIT([ippdb], [0.0.57], [pan-starrs.ifa.hawaii.edu]) 10 10 AC_CONFIG_SRCDIR([ippdb.pc.in]) 11 11 -
trunk/ippdb/src/ippdb.c
r10060 r10110 31 31 #include "ippdb.h" 32 32 33 #define EXPTAGCOUNTER_TABLE_NAME "expTagCounter" 33 34 #define SUMMITEXP_TABLE_NAME "summitExp" 34 35 #define SUMMITIMFILE_TABLE_NAME "summitImfile" … … 235 236 } 236 237 238 static void expTagCounterRowFree(expTagCounterRow *object); 239 240 expTagCounterRow *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 252 static void expTagCounterRowFree(expTagCounterRow *object) 253 { 254 } 255 256 bool 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 272 bool expTagCounterDropTable(psDB *dbh) 273 { 274 return psDBDropTable(dbh, EXPTAGCOUNTER_TABLE_NAME); 275 } 276 277 bool 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 292 long 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 } 306 bool expTagCounterInsertObject(psDB *dbh, expTagCounterRow *object) 307 { 308 return expTagCounterInsert(dbh, object->counter); 309 } 310 311 bool 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 322 bool 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 357 bool 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 378 psMetadata *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 391 expTagCounterRow *expTagCounterObjectFromMetadata(psMetadata *md) 392 { 393 394 bool 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 } 403 psArray *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 } 428 bool 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 } 446 long 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 } 465 bool 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 } 237 496 static void summitExpRowFree(summitExpRow *object); 238 497 … … 2408 2667 static void newExpRowFree(newExpRow *object); 2409 2668 2410 newExpRow *newExpRowAlloc( psU64exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles)2669 newExpRow *newExpRowAlloc(const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles) 2411 2670 { 2412 2671 newExpRow *_object; … … 2415 2674 psMemSetDeallocator(_object, (psFreeFunc)newExpRowFree); 2416 2675 2417 _object->exp_tag = exp_tag;2676 _object->exp_tag = psStringCopy(exp_tag); 2418 2677 _object->exp_id = psStringCopy(exp_id); 2419 2678 _object->camera = psStringCopy(camera); … … 2428 2687 static void newExpRowFree(newExpRow *object) 2429 2688 { 2689 psFree(object->exp_tag); 2430 2690 psFree(object->exp_id); 2431 2691 psFree(object->camera); … … 2438 2698 { 2439 2699 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")) { 2441 2701 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 2442 2702 psFree(md); … … 2489 2749 } 2490 2750 2491 bool newExpInsert(psDB * dbh, psU64exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles)2751 bool 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) 2492 2752 { 2493 2753 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)) { 2495 2755 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 2496 2756 psFree(md); … … 2623 2883 { 2624 2884 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)) { 2626 2886 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 2627 2887 psFree(md); … … 2667 2927 2668 2928 bool status = false; 2669 psU64 exp_tag = psMetadataLookupU64(&status, md, "exp_tag");2929 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag"); 2670 2930 if (!status) { 2671 2931 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag"); -
trunk/ippdb/src/ippdb.h
r10060 r10110 125 125 ); 126 126 127 /** expTagCounterRow data structure 128 * 129 * Structure for representing a single row of expTagCounter table data. 130 */ 131 132 typedef 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 141 expTagCounterRow *expTagCounterRowAlloc( 142 psU64 counter 143 ); 144 145 /** Creates a new expTagCounter table 146 * 147 * @return true on success 148 */ 149 150 bool expTagCounterCreateTable( 151 psDB *dbh ///< Database handle 152 ); 153 154 /** Deletes a expTagCounter table 155 * 156 * @return true on success 157 */ 158 159 bool 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 170 bool 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 180 long 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 193 bool 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 205 bool 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 220 bool 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 235 bool 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 247 psMetadata *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 256 expTagCounterRow *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 266 psArray *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 279 bool 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 291 long 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 304 bool expTagCounterPrintObjects( 305 FILE *stream, ///< a stream 306 psArray *objects, ///< An array of expTagCounterRow objects 307 bool mdcf ///< format as mdconfig or simple 308 ); 127 309 /** summitExpRow data structure 128 310 * … … 1307 1489 1308 1490 typedef struct { 1309 psU64exp_tag;1491 char *exp_tag; 1310 1492 char *exp_id; 1311 1493 char *camera; … … 1322 1504 1323 1505 newExpRow *newExpRowAlloc( 1324 psU64exp_tag,1506 const char *exp_tag, 1325 1507 const char *exp_id, 1326 1508 const char *camera, … … 1358 1540 bool newExpInsert( 1359 1541 psDB *dbh, ///< Database handle 1360 psU64exp_tag,1542 const char *exp_tag, 1361 1543 const char *exp_id, 1362 1544 const char *camera, -
trunk/ippdb/tests/alloc.c
r10060 r10110 9 9 { 10 10 { 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 { 11 27 summitExpRow *object; 12 28 … … 224 240 newExpRow *object; 225 241 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)) { 232 249 psFree(object); 233 250 exit(EXIT_FAILURE); -
trunk/ippdb/tests/createtable.c
r10060 r10110 13 13 } 14 14 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 15 30 if(!summitExpCreateTable(dbh)) { 16 31 exit(EXIT_FAILURE); -
trunk/ippdb/tests/dbcleanup.c
r10060 r10110 11 11 } 12 12 13 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS expTagCounter"); 13 14 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS summitExp"); 14 15 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS summitImfile"); -
trunk/ippdb/tests/dbsetup.c
r10060 r10110 13 13 14 14 // remove the table if it already exists 15 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS expTagCounter"); 16 expTagCounterCreateTable(dbh); 17 15 18 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS summitExp"); 16 19 summitExpCreateTable(dbh); -
trunk/ippdb/tests/droptable.c
r10060 r10110 13 13 } 14 14 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 15 30 if (!summitExpDropTable(dbh)) { 16 31 exit(EXIT_FAILURE); -
trunk/ippdb/tests/insert.c
r10060 r10110 13 13 } 14 14 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 15 30 if (!summitExpInsert(dbh, "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", "a string", -32)) { 16 31 exit(EXIT_FAILURE); … … 103 118 } 104 119 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)) { 106 121 exit(EXIT_FAILURE); 107 122 } -
trunk/ippdb/tests/insertfits.c
r10060 r10110 24 24 } 25 25 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 26 52 if (!summitExpInsertFits(dbh, fits)) { 27 53 exit(EXIT_FAILURE); -
trunk/ippdb/tests/insertobject.c
r10060 r10110 7 7 { 8 8 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; 9 31 summitExpRow *object; 10 32 … … 146 168 } 147 169 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); 149 171 if (!object) { 150 172 exit(EXIT_FAILURE); -
trunk/ippdb/tests/metadatafromobject.c
r10060 r10110 10 10 { 11 11 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; 12 36 summitExpRow *object; 13 37 bool status; … … 274 298 bool status; 275 299 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); 277 301 if (!object) { 278 302 exit(EXIT_FAILURE); … … 286 310 psFree(object); 287 311 312 if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) { 288 313 psFree(md); 289 314 exit(EXIT_FAILURE); -
trunk/ippdb/tests/objectfrommetadata.c
r10060 r10110 10 10 { 11 11 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; 12 36 summitExpRow *object; 13 37 … … 391 415 392 416 md = psMetadataAlloc(); 417 if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_tag", 0, NULL, "a string")) { 393 418 psFree(md); 394 419 exit(EXIT_FAILURE); … … 426 451 psFree(md); 427 452 453 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 428 454 psFree(object); 429 455 exit(EXIT_FAILURE); -
trunk/ippdb/tests/selectrowsfits.c
r10060 r10110 21 21 } 22 22 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 23 45 if (!summitExpSelectRowsFits(dbh, fits, NULL, 1)) { 24 46 exit(EXIT_FAILURE);
Note:
See TracChangeset
for help on using the changeset viewer.
