Changeset 11679
- Timestamp:
- Feb 6, 2007, 3:46:45 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
-
dbconfig/config.md (modified) (1 diff)
-
ippdb/Makefile.am (modified) (1 diff)
-
ippdb/configure.ac (modified) (2 diffs)
-
ippdb/src/ippdb.c (modified) (185 diffs)
-
ippdb/src/ippdb.h (modified) (72 diffs)
-
ippdb/tests/alloc.c (modified) (17 diffs)
-
ippdb/tests/createtable.c (modified) (2 diffs)
-
ippdb/tests/dbcleanup.c (modified) (2 diffs)
-
ippdb/tests/dbsetup.c (modified) (2 diffs)
-
ippdb/tests/droptable.c (modified) (2 diffs)
-
ippdb/tests/insert.c (modified) (2 diffs)
-
ippdb/tests/insertfits.c (modified) (2 diffs)
-
ippdb/tests/insertobject.c (modified) (2 diffs)
-
ippdb/tests/metadatafromobject.c (modified) (4 diffs)
-
ippdb/tests/objectfrommetadata.c (modified) (9 diffs)
-
ippdb/tests/selectrowsfits.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dbconfig/config.md
r11658 r11679 2 2 pkg_name STR ippdb 3 3 pkg_namespace STR ippdb 4 pkg_version STR 1.1. 04 pkg_version STR 1.1.1 5 5 END -
trunk/ippdb/Makefile.am
r11045 r11679 41 41 $(top_builddir)/docs/man/man3/detResidExpRow.3 \ 42 42 $(top_builddir)/docs/man/man3/detRunSummaryRow.3 \ 43 $(top_builddir)/docs/man/man3/p4RunRow.3 \ 44 $(top_builddir)/docs/man/man3/p4InputImfileRow.3 \ 45 $(top_builddir)/docs/man/man3/p4WarpedImfileRow.3 \ 46 $(top_builddir)/docs/man/man3/p4StackedImfileRow.3 \ 47 $(top_builddir)/docs/man/man3/p4DiffImfileRow.3 \ 48 $(top_builddir)/docs/man/man3/p4MagicMaskImfileRow.3 43 $(top_builddir)/docs/man/man3/p4aRunRow.3 \ 44 $(top_builddir)/docs/man/man3/p4aInputExpRow.3 \ 45 $(top_builddir)/docs/man/man3/p4aScfileRow.3 \ 46 $(top_builddir)/docs/man/man3/p4bRunRow.3 \ 47 $(top_builddir)/docs/man/man3/p4bInputScfileRow.3 \ 48 $(top_builddir)/docs/man/man3/p4bDiffScfileRow.3 \ 49 $(top_builddir)/docs/man/man3/p4cRunRow.3 \ 50 $(top_builddir)/docs/man/man3/p4cInputExpRow.3 \ 51 $(top_builddir)/docs/man/man3/p4MagicMaskImfileRow.3 \ 52 $(top_builddir)/docs/man/man3/skyCellRow.3 \ 53 $(top_builddir)/docs/man/man3/skyCellMapRow.3 49 54 50 55 51 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/rawExpRow.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/detResidImfileRow.3 docs/man/man3/detResidExpRow.3 docs/man/man3/detRunSummaryRow.3 docs/man/man3/p4 RunRow.3 docs/man/man3/p4InputImfileRow.3 docs/man/man3/p4WarpedImfileRow.3 docs/man/man3/p4StackedImfileRow.3 docs/man/man3/p4DiffImfileRow.3 docs/man/man3/p4MagicMaskImfileRow.3:56 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/rawExpRow.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/detResidImfileRow.3 docs/man/man3/detResidExpRow.3 docs/man/man3/detRunSummaryRow.3 docs/man/man3/p4aRunRow.3 docs/man/man3/p4aInputExpRow.3 docs/man/man3/p4aScfileRow.3 docs/man/man3/p4bRunRow.3 docs/man/man3/p4bInputScfileRow.3 docs/man/man3/p4bDiffScfileRow.3 docs/man/man3/p4cRunRow.3 docs/man/man3/p4cInputExpRow.3 docs/man/man3/p4MagicMaskImfileRow.3 docs/man/man3/skyCellRow.3 docs/man/man3/skyCellMapRow.3: 52 57 $(DOXYGEN) 53 58 -
trunk/ippdb/configure.ac
r11635 r11679 1 1 dnl 2 dnl This file was generated by glueforge 1.002 dnl This file was generated by glueforge 0.36 3 3 dnl 4 4 dnl Do NOT directly edit this file. … … 7 7 AC_PREREQ(2.59) 8 8 9 AC_INIT([ippdb], [1. 0.0], [pan-starrs.ifa.hawaii.edu])9 AC_INIT([ippdb], [1.1.1], [pan-starrs.ifa.hawaii.edu]) 10 10 AC_CONFIG_SRCDIR([ippdb.pc.in]) 11 11 -
trunk/ippdb/src/ippdb.c
r11635 r11679 20 20 /* 21 21 * 22 * This file was generated by glueforge 1.0022 * This file was generated by glueforge 0.36 23 23 * 24 24 * Do NOT directly edit this file. … … 62 62 #define DETRESIDEXP_TABLE_NAME "detResidExp" 63 63 #define DETRUNSUMMARY_TABLE_NAME "detRunSummary" 64 #define P4RUN_TABLE_NAME "p4Run" 65 #define P4INPUTIMFILE_TABLE_NAME "p4InputImfile" 66 #define P4WARPEDIMFILE_TABLE_NAME "p4WarpedImfile" 67 #define P4STACKEDIMFILE_TABLE_NAME "p4StackedImfile" 68 #define P4DIFFIMFILE_TABLE_NAME "p4DiffImfile" 64 #define P4ARUN_TABLE_NAME "p4aRun" 65 #define P4AINPUTEXP_TABLE_NAME "p4aInputExp" 66 #define P4ASCFILE_TABLE_NAME "p4aScfile" 67 #define P4BRUN_TABLE_NAME "p4bRun" 68 #define P4BINPUTSCFILE_TABLE_NAME "p4bInputScfile" 69 #define P4BDIFFSCFILE_TABLE_NAME "p4bDiffScfile" 70 #define P4CRUN_TABLE_NAME "p4cRun" 71 #define P4CINPUTEXP_TABLE_NAME "p4cInputExp" 69 72 #define P4MAGICMASKIMFILE_TABLE_NAME "p4MagicMaskImfile" 73 #define SKYCELL_TABLE_NAME "skyCell" 74 #define SKYCELLMAP_TABLE_NAME "skyCellMap" 70 75 #define MAX_STRING_LENGTH 1024 71 76 … … 438 443 psMetadata *where = expTagCounterMetadataFromObject(object); 439 444 long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, 0); 440 psFree(where) 445 psFree(where); 441 446 if (count < 0) { 442 447 psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter"); … … 460 465 psMetadata *where = expTagCounterMetadataFromObject(object); 461 466 long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit); 462 psFree(where) 467 psFree(where); 463 468 if (count < 0) { 464 469 psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter"); … … 843 848 psMetadata *where = summitExpMetadataFromObject(object); 844 849 long long count = psDBDeleteRows(dbh, SUMMITEXP_TABLE_NAME, where, 0); 845 psFree(where) 850 psFree(where); 846 851 if (count < 0) { 847 852 psError(PS_ERR_UNKNOWN, true, "failed to delete row from summitExp"); … … 865 870 psMetadata *where = summitExpMetadataFromObject(object); 866 871 long long count = psDBDeleteRows(dbh, SUMMITEXP_TABLE_NAME, where, limit); 867 psFree(where) 872 psFree(where); 868 873 if (count < 0) { 869 874 psError(PS_ERR_UNKNOWN, true, "failed to delete row from summitExp"); … … 1292 1297 psMetadata *where = summitImfileMetadataFromObject(object); 1293 1298 long long count = psDBDeleteRows(dbh, SUMMITIMFILE_TABLE_NAME, where, 0); 1294 psFree(where) 1299 psFree(where); 1295 1300 if (count < 0) { 1296 1301 psError(PS_ERR_UNKNOWN, true, "failed to delete row from summitImfile"); … … 1314 1319 psMetadata *where = summitImfileMetadataFromObject(object); 1315 1320 long long count = psDBDeleteRows(dbh, SUMMITIMFILE_TABLE_NAME, where, limit); 1316 psFree(where) 1321 psFree(where); 1317 1322 if (count < 0) { 1318 1323 psError(PS_ERR_UNKNOWN, true, "failed to delete row from summitImfile"); … … 1610 1615 psMetadata *where = pzPendingExpMetadataFromObject(object); 1611 1616 long long count = psDBDeleteRows(dbh, PZPENDINGEXP_TABLE_NAME, where, 0); 1612 psFree(where) 1617 psFree(where); 1613 1618 if (count < 0) { 1614 1619 psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzPendingExp"); … … 1632 1637 psMetadata *where = pzPendingExpMetadataFromObject(object); 1633 1638 long long count = psDBDeleteRows(dbh, PZPENDINGEXP_TABLE_NAME, where, limit); 1634 psFree(where) 1639 psFree(where); 1635 1640 if (count < 0) { 1636 1641 psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzPendingExp"); … … 1994 1999 psMetadata *where = pzPendingImfileMetadataFromObject(object); 1995 2000 long long count = psDBDeleteRows(dbh, PZPENDINGIMFILE_TABLE_NAME, where, 0); 1996 psFree(where) 2001 psFree(where); 1997 2002 if (count < 0) { 1998 2003 psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzPendingImfile"); … … 2016 2021 psMetadata *where = pzPendingImfileMetadataFromObject(object); 2017 2022 long long count = psDBDeleteRows(dbh, PZPENDINGIMFILE_TABLE_NAME, where, limit); 2018 psFree(where) 2023 psFree(where); 2019 2024 if (count < 0) { 2020 2025 psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzPendingImfile"); … … 2312 2317 psMetadata *where = pzDoneExpMetadataFromObject(object); 2313 2318 long long count = psDBDeleteRows(dbh, PZDONEEXP_TABLE_NAME, where, 0); 2314 psFree(where) 2319 psFree(where); 2315 2320 if (count < 0) { 2316 2321 psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzDoneExp"); … … 2334 2339 psMetadata *where = pzDoneExpMetadataFromObject(object); 2335 2340 long long count = psDBDeleteRows(dbh, PZDONEEXP_TABLE_NAME, where, limit); 2336 psFree(where) 2341 psFree(where); 2337 2342 if (count < 0) { 2338 2343 psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzDoneExp"); … … 2718 2723 psMetadata *where = pzDoneImfileMetadataFromObject(object); 2719 2724 long long count = psDBDeleteRows(dbh, PZDONEIMFILE_TABLE_NAME, where, 0); 2720 psFree(where) 2725 psFree(where); 2721 2726 if (count < 0) { 2722 2727 psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzDoneImfile"); … … 2740 2745 psMetadata *where = pzDoneImfileMetadataFromObject(object); 2741 2746 long long count = psDBDeleteRows(dbh, PZDONEIMFILE_TABLE_NAME, where, limit); 2742 psFree(where) 2747 psFree(where); 2743 2748 if (count < 0) { 2744 2749 psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzDoneImfile"); … … 3101 3106 psMetadata *where = newExpMetadataFromObject(object); 3102 3107 long long count = psDBDeleteRows(dbh, NEWEXP_TABLE_NAME, where, 0); 3103 psFree(where) 3108 psFree(where); 3104 3109 if (count < 0) { 3105 3110 psError(PS_ERR_UNKNOWN, true, "failed to delete row from newExp"); … … 3123 3128 psMetadata *where = newExpMetadataFromObject(object); 3124 3129 long long count = psDBDeleteRows(dbh, NEWEXP_TABLE_NAME, where, limit); 3125 psFree(where) 3130 psFree(where); 3126 3131 if (count < 0) { 3127 3132 psError(PS_ERR_UNKNOWN, true, "failed to delete row from newExp"); … … 3441 3446 psMetadata *where = newImfileMetadataFromObject(object); 3442 3447 long long count = psDBDeleteRows(dbh, NEWIMFILE_TABLE_NAME, where, 0); 3443 psFree(where) 3448 psFree(where); 3444 3449 if (count < 0) { 3445 3450 psError(PS_ERR_UNKNOWN, true, "failed to delete row from newImfile"); … … 3463 3468 psMetadata *where = newImfileMetadataFromObject(object); 3464 3469 long long count = psDBDeleteRows(dbh, NEWIMFILE_TABLE_NAME, where, limit); 3465 psFree(where) 3470 psFree(where); 3466 3471 if (count < 0) { 3467 3472 psError(PS_ERR_UNKNOWN, true, "failed to delete row from newImfile"); … … 4164 4169 psMetadata *where = rawExpMetadataFromObject(object); 4165 4170 long long count = psDBDeleteRows(dbh, RAWEXP_TABLE_NAME, where, 0); 4166 psFree(where) 4171 psFree(where); 4167 4172 if (count < 0) { 4168 4173 psError(PS_ERR_UNKNOWN, true, "failed to delete row from rawExp"); … … 4186 4191 psMetadata *where = rawExpMetadataFromObject(object); 4187 4192 long long count = psDBDeleteRows(dbh, RAWEXP_TABLE_NAME, where, limit); 4188 psFree(where) 4193 psFree(where); 4189 4194 if (count < 0) { 4190 4195 psError(PS_ERR_UNKNOWN, true, "failed to delete row from rawExp"); … … 4844 4849 psMetadata *where = rawImfileMetadataFromObject(object); 4845 4850 long long count = psDBDeleteRows(dbh, RAWIMFILE_TABLE_NAME, where, 0); 4846 psFree(where) 4851 psFree(where); 4847 4852 if (count < 0) { 4848 4853 psError(PS_ERR_UNKNOWN, true, "failed to delete row from rawImfile"); … … 4866 4871 psMetadata *where = rawImfileMetadataFromObject(object); 4867 4872 long long count = psDBDeleteRows(dbh, RAWIMFILE_TABLE_NAME, where, limit); 4868 psFree(where) 4873 psFree(where); 4869 4874 if (count < 0) { 4870 4875 psError(PS_ERR_UNKNOWN, true, "failed to delete row from rawImfile"); … … 5161 5166 psMetadata *where = p1PendingExpMetadataFromObject(object); 5162 5167 long long count = psDBDeleteRows(dbh, P1PENDINGEXP_TABLE_NAME, where, 0); 5163 psFree(where) 5168 psFree(where); 5164 5169 if (count < 0) { 5165 5170 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p1PendingExp"); … … 5183 5188 psMetadata *where = p1PendingExpMetadataFromObject(object); 5184 5189 long long count = psDBDeleteRows(dbh, P1PENDINGEXP_TABLE_NAME, where, limit); 5185 psFree(where) 5190 psFree(where); 5186 5191 if (count < 0) { 5187 5192 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p1PendingExp"); … … 5521 5526 psMetadata *where = p2PendingExpMetadataFromObject(object); 5522 5527 long long count = psDBDeleteRows(dbh, P2PENDINGEXP_TABLE_NAME, where, 0); 5523 psFree(where) 5528 psFree(where); 5524 5529 if (count < 0) { 5525 5530 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2PendingExp"); … … 5543 5548 psMetadata *where = p2PendingExpMetadataFromObject(object); 5544 5549 long long count = psDBDeleteRows(dbh, P2PENDINGEXP_TABLE_NAME, where, limit); 5545 psFree(where) 5550 psFree(where); 5546 5551 if (count < 0) { 5547 5552 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2PendingExp"); … … 5903 5908 psMetadata *where = p2PendingImfileMetadataFromObject(object); 5904 5909 long long count = psDBDeleteRows(dbh, P2PENDINGIMFILE_TABLE_NAME, where, 0); 5905 psFree(where) 5910 psFree(where); 5906 5911 if (count < 0) { 5907 5912 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2PendingImfile"); … … 5925 5930 psMetadata *where = p2PendingImfileMetadataFromObject(object); 5926 5931 long long count = psDBDeleteRows(dbh, P2PENDINGIMFILE_TABLE_NAME, where, limit); 5927 psFree(where) 5932 psFree(where); 5928 5933 if (count < 0) { 5929 5934 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2PendingImfile"); … … 6241 6246 psMetadata *where = p2ProcessedExpMetadataFromObject(object); 6242 6247 long long count = psDBDeleteRows(dbh, P2PROCESSEDEXP_TABLE_NAME, where, 0); 6243 psFree(where) 6248 psFree(where); 6244 6249 if (count < 0) { 6245 6250 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2ProcessedExp"); … … 6263 6268 psMetadata *where = p2ProcessedExpMetadataFromObject(object); 6264 6269 long long count = psDBDeleteRows(dbh, P2PROCESSEDEXP_TABLE_NAME, where, limit); 6265 psFree(where) 6270 psFree(where); 6266 6271 if (count < 0) { 6267 6272 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2ProcessedExp"); … … 6515 6520 psMetadata *where = p2MaskMetadataFromObject(object); 6516 6521 long long count = psDBDeleteRows(dbh, P2MASK_TABLE_NAME, where, 0); 6517 psFree(where) 6522 psFree(where); 6518 6523 if (count < 0) { 6519 6524 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2Mask"); … … 6537 6542 psMetadata *where = p2MaskMetadataFromObject(object); 6538 6543 long long count = psDBDeleteRows(dbh, P2MASK_TABLE_NAME, where, limit); 6539 psFree(where) 6544 psFree(where); 6540 6545 if (count < 0) { 6541 6546 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2Mask"); … … 7025 7030 psMetadata *where = p2ProcessedImfileMetadataFromObject(object); 7026 7031 long long count = psDBDeleteRows(dbh, P2PROCESSEDIMFILE_TABLE_NAME, where, 0); 7027 psFree(where) 7032 psFree(where); 7028 7033 if (count < 0) { 7029 7034 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2ProcessedImfile"); … … 7047 7052 psMetadata *where = p2ProcessedImfileMetadataFromObject(object); 7048 7053 long long count = psDBDeleteRows(dbh, P2PROCESSEDIMFILE_TABLE_NAME, where, limit); 7049 psFree(where) 7054 psFree(where); 7050 7055 if (count < 0) { 7051 7056 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2ProcessedImfile"); … … 7363 7368 psMetadata *where = p3PendingExpMetadataFromObject(object); 7364 7369 long long count = psDBDeleteRows(dbh, P3PENDINGEXP_TABLE_NAME, where, 0); 7365 psFree(where) 7370 psFree(where); 7366 7371 if (count < 0) { 7367 7372 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p3PendingExp"); … … 7385 7390 psMetadata *where = p3PendingExpMetadataFromObject(object); 7386 7391 long long count = psDBDeleteRows(dbh, P3PENDINGEXP_TABLE_NAME, where, limit); 7387 psFree(where) 7392 psFree(where); 7388 7393 if (count < 0) { 7389 7394 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p3PendingExp"); … … 7978 7983 psMetadata *where = p3ProcessedExpMetadataFromObject(object); 7979 7984 long long count = psDBDeleteRows(dbh, P3PROCESSEDEXP_TABLE_NAME, where, 0); 7980 psFree(where) 7985 psFree(where); 7981 7986 if (count < 0) { 7982 7987 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p3ProcessedExp"); … … 8000 8005 psMetadata *where = p3ProcessedExpMetadataFromObject(object); 8001 8006 long long count = psDBDeleteRows(dbh, P3PROCESSEDEXP_TABLE_NAME, where, limit); 8002 psFree(where) 8007 psFree(where); 8003 8008 if (count < 0) { 8004 8009 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p3ProcessedExp"); … … 8252 8257 psMetadata *where = p3MaskMetadataFromObject(object); 8253 8258 long long count = psDBDeleteRows(dbh, P3MASK_TABLE_NAME, where, 0); 8254 psFree(where) 8259 psFree(where); 8255 8260 if (count < 0) { 8256 8261 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p3Mask"); … … 8274 8279 psMetadata *where = p3MaskMetadataFromObject(object); 8275 8280 long long count = psDBDeleteRows(dbh, P3MASK_TABLE_NAME, where, limit); 8276 psFree(where) 8281 psFree(where); 8277 8282 if (count < 0) { 8278 8283 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p3Mask"); … … 9000 9005 psMetadata *where = detRunMetadataFromObject(object); 9001 9006 long long count = psDBDeleteRows(dbh, DETRUN_TABLE_NAME, where, 0); 9002 psFree(where) 9007 psFree(where); 9003 9008 if (count < 0) { 9004 9009 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detRun"); … … 9022 9027 psMetadata *where = detRunMetadataFromObject(object); 9023 9028 long long count = psDBDeleteRows(dbh, DETRUN_TABLE_NAME, where, limit); 9024 psFree(where) 9029 psFree(where); 9025 9030 if (count < 0) { 9026 9031 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detRun"); … … 9337 9342 psMetadata *where = detInputExpMetadataFromObject(object); 9338 9343 long long count = psDBDeleteRows(dbh, DETINPUTEXP_TABLE_NAME, where, 0); 9339 psFree(where) 9344 psFree(where); 9340 9345 if (count < 0) { 9341 9346 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detInputExp"); … … 9359 9364 psMetadata *where = detInputExpMetadataFromObject(object); 9360 9365 long long count = psDBDeleteRows(dbh, DETINPUTEXP_TABLE_NAME, where, limit); 9361 psFree(where) 9366 psFree(where); 9362 9367 if (count < 0) { 9363 9368 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detInputExp"); … … 9826 9831 psMetadata *where = detProcessedImfileMetadataFromObject(object); 9827 9832 long long count = psDBDeleteRows(dbh, DETPROCESSEDIMFILE_TABLE_NAME, where, 0); 9828 psFree(where) 9833 psFree(where); 9829 9834 if (count < 0) { 9830 9835 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detProcessedImfile"); … … 9848 9853 psMetadata *where = detProcessedImfileMetadataFromObject(object); 9849 9854 long long count = psDBDeleteRows(dbh, DETPROCESSEDIMFILE_TABLE_NAME, where, limit); 9850 psFree(where) 9855 psFree(where); 9851 9856 if (count < 0) { 9852 9857 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detProcessedImfile"); … … 10271 10276 psMetadata *where = detProcessedExpMetadataFromObject(object); 10272 10277 long long count = psDBDeleteRows(dbh, DETPROCESSEDEXP_TABLE_NAME, where, 0); 10273 psFree(where) 10278 psFree(where); 10274 10279 if (count < 0) { 10275 10280 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detProcessedExp"); … … 10293 10298 psMetadata *where = detProcessedExpMetadataFromObject(object); 10294 10299 long long count = psDBDeleteRows(dbh, DETPROCESSEDEXP_TABLE_NAME, where, limit); 10295 psFree(where) 10300 psFree(where); 10296 10301 if (count < 0) { 10297 10302 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detProcessedExp"); … … 10715 10720 psMetadata *where = detStackedImfileMetadataFromObject(object); 10716 10721 long long count = psDBDeleteRows(dbh, DETSTACKEDIMFILE_TABLE_NAME, where, 0); 10717 psFree(where) 10722 psFree(where); 10718 10723 if (count < 0) { 10719 10724 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detStackedImfile"); … … 10737 10742 psMetadata *where = detStackedImfileMetadataFromObject(object); 10738 10743 long long count = psDBDeleteRows(dbh, DETSTACKEDIMFILE_TABLE_NAME, where, limit); 10739 psFree(where) 10744 psFree(where); 10740 10745 if (count < 0) { 10741 10746 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detStackedImfile"); … … 11073 11078 psMetadata *where = detNormalizedStatImfileMetadataFromObject(object); 11074 11079 long long count = psDBDeleteRows(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, where, 0); 11075 psFree(where) 11080 psFree(where); 11076 11081 if (count < 0) { 11077 11082 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedStatImfile"); … … 11095 11100 psMetadata *where = detNormalizedStatImfileMetadataFromObject(object); 11096 11101 long long count = psDBDeleteRows(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, where, limit); 11097 psFree(where) 11102 psFree(where); 11098 11103 if (count < 0) { 11099 11104 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedStatImfile"); … … 11539 11544 psMetadata *where = detNormalizedImfileMetadataFromObject(object); 11540 11545 long long count = psDBDeleteRows(dbh, DETNORMALIZEDIMFILE_TABLE_NAME, where, 0); 11541 psFree(where) 11546 psFree(where); 11542 11547 if (count < 0) { 11543 11548 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedImfile"); … … 11561 11566 psMetadata *where = detNormalizedImfileMetadataFromObject(object); 11562 11567 long long count = psDBDeleteRows(dbh, DETNORMALIZEDIMFILE_TABLE_NAME, where, limit); 11563 psFree(where) 11568 psFree(where); 11564 11569 if (count < 0) { 11565 11570 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedImfile"); … … 11983 11988 psMetadata *where = detNormalizedExpMetadataFromObject(object); 11984 11989 long long count = psDBDeleteRows(dbh, DETNORMALIZEDEXP_TABLE_NAME, where, 0); 11985 psFree(where) 11990 psFree(where); 11986 11991 if (count < 0) { 11987 11992 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedExp"); … … 12005 12010 psMetadata *where = detNormalizedExpMetadataFromObject(object); 12006 12011 long long count = psDBDeleteRows(dbh, DETNORMALIZEDEXP_TABLE_NAME, where, limit); 12007 psFree(where) 12012 psFree(where); 12008 12013 if (count < 0) { 12009 12014 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedExp"); … … 12493 12498 psMetadata *where = detResidImfileMetadataFromObject(object); 12494 12499 long long count = psDBDeleteRows(dbh, DETRESIDIMFILE_TABLE_NAME, where, 0); 12495 psFree(where) 12500 psFree(where); 12496 12501 if (count < 0) { 12497 12502 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detResidImfile"); … … 12515 12520 psMetadata *where = detResidImfileMetadataFromObject(object); 12516 12521 long long count = psDBDeleteRows(dbh, DETRESIDIMFILE_TABLE_NAME, where, limit); 12517 psFree(where) 12522 psFree(where); 12518 12523 if (count < 0) { 12519 12524 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detResidImfile"); … … 12980 12985 psMetadata *where = detResidExpMetadataFromObject(object); 12981 12986 long long count = psDBDeleteRows(dbh, DETRESIDEXP_TABLE_NAME, where, 0); 12982 psFree(where) 12987 psFree(where); 12983 12988 if (count < 0) { 12984 12989 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detResidExp"); … … 13002 13007 psMetadata *where = detResidExpMetadataFromObject(object); 13003 13008 long long count = psDBDeleteRows(dbh, DETRESIDEXP_TABLE_NAME, where, limit); 13004 psFree(where) 13009 psFree(where); 13005 13010 if (count < 0) { 13006 13011 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detResidExp"); … … 13379 13384 psMetadata *where = detRunSummaryMetadataFromObject(object); 13380 13385 long long count = psDBDeleteRows(dbh, DETRUNSUMMARY_TABLE_NAME, where, 0); 13381 psFree(where) 13386 psFree(where); 13382 13387 if (count < 0) { 13383 13388 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detRunSummary"); … … 13401 13406 psMetadata *where = detRunSummaryMetadataFromObject(object); 13402 13407 long long count = psDBDeleteRows(dbh, DETRUNSUMMARY_TABLE_NAME, where, limit); 13403 psFree(where) 13408 psFree(where); 13404 13409 if (count < 0) { 13405 13410 psError(PS_ERR_UNKNOWN, true, "failed to delete row from detRunSummary"); … … 13458 13463 return true; 13459 13464 } 13460 static void p4RunRowFree(p4RunRow *object); 13461 13462 p4RunRow *p4RunRowAlloc(psS32 p4_id, const char *survey_mode, const char *state, const char *workdir, const char *filter, const char *skycell_id, const char *tess_id, psF64 ra, psF64 decl, const char *input_ss, const char *output_ss) 13463 { 13464 p4RunRow *_object; 13465 13466 _object = psAlloc(sizeof(p4RunRow)); 13467 psMemSetDeallocator(_object, (psFreeFunc)p4RunRowFree); 13468 13469 _object->p4_id = p4_id; 13470 _object->survey_mode = psStringCopy(survey_mode); 13465 static void p4aRunRowFree(p4aRunRow *object); 13466 13467 p4aRunRow *p4aRunRowAlloc(psS32 p4a_id, const char *state, const char *workdir, bool magic) 13468 { 13469 p4aRunRow *_object; 13470 13471 _object = psAlloc(sizeof(p4aRunRow)); 13472 psMemSetDeallocator(_object, (psFreeFunc)p4aRunRowFree); 13473 13474 _object->p4a_id = p4a_id; 13471 13475 _object->state = psStringCopy(state); 13472 13476 _object->workdir = psStringCopy(workdir); 13473 _object->filter = psStringCopy(filter); 13474 _object->skycell_id = psStringCopy(skycell_id); 13475 _object->tess_id = psStringCopy(tess_id); 13476 _object->ra = ra; 13477 _object->decl = decl; 13478 _object->input_ss = psStringCopy(input_ss); 13479 _object->output_ss = psStringCopy(output_ss); 13477 _object->magic = magic; 13480 13478 13481 13479 return _object; 13482 13480 } 13483 13481 13484 static void p4RunRowFree(p4RunRow *object) 13485 { 13486 psFree(object->survey_mode); 13482 static void p4aRunRowFree(p4aRunRow *object) 13483 { 13487 13484 psFree(object->state); 13488 13485 psFree(object->workdir); 13489 psFree(object->filter); 13490 psFree(object->skycell_id); 13491 psFree(object->tess_id); 13492 psFree(object->input_ss); 13493 psFree(object->output_ss); 13494 } 13495 13496 bool p4RunCreateTable(psDB *dbh) 13486 } 13487 13488 bool p4aRunCreateTable(psDB *dbh) 13497 13489 { 13498 13490 psMetadata *md = psMetadataAlloc(); 13499 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, "Primary Key AUTO_INCREMENT", 0)) { 13500 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 13501 psFree(md); 13502 return false; 13503 } 13504 if (!psMetadataAdd(md, PS_LIST_TAIL, "survey_mode", PS_DATA_STRING, "Key", "64")) { 13505 psError(PS_ERR_UNKNOWN, false, "failed to add item survey_mode"); 13491 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4a_id", PS_DATA_S32, "Primary Key AUTO_INCREMENT", 0)) { 13492 psError(PS_ERR_UNKNOWN, false, "failed to add item p4a_id"); 13506 13493 psFree(md); 13507 13494 return false; … … 13517 13504 return false; 13518 13505 } 13519 if (!psMetadataAdd(md, PS_LIST_TAIL, "filter", PS_DATA_STRING, NULL, "64")) { 13520 psError(PS_ERR_UNKNOWN, false, "failed to add item filter"); 13521 psFree(md); 13522 return false; 13523 } 13524 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, "64")) { 13525 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 13526 psFree(md); 13527 return false; 13528 } 13529 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, "64")) { 13530 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 13531 psFree(md); 13532 return false; 13533 } 13534 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra", PS_DATA_F64, NULL, 0.0)) { 13535 psError(PS_ERR_UNKNOWN, false, "failed to add item ra"); 13536 psFree(md); 13537 return false; 13538 } 13539 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl", PS_DATA_F64, NULL, 0.0)) { 13540 psError(PS_ERR_UNKNOWN, false, "failed to add item decl"); 13541 psFree(md); 13542 return false; 13543 } 13544 if (!psMetadataAdd(md, PS_LIST_TAIL, "input_ss", PS_DATA_STRING, NULL, "64")) { 13545 psError(PS_ERR_UNKNOWN, false, "failed to add item input_ss"); 13546 psFree(md); 13547 return false; 13548 } 13549 if (!psMetadataAdd(md, PS_LIST_TAIL, "output_ss", PS_DATA_STRING, NULL, "64")) { 13550 psError(PS_ERR_UNKNOWN, false, "failed to add item output_ss"); 13551 psFree(md); 13552 return false; 13553 } 13554 13555 bool status = psDBCreateTable(dbh, P4RUN_TABLE_NAME, md); 13506 if (!psMetadataAdd(md, PS_LIST_TAIL, "magic", PS_DATA_BOOL, "Primary Key", 0)) { 13507 psError(PS_ERR_UNKNOWN, false, "failed to add item magic"); 13508 psFree(md); 13509 return false; 13510 } 13511 13512 bool status = psDBCreateTable(dbh, P4ARUN_TABLE_NAME, md); 13556 13513 13557 13514 psFree(md); … … 13560 13517 } 13561 13518 13562 bool p4 RunDropTable(psDB *dbh)13563 { 13564 return psDBDropTable(dbh, P4 RUN_TABLE_NAME);13565 } 13566 13567 bool p4 RunInsert(psDB * dbh, psS32 p4_id, const char *survey_mode, const char *state, const char *workdir, const char *filter, const char *skycell_id, const char *tess_id, psF64 ra, psF64 decl, const char *input_ss, const char *output_ss)13519 bool p4aRunDropTable(psDB *dbh) 13520 { 13521 return psDBDropTable(dbh, P4ARUN_TABLE_NAME); 13522 } 13523 13524 bool p4aRunInsert(psDB * dbh, psS32 p4a_id, const char *state, const char *workdir, bool magic) 13568 13525 { 13569 13526 psMetadata *md = psMetadataAlloc(); 13570 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, NULL, p4_id)) { 13571 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 13572 psFree(md); 13573 return false; 13574 } 13575 if (!psMetadataAdd(md, PS_LIST_TAIL, "survey_mode", PS_DATA_STRING, NULL, survey_mode)) { 13576 psError(PS_ERR_UNKNOWN, false, "failed to add item survey_mode"); 13527 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4a_id", PS_DATA_S32, NULL, p4a_id)) { 13528 psError(PS_ERR_UNKNOWN, false, "failed to add item p4a_id"); 13577 13529 psFree(md); 13578 13530 return false; … … 13588 13540 return false; 13589 13541 } 13590 if (!psMetadataAdd(md, PS_LIST_TAIL, "filter", PS_DATA_STRING, NULL, filter)) { 13591 psError(PS_ERR_UNKNOWN, false, "failed to add item filter"); 13592 psFree(md); 13593 return false; 13594 } 13595 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, skycell_id)) { 13596 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 13597 psFree(md); 13598 return false; 13599 } 13600 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, tess_id)) { 13601 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 13602 psFree(md); 13603 return false; 13604 } 13605 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra", PS_DATA_F64, NULL, ra)) { 13606 psError(PS_ERR_UNKNOWN, false, "failed to add item ra"); 13607 psFree(md); 13608 return false; 13609 } 13610 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl", PS_DATA_F64, NULL, decl)) { 13611 psError(PS_ERR_UNKNOWN, false, "failed to add item decl"); 13612 psFree(md); 13613 return false; 13614 } 13615 if (!psMetadataAdd(md, PS_LIST_TAIL, "input_ss", PS_DATA_STRING, NULL, input_ss)) { 13616 psError(PS_ERR_UNKNOWN, false, "failed to add item input_ss"); 13617 psFree(md); 13618 return false; 13619 } 13620 if (!psMetadataAdd(md, PS_LIST_TAIL, "output_ss", PS_DATA_STRING, NULL, output_ss)) { 13621 psError(PS_ERR_UNKNOWN, false, "failed to add item output_ss"); 13622 psFree(md); 13623 return false; 13624 } 13625 13626 bool status = psDBInsertOneRow(dbh, P4RUN_TABLE_NAME, md); 13542 if (!psMetadataAdd(md, PS_LIST_TAIL, "magic", PS_DATA_BOOL, NULL, magic)) { 13543 psError(PS_ERR_UNKNOWN, false, "failed to add item magic"); 13544 psFree(md); 13545 return false; 13546 } 13547 13548 bool status = psDBInsertOneRow(dbh, P4ARUN_TABLE_NAME, md); 13627 13549 psFree(md); 13628 13550 … … 13630 13552 } 13631 13553 13632 long long p4 RunDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)13554 long long p4aRunDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 13633 13555 { 13634 13556 long long deleted = 0; 13635 13557 13636 long long count = psDBDeleteRows(dbh, P4 RUN_TABLE_NAME, where, limit);13558 long long count = psDBDeleteRows(dbh, P4ARUN_TABLE_NAME, where, limit); 13637 13559 if (count < 0) { 13638 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 Run");13560 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aRun"); 13639 13561 return count; 13640 13562 … … 13644 13566 return deleted; 13645 13567 } 13646 bool p4 RunInsertObject(psDB *dbh, p4RunRow *object)13647 { 13648 return p4 RunInsert(dbh, object->p4_id, object->survey_mode, object->state, object->workdir, object->filter, object->skycell_id, object->tess_id, object->ra, object->decl, object->input_ss, object->output_ss);13649 } 13650 13651 bool p4 RunInsertObjects(psDB *dbh, psArray *objects)13568 bool p4aRunInsertObject(psDB *dbh, p4aRunRow *object) 13569 { 13570 return p4aRunInsert(dbh, object->p4a_id, object->state, object->workdir, object->magic); 13571 } 13572 13573 bool p4aRunInsertObjects(psDB *dbh, psArray *objects) 13652 13574 { 13653 13575 for (long i = 0; i < psArrayLength(objects); i++) { 13654 if (!p4 RunInsertObject(dbh, objects->data[i])) {13576 if (!p4aRunInsertObject(dbh, objects->data[i])) { 13655 13577 return false; 13656 13578 } … … 13660 13582 } 13661 13583 13662 bool p4 RunInsertFits(psDB *dbh, const psFits *fits)13584 bool p4aRunInsertFits(psDB *dbh, const psFits *fits) 13663 13585 { 13664 13586 psArray *rowSet; 13665 13587 13666 // move to (the first?) extension named P4 RUN_TABLE_NAME13667 if (!psFitsMoveExtName(fits, P4 RUN_TABLE_NAME)) {13668 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4 RUN_TABLE_NAME);13588 // move to (the first?) extension named P4ARUN_TABLE_NAME 13589 if (!psFitsMoveExtName(fits, P4ARUN_TABLE_NAME)) { 13590 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4ARUN_TABLE_NAME); 13669 13591 return false; 13670 13592 } … … 13684 13606 } 13685 13607 13686 if (!psDBInsertRows(dbh, P4 RUN_TABLE_NAME, rowSet)) {13608 if (!psDBInsertRows(dbh, P4ARUN_TABLE_NAME, rowSet)) { 13687 13609 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 13688 13610 psFree(rowSet); … … 13695 13617 } 13696 13618 13697 bool p4 RunSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)13619 bool p4aRunSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 13698 13620 { 13699 13621 psArray *rowSet; 13700 13622 13701 rowSet = psDBSelectRows(dbh, P4 RUN_TABLE_NAME, where, limit);13623 rowSet = psDBSelectRows(dbh, P4ARUN_TABLE_NAME, where, limit); 13702 13624 if (!rowSet) { 13703 13625 return false; … … 13705 13627 13706 13628 // output to fits 13707 if (!psFitsWriteTable(fits, NULL, rowSet, P4 RUN_TABLE_NAME)) {13629 if (!psFitsWriteTable(fits, NULL, rowSet, P4ARUN_TABLE_NAME)) { 13708 13630 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 13709 13631 psFree(rowSet); … … 13716 13638 } 13717 13639 13718 psMetadata *p4 RunMetadataFromObject(const p4RunRow *object)13640 psMetadata *p4aRunMetadataFromObject(const p4aRunRow *object) 13719 13641 { 13720 13642 psMetadata *md = psMetadataAlloc(); 13721 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, NULL, object->p4_id)) { 13722 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 13723 psFree(md); 13724 return false; 13725 } 13726 if (!psMetadataAdd(md, PS_LIST_TAIL, "survey_mode", PS_DATA_STRING, NULL, object->survey_mode)) { 13727 psError(PS_ERR_UNKNOWN, false, "failed to add item survey_mode"); 13643 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4a_id", PS_DATA_S32, NULL, object->p4a_id)) { 13644 psError(PS_ERR_UNKNOWN, false, "failed to add item p4a_id"); 13728 13645 psFree(md); 13729 13646 return false; … … 13739 13656 return false; 13740 13657 } 13741 if (!psMetadataAdd(md, PS_LIST_TAIL, "filter", PS_DATA_STRING, NULL, object->filter)) { 13742 psError(PS_ERR_UNKNOWN, false, "failed to add item filter"); 13743 psFree(md); 13744 return false; 13745 } 13746 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, object->skycell_id)) { 13747 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 13748 psFree(md); 13749 return false; 13750 } 13751 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, object->tess_id)) { 13752 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 13753 psFree(md); 13754 return false; 13755 } 13756 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra", PS_DATA_F64, NULL, object->ra)) { 13757 psError(PS_ERR_UNKNOWN, false, "failed to add item ra"); 13758 psFree(md); 13759 return false; 13760 } 13761 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl", PS_DATA_F64, NULL, object->decl)) { 13762 psError(PS_ERR_UNKNOWN, false, "failed to add item decl"); 13763 psFree(md); 13764 return false; 13765 } 13766 if (!psMetadataAdd(md, PS_LIST_TAIL, "input_ss", PS_DATA_STRING, NULL, object->input_ss)) { 13767 psError(PS_ERR_UNKNOWN, false, "failed to add item input_ss"); 13768 psFree(md); 13769 return false; 13770 } 13771 if (!psMetadataAdd(md, PS_LIST_TAIL, "output_ss", PS_DATA_STRING, NULL, object->output_ss)) { 13772 psError(PS_ERR_UNKNOWN, false, "failed to add item output_ss"); 13658 if (!psMetadataAdd(md, PS_LIST_TAIL, "magic", PS_DATA_BOOL, NULL, object->magic)) { 13659 psError(PS_ERR_UNKNOWN, false, "failed to add item magic"); 13773 13660 psFree(md); 13774 13661 return false; … … 13779 13666 } 13780 13667 13781 p4 RunRow *p4RunObjectFromMetadata(psMetadata *md)13668 p4aRunRow *p4aRunObjectFromMetadata(psMetadata *md) 13782 13669 { 13783 13670 13784 13671 bool status = false; 13785 psS32 p4_id = psMetadataLookupS32(&status, md, "p4_id"); 13786 if (!status) { 13787 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4_id"); 13788 return false; 13789 } 13790 char* survey_mode = psMetadataLookupPtr(&status, md, "survey_mode"); 13791 if (!status) { 13792 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item survey_mode"); 13672 psS32 p4a_id = psMetadataLookupS32(&status, md, "p4a_id"); 13673 if (!status) { 13674 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4a_id"); 13793 13675 return false; 13794 13676 } … … 13803 13685 return false; 13804 13686 } 13805 char* filter = psMetadataLookupPtr(&status, md, "filter"); 13806 if (!status) { 13807 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item filter"); 13808 return false; 13809 } 13810 char* skycell_id = psMetadataLookupPtr(&status, md, "skycell_id"); 13811 if (!status) { 13812 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item skycell_id"); 13813 return false; 13814 } 13815 char* tess_id = psMetadataLookupPtr(&status, md, "tess_id"); 13816 if (!status) { 13817 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item tess_id"); 13818 return false; 13819 } 13820 psF64 ra = psMetadataLookupF64(&status, md, "ra"); 13821 if (!status) { 13822 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item ra"); 13823 return false; 13824 } 13825 psF64 decl = psMetadataLookupF64(&status, md, "decl"); 13826 if (!status) { 13827 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item decl"); 13828 return false; 13829 } 13830 char* input_ss = psMetadataLookupPtr(&status, md, "input_ss"); 13831 if (!status) { 13832 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item input_ss"); 13833 return false; 13834 } 13835 char* output_ss = psMetadataLookupPtr(&status, md, "output_ss"); 13836 if (!status) { 13837 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item output_ss"); 13838 return false; 13839 } 13840 13841 return p4RunRowAlloc(p4_id, survey_mode, state, workdir, filter, skycell_id, tess_id, ra, decl, input_ss, output_ss); 13842 } 13843 psArray *p4RunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 13687 bool magic = psMetadataLookupBool(&status, md, "magic"); 13688 if (!status) { 13689 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item magic"); 13690 return false; 13691 } 13692 13693 return p4aRunRowAlloc(p4a_id, state, workdir, magic); 13694 } 13695 psArray *p4aRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 13844 13696 { 13845 13697 psArray *rowSet; … … 13847 13699 psU64 i; 13848 13700 13849 rowSet = psDBSelectRows(dbh, P4 RUN_TABLE_NAME, where, limit);13701 rowSet = psDBSelectRows(dbh, P4ARUN_TABLE_NAME, where, limit); 13850 13702 if (!rowSet) { 13851 13703 return NULL; … … 13857 13709 13858 13710 for (i = 0; i < rowSet->n; i++) { 13859 p4 RunRow *object = p4RunObjectFromMetadata(rowSet->data[i]);13711 p4aRunRow *object = p4aRunObjectFromMetadata(rowSet->data[i]); 13860 13712 psArrayAdd(returnSet, 0, object); 13861 13713 psFree(object); … … 13866 13718 return returnSet; 13867 13719 } 13868 bool p4 RunDeleteObject(psDB *dbh, const p4RunRow *object)13869 { 13870 psMetadata *where = p4 RunMetadataFromObject(object);13871 long long count = psDBDeleteRows(dbh, P4 RUN_TABLE_NAME, where, 0);13872 psFree(where) 13720 bool p4aRunDeleteObject(psDB *dbh, const p4aRunRow *object) 13721 { 13722 psMetadata *where = p4aRunMetadataFromObject(object); 13723 long long count = psDBDeleteRows(dbh, P4ARUN_TABLE_NAME, where, 0); 13724 psFree(where); 13873 13725 if (count < 0) { 13874 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 Run");13726 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aRun"); 13875 13727 return false; 13876 13728 } … … 13878 13730 // XXX should this be a psAbort() instead? It is possible that 13879 13731 // having an object match multiple rows was by design. 13880 psError(PS_ERR_UNKNOWN, true, "p4 RunRow object matched more then one row. Check your database schema");13881 return false; 13882 } 13883 13884 return true; 13885 } 13886 long long p4 RunDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)13732 psError(PS_ERR_UNKNOWN, true, "p4aRunRow object matched more then one row. Check your database schema"); 13733 return false; 13734 } 13735 13736 return true; 13737 } 13738 long long p4aRunDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 13887 13739 { 13888 13740 long long deleted = 0; 13889 13741 13890 13742 for (long long i = 0; i < objects->n; i++) { 13891 p4 RunRow *object = objects->data[i];13892 psMetadata *where = p4 RunMetadataFromObject(object);13893 long long count = psDBDeleteRows(dbh, P4 RUN_TABLE_NAME, where, limit);13894 psFree(where) 13743 p4aRunRow *object = objects->data[i]; 13744 psMetadata *where = p4aRunMetadataFromObject(object); 13745 long long count = psDBDeleteRows(dbh, P4ARUN_TABLE_NAME, where, limit); 13746 psFree(where); 13895 13747 if (count < 0) { 13896 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 Run");13748 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aRun"); 13897 13749 return count; 13898 13750 } … … 13903 13755 return deleted; 13904 13756 } 13905 bool p4 RunPrintObjects(FILE *stream, psArray *objects, bool mdcf)13757 bool p4aRunPrintObjects(FILE *stream, psArray *objects, bool mdcf) 13906 13758 { 13907 13759 PS_ASSERT_PTR_NON_NULL(objects, false); … … 13909 13761 psMetadata *output = psMetadataAlloc(); 13910 13762 for (long i = 0; i < psArrayLength(objects); i++) { 13911 psMetadata *md = p4 RunMetadataFromObject(objects->data[i]);13763 psMetadata *md = p4aRunMetadataFromObject(objects->data[i]); 13912 13764 if (!psMetadataAddMetadata( 13913 13765 output, 13914 13766 PS_LIST_TAIL, 13915 P4 RUN_TABLE_NAME,13767 P4ARUN_TABLE_NAME, 13916 13768 PS_META_DUPLICATE_OK, 13917 13769 NULL, … … 13934 13786 return true; 13935 13787 } 13936 bool p4 RunPrintObject(FILE *stream, p4RunRow *object, bool mdcf)13788 bool p4aRunPrintObject(FILE *stream, p4aRunRow *object, bool mdcf) 13937 13789 { 13938 13790 PS_ASSERT_PTR_NON_NULL(object, false); 13939 13791 13940 psMetadata *md = p4 RunMetadataFromObject(object);13792 psMetadata *md = p4aRunMetadataFromObject(object); 13941 13793 13942 13794 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { … … 13949 13801 return true; 13950 13802 } 13951 static void p4 InputImfileRowFree(p4InputImfileRow *object);13952 13953 p4 InputImfileRow *p4InputImfileRowAlloc(psS32 p4_id, const char *exp_tag, psS32 p3_version, const char *class_id)13954 { 13955 p4 InputImfileRow*_object;13956 13957 _object = psAlloc(sizeof(p4 InputImfileRow));13958 psMemSetDeallocator(_object, (psFreeFunc)p4 InputImfileRowFree);13959 13960 _object->p4 _id = p4_id;13803 static void p4aInputExpRowFree(p4aInputExpRow *object); 13804 13805 p4aInputExpRow *p4aInputExpRowAlloc(psS32 p4a_id, const char *exp_tag, psS32 p3_version) 13806 { 13807 p4aInputExpRow *_object; 13808 13809 _object = psAlloc(sizeof(p4aInputExpRow)); 13810 psMemSetDeallocator(_object, (psFreeFunc)p4aInputExpRowFree); 13811 13812 _object->p4a_id = p4a_id; 13961 13813 _object->exp_tag = psStringCopy(exp_tag); 13962 13814 _object->p3_version = p3_version; 13963 _object->class_id = psStringCopy(class_id);13964 13815 13965 13816 return _object; 13966 13817 } 13967 13818 13968 static void p4 InputImfileRowFree(p4InputImfileRow *object)13819 static void p4aInputExpRowFree(p4aInputExpRow *object) 13969 13820 { 13970 13821 psFree(object->exp_tag); 13971 psFree(object->class_id); 13972 } 13973 13974 bool p4InputImfileCreateTable(psDB *dbh) 13822 } 13823 13824 bool p4aInputExpCreateTable(psDB *dbh) 13975 13825 { 13976 13826 psMetadata *md = psMetadataAlloc(); 13977 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4 _id", PS_DATA_S32, "Primary Key", 0)) {13978 psError(PS_ERR_UNKNOWN, false, "failed to add item p4 _id");13827 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4a_id", PS_DATA_S32, "Primary Key", 0)) { 13828 psError(PS_ERR_UNKNOWN, false, "failed to add item p4a_id"); 13979 13829 psFree(md); 13980 13830 return false; … … 13990 13840 return false; 13991 13841 } 13992 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, "Primary Key", "64")) { 13993 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 13994 psFree(md); 13995 return false; 13996 } 13997 13998 bool status = psDBCreateTable(dbh, P4INPUTIMFILE_TABLE_NAME, md); 13842 13843 bool status = psDBCreateTable(dbh, P4AINPUTEXP_TABLE_NAME, md); 13999 13844 14000 13845 psFree(md); … … 14003 13848 } 14004 13849 14005 bool p4 InputImfileDropTable(psDB *dbh)14006 { 14007 return psDBDropTable(dbh, P4 INPUTIMFILE_TABLE_NAME);14008 } 14009 14010 bool p4 InputImfileInsert(psDB * dbh, psS32 p4_id, const char *exp_tag, psS32 p3_version, const char *class_id)13850 bool p4aInputExpDropTable(psDB *dbh) 13851 { 13852 return psDBDropTable(dbh, P4AINPUTEXP_TABLE_NAME); 13853 } 13854 13855 bool p4aInputExpInsert(psDB * dbh, psS32 p4a_id, const char *exp_tag, psS32 p3_version) 14011 13856 { 14012 13857 psMetadata *md = psMetadataAlloc(); 14013 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4 _id", PS_DATA_S32, NULL, p4_id)) {14014 psError(PS_ERR_UNKNOWN, false, "failed to add item p4 _id");13858 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4a_id", PS_DATA_S32, NULL, p4a_id)) { 13859 psError(PS_ERR_UNKNOWN, false, "failed to add item p4a_id"); 14015 13860 psFree(md); 14016 13861 return false; … … 14026 13871 return false; 14027 13872 } 14028 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, class_id)) { 14029 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 14030 psFree(md); 14031 return false; 14032 } 14033 14034 bool status = psDBInsertOneRow(dbh, P4INPUTIMFILE_TABLE_NAME, md); 13873 13874 bool status = psDBInsertOneRow(dbh, P4AINPUTEXP_TABLE_NAME, md); 14035 13875 psFree(md); 14036 13876 … … 14038 13878 } 14039 13879 14040 long long p4 InputImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)13880 long long p4aInputExpDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 14041 13881 { 14042 13882 long long deleted = 0; 14043 13883 14044 long long count = psDBDeleteRows(dbh, P4 INPUTIMFILE_TABLE_NAME, where, limit);13884 long long count = psDBDeleteRows(dbh, P4AINPUTEXP_TABLE_NAME, where, limit); 14045 13885 if (count < 0) { 14046 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 InputImfile");13886 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aInputExp"); 14047 13887 return count; 14048 13888 … … 14052 13892 return deleted; 14053 13893 } 14054 bool p4 InputImfileInsertObject(psDB *dbh, p4InputImfileRow *object)14055 { 14056 return p4 InputImfileInsert(dbh, object->p4_id, object->exp_tag, object->p3_version, object->class_id);14057 } 14058 14059 bool p4 InputImfileInsertObjects(psDB *dbh, psArray *objects)13894 bool p4aInputExpInsertObject(psDB *dbh, p4aInputExpRow *object) 13895 { 13896 return p4aInputExpInsert(dbh, object->p4a_id, object->exp_tag, object->p3_version); 13897 } 13898 13899 bool p4aInputExpInsertObjects(psDB *dbh, psArray *objects) 14060 13900 { 14061 13901 for (long i = 0; i < psArrayLength(objects); i++) { 14062 if (!p4 InputImfileInsertObject(dbh, objects->data[i])) {13902 if (!p4aInputExpInsertObject(dbh, objects->data[i])) { 14063 13903 return false; 14064 13904 } … … 14068 13908 } 14069 13909 14070 bool p4 InputImfileInsertFits(psDB *dbh, const psFits *fits)13910 bool p4aInputExpInsertFits(psDB *dbh, const psFits *fits) 14071 13911 { 14072 13912 psArray *rowSet; 14073 13913 14074 // move to (the first?) extension named P4 INPUTIMFILE_TABLE_NAME14075 if (!psFitsMoveExtName(fits, P4 INPUTIMFILE_TABLE_NAME)) {14076 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4 INPUTIMFILE_TABLE_NAME);13914 // move to (the first?) extension named P4AINPUTEXP_TABLE_NAME 13915 if (!psFitsMoveExtName(fits, P4AINPUTEXP_TABLE_NAME)) { 13916 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4AINPUTEXP_TABLE_NAME); 14077 13917 return false; 14078 13918 } … … 14092 13932 } 14093 13933 14094 if (!psDBInsertRows(dbh, P4 INPUTIMFILE_TABLE_NAME, rowSet)) {13934 if (!psDBInsertRows(dbh, P4AINPUTEXP_TABLE_NAME, rowSet)) { 14095 13935 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 14096 13936 psFree(rowSet); … … 14103 13943 } 14104 13944 14105 bool p4 InputImfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)13945 bool p4aInputExpSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 14106 13946 { 14107 13947 psArray *rowSet; 14108 13948 14109 rowSet = psDBSelectRows(dbh, P4 INPUTIMFILE_TABLE_NAME, where, limit);13949 rowSet = psDBSelectRows(dbh, P4AINPUTEXP_TABLE_NAME, where, limit); 14110 13950 if (!rowSet) { 14111 13951 return false; … … 14113 13953 14114 13954 // output to fits 14115 if (!psFitsWriteTable(fits, NULL, rowSet, P4 INPUTIMFILE_TABLE_NAME)) {13955 if (!psFitsWriteTable(fits, NULL, rowSet, P4AINPUTEXP_TABLE_NAME)) { 14116 13956 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 14117 13957 psFree(rowSet); … … 14124 13964 } 14125 13965 14126 psMetadata *p4 InputImfileMetadataFromObject(const p4InputImfileRow *object)13966 psMetadata *p4aInputExpMetadataFromObject(const p4aInputExpRow *object) 14127 13967 { 14128 13968 psMetadata *md = psMetadataAlloc(); 14129 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4 _id", PS_DATA_S32, NULL, object->p4_id)) {14130 psError(PS_ERR_UNKNOWN, false, "failed to add item p4 _id");13969 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4a_id", PS_DATA_S32, NULL, object->p4a_id)) { 13970 psError(PS_ERR_UNKNOWN, false, "failed to add item p4a_id"); 14131 13971 psFree(md); 14132 13972 return false; … … 14142 13982 return false; 14143 13983 } 14144 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, object->class_id)) {14145 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");14146 psFree(md);14147 return false;14148 }14149 13984 14150 13985 … … 14152 13987 } 14153 13988 14154 p4 InputImfileRow *p4InputImfileObjectFromMetadata(psMetadata *md)13989 p4aInputExpRow *p4aInputExpObjectFromMetadata(psMetadata *md) 14155 13990 { 14156 13991 14157 13992 bool status = false; 14158 psS32 p4 _id = psMetadataLookupS32(&status, md, "p4_id");14159 if (!status) { 14160 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4 _id");13993 psS32 p4a_id = psMetadataLookupS32(&status, md, "p4a_id"); 13994 if (!status) { 13995 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4a_id"); 14161 13996 return false; 14162 13997 } … … 14171 14006 return false; 14172 14007 } 14173 char* class_id = psMetadataLookupPtr(&status, md, "class_id"); 14174 if (!status) { 14175 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id"); 14176 return false; 14177 } 14178 14179 return p4InputImfileRowAlloc(p4_id, exp_tag, p3_version, class_id); 14180 } 14181 psArray *p4InputImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 14008 14009 return p4aInputExpRowAlloc(p4a_id, exp_tag, p3_version); 14010 } 14011 psArray *p4aInputExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 14182 14012 { 14183 14013 psArray *rowSet; … … 14185 14015 psU64 i; 14186 14016 14187 rowSet = psDBSelectRows(dbh, P4 INPUTIMFILE_TABLE_NAME, where, limit);14017 rowSet = psDBSelectRows(dbh, P4AINPUTEXP_TABLE_NAME, where, limit); 14188 14018 if (!rowSet) { 14189 14019 return NULL; … … 14195 14025 14196 14026 for (i = 0; i < rowSet->n; i++) { 14197 p4 InputImfileRow *object = p4InputImfileObjectFromMetadata(rowSet->data[i]);14027 p4aInputExpRow *object = p4aInputExpObjectFromMetadata(rowSet->data[i]); 14198 14028 psArrayAdd(returnSet, 0, object); 14199 14029 psFree(object); … … 14204 14034 return returnSet; 14205 14035 } 14206 bool p4 InputImfileDeleteObject(psDB *dbh, const p4InputImfileRow *object)14207 { 14208 psMetadata *where = p4 InputImfileMetadataFromObject(object);14209 long long count = psDBDeleteRows(dbh, P4 INPUTIMFILE_TABLE_NAME, where, 0);14210 psFree(where) 14036 bool p4aInputExpDeleteObject(psDB *dbh, const p4aInputExpRow *object) 14037 { 14038 psMetadata *where = p4aInputExpMetadataFromObject(object); 14039 long long count = psDBDeleteRows(dbh, P4AINPUTEXP_TABLE_NAME, where, 0); 14040 psFree(where); 14211 14041 if (count < 0) { 14212 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 InputImfile");14042 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aInputExp"); 14213 14043 return false; 14214 14044 } … … 14216 14046 // XXX should this be a psAbort() instead? It is possible that 14217 14047 // having an object match multiple rows was by design. 14218 psError(PS_ERR_UNKNOWN, true, "p4 InputImfileRow object matched more then one row. Check your database schema");14219 return false; 14220 } 14221 14222 return true; 14223 } 14224 long long p4 InputImfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)14048 psError(PS_ERR_UNKNOWN, true, "p4aInputExpRow object matched more then one row. Check your database schema"); 14049 return false; 14050 } 14051 14052 return true; 14053 } 14054 long long p4aInputExpDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 14225 14055 { 14226 14056 long long deleted = 0; 14227 14057 14228 14058 for (long long i = 0; i < objects->n; i++) { 14229 p4 InputImfileRow *object = objects->data[i];14230 psMetadata *where = p4 InputImfileMetadataFromObject(object);14231 long long count = psDBDeleteRows(dbh, P4 INPUTIMFILE_TABLE_NAME, where, limit);14232 psFree(where) 14059 p4aInputExpRow *object = objects->data[i]; 14060 psMetadata *where = p4aInputExpMetadataFromObject(object); 14061 long long count = psDBDeleteRows(dbh, P4AINPUTEXP_TABLE_NAME, where, limit); 14062 psFree(where); 14233 14063 if (count < 0) { 14234 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 InputImfile");14064 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aInputExp"); 14235 14065 return count; 14236 14066 } … … 14241 14071 return deleted; 14242 14072 } 14243 bool p4 InputImfilePrintObjects(FILE *stream, psArray *objects, bool mdcf)14073 bool p4aInputExpPrintObjects(FILE *stream, psArray *objects, bool mdcf) 14244 14074 { 14245 14075 PS_ASSERT_PTR_NON_NULL(objects, false); … … 14247 14077 psMetadata *output = psMetadataAlloc(); 14248 14078 for (long i = 0; i < psArrayLength(objects); i++) { 14249 psMetadata *md = p4 InputImfileMetadataFromObject(objects->data[i]);14079 psMetadata *md = p4aInputExpMetadataFromObject(objects->data[i]); 14250 14080 if (!psMetadataAddMetadata( 14251 14081 output, 14252 14082 PS_LIST_TAIL, 14253 P4 INPUTIMFILE_TABLE_NAME,14083 P4AINPUTEXP_TABLE_NAME, 14254 14084 PS_META_DUPLICATE_OK, 14255 14085 NULL, … … 14272 14102 return true; 14273 14103 } 14274 bool p4 InputImfilePrintObject(FILE *stream, p4InputImfileRow *object, bool mdcf)14104 bool p4aInputExpPrintObject(FILE *stream, p4aInputExpRow *object, bool mdcf) 14275 14105 { 14276 14106 PS_ASSERT_PTR_NON_NULL(object, false); 14277 14107 14278 psMetadata *md = p4 InputImfileMetadataFromObject(object);14108 psMetadata *md = p4aInputExpMetadataFromObject(object); 14279 14109 14280 14110 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { … … 14287 14117 return true; 14288 14118 } 14289 static void p4WarpedImfileRowFree(p4WarpedImfileRow *object); 14290 14291 p4WarpedImfileRow *p4WarpedImfileRowAlloc(psS32 p4_id, const char *exp_tag, psS32 p3_version, const char *class_id, const char *uri, const char *b1_uri, const char *b2_uri) 14292 { 14293 p4WarpedImfileRow *_object; 14294 14295 _object = psAlloc(sizeof(p4WarpedImfileRow)); 14296 psMemSetDeallocator(_object, (psFreeFunc)p4WarpedImfileRowFree); 14297 14298 _object->p4_id = p4_id; 14119 static void p4aScfileRowFree(p4aScfileRow *object); 14120 14121 p4aScfileRow *p4aScfileRowAlloc(psS32 p4a_id, const char *skycell_id, const char *tess_id, const char *exp_tag, psS32 p3_version, const char *uri, psF64 bg, psF64 bg_mean_stdev) 14122 { 14123 p4aScfileRow *_object; 14124 14125 _object = psAlloc(sizeof(p4aScfileRow)); 14126 psMemSetDeallocator(_object, (psFreeFunc)p4aScfileRowFree); 14127 14128 _object->p4a_id = p4a_id; 14129 _object->skycell_id = psStringCopy(skycell_id); 14130 _object->tess_id = psStringCopy(tess_id); 14299 14131 _object->exp_tag = psStringCopy(exp_tag); 14300 14132 _object->p3_version = p3_version; 14301 _object->class_id = psStringCopy(class_id);14302 14133 _object->uri = psStringCopy(uri); 14303 _object->b 1_uri = psStringCopy(b1_uri);14304 _object->b 2_uri = psStringCopy(b2_uri);14134 _object->bg = bg; 14135 _object->bg_mean_stdev = bg_mean_stdev; 14305 14136 14306 14137 return _object; 14307 14138 } 14308 14139 14309 static void p4WarpedImfileRowFree(p4WarpedImfileRow *object) 14310 { 14140 static void p4aScfileRowFree(p4aScfileRow *object) 14141 { 14142 psFree(object->skycell_id); 14143 psFree(object->tess_id); 14311 14144 psFree(object->exp_tag); 14312 psFree(object->class_id);14313 14145 psFree(object->uri); 14314 psFree(object->b1_uri); 14315 psFree(object->b2_uri); 14316 } 14317 14318 bool p4WarpedImfileCreateTable(psDB *dbh) 14146 } 14147 14148 bool p4aScfileCreateTable(psDB *dbh) 14319 14149 { 14320 14150 psMetadata *md = psMetadataAlloc(); 14321 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, "Primary Key", 0)) { 14322 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 14151 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4a_id", PS_DATA_S32, "Primary Key", 0)) { 14152 psError(PS_ERR_UNKNOWN, false, "failed to add item p4a_id"); 14153 psFree(md); 14154 return false; 14155 } 14156 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, "Primary Key", "64")) { 14157 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 14158 psFree(md); 14159 return false; 14160 } 14161 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, "Primary Key", "64")) { 14162 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 14323 14163 psFree(md); 14324 14164 return false; … … 14334 14174 return false; 14335 14175 } 14336 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, "Primary Key", "64")) {14337 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");14338 psFree(md);14339 return false;14340 }14341 14176 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, "255")) { 14342 14177 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); … … 14344 14179 return false; 14345 14180 } 14346 if (!psMetadataAdd(md, PS_LIST_TAIL, "b 1_uri", PS_DATA_STRING, NULL, "255")) {14347 psError(PS_ERR_UNKNOWN, false, "failed to add item b 1_uri");14348 psFree(md); 14349 return false; 14350 } 14351 if (!psMetadataAdd(md, PS_LIST_TAIL, "b 2_uri", PS_DATA_STRING, NULL, "255")) {14352 psError(PS_ERR_UNKNOWN, false, "failed to add item b 2_uri");14353 psFree(md); 14354 return false; 14355 } 14356 14357 bool status = psDBCreateTable(dbh, P4 WARPEDIMFILE_TABLE_NAME, md);14181 if (!psMetadataAdd(md, PS_LIST_TAIL, "bg", PS_DATA_F64, NULL, 0.0)) { 14182 psError(PS_ERR_UNKNOWN, false, "failed to add item bg"); 14183 psFree(md); 14184 return false; 14185 } 14186 if (!psMetadataAdd(md, PS_LIST_TAIL, "bg_mean_stdev", PS_DATA_F64, NULL, 0.0)) { 14187 psError(PS_ERR_UNKNOWN, false, "failed to add item bg_mean_stdev"); 14188 psFree(md); 14189 return false; 14190 } 14191 14192 bool status = psDBCreateTable(dbh, P4ASCFILE_TABLE_NAME, md); 14358 14193 14359 14194 psFree(md); … … 14362 14197 } 14363 14198 14364 bool p4 WarpedImfileDropTable(psDB *dbh)14365 { 14366 return psDBDropTable(dbh, P4 WARPEDIMFILE_TABLE_NAME);14367 } 14368 14369 bool p4 WarpedImfileInsert(psDB * dbh, psS32 p4_id, const char *exp_tag, psS32 p3_version, const char *class_id, const char *uri, const char *b1_uri, const char *b2_uri)14199 bool p4aScfileDropTable(psDB *dbh) 14200 { 14201 return psDBDropTable(dbh, P4ASCFILE_TABLE_NAME); 14202 } 14203 14204 bool p4aScfileInsert(psDB * dbh, psS32 p4a_id, const char *skycell_id, const char *tess_id, const char *exp_tag, psS32 p3_version, const char *uri, psF64 bg, psF64 bg_mean_stdev) 14370 14205 { 14371 14206 psMetadata *md = psMetadataAlloc(); 14372 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, NULL, p4_id)) { 14373 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 14207 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4a_id", PS_DATA_S32, NULL, p4a_id)) { 14208 psError(PS_ERR_UNKNOWN, false, "failed to add item p4a_id"); 14209 psFree(md); 14210 return false; 14211 } 14212 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, skycell_id)) { 14213 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 14214 psFree(md); 14215 return false; 14216 } 14217 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, tess_id)) { 14218 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 14374 14219 psFree(md); 14375 14220 return false; … … 14385 14230 return false; 14386 14231 } 14387 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, class_id)) {14388 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");14389 psFree(md);14390 return false;14391 }14392 14232 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, uri)) { 14393 14233 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); … … 14395 14235 return false; 14396 14236 } 14397 if (!psMetadataAdd(md, PS_LIST_TAIL, "b 1_uri", PS_DATA_STRING, NULL, b1_uri)) {14398 psError(PS_ERR_UNKNOWN, false, "failed to add item b 1_uri");14399 psFree(md); 14400 return false; 14401 } 14402 if (!psMetadataAdd(md, PS_LIST_TAIL, "b 2_uri", PS_DATA_STRING, NULL, b2_uri)) {14403 psError(PS_ERR_UNKNOWN, false, "failed to add item b 2_uri");14404 psFree(md); 14405 return false; 14406 } 14407 14408 bool status = psDBInsertOneRow(dbh, P4 WARPEDIMFILE_TABLE_NAME, md);14237 if (!psMetadataAdd(md, PS_LIST_TAIL, "bg", PS_DATA_F64, NULL, bg)) { 14238 psError(PS_ERR_UNKNOWN, false, "failed to add item bg"); 14239 psFree(md); 14240 return false; 14241 } 14242 if (!psMetadataAdd(md, PS_LIST_TAIL, "bg_mean_stdev", PS_DATA_F64, NULL, bg_mean_stdev)) { 14243 psError(PS_ERR_UNKNOWN, false, "failed to add item bg_mean_stdev"); 14244 psFree(md); 14245 return false; 14246 } 14247 14248 bool status = psDBInsertOneRow(dbh, P4ASCFILE_TABLE_NAME, md); 14409 14249 psFree(md); 14410 14250 … … 14412 14252 } 14413 14253 14414 long long p4 WarpedImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)14254 long long p4aScfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 14415 14255 { 14416 14256 long long deleted = 0; 14417 14257 14418 long long count = psDBDeleteRows(dbh, P4 WARPEDIMFILE_TABLE_NAME, where, limit);14258 long long count = psDBDeleteRows(dbh, P4ASCFILE_TABLE_NAME, where, limit); 14419 14259 if (count < 0) { 14420 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 WarpedImfile");14260 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aScfile"); 14421 14261 return count; 14422 14262 … … 14426 14266 return deleted; 14427 14267 } 14428 bool p4 WarpedImfileInsertObject(psDB *dbh, p4WarpedImfileRow *object)14429 { 14430 return p4 WarpedImfileInsert(dbh, object->p4_id, object->exp_tag, object->p3_version, object->class_id, object->uri, object->b1_uri, object->b2_uri);14431 } 14432 14433 bool p4 WarpedImfileInsertObjects(psDB *dbh, psArray *objects)14268 bool p4aScfileInsertObject(psDB *dbh, p4aScfileRow *object) 14269 { 14270 return p4aScfileInsert(dbh, object->p4a_id, object->skycell_id, object->tess_id, object->exp_tag, object->p3_version, object->uri, object->bg, object->bg_mean_stdev); 14271 } 14272 14273 bool p4aScfileInsertObjects(psDB *dbh, psArray *objects) 14434 14274 { 14435 14275 for (long i = 0; i < psArrayLength(objects); i++) { 14436 if (!p4 WarpedImfileInsertObject(dbh, objects->data[i])) {14276 if (!p4aScfileInsertObject(dbh, objects->data[i])) { 14437 14277 return false; 14438 14278 } … … 14442 14282 } 14443 14283 14444 bool p4 WarpedImfileInsertFits(psDB *dbh, const psFits *fits)14284 bool p4aScfileInsertFits(psDB *dbh, const psFits *fits) 14445 14285 { 14446 14286 psArray *rowSet; 14447 14287 14448 // move to (the first?) extension named P4 WARPEDIMFILE_TABLE_NAME14449 if (!psFitsMoveExtName(fits, P4 WARPEDIMFILE_TABLE_NAME)) {14450 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4 WARPEDIMFILE_TABLE_NAME);14288 // move to (the first?) extension named P4ASCFILE_TABLE_NAME 14289 if (!psFitsMoveExtName(fits, P4ASCFILE_TABLE_NAME)) { 14290 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4ASCFILE_TABLE_NAME); 14451 14291 return false; 14452 14292 } … … 14466 14306 } 14467 14307 14468 if (!psDBInsertRows(dbh, P4 WARPEDIMFILE_TABLE_NAME, rowSet)) {14308 if (!psDBInsertRows(dbh, P4ASCFILE_TABLE_NAME, rowSet)) { 14469 14309 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 14470 14310 psFree(rowSet); … … 14477 14317 } 14478 14318 14479 bool p4 WarpedImfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)14319 bool p4aScfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 14480 14320 { 14481 14321 psArray *rowSet; 14482 14322 14483 rowSet = psDBSelectRows(dbh, P4 WARPEDIMFILE_TABLE_NAME, where, limit);14323 rowSet = psDBSelectRows(dbh, P4ASCFILE_TABLE_NAME, where, limit); 14484 14324 if (!rowSet) { 14485 14325 return false; … … 14487 14327 14488 14328 // output to fits 14489 if (!psFitsWriteTable(fits, NULL, rowSet, P4 WARPEDIMFILE_TABLE_NAME)) {14329 if (!psFitsWriteTable(fits, NULL, rowSet, P4ASCFILE_TABLE_NAME)) { 14490 14330 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 14491 14331 psFree(rowSet); … … 14498 14338 } 14499 14339 14500 psMetadata *p4 WarpedImfileMetadataFromObject(const p4WarpedImfileRow *object)14340 psMetadata *p4aScfileMetadataFromObject(const p4aScfileRow *object) 14501 14341 { 14502 14342 psMetadata *md = psMetadataAlloc(); 14503 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, NULL, object->p4_id)) { 14504 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 14343 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4a_id", PS_DATA_S32, NULL, object->p4a_id)) { 14344 psError(PS_ERR_UNKNOWN, false, "failed to add item p4a_id"); 14345 psFree(md); 14346 return false; 14347 } 14348 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, object->skycell_id)) { 14349 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 14350 psFree(md); 14351 return false; 14352 } 14353 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, object->tess_id)) { 14354 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 14505 14355 psFree(md); 14506 14356 return false; … … 14516 14366 return false; 14517 14367 } 14518 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, object->class_id)) {14519 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");14520 psFree(md);14521 return false;14522 }14523 14368 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, object->uri)) { 14524 14369 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); … … 14526 14371 return false; 14527 14372 } 14528 if (!psMetadataAdd(md, PS_LIST_TAIL, "b 1_uri", PS_DATA_STRING, NULL, object->b1_uri)) {14529 psError(PS_ERR_UNKNOWN, false, "failed to add item b 1_uri");14530 psFree(md); 14531 return false; 14532 } 14533 if (!psMetadataAdd(md, PS_LIST_TAIL, "b 2_uri", PS_DATA_STRING, NULL, object->b2_uri)) {14534 psError(PS_ERR_UNKNOWN, false, "failed to add item b 2_uri");14373 if (!psMetadataAdd(md, PS_LIST_TAIL, "bg", PS_DATA_F64, NULL, object->bg)) { 14374 psError(PS_ERR_UNKNOWN, false, "failed to add item bg"); 14375 psFree(md); 14376 return false; 14377 } 14378 if (!psMetadataAdd(md, PS_LIST_TAIL, "bg_mean_stdev", PS_DATA_F64, NULL, object->bg_mean_stdev)) { 14379 psError(PS_ERR_UNKNOWN, false, "failed to add item bg_mean_stdev"); 14535 14380 psFree(md); 14536 14381 return false; … … 14541 14386 } 14542 14387 14543 p4 WarpedImfileRow *p4WarpedImfileObjectFromMetadata(psMetadata *md)14388 p4aScfileRow *p4aScfileObjectFromMetadata(psMetadata *md) 14544 14389 { 14545 14390 14546 14391 bool status = false; 14547 psS32 p4_id = psMetadataLookupS32(&status, md, "p4_id"); 14548 if (!status) { 14549 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4_id"); 14392 psS32 p4a_id = psMetadataLookupS32(&status, md, "p4a_id"); 14393 if (!status) { 14394 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4a_id"); 14395 return false; 14396 } 14397 char* skycell_id = psMetadataLookupPtr(&status, md, "skycell_id"); 14398 if (!status) { 14399 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item skycell_id"); 14400 return false; 14401 } 14402 char* tess_id = psMetadataLookupPtr(&status, md, "tess_id"); 14403 if (!status) { 14404 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item tess_id"); 14550 14405 return false; 14551 14406 } … … 14560 14415 return false; 14561 14416 } 14562 char* class_id = psMetadataLookupPtr(&status, md, "class_id");14563 if (!status) {14564 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id");14565 return false;14566 }14567 14417 char* uri = psMetadataLookupPtr(&status, md, "uri"); 14568 14418 if (!status) { … … 14570 14420 return false; 14571 14421 } 14572 char* b1_uri = psMetadataLookupPtr(&status, md, "b1_uri");14573 if (!status) { 14574 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item b 1_uri");14575 return false; 14576 } 14577 char* b2_uri = psMetadataLookupPtr(&status, md, "b2_uri");14578 if (!status) { 14579 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item b 2_uri");14580 return false; 14581 } 14582 14583 return p4 WarpedImfileRowAlloc(p4_id, exp_tag, p3_version, class_id, uri, b1_uri, b2_uri);14584 } 14585 psArray *p4 WarpedImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)14422 psF64 bg = psMetadataLookupF64(&status, md, "bg"); 14423 if (!status) { 14424 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item bg"); 14425 return false; 14426 } 14427 psF64 bg_mean_stdev = psMetadataLookupF64(&status, md, "bg_mean_stdev"); 14428 if (!status) { 14429 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item bg_mean_stdev"); 14430 return false; 14431 } 14432 14433 return p4aScfileRowAlloc(p4a_id, skycell_id, tess_id, exp_tag, p3_version, uri, bg, bg_mean_stdev); 14434 } 14435 psArray *p4aScfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 14586 14436 { 14587 14437 psArray *rowSet; … … 14589 14439 psU64 i; 14590 14440 14591 rowSet = psDBSelectRows(dbh, P4 WARPEDIMFILE_TABLE_NAME, where, limit);14441 rowSet = psDBSelectRows(dbh, P4ASCFILE_TABLE_NAME, where, limit); 14592 14442 if (!rowSet) { 14593 14443 return NULL; … … 14599 14449 14600 14450 for (i = 0; i < rowSet->n; i++) { 14601 p4 WarpedImfileRow *object = p4WarpedImfileObjectFromMetadata(rowSet->data[i]);14451 p4aScfileRow *object = p4aScfileObjectFromMetadata(rowSet->data[i]); 14602 14452 psArrayAdd(returnSet, 0, object); 14603 14453 psFree(object); … … 14608 14458 return returnSet; 14609 14459 } 14610 bool p4 WarpedImfileDeleteObject(psDB *dbh, const p4WarpedImfileRow *object)14611 { 14612 psMetadata *where = p4 WarpedImfileMetadataFromObject(object);14613 long long count = psDBDeleteRows(dbh, P4 WARPEDIMFILE_TABLE_NAME, where, 0);14614 psFree(where) 14460 bool p4aScfileDeleteObject(psDB *dbh, const p4aScfileRow *object) 14461 { 14462 psMetadata *where = p4aScfileMetadataFromObject(object); 14463 long long count = psDBDeleteRows(dbh, P4ASCFILE_TABLE_NAME, where, 0); 14464 psFree(where); 14615 14465 if (count < 0) { 14616 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 WarpedImfile");14466 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aScfile"); 14617 14467 return false; 14618 14468 } … … 14620 14470 // XXX should this be a psAbort() instead? It is possible that 14621 14471 // having an object match multiple rows was by design. 14622 psError(PS_ERR_UNKNOWN, true, "p4 WarpedImfileRow object matched more then one row. Check your database schema");14623 return false; 14624 } 14625 14626 return true; 14627 } 14628 long long p4 WarpedImfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)14472 psError(PS_ERR_UNKNOWN, true, "p4aScfileRow object matched more then one row. Check your database schema"); 14473 return false; 14474 } 14475 14476 return true; 14477 } 14478 long long p4aScfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 14629 14479 { 14630 14480 long long deleted = 0; 14631 14481 14632 14482 for (long long i = 0; i < objects->n; i++) { 14633 p4 WarpedImfileRow *object = objects->data[i];14634 psMetadata *where = p4 WarpedImfileMetadataFromObject(object);14635 long long count = psDBDeleteRows(dbh, P4 WARPEDIMFILE_TABLE_NAME, where, limit);14636 psFree(where) 14483 p4aScfileRow *object = objects->data[i]; 14484 psMetadata *where = p4aScfileMetadataFromObject(object); 14485 long long count = psDBDeleteRows(dbh, P4ASCFILE_TABLE_NAME, where, limit); 14486 psFree(where); 14637 14487 if (count < 0) { 14638 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 WarpedImfile");14488 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aScfile"); 14639 14489 return count; 14640 14490 } … … 14645 14495 return deleted; 14646 14496 } 14647 bool p4 WarpedImfilePrintObjects(FILE *stream, psArray *objects, bool mdcf)14497 bool p4aScfilePrintObjects(FILE *stream, psArray *objects, bool mdcf) 14648 14498 { 14649 14499 PS_ASSERT_PTR_NON_NULL(objects, false); … … 14651 14501 psMetadata *output = psMetadataAlloc(); 14652 14502 for (long i = 0; i < psArrayLength(objects); i++) { 14653 psMetadata *md = p4 WarpedImfileMetadataFromObject(objects->data[i]);14503 psMetadata *md = p4aScfileMetadataFromObject(objects->data[i]); 14654 14504 if (!psMetadataAddMetadata( 14655 14505 output, 14656 14506 PS_LIST_TAIL, 14657 P4 WARPEDIMFILE_TABLE_NAME,14507 P4ASCFILE_TABLE_NAME, 14658 14508 PS_META_DUPLICATE_OK, 14659 14509 NULL, … … 14676 14526 return true; 14677 14527 } 14678 bool p4 WarpedImfilePrintObject(FILE *stream, p4WarpedImfileRow *object, bool mdcf)14528 bool p4aScfilePrintObject(FILE *stream, p4aScfileRow *object, bool mdcf) 14679 14529 { 14680 14530 PS_ASSERT_PTR_NON_NULL(object, false); 14681 14531 14682 psMetadata *md = p4 WarpedImfileMetadataFromObject(object);14532 psMetadata *md = p4aScfileMetadataFromObject(object); 14683 14533 14684 14534 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { … … 14691 14541 return true; 14692 14542 } 14693 static void p4StackedImfileRowFree(p4StackedImfileRow *object); 14694 14695 p4StackedImfileRow *p4StackedImfileRowAlloc(psS32 p4_id, const char *class_id, const char *uri, const char *b1_uri, const char *b2_uri) 14696 { 14697 p4StackedImfileRow *_object; 14698 14699 _object = psAlloc(sizeof(p4StackedImfileRow)); 14700 psMemSetDeallocator(_object, (psFreeFunc)p4StackedImfileRowFree); 14701 14702 _object->p4_id = p4_id; 14703 _object->class_id = psStringCopy(class_id); 14704 _object->uri = psStringCopy(uri); 14705 _object->b1_uri = psStringCopy(b1_uri); 14706 _object->b2_uri = psStringCopy(b2_uri); 14543 static void p4bRunRowFree(p4bRunRow *object); 14544 14545 p4bRunRow *p4bRunRowAlloc(psS32 p4b_id, const char *state, const char *workdir, bool magic) 14546 { 14547 p4bRunRow *_object; 14548 14549 _object = psAlloc(sizeof(p4bRunRow)); 14550 psMemSetDeallocator(_object, (psFreeFunc)p4bRunRowFree); 14551 14552 _object->p4b_id = p4b_id; 14553 _object->state = psStringCopy(state); 14554 _object->workdir = psStringCopy(workdir); 14555 _object->magic = magic; 14707 14556 14708 14557 return _object; 14709 14558 } 14710 14559 14711 static void p4StackedImfileRowFree(p4StackedImfileRow *object) 14712 { 14713 psFree(object->class_id); 14714 psFree(object->uri); 14715 psFree(object->b1_uri); 14716 psFree(object->b2_uri); 14717 } 14718 14719 bool p4StackedImfileCreateTable(psDB *dbh) 14560 static void p4bRunRowFree(p4bRunRow *object) 14561 { 14562 psFree(object->state); 14563 psFree(object->workdir); 14564 } 14565 14566 bool p4bRunCreateTable(psDB *dbh) 14720 14567 { 14721 14568 psMetadata *md = psMetadataAlloc(); 14722 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, "Primary Key", 0)) { 14723 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 14724 psFree(md); 14725 return false; 14726 } 14727 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, "Primary Key", "64")) { 14728 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 14729 psFree(md); 14730 return false; 14731 } 14732 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, "255")) { 14733 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 14734 psFree(md); 14735 return false; 14736 } 14737 if (!psMetadataAdd(md, PS_LIST_TAIL, "b1_uri", PS_DATA_STRING, NULL, "255")) { 14738 psError(PS_ERR_UNKNOWN, false, "failed to add item b1_uri"); 14739 psFree(md); 14740 return false; 14741 } 14742 if (!psMetadataAdd(md, PS_LIST_TAIL, "b2_uri", PS_DATA_STRING, NULL, "255")) { 14743 psError(PS_ERR_UNKNOWN, false, "failed to add item b2_uri"); 14744 psFree(md); 14745 return false; 14746 } 14747 14748 bool status = psDBCreateTable(dbh, P4STACKEDIMFILE_TABLE_NAME, md); 14569 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4b_id", PS_DATA_S32, "Primary Key AUTO_INCREMENT", 0)) { 14570 psError(PS_ERR_UNKNOWN, false, "failed to add item p4b_id"); 14571 psFree(md); 14572 return false; 14573 } 14574 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, "Key", "64")) { 14575 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 14576 psFree(md); 14577 return false; 14578 } 14579 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, "255")) { 14580 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 14581 psFree(md); 14582 return false; 14583 } 14584 if (!psMetadataAdd(md, PS_LIST_TAIL, "magic", PS_DATA_BOOL, "Primary Key", 0)) { 14585 psError(PS_ERR_UNKNOWN, false, "failed to add item magic"); 14586 psFree(md); 14587 return false; 14588 } 14589 14590 bool status = psDBCreateTable(dbh, P4BRUN_TABLE_NAME, md); 14749 14591 14750 14592 psFree(md); … … 14753 14595 } 14754 14596 14755 bool p4 StackedImfileDropTable(psDB *dbh)14756 { 14757 return psDBDropTable(dbh, P4 STACKEDIMFILE_TABLE_NAME);14758 } 14759 14760 bool p4 StackedImfileInsert(psDB * dbh, psS32 p4_id, const char *class_id, const char *uri, const char *b1_uri, const char *b2_uri)14597 bool p4bRunDropTable(psDB *dbh) 14598 { 14599 return psDBDropTable(dbh, P4BRUN_TABLE_NAME); 14600 } 14601 14602 bool p4bRunInsert(psDB * dbh, psS32 p4b_id, const char *state, const char *workdir, bool magic) 14761 14603 { 14762 14604 psMetadata *md = psMetadataAlloc(); 14763 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, NULL, p4_id)) { 14764 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 14765 psFree(md); 14766 return false; 14767 } 14768 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, class_id)) { 14769 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 14770 psFree(md); 14771 return false; 14772 } 14773 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, uri)) { 14774 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 14775 psFree(md); 14776 return false; 14777 } 14778 if (!psMetadataAdd(md, PS_LIST_TAIL, "b1_uri", PS_DATA_STRING, NULL, b1_uri)) { 14779 psError(PS_ERR_UNKNOWN, false, "failed to add item b1_uri"); 14780 psFree(md); 14781 return false; 14782 } 14783 if (!psMetadataAdd(md, PS_LIST_TAIL, "b2_uri", PS_DATA_STRING, NULL, b2_uri)) { 14784 psError(PS_ERR_UNKNOWN, false, "failed to add item b2_uri"); 14785 psFree(md); 14786 return false; 14787 } 14788 14789 bool status = psDBInsertOneRow(dbh, P4STACKEDIMFILE_TABLE_NAME, md); 14605 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4b_id", PS_DATA_S32, NULL, p4b_id)) { 14606 psError(PS_ERR_UNKNOWN, false, "failed to add item p4b_id"); 14607 psFree(md); 14608 return false; 14609 } 14610 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, state)) { 14611 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 14612 psFree(md); 14613 return false; 14614 } 14615 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, workdir)) { 14616 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 14617 psFree(md); 14618 return false; 14619 } 14620 if (!psMetadataAdd(md, PS_LIST_TAIL, "magic", PS_DATA_BOOL, NULL, magic)) { 14621 psError(PS_ERR_UNKNOWN, false, "failed to add item magic"); 14622 psFree(md); 14623 return false; 14624 } 14625 14626 bool status = psDBInsertOneRow(dbh, P4BRUN_TABLE_NAME, md); 14790 14627 psFree(md); 14791 14628 … … 14793 14630 } 14794 14631 14795 long long p4 StackedImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)14632 long long p4bRunDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 14796 14633 { 14797 14634 long long deleted = 0; 14798 14635 14799 long long count = psDBDeleteRows(dbh, P4 STACKEDIMFILE_TABLE_NAME, where, limit);14636 long long count = psDBDeleteRows(dbh, P4BRUN_TABLE_NAME, where, limit); 14800 14637 if (count < 0) { 14801 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 StackedImfile");14638 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bRun"); 14802 14639 return count; 14803 14640 … … 14807 14644 return deleted; 14808 14645 } 14809 bool p4 StackedImfileInsertObject(psDB *dbh, p4StackedImfileRow *object)14810 { 14811 return p4 StackedImfileInsert(dbh, object->p4_id, object->class_id, object->uri, object->b1_uri, object->b2_uri);14812 } 14813 14814 bool p4 StackedImfileInsertObjects(psDB *dbh, psArray *objects)14646 bool p4bRunInsertObject(psDB *dbh, p4bRunRow *object) 14647 { 14648 return p4bRunInsert(dbh, object->p4b_id, object->state, object->workdir, object->magic); 14649 } 14650 14651 bool p4bRunInsertObjects(psDB *dbh, psArray *objects) 14815 14652 { 14816 14653 for (long i = 0; i < psArrayLength(objects); i++) { 14817 if (!p4 StackedImfileInsertObject(dbh, objects->data[i])) {14654 if (!p4bRunInsertObject(dbh, objects->data[i])) { 14818 14655 return false; 14819 14656 } … … 14823 14660 } 14824 14661 14825 bool p4 StackedImfileInsertFits(psDB *dbh, const psFits *fits)14662 bool p4bRunInsertFits(psDB *dbh, const psFits *fits) 14826 14663 { 14827 14664 psArray *rowSet; 14828 14665 14829 // move to (the first?) extension named P4 STACKEDIMFILE_TABLE_NAME14830 if (!psFitsMoveExtName(fits, P4 STACKEDIMFILE_TABLE_NAME)) {14831 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4 STACKEDIMFILE_TABLE_NAME);14666 // move to (the first?) extension named P4BRUN_TABLE_NAME 14667 if (!psFitsMoveExtName(fits, P4BRUN_TABLE_NAME)) { 14668 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4BRUN_TABLE_NAME); 14832 14669 return false; 14833 14670 } … … 14847 14684 } 14848 14685 14849 if (!psDBInsertRows(dbh, P4 STACKEDIMFILE_TABLE_NAME, rowSet)) {14686 if (!psDBInsertRows(dbh, P4BRUN_TABLE_NAME, rowSet)) { 14850 14687 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 14851 14688 psFree(rowSet); … … 14858 14695 } 14859 14696 14860 bool p4 StackedImfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)14697 bool p4bRunSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 14861 14698 { 14862 14699 psArray *rowSet; 14863 14700 14864 rowSet = psDBSelectRows(dbh, P4 STACKEDIMFILE_TABLE_NAME, where, limit);14701 rowSet = psDBSelectRows(dbh, P4BRUN_TABLE_NAME, where, limit); 14865 14702 if (!rowSet) { 14866 14703 return false; … … 14868 14705 14869 14706 // output to fits 14870 if (!psFitsWriteTable(fits, NULL, rowSet, P4 STACKEDIMFILE_TABLE_NAME)) {14707 if (!psFitsWriteTable(fits, NULL, rowSet, P4BRUN_TABLE_NAME)) { 14871 14708 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 14872 14709 psFree(rowSet); … … 14879 14716 } 14880 14717 14881 psMetadata *p4 StackedImfileMetadataFromObject(const p4StackedImfileRow *object)14718 psMetadata *p4bRunMetadataFromObject(const p4bRunRow *object) 14882 14719 { 14883 14720 psMetadata *md = psMetadataAlloc(); 14884 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, NULL, object->p4_id)) { 14885 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 14886 psFree(md); 14887 return false; 14888 } 14889 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, object->class_id)) { 14890 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 14891 psFree(md); 14892 return false; 14893 } 14894 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, object->uri)) { 14895 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 14896 psFree(md); 14897 return false; 14898 } 14899 if (!psMetadataAdd(md, PS_LIST_TAIL, "b1_uri", PS_DATA_STRING, NULL, object->b1_uri)) { 14900 psError(PS_ERR_UNKNOWN, false, "failed to add item b1_uri"); 14901 psFree(md); 14902 return false; 14903 } 14904 if (!psMetadataAdd(md, PS_LIST_TAIL, "b2_uri", PS_DATA_STRING, NULL, object->b2_uri)) { 14905 psError(PS_ERR_UNKNOWN, false, "failed to add item b2_uri"); 14721 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4b_id", PS_DATA_S32, NULL, object->p4b_id)) { 14722 psError(PS_ERR_UNKNOWN, false, "failed to add item p4b_id"); 14723 psFree(md); 14724 return false; 14725 } 14726 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, object->state)) { 14727 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 14728 psFree(md); 14729 return false; 14730 } 14731 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, object->workdir)) { 14732 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 14733 psFree(md); 14734 return false; 14735 } 14736 if (!psMetadataAdd(md, PS_LIST_TAIL, "magic", PS_DATA_BOOL, NULL, object->magic)) { 14737 psError(PS_ERR_UNKNOWN, false, "failed to add item magic"); 14906 14738 psFree(md); 14907 14739 return false; … … 14912 14744 } 14913 14745 14914 p4 StackedImfileRow *p4StackedImfileObjectFromMetadata(psMetadata *md)14746 p4bRunRow *p4bRunObjectFromMetadata(psMetadata *md) 14915 14747 { 14916 14748 14917 14749 bool status = false; 14918 psS32 p4_id = psMetadataLookupS32(&status, md, "p4_id"); 14919 if (!status) { 14920 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4_id"); 14921 return false; 14922 } 14923 char* class_id = psMetadataLookupPtr(&status, md, "class_id"); 14924 if (!status) { 14925 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id"); 14926 return false; 14927 } 14928 char* uri = psMetadataLookupPtr(&status, md, "uri"); 14929 if (!status) { 14930 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item uri"); 14931 return false; 14932 } 14933 char* b1_uri = psMetadataLookupPtr(&status, md, "b1_uri"); 14934 if (!status) { 14935 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item b1_uri"); 14936 return false; 14937 } 14938 char* b2_uri = psMetadataLookupPtr(&status, md, "b2_uri"); 14939 if (!status) { 14940 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item b2_uri"); 14941 return false; 14942 } 14943 14944 return p4StackedImfileRowAlloc(p4_id, class_id, uri, b1_uri, b2_uri); 14945 } 14946 psArray *p4StackedImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 14750 psS32 p4b_id = psMetadataLookupS32(&status, md, "p4b_id"); 14751 if (!status) { 14752 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4b_id"); 14753 return false; 14754 } 14755 char* state = psMetadataLookupPtr(&status, md, "state"); 14756 if (!status) { 14757 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item state"); 14758 return false; 14759 } 14760 char* workdir = psMetadataLookupPtr(&status, md, "workdir"); 14761 if (!status) { 14762 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item workdir"); 14763 return false; 14764 } 14765 bool magic = psMetadataLookupBool(&status, md, "magic"); 14766 if (!status) { 14767 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item magic"); 14768 return false; 14769 } 14770 14771 return p4bRunRowAlloc(p4b_id, state, workdir, magic); 14772 } 14773 psArray *p4bRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 14947 14774 { 14948 14775 psArray *rowSet; … … 14950 14777 psU64 i; 14951 14778 14952 rowSet = psDBSelectRows(dbh, P4 STACKEDIMFILE_TABLE_NAME, where, limit);14779 rowSet = psDBSelectRows(dbh, P4BRUN_TABLE_NAME, where, limit); 14953 14780 if (!rowSet) { 14954 14781 return NULL; … … 14960 14787 14961 14788 for (i = 0; i < rowSet->n; i++) { 14962 p4 StackedImfileRow *object = p4StackedImfileObjectFromMetadata(rowSet->data[i]);14789 p4bRunRow *object = p4bRunObjectFromMetadata(rowSet->data[i]); 14963 14790 psArrayAdd(returnSet, 0, object); 14964 14791 psFree(object); … … 14969 14796 return returnSet; 14970 14797 } 14971 bool p4 StackedImfileDeleteObject(psDB *dbh, const p4StackedImfileRow *object)14972 { 14973 psMetadata *where = p4 StackedImfileMetadataFromObject(object);14974 long long count = psDBDeleteRows(dbh, P4 STACKEDIMFILE_TABLE_NAME, where, 0);14975 psFree(where) 14798 bool p4bRunDeleteObject(psDB *dbh, const p4bRunRow *object) 14799 { 14800 psMetadata *where = p4bRunMetadataFromObject(object); 14801 long long count = psDBDeleteRows(dbh, P4BRUN_TABLE_NAME, where, 0); 14802 psFree(where); 14976 14803 if (count < 0) { 14977 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 StackedImfile");14804 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bRun"); 14978 14805 return false; 14979 14806 } … … 14981 14808 // XXX should this be a psAbort() instead? It is possible that 14982 14809 // having an object match multiple rows was by design. 14983 psError(PS_ERR_UNKNOWN, true, "p4 StackedImfileRow object matched more then one row. Check your database schema");14984 return false; 14985 } 14986 14987 return true; 14988 } 14989 long long p4 StackedImfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)14810 psError(PS_ERR_UNKNOWN, true, "p4bRunRow object matched more then one row. Check your database schema"); 14811 return false; 14812 } 14813 14814 return true; 14815 } 14816 long long p4bRunDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 14990 14817 { 14991 14818 long long deleted = 0; 14992 14819 14993 14820 for (long long i = 0; i < objects->n; i++) { 14994 p4 StackedImfileRow *object = objects->data[i];14995 psMetadata *where = p4 StackedImfileMetadataFromObject(object);14996 long long count = psDBDeleteRows(dbh, P4 STACKEDIMFILE_TABLE_NAME, where, limit);14997 psFree(where) 14821 p4bRunRow *object = objects->data[i]; 14822 psMetadata *where = p4bRunMetadataFromObject(object); 14823 long long count = psDBDeleteRows(dbh, P4BRUN_TABLE_NAME, where, limit); 14824 psFree(where); 14998 14825 if (count < 0) { 14999 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 StackedImfile");14826 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bRun"); 15000 14827 return count; 15001 14828 } … … 15006 14833 return deleted; 15007 14834 } 15008 bool p4 StackedImfilePrintObjects(FILE *stream, psArray *objects, bool mdcf)14835 bool p4bRunPrintObjects(FILE *stream, psArray *objects, bool mdcf) 15009 14836 { 15010 14837 PS_ASSERT_PTR_NON_NULL(objects, false); … … 15012 14839 psMetadata *output = psMetadataAlloc(); 15013 14840 for (long i = 0; i < psArrayLength(objects); i++) { 15014 psMetadata *md = p4 StackedImfileMetadataFromObject(objects->data[i]);14841 psMetadata *md = p4bRunMetadataFromObject(objects->data[i]); 15015 14842 if (!psMetadataAddMetadata( 15016 14843 output, 15017 14844 PS_LIST_TAIL, 15018 P4 STACKEDIMFILE_TABLE_NAME,14845 P4BRUN_TABLE_NAME, 15019 14846 PS_META_DUPLICATE_OK, 15020 14847 NULL, … … 15037 14864 return true; 15038 14865 } 15039 bool p4 StackedImfilePrintObject(FILE *stream, p4StackedImfileRow *object, bool mdcf)14866 bool p4bRunPrintObject(FILE *stream, p4bRunRow *object, bool mdcf) 15040 14867 { 15041 14868 PS_ASSERT_PTR_NON_NULL(object, false); 15042 14869 15043 psMetadata *md = p4 StackedImfileMetadataFromObject(object);14870 psMetadata *md = p4bRunMetadataFromObject(object); 15044 14871 15045 14872 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { … … 15052 14879 return true; 15053 14880 } 15054 static void p4DiffImfileRowFree(p4DiffImfileRow *object); 15055 15056 p4DiffImfileRow *p4DiffImfileRowAlloc(psS32 p4_id, const char *exp_tag, psS32 p3_version, const char *class_id, const char *uri, const char *b1_uri, const char *b2_uri) 15057 { 15058 p4DiffImfileRow *_object; 15059 15060 _object = psAlloc(sizeof(p4DiffImfileRow)); 15061 psMemSetDeallocator(_object, (psFreeFunc)p4DiffImfileRowFree); 15062 15063 _object->p4_id = p4_id; 14881 static void p4bInputScfileRowFree(p4bInputScfileRow *object); 14882 14883 p4bInputScfileRow *p4bInputScfileRowAlloc(psS32 p4b_id, const char *skycell_id, const char *tess_id, const char *exp_tag, psS32 p3_version, const char *kind) 14884 { 14885 p4bInputScfileRow *_object; 14886 14887 _object = psAlloc(sizeof(p4bInputScfileRow)); 14888 psMemSetDeallocator(_object, (psFreeFunc)p4bInputScfileRowFree); 14889 14890 _object->p4b_id = p4b_id; 14891 _object->skycell_id = psStringCopy(skycell_id); 14892 _object->tess_id = psStringCopy(tess_id); 15064 14893 _object->exp_tag = psStringCopy(exp_tag); 15065 14894 _object->p3_version = p3_version; 15066 _object->class_id = psStringCopy(class_id); 15067 _object->uri = psStringCopy(uri); 15068 _object->b1_uri = psStringCopy(b1_uri); 15069 _object->b2_uri = psStringCopy(b2_uri); 14895 _object->kind = psStringCopy(kind); 15070 14896 15071 14897 return _object; 15072 14898 } 15073 14899 15074 static void p4DiffImfileRowFree(p4DiffImfileRow *object) 15075 { 14900 static void p4bInputScfileRowFree(p4bInputScfileRow *object) 14901 { 14902 psFree(object->skycell_id); 14903 psFree(object->tess_id); 15076 14904 psFree(object->exp_tag); 15077 psFree(object->class_id); 15078 psFree(object->uri); 15079 psFree(object->b1_uri); 15080 psFree(object->b2_uri); 15081 } 15082 15083 bool p4DiffImfileCreateTable(psDB *dbh) 14905 psFree(object->kind); 14906 } 14907 14908 bool p4bInputScfileCreateTable(psDB *dbh) 15084 14909 { 15085 14910 psMetadata *md = psMetadataAlloc(); 15086 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, "Primary Key", 0)) { 15087 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 14911 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4b_id", PS_DATA_S32, "Primary Key", 0)) { 14912 psError(PS_ERR_UNKNOWN, false, "failed to add item p4b_id"); 14913 psFree(md); 14914 return false; 14915 } 14916 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, "Primary Key", "64")) { 14917 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 14918 psFree(md); 14919 return false; 14920 } 14921 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, "Primary Key", "64")) { 14922 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 15088 14923 psFree(md); 15089 14924 return false; … … 15099 14934 return false; 15100 14935 } 15101 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, "Primary Key", "64")) { 15102 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 15103 psFree(md); 15104 return false; 15105 } 15106 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, "255")) { 15107 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 15108 psFree(md); 15109 return false; 15110 } 15111 if (!psMetadataAdd(md, PS_LIST_TAIL, "b1_uri", PS_DATA_STRING, NULL, "255")) { 15112 psError(PS_ERR_UNKNOWN, false, "failed to add item b1_uri"); 15113 psFree(md); 15114 return false; 15115 } 15116 if (!psMetadataAdd(md, PS_LIST_TAIL, "b2_uri", PS_DATA_STRING, NULL, "255")) { 15117 psError(PS_ERR_UNKNOWN, false, "failed to add item b2_uri"); 15118 psFree(md); 15119 return false; 15120 } 15121 15122 bool status = psDBCreateTable(dbh, P4DIFFIMFILE_TABLE_NAME, md); 14936 if (!psMetadataAdd(md, PS_LIST_TAIL, "kind", PS_DATA_STRING, "Key", "64")) { 14937 psError(PS_ERR_UNKNOWN, false, "failed to add item kind"); 14938 psFree(md); 14939 return false; 14940 } 14941 14942 bool status = psDBCreateTable(dbh, P4BINPUTSCFILE_TABLE_NAME, md); 15123 14943 15124 14944 psFree(md); … … 15127 14947 } 15128 14948 15129 bool p4 DiffImfileDropTable(psDB *dbh)15130 { 15131 return psDBDropTable(dbh, P4 DIFFIMFILE_TABLE_NAME);15132 } 15133 15134 bool p4 DiffImfileInsert(psDB * dbh, psS32 p4_id, const char *exp_tag, psS32 p3_version, const char *class_id, const char *uri, const char *b1_uri, const char *b2_uri)14949 bool p4bInputScfileDropTable(psDB *dbh) 14950 { 14951 return psDBDropTable(dbh, P4BINPUTSCFILE_TABLE_NAME); 14952 } 14953 14954 bool p4bInputScfileInsert(psDB * dbh, psS32 p4b_id, const char *skycell_id, const char *tess_id, const char *exp_tag, psS32 p3_version, const char *kind) 15135 14955 { 15136 14956 psMetadata *md = psMetadataAlloc(); 15137 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, NULL, p4_id)) { 15138 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 14957 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4b_id", PS_DATA_S32, NULL, p4b_id)) { 14958 psError(PS_ERR_UNKNOWN, false, "failed to add item p4b_id"); 14959 psFree(md); 14960 return false; 14961 } 14962 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, skycell_id)) { 14963 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 14964 psFree(md); 14965 return false; 14966 } 14967 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, tess_id)) { 14968 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 15139 14969 psFree(md); 15140 14970 return false; … … 15150 14980 return false; 15151 14981 } 15152 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, class_id)) { 15153 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 15154 psFree(md); 15155 return false; 15156 } 15157 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, uri)) { 15158 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 15159 psFree(md); 15160 return false; 15161 } 15162 if (!psMetadataAdd(md, PS_LIST_TAIL, "b1_uri", PS_DATA_STRING, NULL, b1_uri)) { 15163 psError(PS_ERR_UNKNOWN, false, "failed to add item b1_uri"); 15164 psFree(md); 15165 return false; 15166 } 15167 if (!psMetadataAdd(md, PS_LIST_TAIL, "b2_uri", PS_DATA_STRING, NULL, b2_uri)) { 15168 psError(PS_ERR_UNKNOWN, false, "failed to add item b2_uri"); 15169 psFree(md); 15170 return false; 15171 } 15172 15173 bool status = psDBInsertOneRow(dbh, P4DIFFIMFILE_TABLE_NAME, md); 14982 if (!psMetadataAdd(md, PS_LIST_TAIL, "kind", PS_DATA_STRING, NULL, kind)) { 14983 psError(PS_ERR_UNKNOWN, false, "failed to add item kind"); 14984 psFree(md); 14985 return false; 14986 } 14987 14988 bool status = psDBInsertOneRow(dbh, P4BINPUTSCFILE_TABLE_NAME, md); 15174 14989 psFree(md); 15175 14990 … … 15177 14992 } 15178 14993 15179 long long p4 DiffImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)14994 long long p4bInputScfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 15180 14995 { 15181 14996 long long deleted = 0; 15182 14997 15183 long long count = psDBDeleteRows(dbh, P4 DIFFIMFILE_TABLE_NAME, where, limit);14998 long long count = psDBDeleteRows(dbh, P4BINPUTSCFILE_TABLE_NAME, where, limit); 15184 14999 if (count < 0) { 15185 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 DiffImfile");15000 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bInputScfile"); 15186 15001 return count; 15187 15002 … … 15191 15006 return deleted; 15192 15007 } 15193 bool p4 DiffImfileInsertObject(psDB *dbh, p4DiffImfileRow *object)15194 { 15195 return p4 DiffImfileInsert(dbh, object->p4_id, object->exp_tag, object->p3_version, object->class_id, object->uri, object->b1_uri, object->b2_uri);15196 } 15197 15198 bool p4 DiffImfileInsertObjects(psDB *dbh, psArray *objects)15008 bool p4bInputScfileInsertObject(psDB *dbh, p4bInputScfileRow *object) 15009 { 15010 return p4bInputScfileInsert(dbh, object->p4b_id, object->skycell_id, object->tess_id, object->exp_tag, object->p3_version, object->kind); 15011 } 15012 15013 bool p4bInputScfileInsertObjects(psDB *dbh, psArray *objects) 15199 15014 { 15200 15015 for (long i = 0; i < psArrayLength(objects); i++) { 15201 if (!p4 DiffImfileInsertObject(dbh, objects->data[i])) {15016 if (!p4bInputScfileInsertObject(dbh, objects->data[i])) { 15202 15017 return false; 15203 15018 } … … 15207 15022 } 15208 15023 15209 bool p4 DiffImfileInsertFits(psDB *dbh, const psFits *fits)15024 bool p4bInputScfileInsertFits(psDB *dbh, const psFits *fits) 15210 15025 { 15211 15026 psArray *rowSet; 15212 15027 15213 // move to (the first?) extension named P4 DIFFIMFILE_TABLE_NAME15214 if (!psFitsMoveExtName(fits, P4 DIFFIMFILE_TABLE_NAME)) {15215 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4 DIFFIMFILE_TABLE_NAME);15028 // move to (the first?) extension named P4BINPUTSCFILE_TABLE_NAME 15029 if (!psFitsMoveExtName(fits, P4BINPUTSCFILE_TABLE_NAME)) { 15030 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4BINPUTSCFILE_TABLE_NAME); 15216 15031 return false; 15217 15032 } … … 15231 15046 } 15232 15047 15233 if (!psDBInsertRows(dbh, P4 DIFFIMFILE_TABLE_NAME, rowSet)) {15048 if (!psDBInsertRows(dbh, P4BINPUTSCFILE_TABLE_NAME, rowSet)) { 15234 15049 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 15235 15050 psFree(rowSet); … … 15242 15057 } 15243 15058 15244 bool p4 DiffImfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)15059 bool p4bInputScfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 15245 15060 { 15246 15061 psArray *rowSet; 15247 15062 15248 rowSet = psDBSelectRows(dbh, P4 DIFFIMFILE_TABLE_NAME, where, limit);15063 rowSet = psDBSelectRows(dbh, P4BINPUTSCFILE_TABLE_NAME, where, limit); 15249 15064 if (!rowSet) { 15250 15065 return false; … … 15252 15067 15253 15068 // output to fits 15254 if (!psFitsWriteTable(fits, NULL, rowSet, P4 DIFFIMFILE_TABLE_NAME)) {15069 if (!psFitsWriteTable(fits, NULL, rowSet, P4BINPUTSCFILE_TABLE_NAME)) { 15255 15070 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 15256 15071 psFree(rowSet); … … 15263 15078 } 15264 15079 15265 psMetadata *p4 DiffImfileMetadataFromObject(const p4DiffImfileRow *object)15080 psMetadata *p4bInputScfileMetadataFromObject(const p4bInputScfileRow *object) 15266 15081 { 15267 15082 psMetadata *md = psMetadataAlloc(); 15268 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, NULL, object->p4_id)) { 15269 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 15083 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4b_id", PS_DATA_S32, NULL, object->p4b_id)) { 15084 psError(PS_ERR_UNKNOWN, false, "failed to add item p4b_id"); 15085 psFree(md); 15086 return false; 15087 } 15088 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, object->skycell_id)) { 15089 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 15090 psFree(md); 15091 return false; 15092 } 15093 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, object->tess_id)) { 15094 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 15270 15095 psFree(md); 15271 15096 return false; … … 15281 15106 return false; 15282 15107 } 15283 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, object->class_id)) { 15284 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 15285 psFree(md); 15286 return false; 15287 } 15288 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, object->uri)) { 15289 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 15290 psFree(md); 15291 return false; 15292 } 15293 if (!psMetadataAdd(md, PS_LIST_TAIL, "b1_uri", PS_DATA_STRING, NULL, object->b1_uri)) { 15294 psError(PS_ERR_UNKNOWN, false, "failed to add item b1_uri"); 15295 psFree(md); 15296 return false; 15297 } 15298 if (!psMetadataAdd(md, PS_LIST_TAIL, "b2_uri", PS_DATA_STRING, NULL, object->b2_uri)) { 15299 psError(PS_ERR_UNKNOWN, false, "failed to add item b2_uri"); 15108 if (!psMetadataAdd(md, PS_LIST_TAIL, "kind", PS_DATA_STRING, NULL, object->kind)) { 15109 psError(PS_ERR_UNKNOWN, false, "failed to add item kind"); 15300 15110 psFree(md); 15301 15111 return false; … … 15306 15116 } 15307 15117 15308 p4 DiffImfileRow *p4DiffImfileObjectFromMetadata(psMetadata *md)15118 p4bInputScfileRow *p4bInputScfileObjectFromMetadata(psMetadata *md) 15309 15119 { 15310 15120 15311 15121 bool status = false; 15312 psS32 p4_id = psMetadataLookupS32(&status, md, "p4_id"); 15313 if (!status) { 15314 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4_id"); 15122 psS32 p4b_id = psMetadataLookupS32(&status, md, "p4b_id"); 15123 if (!status) { 15124 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4b_id"); 15125 return false; 15126 } 15127 char* skycell_id = psMetadataLookupPtr(&status, md, "skycell_id"); 15128 if (!status) { 15129 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item skycell_id"); 15130 return false; 15131 } 15132 char* tess_id = psMetadataLookupPtr(&status, md, "tess_id"); 15133 if (!status) { 15134 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item tess_id"); 15315 15135 return false; 15316 15136 } … … 15325 15145 return false; 15326 15146 } 15327 char* class_id = psMetadataLookupPtr(&status, md, "class_id"); 15328 if (!status) { 15329 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id"); 15330 return false; 15331 } 15332 char* uri = psMetadataLookupPtr(&status, md, "uri"); 15333 if (!status) { 15334 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item uri"); 15335 return false; 15336 } 15337 char* b1_uri = psMetadataLookupPtr(&status, md, "b1_uri"); 15338 if (!status) { 15339 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item b1_uri"); 15340 return false; 15341 } 15342 char* b2_uri = psMetadataLookupPtr(&status, md, "b2_uri"); 15343 if (!status) { 15344 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item b2_uri"); 15345 return false; 15346 } 15347 15348 return p4DiffImfileRowAlloc(p4_id, exp_tag, p3_version, class_id, uri, b1_uri, b2_uri); 15349 } 15350 psArray *p4DiffImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 15147 char* kind = psMetadataLookupPtr(&status, md, "kind"); 15148 if (!status) { 15149 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item kind"); 15150 return false; 15151 } 15152 15153 return p4bInputScfileRowAlloc(p4b_id, skycell_id, tess_id, exp_tag, p3_version, kind); 15154 } 15155 psArray *p4bInputScfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 15351 15156 { 15352 15157 psArray *rowSet; … … 15354 15159 psU64 i; 15355 15160 15356 rowSet = psDBSelectRows(dbh, P4 DIFFIMFILE_TABLE_NAME, where, limit);15161 rowSet = psDBSelectRows(dbh, P4BINPUTSCFILE_TABLE_NAME, where, limit); 15357 15162 if (!rowSet) { 15358 15163 return NULL; … … 15364 15169 15365 15170 for (i = 0; i < rowSet->n; i++) { 15366 p4 DiffImfileRow *object = p4DiffImfileObjectFromMetadata(rowSet->data[i]);15171 p4bInputScfileRow *object = p4bInputScfileObjectFromMetadata(rowSet->data[i]); 15367 15172 psArrayAdd(returnSet, 0, object); 15368 15173 psFree(object); … … 15373 15178 return returnSet; 15374 15179 } 15375 bool p4 DiffImfileDeleteObject(psDB *dbh, const p4DiffImfileRow *object)15376 { 15377 psMetadata *where = p4 DiffImfileMetadataFromObject(object);15378 long long count = psDBDeleteRows(dbh, P4 DIFFIMFILE_TABLE_NAME, where, 0);15379 psFree(where) 15180 bool p4bInputScfileDeleteObject(psDB *dbh, const p4bInputScfileRow *object) 15181 { 15182 psMetadata *where = p4bInputScfileMetadataFromObject(object); 15183 long long count = psDBDeleteRows(dbh, P4BINPUTSCFILE_TABLE_NAME, where, 0); 15184 psFree(where); 15380 15185 if (count < 0) { 15381 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 DiffImfile");15186 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bInputScfile"); 15382 15187 return false; 15383 15188 } … … 15385 15190 // XXX should this be a psAbort() instead? It is possible that 15386 15191 // having an object match multiple rows was by design. 15387 psError(PS_ERR_UNKNOWN, true, "p4 DiffImfileRow object matched more then one row. Check your database schema");15388 return false; 15389 } 15390 15391 return true; 15392 } 15393 long long p4 DiffImfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)15192 psError(PS_ERR_UNKNOWN, true, "p4bInputScfileRow object matched more then one row. Check your database schema"); 15193 return false; 15194 } 15195 15196 return true; 15197 } 15198 long long p4bInputScfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 15394 15199 { 15395 15200 long long deleted = 0; 15396 15201 15397 15202 for (long long i = 0; i < objects->n; i++) { 15398 p4 DiffImfileRow *object = objects->data[i];15399 psMetadata *where = p4 DiffImfileMetadataFromObject(object);15400 long long count = psDBDeleteRows(dbh, P4 DIFFIMFILE_TABLE_NAME, where, limit);15401 psFree(where) 15203 p4bInputScfileRow *object = objects->data[i]; 15204 psMetadata *where = p4bInputScfileMetadataFromObject(object); 15205 long long count = psDBDeleteRows(dbh, P4BINPUTSCFILE_TABLE_NAME, where, limit); 15206 psFree(where); 15402 15207 if (count < 0) { 15403 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 DiffImfile");15208 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bInputScfile"); 15404 15209 return count; 15405 15210 } … … 15410 15215 return deleted; 15411 15216 } 15412 bool p4 DiffImfilePrintObjects(FILE *stream, psArray *objects, bool mdcf)15217 bool p4bInputScfilePrintObjects(FILE *stream, psArray *objects, bool mdcf) 15413 15218 { 15414 15219 PS_ASSERT_PTR_NON_NULL(objects, false); … … 15416 15221 psMetadata *output = psMetadataAlloc(); 15417 15222 for (long i = 0; i < psArrayLength(objects); i++) { 15418 psMetadata *md = p4 DiffImfileMetadataFromObject(objects->data[i]);15223 psMetadata *md = p4bInputScfileMetadataFromObject(objects->data[i]); 15419 15224 if (!psMetadataAddMetadata( 15420 15225 output, 15421 15226 PS_LIST_TAIL, 15422 P4 DIFFIMFILE_TABLE_NAME,15227 P4BINPUTSCFILE_TABLE_NAME, 15423 15228 PS_META_DUPLICATE_OK, 15424 15229 NULL, … … 15441 15246 return true; 15442 15247 } 15443 bool p4 DiffImfilePrintObject(FILE *stream, p4DiffImfileRow *object, bool mdcf)15248 bool p4bInputScfilePrintObject(FILE *stream, p4bInputScfileRow *object, bool mdcf) 15444 15249 { 15445 15250 PS_ASSERT_PTR_NON_NULL(object, false); 15446 15251 15447 psMetadata *md = p4 DiffImfileMetadataFromObject(object);15252 psMetadata *md = p4bInputScfileMetadataFromObject(object); 15448 15253 15449 15254 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { … … 15456 15261 return true; 15457 15262 } 15458 static void p4MagicMaskImfileRowFree(p4MagicMaskImfileRow *object); 15459 15460 p4MagicMaskImfileRow *p4MagicMaskImfileRowAlloc(psS32 p4_id, const char *exp_tag, psS32 p3_version, const char *class_id, const char *uri) 15461 { 15462 p4MagicMaskImfileRow *_object; 15463 15464 _object = psAlloc(sizeof(p4MagicMaskImfileRow)); 15465 psMemSetDeallocator(_object, (psFreeFunc)p4MagicMaskImfileRowFree); 15466 15467 _object->p4_id = p4_id; 15263 static void p4bDiffScfileRowFree(p4bDiffScfileRow *object); 15264 15265 p4bDiffScfileRow *p4bDiffScfileRowAlloc(psS32 p4b_id, const char *skycell_id, const char *tess_id, const char *exp_tag, psS32 p3_version, const char *uri, psF64 bg, psF64 bg_mean_stdev) 15266 { 15267 p4bDiffScfileRow *_object; 15268 15269 _object = psAlloc(sizeof(p4bDiffScfileRow)); 15270 psMemSetDeallocator(_object, (psFreeFunc)p4bDiffScfileRowFree); 15271 15272 _object->p4b_id = p4b_id; 15273 _object->skycell_id = psStringCopy(skycell_id); 15274 _object->tess_id = psStringCopy(tess_id); 15468 15275 _object->exp_tag = psStringCopy(exp_tag); 15469 15276 _object->p3_version = p3_version; 15470 _object->class_id = psStringCopy(class_id);15471 15277 _object->uri = psStringCopy(uri); 15278 _object->bg = bg; 15279 _object->bg_mean_stdev = bg_mean_stdev; 15472 15280 15473 15281 return _object; 15474 15282 } 15475 15283 15476 static void p4MagicMaskImfileRowFree(p4MagicMaskImfileRow *object) 15477 { 15284 static void p4bDiffScfileRowFree(p4bDiffScfileRow *object) 15285 { 15286 psFree(object->skycell_id); 15287 psFree(object->tess_id); 15478 15288 psFree(object->exp_tag); 15479 psFree(object->class_id);15480 15289 psFree(object->uri); 15481 15290 } 15482 15291 15483 bool p4 MagicMaskImfileCreateTable(psDB *dbh)15292 bool p4bDiffScfileCreateTable(psDB *dbh) 15484 15293 { 15485 15294 psMetadata *md = psMetadataAlloc(); 15486 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, "Primary Key", 0)) { 15487 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 15295 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4b_id", PS_DATA_S32, "Primary Key", 0)) { 15296 psError(PS_ERR_UNKNOWN, false, "failed to add item p4b_id"); 15297 psFree(md); 15298 return false; 15299 } 15300 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, "Primary Key", "64")) { 15301 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 15302 psFree(md); 15303 return false; 15304 } 15305 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, "Primary Key", "64")) { 15306 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 15488 15307 psFree(md); 15489 15308 return false; … … 15499 15318 return false; 15500 15319 } 15501 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, "Primary Key", "64")) {15502 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");15503 psFree(md);15504 return false;15505 }15506 15320 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, "255")) { 15507 15321 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); … … 15509 15323 return false; 15510 15324 } 15511 15512 bool status = psDBCreateTable(dbh, P4MAGICMASKIMFILE_TABLE_NAME, md); 15325 if (!psMetadataAdd(md, PS_LIST_TAIL, "bg", PS_DATA_F64, NULL, 0.0)) { 15326 psError(PS_ERR_UNKNOWN, false, "failed to add item bg"); 15327 psFree(md); 15328 return false; 15329 } 15330 if (!psMetadataAdd(md, PS_LIST_TAIL, "bg_mean_stdev", PS_DATA_F64, NULL, 0.0)) { 15331 psError(PS_ERR_UNKNOWN, false, "failed to add item bg_mean_stdev"); 15332 psFree(md); 15333 return false; 15334 } 15335 15336 bool status = psDBCreateTable(dbh, P4BDIFFSCFILE_TABLE_NAME, md); 15513 15337 15514 15338 psFree(md); … … 15517 15341 } 15518 15342 15519 bool p4 MagicMaskImfileDropTable(psDB *dbh)15520 { 15521 return psDBDropTable(dbh, P4 MAGICMASKIMFILE_TABLE_NAME);15522 } 15523 15524 bool p4 MagicMaskImfileInsert(psDB * dbh, psS32 p4_id, const char *exp_tag, psS32 p3_version, const char *class_id, const char *uri)15343 bool p4bDiffScfileDropTable(psDB *dbh) 15344 { 15345 return psDBDropTable(dbh, P4BDIFFSCFILE_TABLE_NAME); 15346 } 15347 15348 bool p4bDiffScfileInsert(psDB * dbh, psS32 p4b_id, const char *skycell_id, const char *tess_id, const char *exp_tag, psS32 p3_version, const char *uri, psF64 bg, psF64 bg_mean_stdev) 15525 15349 { 15526 15350 psMetadata *md = psMetadataAlloc(); 15527 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4_id", PS_DATA_S32, NULL, p4_id)) { 15528 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 15351 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4b_id", PS_DATA_S32, NULL, p4b_id)) { 15352 psError(PS_ERR_UNKNOWN, false, "failed to add item p4b_id"); 15353 psFree(md); 15354 return false; 15355 } 15356 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, skycell_id)) { 15357 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 15358 psFree(md); 15359 return false; 15360 } 15361 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, tess_id)) { 15362 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 15529 15363 psFree(md); 15530 15364 return false; … … 15540 15374 return false; 15541 15375 } 15542 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, class_id)) {15543 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");15544 psFree(md);15545 return false;15546 }15547 15376 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, uri)) { 15548 15377 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); … … 15550 15379 return false; 15551 15380 } 15552 15553 bool status = psDBInsertOneRow(dbh, P4MAGICMASKIMFILE_TABLE_NAME, md); 15381 if (!psMetadataAdd(md, PS_LIST_TAIL, "bg", PS_DATA_F64, NULL, bg)) { 15382 psError(PS_ERR_UNKNOWN, false, "failed to add item bg"); 15383 psFree(md); 15384 return false; 15385 } 15386 if (!psMetadataAdd(md, PS_LIST_TAIL, "bg_mean_stdev", PS_DATA_F64, NULL, bg_mean_stdev)) { 15387 psError(PS_ERR_UNKNOWN, false, "failed to add item bg_mean_stdev"); 15388 psFree(md); 15389 return false; 15390 } 15391 15392 bool status = psDBInsertOneRow(dbh, P4BDIFFSCFILE_TABLE_NAME, md); 15554 15393 psFree(md); 15555 15394 … … 15557 15396 } 15558 15397 15559 long long p4 MagicMaskImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)15398 long long p4bDiffScfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 15560 15399 { 15561 15400 long long deleted = 0; 15562 15401 15563 long long count = psDBDeleteRows(dbh, P4 MAGICMASKIMFILE_TABLE_NAME, where, limit);15402 long long count = psDBDeleteRows(dbh, P4BDIFFSCFILE_TABLE_NAME, where, limit); 15564 15403 if (count < 0) { 15565 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4 MagicMaskImfile");15404 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bDiffScfile"); 15566 15405 return count; 15567 15406 … … 15571 15410 return deleted; 15572 15411 } 15573 bool p4 MagicMaskImfileInsertObject(psDB *dbh, p4MagicMaskImfileRow *object)15574 { 15575 return p4 MagicMaskImfileInsert(dbh, object->p4_id, object->exp_tag, object->p3_version, object->class_id, object->uri);15576 } 15577 15578 bool p4 MagicMaskImfileInsertObjects(psDB *dbh, psArray *objects)15412 bool p4bDiffScfileInsertObject(psDB *dbh, p4bDiffScfileRow *object) 15413 { 15414 return p4bDiffScfileInsert(dbh, object->p4b_id, object->skycell_id, object->tess_id, object->exp_tag, object->p3_version, object->uri, object->bg, object->bg_mean_stdev); 15415 } 15416 15417 bool p4bDiffScfileInsertObjects(psDB *dbh, psArray *objects) 15579 15418 { 15580 15419 for (long i = 0; i < psArrayLength(objects); i++) { 15581 if (!p4 MagicMaskImfileInsertObject(dbh, objects->data[i])) {15420 if (!p4bDiffScfileInsertObject(dbh, objects->data[i])) { 15582 15421 return false; 15583 15422 } … … 15587 15426 } 15588 15427 15589 bool p4 MagicMaskImfileInsertFits(psDB *dbh, const psFits *fits)15428 bool p4bDiffScfileInsertFits(psDB *dbh, const psFits *fits) 15590 15429 { 15591 15430 psArray *rowSet; 15592 15431 15593 // move to (the first?) extension named P4 MAGICMASKIMFILE_TABLE_NAME15594 if (!psFitsMoveExtName(fits, P4 MAGICMASKIMFILE_TABLE_NAME)) {15595 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4 MAGICMASKIMFILE_TABLE_NAME);15432 // move to (the first?) extension named P4BDIFFSCFILE_TABLE_NAME 15433 if (!psFitsMoveExtName(fits, P4BDIFFSCFILE_TABLE_NAME)) { 15434 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4BDIFFSCFILE_TABLE_NAME); 15596 15435 return false; 15597 15436 } … … 15611 15450 } 15612 15451 15452 if (!psDBInsertRows(dbh, P4BDIFFSCFILE_TABLE_NAME, rowSet)) { 15453 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 15454 psFree(rowSet); 15455 return false; 15456 } 15457 15458 psFree(rowSet); 15459 15460 return true; 15461 } 15462 15463 bool p4bDiffScfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 15464 { 15465 psArray *rowSet; 15466 15467 rowSet = psDBSelectRows(dbh, P4BDIFFSCFILE_TABLE_NAME, where, limit); 15468 if (!rowSet) { 15469 return false; 15470 } 15471 15472 // output to fits 15473 if (!psFitsWriteTable(fits, NULL, rowSet, P4BDIFFSCFILE_TABLE_NAME)) { 15474 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 15475 psFree(rowSet); 15476 return false; 15477 } 15478 15479 psFree(rowSet); 15480 15481 return true; 15482 } 15483 15484 psMetadata *p4bDiffScfileMetadataFromObject(const p4bDiffScfileRow *object) 15485 { 15486 psMetadata *md = psMetadataAlloc(); 15487 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4b_id", PS_DATA_S32, NULL, object->p4b_id)) { 15488 psError(PS_ERR_UNKNOWN, false, "failed to add item p4b_id"); 15489 psFree(md); 15490 return false; 15491 } 15492 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, object->skycell_id)) { 15493 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 15494 psFree(md); 15495 return false; 15496 } 15497 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, object->tess_id)) { 15498 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 15499 psFree(md); 15500 return false; 15501 } 15502 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, object->exp_tag)) { 15503 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 15504 psFree(md); 15505 return false; 15506 } 15507 if (!psMetadataAdd(md, PS_LIST_TAIL, "p3_version", PS_DATA_S32, NULL, object->p3_version)) { 15508 psError(PS_ERR_UNKNOWN, false, "failed to add item p3_version"); 15509 psFree(md); 15510 return false; 15511 } 15512 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, object->uri)) { 15513 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 15514 psFree(md); 15515 return false; 15516 } 15517 if (!psMetadataAdd(md, PS_LIST_TAIL, "bg", PS_DATA_F64, NULL, object->bg)) { 15518 psError(PS_ERR_UNKNOWN, false, "failed to add item bg"); 15519 psFree(md); 15520 return false; 15521 } 15522 if (!psMetadataAdd(md, PS_LIST_TAIL, "bg_mean_stdev", PS_DATA_F64, NULL, object->bg_mean_stdev)) { 15523 psError(PS_ERR_UNKNOWN, false, "failed to add item bg_mean_stdev"); 15524 psFree(md); 15525 return false; 15526 } 15527 15528 15529 return md; 15530 } 15531 15532 p4bDiffScfileRow *p4bDiffScfileObjectFromMetadata(psMetadata *md) 15533 { 15534 15535 bool status = false; 15536 psS32 p4b_id = psMetadataLookupS32(&status, md, "p4b_id"); 15537 if (!status) { 15538 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4b_id"); 15539 return false; 15540 } 15541 char* skycell_id = psMetadataLookupPtr(&status, md, "skycell_id"); 15542 if (!status) { 15543 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item skycell_id"); 15544 return false; 15545 } 15546 char* tess_id = psMetadataLookupPtr(&status, md, "tess_id"); 15547 if (!status) { 15548 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item tess_id"); 15549 return false; 15550 } 15551 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag"); 15552 if (!status) { 15553 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag"); 15554 return false; 15555 } 15556 psS32 p3_version = psMetadataLookupS32(&status, md, "p3_version"); 15557 if (!status) { 15558 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p3_version"); 15559 return false; 15560 } 15561 char* uri = psMetadataLookupPtr(&status, md, "uri"); 15562 if (!status) { 15563 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item uri"); 15564 return false; 15565 } 15566 psF64 bg = psMetadataLookupF64(&status, md, "bg"); 15567 if (!status) { 15568 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item bg"); 15569 return false; 15570 } 15571 psF64 bg_mean_stdev = psMetadataLookupF64(&status, md, "bg_mean_stdev"); 15572 if (!status) { 15573 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item bg_mean_stdev"); 15574 return false; 15575 } 15576 15577 return p4bDiffScfileRowAlloc(p4b_id, skycell_id, tess_id, exp_tag, p3_version, uri, bg, bg_mean_stdev); 15578 } 15579 psArray *p4bDiffScfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 15580 { 15581 psArray *rowSet; 15582 psArray *returnSet; 15583 psU64 i; 15584 15585 rowSet = psDBSelectRows(dbh, P4BDIFFSCFILE_TABLE_NAME, where, limit); 15586 if (!rowSet) { 15587 return NULL; 15588 } 15589 15590 // convert psMetadata rows to row objects 15591 15592 returnSet = psArrayAllocEmpty(rowSet->n); 15593 15594 for (i = 0; i < rowSet->n; i++) { 15595 p4bDiffScfileRow *object = p4bDiffScfileObjectFromMetadata(rowSet->data[i]); 15596 psArrayAdd(returnSet, 0, object); 15597 psFree(object); 15598 } 15599 15600 psFree(rowSet); 15601 15602 return returnSet; 15603 } 15604 bool p4bDiffScfileDeleteObject(psDB *dbh, const p4bDiffScfileRow *object) 15605 { 15606 psMetadata *where = p4bDiffScfileMetadataFromObject(object); 15607 long long count = psDBDeleteRows(dbh, P4BDIFFSCFILE_TABLE_NAME, where, 0); 15608 psFree(where); 15609 if (count < 0) { 15610 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bDiffScfile"); 15611 return false; 15612 } 15613 if (count > 1) { 15614 // XXX should this be a psAbort() instead? It is possible that 15615 // having an object match multiple rows was by design. 15616 psError(PS_ERR_UNKNOWN, true, "p4bDiffScfileRow object matched more then one row. Check your database schema"); 15617 return false; 15618 } 15619 15620 return true; 15621 } 15622 long long p4bDiffScfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 15623 { 15624 long long deleted = 0; 15625 15626 for (long long i = 0; i < objects->n; i++) { 15627 p4bDiffScfileRow *object = objects->data[i]; 15628 psMetadata *where = p4bDiffScfileMetadataFromObject(object); 15629 long long count = psDBDeleteRows(dbh, P4BDIFFSCFILE_TABLE_NAME, where, limit); 15630 psFree(where); 15631 if (count < 0) { 15632 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bDiffScfile"); 15633 return count; 15634 } 15635 15636 deleted += count; 15637 } 15638 15639 return deleted; 15640 } 15641 bool p4bDiffScfilePrintObjects(FILE *stream, psArray *objects, bool mdcf) 15642 { 15643 PS_ASSERT_PTR_NON_NULL(objects, false); 15644 15645 psMetadata *output = psMetadataAlloc(); 15646 for (long i = 0; i < psArrayLength(objects); i++) { 15647 psMetadata *md = p4bDiffScfileMetadataFromObject(objects->data[i]); 15648 if (!psMetadataAddMetadata( 15649 output, 15650 PS_LIST_TAIL, 15651 P4BDIFFSCFILE_TABLE_NAME, 15652 PS_META_DUPLICATE_OK, 15653 NULL, 15654 md 15655 )) { 15656 psError(PS_ERR_UNKNOWN, false, "failed to add metadata"); 15657 psFree(md); 15658 psFree(output); 15659 return false; 15660 } 15661 psFree(md); 15662 } 15663 15664 if (!ippdbPrintMetadataRaw(stream, output, mdcf)) { 15665 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 15666 psFree(output); 15667 } 15668 psFree(output); 15669 15670 return true; 15671 } 15672 bool p4bDiffScfilePrintObject(FILE *stream, p4bDiffScfileRow *object, bool mdcf) 15673 { 15674 PS_ASSERT_PTR_NON_NULL(object, false); 15675 15676 psMetadata *md = p4bDiffScfileMetadataFromObject(object); 15677 15678 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { 15679 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 15680 psFree(md); 15681 } 15682 15683 psFree(md); 15684 15685 return true; 15686 } 15687 static void p4cRunRowFree(p4cRunRow *object); 15688 15689 p4cRunRow *p4cRunRowAlloc(psS32 p4c_id, const char *state, const char *workdir, bool magic) 15690 { 15691 p4cRunRow *_object; 15692 15693 _object = psAlloc(sizeof(p4cRunRow)); 15694 psMemSetDeallocator(_object, (psFreeFunc)p4cRunRowFree); 15695 15696 _object->p4c_id = p4c_id; 15697 _object->state = psStringCopy(state); 15698 _object->workdir = psStringCopy(workdir); 15699 _object->magic = magic; 15700 15701 return _object; 15702 } 15703 15704 static void p4cRunRowFree(p4cRunRow *object) 15705 { 15706 psFree(object->state); 15707 psFree(object->workdir); 15708 } 15709 15710 bool p4cRunCreateTable(psDB *dbh) 15711 { 15712 psMetadata *md = psMetadataAlloc(); 15713 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4c_id", PS_DATA_S32, "Primary Key AUTO_INCREMENT", 0)) { 15714 psError(PS_ERR_UNKNOWN, false, "failed to add item p4c_id"); 15715 psFree(md); 15716 return false; 15717 } 15718 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, "Key", "64")) { 15719 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 15720 psFree(md); 15721 return false; 15722 } 15723 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, "255")) { 15724 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 15725 psFree(md); 15726 return false; 15727 } 15728 if (!psMetadataAdd(md, PS_LIST_TAIL, "magic", PS_DATA_BOOL, "Primary Key", 0)) { 15729 psError(PS_ERR_UNKNOWN, false, "failed to add item magic"); 15730 psFree(md); 15731 return false; 15732 } 15733 15734 bool status = psDBCreateTable(dbh, P4CRUN_TABLE_NAME, md); 15735 15736 psFree(md); 15737 15738 return status; 15739 } 15740 15741 bool p4cRunDropTable(psDB *dbh) 15742 { 15743 return psDBDropTable(dbh, P4CRUN_TABLE_NAME); 15744 } 15745 15746 bool p4cRunInsert(psDB * dbh, psS32 p4c_id, const char *state, const char *workdir, bool magic) 15747 { 15748 psMetadata *md = psMetadataAlloc(); 15749 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4c_id", PS_DATA_S32, NULL, p4c_id)) { 15750 psError(PS_ERR_UNKNOWN, false, "failed to add item p4c_id"); 15751 psFree(md); 15752 return false; 15753 } 15754 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, state)) { 15755 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 15756 psFree(md); 15757 return false; 15758 } 15759 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, workdir)) { 15760 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 15761 psFree(md); 15762 return false; 15763 } 15764 if (!psMetadataAdd(md, PS_LIST_TAIL, "magic", PS_DATA_BOOL, NULL, magic)) { 15765 psError(PS_ERR_UNKNOWN, false, "failed to add item magic"); 15766 psFree(md); 15767 return false; 15768 } 15769 15770 bool status = psDBInsertOneRow(dbh, P4CRUN_TABLE_NAME, md); 15771 psFree(md); 15772 15773 return status; 15774 } 15775 15776 long long p4cRunDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 15777 { 15778 long long deleted = 0; 15779 15780 long long count = psDBDeleteRows(dbh, P4CRUN_TABLE_NAME, where, limit); 15781 if (count < 0) { 15782 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4cRun"); 15783 return count; 15784 15785 deleted += count; 15786 } 15787 15788 return deleted; 15789 } 15790 bool p4cRunInsertObject(psDB *dbh, p4cRunRow *object) 15791 { 15792 return p4cRunInsert(dbh, object->p4c_id, object->state, object->workdir, object->magic); 15793 } 15794 15795 bool p4cRunInsertObjects(psDB *dbh, psArray *objects) 15796 { 15797 for (long i = 0; i < psArrayLength(objects); i++) { 15798 if (!p4cRunInsertObject(dbh, objects->data[i])) { 15799 return false; 15800 } 15801 } 15802 15803 return true; 15804 } 15805 15806 bool p4cRunInsertFits(psDB *dbh, const psFits *fits) 15807 { 15808 psArray *rowSet; 15809 15810 // move to (the first?) extension named P4CRUN_TABLE_NAME 15811 if (!psFitsMoveExtName(fits, P4CRUN_TABLE_NAME)) { 15812 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4CRUN_TABLE_NAME); 15813 return false; 15814 } 15815 15816 // check HDU type 15817 if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE) { 15818 psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE"); 15819 return false; 15820 } 15821 15822 // read fits table 15823 rowSet = psFitsReadTable(fits); 15824 if (!rowSet) { 15825 psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty"); 15826 psFree(rowSet); 15827 return false; 15828 } 15829 15830 if (!psDBInsertRows(dbh, P4CRUN_TABLE_NAME, rowSet)) { 15831 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 15832 psFree(rowSet); 15833 return false; 15834 } 15835 15836 psFree(rowSet); 15837 15838 return true; 15839 } 15840 15841 bool p4cRunSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 15842 { 15843 psArray *rowSet; 15844 15845 rowSet = psDBSelectRows(dbh, P4CRUN_TABLE_NAME, where, limit); 15846 if (!rowSet) { 15847 return false; 15848 } 15849 15850 // output to fits 15851 if (!psFitsWriteTable(fits, NULL, rowSet, P4CRUN_TABLE_NAME)) { 15852 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 15853 psFree(rowSet); 15854 return false; 15855 } 15856 15857 psFree(rowSet); 15858 15859 return true; 15860 } 15861 15862 psMetadata *p4cRunMetadataFromObject(const p4cRunRow *object) 15863 { 15864 psMetadata *md = psMetadataAlloc(); 15865 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4c_id", PS_DATA_S32, NULL, object->p4c_id)) { 15866 psError(PS_ERR_UNKNOWN, false, "failed to add item p4c_id"); 15867 psFree(md); 15868 return false; 15869 } 15870 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, object->state)) { 15871 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 15872 psFree(md); 15873 return false; 15874 } 15875 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, object->workdir)) { 15876 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 15877 psFree(md); 15878 return false; 15879 } 15880 if (!psMetadataAdd(md, PS_LIST_TAIL, "magic", PS_DATA_BOOL, NULL, object->magic)) { 15881 psError(PS_ERR_UNKNOWN, false, "failed to add item magic"); 15882 psFree(md); 15883 return false; 15884 } 15885 15886 15887 return md; 15888 } 15889 15890 p4cRunRow *p4cRunObjectFromMetadata(psMetadata *md) 15891 { 15892 15893 bool status = false; 15894 psS32 p4c_id = psMetadataLookupS32(&status, md, "p4c_id"); 15895 if (!status) { 15896 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4c_id"); 15897 return false; 15898 } 15899 char* state = psMetadataLookupPtr(&status, md, "state"); 15900 if (!status) { 15901 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item state"); 15902 return false; 15903 } 15904 char* workdir = psMetadataLookupPtr(&status, md, "workdir"); 15905 if (!status) { 15906 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item workdir"); 15907 return false; 15908 } 15909 bool magic = psMetadataLookupBool(&status, md, "magic"); 15910 if (!status) { 15911 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item magic"); 15912 return false; 15913 } 15914 15915 return p4cRunRowAlloc(p4c_id, state, workdir, magic); 15916 } 15917 psArray *p4cRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 15918 { 15919 psArray *rowSet; 15920 psArray *returnSet; 15921 psU64 i; 15922 15923 rowSet = psDBSelectRows(dbh, P4CRUN_TABLE_NAME, where, limit); 15924 if (!rowSet) { 15925 return NULL; 15926 } 15927 15928 // convert psMetadata rows to row objects 15929 15930 returnSet = psArrayAllocEmpty(rowSet->n); 15931 15932 for (i = 0; i < rowSet->n; i++) { 15933 p4cRunRow *object = p4cRunObjectFromMetadata(rowSet->data[i]); 15934 psArrayAdd(returnSet, 0, object); 15935 psFree(object); 15936 } 15937 15938 psFree(rowSet); 15939 15940 return returnSet; 15941 } 15942 bool p4cRunDeleteObject(psDB *dbh, const p4cRunRow *object) 15943 { 15944 psMetadata *where = p4cRunMetadataFromObject(object); 15945 long long count = psDBDeleteRows(dbh, P4CRUN_TABLE_NAME, where, 0); 15946 psFree(where); 15947 if (count < 0) { 15948 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4cRun"); 15949 return false; 15950 } 15951 if (count > 1) { 15952 // XXX should this be a psAbort() instead? It is possible that 15953 // having an object match multiple rows was by design. 15954 psError(PS_ERR_UNKNOWN, true, "p4cRunRow object matched more then one row. Check your database schema"); 15955 return false; 15956 } 15957 15958 return true; 15959 } 15960 long long p4cRunDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 15961 { 15962 long long deleted = 0; 15963 15964 for (long long i = 0; i < objects->n; i++) { 15965 p4cRunRow *object = objects->data[i]; 15966 psMetadata *where = p4cRunMetadataFromObject(object); 15967 long long count = psDBDeleteRows(dbh, P4CRUN_TABLE_NAME, where, limit); 15968 psFree(where); 15969 if (count < 0) { 15970 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4cRun"); 15971 return count; 15972 } 15973 15974 deleted += count; 15975 } 15976 15977 return deleted; 15978 } 15979 bool p4cRunPrintObjects(FILE *stream, psArray *objects, bool mdcf) 15980 { 15981 PS_ASSERT_PTR_NON_NULL(objects, false); 15982 15983 psMetadata *output = psMetadataAlloc(); 15984 for (long i = 0; i < psArrayLength(objects); i++) { 15985 psMetadata *md = p4cRunMetadataFromObject(objects->data[i]); 15986 if (!psMetadataAddMetadata( 15987 output, 15988 PS_LIST_TAIL, 15989 P4CRUN_TABLE_NAME, 15990 PS_META_DUPLICATE_OK, 15991 NULL, 15992 md 15993 )) { 15994 psError(PS_ERR_UNKNOWN, false, "failed to add metadata"); 15995 psFree(md); 15996 psFree(output); 15997 return false; 15998 } 15999 psFree(md); 16000 } 16001 16002 if (!ippdbPrintMetadataRaw(stream, output, mdcf)) { 16003 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 16004 psFree(output); 16005 } 16006 psFree(output); 16007 16008 return true; 16009 } 16010 bool p4cRunPrintObject(FILE *stream, p4cRunRow *object, bool mdcf) 16011 { 16012 PS_ASSERT_PTR_NON_NULL(object, false); 16013 16014 psMetadata *md = p4cRunMetadataFromObject(object); 16015 16016 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { 16017 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 16018 psFree(md); 16019 } 16020 16021 psFree(md); 16022 16023 return true; 16024 } 16025 static void p4cInputExpRowFree(p4cInputExpRow *object); 16026 16027 p4cInputExpRow *p4cInputExpRowAlloc(psS32 p4c_id, const char *exp_tag, psS32 p3_version) 16028 { 16029 p4cInputExpRow *_object; 16030 16031 _object = psAlloc(sizeof(p4cInputExpRow)); 16032 psMemSetDeallocator(_object, (psFreeFunc)p4cInputExpRowFree); 16033 16034 _object->p4c_id = p4c_id; 16035 _object->exp_tag = psStringCopy(exp_tag); 16036 _object->p3_version = p3_version; 16037 16038 return _object; 16039 } 16040 16041 static void p4cInputExpRowFree(p4cInputExpRow *object) 16042 { 16043 psFree(object->exp_tag); 16044 } 16045 16046 bool p4cInputExpCreateTable(psDB *dbh) 16047 { 16048 psMetadata *md = psMetadataAlloc(); 16049 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4c_id", PS_DATA_S32, "Primary Key", 0)) { 16050 psError(PS_ERR_UNKNOWN, false, "failed to add item p4c_id"); 16051 psFree(md); 16052 return false; 16053 } 16054 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, "Primary Key", "64")) { 16055 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 16056 psFree(md); 16057 return false; 16058 } 16059 if (!psMetadataAdd(md, PS_LIST_TAIL, "p3_version", PS_DATA_S32, "Primary Key", 0)) { 16060 psError(PS_ERR_UNKNOWN, false, "failed to add item p3_version"); 16061 psFree(md); 16062 return false; 16063 } 16064 16065 bool status = psDBCreateTable(dbh, P4CINPUTEXP_TABLE_NAME, md); 16066 16067 psFree(md); 16068 16069 return status; 16070 } 16071 16072 bool p4cInputExpDropTable(psDB *dbh) 16073 { 16074 return psDBDropTable(dbh, P4CINPUTEXP_TABLE_NAME); 16075 } 16076 16077 bool p4cInputExpInsert(psDB * dbh, psS32 p4c_id, const char *exp_tag, psS32 p3_version) 16078 { 16079 psMetadata *md = psMetadataAlloc(); 16080 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4c_id", PS_DATA_S32, NULL, p4c_id)) { 16081 psError(PS_ERR_UNKNOWN, false, "failed to add item p4c_id"); 16082 psFree(md); 16083 return false; 16084 } 16085 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, exp_tag)) { 16086 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 16087 psFree(md); 16088 return false; 16089 } 16090 if (!psMetadataAdd(md, PS_LIST_TAIL, "p3_version", PS_DATA_S32, NULL, p3_version)) { 16091 psError(PS_ERR_UNKNOWN, false, "failed to add item p3_version"); 16092 psFree(md); 16093 return false; 16094 } 16095 16096 bool status = psDBInsertOneRow(dbh, P4CINPUTEXP_TABLE_NAME, md); 16097 psFree(md); 16098 16099 return status; 16100 } 16101 16102 long long p4cInputExpDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 16103 { 16104 long long deleted = 0; 16105 16106 long long count = psDBDeleteRows(dbh, P4CINPUTEXP_TABLE_NAME, where, limit); 16107 if (count < 0) { 16108 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4cInputExp"); 16109 return count; 16110 16111 deleted += count; 16112 } 16113 16114 return deleted; 16115 } 16116 bool p4cInputExpInsertObject(psDB *dbh, p4cInputExpRow *object) 16117 { 16118 return p4cInputExpInsert(dbh, object->p4c_id, object->exp_tag, object->p3_version); 16119 } 16120 16121 bool p4cInputExpInsertObjects(psDB *dbh, psArray *objects) 16122 { 16123 for (long i = 0; i < psArrayLength(objects); i++) { 16124 if (!p4cInputExpInsertObject(dbh, objects->data[i])) { 16125 return false; 16126 } 16127 } 16128 16129 return true; 16130 } 16131 16132 bool p4cInputExpInsertFits(psDB *dbh, const psFits *fits) 16133 { 16134 psArray *rowSet; 16135 16136 // move to (the first?) extension named P4CINPUTEXP_TABLE_NAME 16137 if (!psFitsMoveExtName(fits, P4CINPUTEXP_TABLE_NAME)) { 16138 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4CINPUTEXP_TABLE_NAME); 16139 return false; 16140 } 16141 16142 // check HDU type 16143 if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE) { 16144 psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE"); 16145 return false; 16146 } 16147 16148 // read fits table 16149 rowSet = psFitsReadTable(fits); 16150 if (!rowSet) { 16151 psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty"); 16152 psFree(rowSet); 16153 return false; 16154 } 16155 16156 if (!psDBInsertRows(dbh, P4CINPUTEXP_TABLE_NAME, rowSet)) { 16157 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 16158 psFree(rowSet); 16159 return false; 16160 } 16161 16162 psFree(rowSet); 16163 16164 return true; 16165 } 16166 16167 bool p4cInputExpSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 16168 { 16169 psArray *rowSet; 16170 16171 rowSet = psDBSelectRows(dbh, P4CINPUTEXP_TABLE_NAME, where, limit); 16172 if (!rowSet) { 16173 return false; 16174 } 16175 16176 // output to fits 16177 if (!psFitsWriteTable(fits, NULL, rowSet, P4CINPUTEXP_TABLE_NAME)) { 16178 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 16179 psFree(rowSet); 16180 return false; 16181 } 16182 16183 psFree(rowSet); 16184 16185 return true; 16186 } 16187 16188 psMetadata *p4cInputExpMetadataFromObject(const p4cInputExpRow *object) 16189 { 16190 psMetadata *md = psMetadataAlloc(); 16191 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4c_id", PS_DATA_S32, NULL, object->p4c_id)) { 16192 psError(PS_ERR_UNKNOWN, false, "failed to add item p4c_id"); 16193 psFree(md); 16194 return false; 16195 } 16196 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, object->exp_tag)) { 16197 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 16198 psFree(md); 16199 return false; 16200 } 16201 if (!psMetadataAdd(md, PS_LIST_TAIL, "p3_version", PS_DATA_S32, NULL, object->p3_version)) { 16202 psError(PS_ERR_UNKNOWN, false, "failed to add item p3_version"); 16203 psFree(md); 16204 return false; 16205 } 16206 16207 16208 return md; 16209 } 16210 16211 p4cInputExpRow *p4cInputExpObjectFromMetadata(psMetadata *md) 16212 { 16213 16214 bool status = false; 16215 psS32 p4c_id = psMetadataLookupS32(&status, md, "p4c_id"); 16216 if (!status) { 16217 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4c_id"); 16218 return false; 16219 } 16220 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag"); 16221 if (!status) { 16222 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag"); 16223 return false; 16224 } 16225 psS32 p3_version = psMetadataLookupS32(&status, md, "p3_version"); 16226 if (!status) { 16227 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p3_version"); 16228 return false; 16229 } 16230 16231 return p4cInputExpRowAlloc(p4c_id, exp_tag, p3_version); 16232 } 16233 psArray *p4cInputExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 16234 { 16235 psArray *rowSet; 16236 psArray *returnSet; 16237 psU64 i; 16238 16239 rowSet = psDBSelectRows(dbh, P4CINPUTEXP_TABLE_NAME, where, limit); 16240 if (!rowSet) { 16241 return NULL; 16242 } 16243 16244 // convert psMetadata rows to row objects 16245 16246 returnSet = psArrayAllocEmpty(rowSet->n); 16247 16248 for (i = 0; i < rowSet->n; i++) { 16249 p4cInputExpRow *object = p4cInputExpObjectFromMetadata(rowSet->data[i]); 16250 psArrayAdd(returnSet, 0, object); 16251 psFree(object); 16252 } 16253 16254 psFree(rowSet); 16255 16256 return returnSet; 16257 } 16258 bool p4cInputExpDeleteObject(psDB *dbh, const p4cInputExpRow *object) 16259 { 16260 psMetadata *where = p4cInputExpMetadataFromObject(object); 16261 long long count = psDBDeleteRows(dbh, P4CINPUTEXP_TABLE_NAME, where, 0); 16262 psFree(where); 16263 if (count < 0) { 16264 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4cInputExp"); 16265 return false; 16266 } 16267 if (count > 1) { 16268 // XXX should this be a psAbort() instead? It is possible that 16269 // having an object match multiple rows was by design. 16270 psError(PS_ERR_UNKNOWN, true, "p4cInputExpRow object matched more then one row. Check your database schema"); 16271 return false; 16272 } 16273 16274 return true; 16275 } 16276 long long p4cInputExpDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 16277 { 16278 long long deleted = 0; 16279 16280 for (long long i = 0; i < objects->n; i++) { 16281 p4cInputExpRow *object = objects->data[i]; 16282 psMetadata *where = p4cInputExpMetadataFromObject(object); 16283 long long count = psDBDeleteRows(dbh, P4CINPUTEXP_TABLE_NAME, where, limit); 16284 psFree(where); 16285 if (count < 0) { 16286 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4cInputExp"); 16287 return count; 16288 } 16289 16290 deleted += count; 16291 } 16292 16293 return deleted; 16294 } 16295 bool p4cInputExpPrintObjects(FILE *stream, psArray *objects, bool mdcf) 16296 { 16297 PS_ASSERT_PTR_NON_NULL(objects, false); 16298 16299 psMetadata *output = psMetadataAlloc(); 16300 for (long i = 0; i < psArrayLength(objects); i++) { 16301 psMetadata *md = p4cInputExpMetadataFromObject(objects->data[i]); 16302 if (!psMetadataAddMetadata( 16303 output, 16304 PS_LIST_TAIL, 16305 P4CINPUTEXP_TABLE_NAME, 16306 PS_META_DUPLICATE_OK, 16307 NULL, 16308 md 16309 )) { 16310 psError(PS_ERR_UNKNOWN, false, "failed to add metadata"); 16311 psFree(md); 16312 psFree(output); 16313 return false; 16314 } 16315 psFree(md); 16316 } 16317 16318 if (!ippdbPrintMetadataRaw(stream, output, mdcf)) { 16319 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 16320 psFree(output); 16321 } 16322 psFree(output); 16323 16324 return true; 16325 } 16326 bool p4cInputExpPrintObject(FILE *stream, p4cInputExpRow *object, bool mdcf) 16327 { 16328 PS_ASSERT_PTR_NON_NULL(object, false); 16329 16330 psMetadata *md = p4cInputExpMetadataFromObject(object); 16331 16332 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { 16333 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 16334 psFree(md); 16335 } 16336 16337 psFree(md); 16338 16339 return true; 16340 } 16341 static void p4MagicMaskImfileRowFree(p4MagicMaskImfileRow *object); 16342 16343 p4MagicMaskImfileRow *p4MagicMaskImfileRowAlloc(psS32 p4c_id, const char *exp_tag, psS32 p3_version, const char *class_id, const char *uri) 16344 { 16345 p4MagicMaskImfileRow *_object; 16346 16347 _object = psAlloc(sizeof(p4MagicMaskImfileRow)); 16348 psMemSetDeallocator(_object, (psFreeFunc)p4MagicMaskImfileRowFree); 16349 16350 _object->p4c_id = p4c_id; 16351 _object->exp_tag = psStringCopy(exp_tag); 16352 _object->p3_version = p3_version; 16353 _object->class_id = psStringCopy(class_id); 16354 _object->uri = psStringCopy(uri); 16355 16356 return _object; 16357 } 16358 16359 static void p4MagicMaskImfileRowFree(p4MagicMaskImfileRow *object) 16360 { 16361 psFree(object->exp_tag); 16362 psFree(object->class_id); 16363 psFree(object->uri); 16364 } 16365 16366 bool p4MagicMaskImfileCreateTable(psDB *dbh) 16367 { 16368 psMetadata *md = psMetadataAlloc(); 16369 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4c_id", PS_DATA_S32, "Primary Key", 0)) { 16370 psError(PS_ERR_UNKNOWN, false, "failed to add item p4c_id"); 16371 psFree(md); 16372 return false; 16373 } 16374 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, "Primary Key", "64")) { 16375 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 16376 psFree(md); 16377 return false; 16378 } 16379 if (!psMetadataAdd(md, PS_LIST_TAIL, "p3_version", PS_DATA_S32, "Primary Key", 0)) { 16380 psError(PS_ERR_UNKNOWN, false, "failed to add item p3_version"); 16381 psFree(md); 16382 return false; 16383 } 16384 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, "Primary Key", "64")) { 16385 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 16386 psFree(md); 16387 return false; 16388 } 16389 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, "255")) { 16390 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 16391 psFree(md); 16392 return false; 16393 } 16394 16395 bool status = psDBCreateTable(dbh, P4MAGICMASKIMFILE_TABLE_NAME, md); 16396 16397 psFree(md); 16398 16399 return status; 16400 } 16401 16402 bool p4MagicMaskImfileDropTable(psDB *dbh) 16403 { 16404 return psDBDropTable(dbh, P4MAGICMASKIMFILE_TABLE_NAME); 16405 } 16406 16407 bool p4MagicMaskImfileInsert(psDB * dbh, psS32 p4c_id, const char *exp_tag, psS32 p3_version, const char *class_id, const char *uri) 16408 { 16409 psMetadata *md = psMetadataAlloc(); 16410 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4c_id", PS_DATA_S32, NULL, p4c_id)) { 16411 psError(PS_ERR_UNKNOWN, false, "failed to add item p4c_id"); 16412 psFree(md); 16413 return false; 16414 } 16415 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, exp_tag)) { 16416 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 16417 psFree(md); 16418 return false; 16419 } 16420 if (!psMetadataAdd(md, PS_LIST_TAIL, "p3_version", PS_DATA_S32, NULL, p3_version)) { 16421 psError(PS_ERR_UNKNOWN, false, "failed to add item p3_version"); 16422 psFree(md); 16423 return false; 16424 } 16425 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, class_id)) { 16426 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 16427 psFree(md); 16428 return false; 16429 } 16430 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, uri)) { 16431 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 16432 psFree(md); 16433 return false; 16434 } 16435 16436 bool status = psDBInsertOneRow(dbh, P4MAGICMASKIMFILE_TABLE_NAME, md); 16437 psFree(md); 16438 16439 return status; 16440 } 16441 16442 long long p4MagicMaskImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 16443 { 16444 long long deleted = 0; 16445 16446 long long count = psDBDeleteRows(dbh, P4MAGICMASKIMFILE_TABLE_NAME, where, limit); 16447 if (count < 0) { 16448 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4MagicMaskImfile"); 16449 return count; 16450 16451 deleted += count; 16452 } 16453 16454 return deleted; 16455 } 16456 bool p4MagicMaskImfileInsertObject(psDB *dbh, p4MagicMaskImfileRow *object) 16457 { 16458 return p4MagicMaskImfileInsert(dbh, object->p4c_id, object->exp_tag, object->p3_version, object->class_id, object->uri); 16459 } 16460 16461 bool p4MagicMaskImfileInsertObjects(psDB *dbh, psArray *objects) 16462 { 16463 for (long i = 0; i < psArrayLength(objects); i++) { 16464 if (!p4MagicMaskImfileInsertObject(dbh, objects->data[i])) { 16465 return false; 16466 } 16467 } 16468 16469 return true; 16470 } 16471 16472 bool p4MagicMaskImfileInsertFits(psDB *dbh, const psFits *fits) 16473 { 16474 psArray *rowSet; 16475 16476 // move to (the first?) extension named P4MAGICMASKIMFILE_TABLE_NAME 16477 if (!psFitsMoveExtName(fits, P4MAGICMASKIMFILE_TABLE_NAME)) { 16478 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4MAGICMASKIMFILE_TABLE_NAME); 16479 return false; 16480 } 16481 16482 // check HDU type 16483 if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE) { 16484 psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE"); 16485 return false; 16486 } 16487 16488 // read fits table 16489 rowSet = psFitsReadTable(fits); 16490 if (!rowSet) { 16491 psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty"); 16492 psFree(rowSet); 16493 return false; 16494 } 16495 15613 16496 if (!psDBInsertRows(dbh, P4MAGICMASKIMFILE_TABLE_NAME, rowSet)) { 15614 16497 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); … … 15646 16529 { 15647 16530 psMetadata *md = psMetadataAlloc(); 15648 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4 _id", PS_DATA_S32, NULL, object->p4_id)) {15649 psError(PS_ERR_UNKNOWN, false, "failed to add item p4 _id");16531 if (!psMetadataAdd(md, PS_LIST_TAIL, "p4c_id", PS_DATA_S32, NULL, object->p4c_id)) { 16532 psError(PS_ERR_UNKNOWN, false, "failed to add item p4c_id"); 15650 16533 psFree(md); 15651 16534 return false; … … 15680 16563 15681 16564 bool status = false; 15682 psS32 p4 _id = psMetadataLookupS32(&status, md, "p4_id");15683 if (!status) { 15684 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4 _id");16565 psS32 p4c_id = psMetadataLookupS32(&status, md, "p4c_id"); 16566 if (!status) { 16567 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item p4c_id"); 15685 16568 return false; 15686 16569 } … … 15706 16589 } 15707 16590 15708 return p4MagicMaskImfileRowAlloc(p4 _id, exp_tag, p3_version, class_id, uri);16591 return p4MagicMaskImfileRowAlloc(p4c_id, exp_tag, p3_version, class_id, uri); 15709 16592 } 15710 16593 psArray *p4MagicMaskImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 15737 16620 psMetadata *where = p4MagicMaskImfileMetadataFromObject(object); 15738 16621 long long count = psDBDeleteRows(dbh, P4MAGICMASKIMFILE_TABLE_NAME, where, 0); 15739 psFree(where) 16622 psFree(where); 15740 16623 if (count < 0) { 15741 16624 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4MagicMaskImfile"); … … 15759 16642 psMetadata *where = p4MagicMaskImfileMetadataFromObject(object); 15760 16643 long long count = psDBDeleteRows(dbh, P4MAGICMASKIMFILE_TABLE_NAME, where, limit); 15761 psFree(where) 16644 psFree(where); 15762 16645 if (count < 0) { 15763 16646 psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4MagicMaskImfile"); … … 15816 16699 return true; 15817 16700 } 16701 static void skyCellRowFree(skyCellRow *object); 16702 16703 skyCellRow *skyCellRowAlloc(const char *skycell_id, const char *tess_id, psF64 ra1, psF64 decl1, psF64 ra2, psF64 decl2, psF64 ra3, psF64 decl3, psF64 ra4, psF64 decl4) 16704 { 16705 skyCellRow *_object; 16706 16707 _object = psAlloc(sizeof(skyCellRow)); 16708 psMemSetDeallocator(_object, (psFreeFunc)skyCellRowFree); 16709 16710 _object->skycell_id = psStringCopy(skycell_id); 16711 _object->tess_id = psStringCopy(tess_id); 16712 _object->ra1 = ra1; 16713 _object->decl1 = decl1; 16714 _object->ra2 = ra2; 16715 _object->decl2 = decl2; 16716 _object->ra3 = ra3; 16717 _object->decl3 = decl3; 16718 _object->ra4 = ra4; 16719 _object->decl4 = decl4; 16720 16721 return _object; 16722 } 16723 16724 static void skyCellRowFree(skyCellRow *object) 16725 { 16726 psFree(object->skycell_id); 16727 psFree(object->tess_id); 16728 } 16729 16730 bool skyCellCreateTable(psDB *dbh) 16731 { 16732 psMetadata *md = psMetadataAlloc(); 16733 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, "Primary Key", "64")) { 16734 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 16735 psFree(md); 16736 return false; 16737 } 16738 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, "Primary Key", "64")) { 16739 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 16740 psFree(md); 16741 return false; 16742 } 16743 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra1", PS_DATA_F64, NULL, 0.0)) { 16744 psError(PS_ERR_UNKNOWN, false, "failed to add item ra1"); 16745 psFree(md); 16746 return false; 16747 } 16748 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl1", PS_DATA_F64, NULL, 0.0)) { 16749 psError(PS_ERR_UNKNOWN, false, "failed to add item decl1"); 16750 psFree(md); 16751 return false; 16752 } 16753 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra2", PS_DATA_F64, NULL, 0.0)) { 16754 psError(PS_ERR_UNKNOWN, false, "failed to add item ra2"); 16755 psFree(md); 16756 return false; 16757 } 16758 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl2", PS_DATA_F64, NULL, 0.0)) { 16759 psError(PS_ERR_UNKNOWN, false, "failed to add item decl2"); 16760 psFree(md); 16761 return false; 16762 } 16763 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra3", PS_DATA_F64, NULL, 0.0)) { 16764 psError(PS_ERR_UNKNOWN, false, "failed to add item ra3"); 16765 psFree(md); 16766 return false; 16767 } 16768 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl3", PS_DATA_F64, NULL, 0.0)) { 16769 psError(PS_ERR_UNKNOWN, false, "failed to add item decl3"); 16770 psFree(md); 16771 return false; 16772 } 16773 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra4", PS_DATA_F64, NULL, 0.0)) { 16774 psError(PS_ERR_UNKNOWN, false, "failed to add item ra4"); 16775 psFree(md); 16776 return false; 16777 } 16778 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl4", PS_DATA_F64, NULL, 0.0)) { 16779 psError(PS_ERR_UNKNOWN, false, "failed to add item decl4"); 16780 psFree(md); 16781 return false; 16782 } 16783 16784 bool status = psDBCreateTable(dbh, SKYCELL_TABLE_NAME, md); 16785 16786 psFree(md); 16787 16788 return status; 16789 } 16790 16791 bool skyCellDropTable(psDB *dbh) 16792 { 16793 return psDBDropTable(dbh, SKYCELL_TABLE_NAME); 16794 } 16795 16796 bool skyCellInsert(psDB * dbh, const char *skycell_id, const char *tess_id, psF64 ra1, psF64 decl1, psF64 ra2, psF64 decl2, psF64 ra3, psF64 decl3, psF64 ra4, psF64 decl4) 16797 { 16798 psMetadata *md = psMetadataAlloc(); 16799 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, skycell_id)) { 16800 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 16801 psFree(md); 16802 return false; 16803 } 16804 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, tess_id)) { 16805 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 16806 psFree(md); 16807 return false; 16808 } 16809 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra1", PS_DATA_F64, NULL, ra1)) { 16810 psError(PS_ERR_UNKNOWN, false, "failed to add item ra1"); 16811 psFree(md); 16812 return false; 16813 } 16814 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl1", PS_DATA_F64, NULL, decl1)) { 16815 psError(PS_ERR_UNKNOWN, false, "failed to add item decl1"); 16816 psFree(md); 16817 return false; 16818 } 16819 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra2", PS_DATA_F64, NULL, ra2)) { 16820 psError(PS_ERR_UNKNOWN, false, "failed to add item ra2"); 16821 psFree(md); 16822 return false; 16823 } 16824 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl2", PS_DATA_F64, NULL, decl2)) { 16825 psError(PS_ERR_UNKNOWN, false, "failed to add item decl2"); 16826 psFree(md); 16827 return false; 16828 } 16829 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra3", PS_DATA_F64, NULL, ra3)) { 16830 psError(PS_ERR_UNKNOWN, false, "failed to add item ra3"); 16831 psFree(md); 16832 return false; 16833 } 16834 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl3", PS_DATA_F64, NULL, decl3)) { 16835 psError(PS_ERR_UNKNOWN, false, "failed to add item decl3"); 16836 psFree(md); 16837 return false; 16838 } 16839 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra4", PS_DATA_F64, NULL, ra4)) { 16840 psError(PS_ERR_UNKNOWN, false, "failed to add item ra4"); 16841 psFree(md); 16842 return false; 16843 } 16844 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl4", PS_DATA_F64, NULL, decl4)) { 16845 psError(PS_ERR_UNKNOWN, false, "failed to add item decl4"); 16846 psFree(md); 16847 return false; 16848 } 16849 16850 bool status = psDBInsertOneRow(dbh, SKYCELL_TABLE_NAME, md); 16851 psFree(md); 16852 16853 return status; 16854 } 16855 16856 long long skyCellDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 16857 { 16858 long long deleted = 0; 16859 16860 long long count = psDBDeleteRows(dbh, SKYCELL_TABLE_NAME, where, limit); 16861 if (count < 0) { 16862 psError(PS_ERR_UNKNOWN, true, "failed to delete row from skyCell"); 16863 return count; 16864 16865 deleted += count; 16866 } 16867 16868 return deleted; 16869 } 16870 bool skyCellInsertObject(psDB *dbh, skyCellRow *object) 16871 { 16872 return skyCellInsert(dbh, object->skycell_id, object->tess_id, object->ra1, object->decl1, object->ra2, object->decl2, object->ra3, object->decl3, object->ra4, object->decl4); 16873 } 16874 16875 bool skyCellInsertObjects(psDB *dbh, psArray *objects) 16876 { 16877 for (long i = 0; i < psArrayLength(objects); i++) { 16878 if (!skyCellInsertObject(dbh, objects->data[i])) { 16879 return false; 16880 } 16881 } 16882 16883 return true; 16884 } 16885 16886 bool skyCellInsertFits(psDB *dbh, const psFits *fits) 16887 { 16888 psArray *rowSet; 16889 16890 // move to (the first?) extension named SKYCELL_TABLE_NAME 16891 if (!psFitsMoveExtName(fits, SKYCELL_TABLE_NAME)) { 16892 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", SKYCELL_TABLE_NAME); 16893 return false; 16894 } 16895 16896 // check HDU type 16897 if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE) { 16898 psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE"); 16899 return false; 16900 } 16901 16902 // read fits table 16903 rowSet = psFitsReadTable(fits); 16904 if (!rowSet) { 16905 psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty"); 16906 psFree(rowSet); 16907 return false; 16908 } 16909 16910 if (!psDBInsertRows(dbh, SKYCELL_TABLE_NAME, rowSet)) { 16911 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 16912 psFree(rowSet); 16913 return false; 16914 } 16915 16916 psFree(rowSet); 16917 16918 return true; 16919 } 16920 16921 bool skyCellSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 16922 { 16923 psArray *rowSet; 16924 16925 rowSet = psDBSelectRows(dbh, SKYCELL_TABLE_NAME, where, limit); 16926 if (!rowSet) { 16927 return false; 16928 } 16929 16930 // output to fits 16931 if (!psFitsWriteTable(fits, NULL, rowSet, SKYCELL_TABLE_NAME)) { 16932 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 16933 psFree(rowSet); 16934 return false; 16935 } 16936 16937 psFree(rowSet); 16938 16939 return true; 16940 } 16941 16942 psMetadata *skyCellMetadataFromObject(const skyCellRow *object) 16943 { 16944 psMetadata *md = psMetadataAlloc(); 16945 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, object->skycell_id)) { 16946 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 16947 psFree(md); 16948 return false; 16949 } 16950 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, object->tess_id)) { 16951 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 16952 psFree(md); 16953 return false; 16954 } 16955 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra1", PS_DATA_F64, NULL, object->ra1)) { 16956 psError(PS_ERR_UNKNOWN, false, "failed to add item ra1"); 16957 psFree(md); 16958 return false; 16959 } 16960 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl1", PS_DATA_F64, NULL, object->decl1)) { 16961 psError(PS_ERR_UNKNOWN, false, "failed to add item decl1"); 16962 psFree(md); 16963 return false; 16964 } 16965 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra2", PS_DATA_F64, NULL, object->ra2)) { 16966 psError(PS_ERR_UNKNOWN, false, "failed to add item ra2"); 16967 psFree(md); 16968 return false; 16969 } 16970 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl2", PS_DATA_F64, NULL, object->decl2)) { 16971 psError(PS_ERR_UNKNOWN, false, "failed to add item decl2"); 16972 psFree(md); 16973 return false; 16974 } 16975 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra3", PS_DATA_F64, NULL, object->ra3)) { 16976 psError(PS_ERR_UNKNOWN, false, "failed to add item ra3"); 16977 psFree(md); 16978 return false; 16979 } 16980 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl3", PS_DATA_F64, NULL, object->decl3)) { 16981 psError(PS_ERR_UNKNOWN, false, "failed to add item decl3"); 16982 psFree(md); 16983 return false; 16984 } 16985 if (!psMetadataAdd(md, PS_LIST_TAIL, "ra4", PS_DATA_F64, NULL, object->ra4)) { 16986 psError(PS_ERR_UNKNOWN, false, "failed to add item ra4"); 16987 psFree(md); 16988 return false; 16989 } 16990 if (!psMetadataAdd(md, PS_LIST_TAIL, "decl4", PS_DATA_F64, NULL, object->decl4)) { 16991 psError(PS_ERR_UNKNOWN, false, "failed to add item decl4"); 16992 psFree(md); 16993 return false; 16994 } 16995 16996 16997 return md; 16998 } 16999 17000 skyCellRow *skyCellObjectFromMetadata(psMetadata *md) 17001 { 17002 17003 bool status = false; 17004 char* skycell_id = psMetadataLookupPtr(&status, md, "skycell_id"); 17005 if (!status) { 17006 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item skycell_id"); 17007 return false; 17008 } 17009 char* tess_id = psMetadataLookupPtr(&status, md, "tess_id"); 17010 if (!status) { 17011 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item tess_id"); 17012 return false; 17013 } 17014 psF64 ra1 = psMetadataLookupF64(&status, md, "ra1"); 17015 if (!status) { 17016 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item ra1"); 17017 return false; 17018 } 17019 psF64 decl1 = psMetadataLookupF64(&status, md, "decl1"); 17020 if (!status) { 17021 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item decl1"); 17022 return false; 17023 } 17024 psF64 ra2 = psMetadataLookupF64(&status, md, "ra2"); 17025 if (!status) { 17026 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item ra2"); 17027 return false; 17028 } 17029 psF64 decl2 = psMetadataLookupF64(&status, md, "decl2"); 17030 if (!status) { 17031 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item decl2"); 17032 return false; 17033 } 17034 psF64 ra3 = psMetadataLookupF64(&status, md, "ra3"); 17035 if (!status) { 17036 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item ra3"); 17037 return false; 17038 } 17039 psF64 decl3 = psMetadataLookupF64(&status, md, "decl3"); 17040 if (!status) { 17041 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item decl3"); 17042 return false; 17043 } 17044 psF64 ra4 = psMetadataLookupF64(&status, md, "ra4"); 17045 if (!status) { 17046 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item ra4"); 17047 return false; 17048 } 17049 psF64 decl4 = psMetadataLookupF64(&status, md, "decl4"); 17050 if (!status) { 17051 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item decl4"); 17052 return false; 17053 } 17054 17055 return skyCellRowAlloc(skycell_id, tess_id, ra1, decl1, ra2, decl2, ra3, decl3, ra4, decl4); 17056 } 17057 psArray *skyCellSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 17058 { 17059 psArray *rowSet; 17060 psArray *returnSet; 17061 psU64 i; 17062 17063 rowSet = psDBSelectRows(dbh, SKYCELL_TABLE_NAME, where, limit); 17064 if (!rowSet) { 17065 return NULL; 17066 } 17067 17068 // convert psMetadata rows to row objects 17069 17070 returnSet = psArrayAllocEmpty(rowSet->n); 17071 17072 for (i = 0; i < rowSet->n; i++) { 17073 skyCellRow *object = skyCellObjectFromMetadata(rowSet->data[i]); 17074 psArrayAdd(returnSet, 0, object); 17075 psFree(object); 17076 } 17077 17078 psFree(rowSet); 17079 17080 return returnSet; 17081 } 17082 bool skyCellDeleteObject(psDB *dbh, const skyCellRow *object) 17083 { 17084 psMetadata *where = skyCellMetadataFromObject(object); 17085 long long count = psDBDeleteRows(dbh, SKYCELL_TABLE_NAME, where, 0); 17086 psFree(where); 17087 if (count < 0) { 17088 psError(PS_ERR_UNKNOWN, true, "failed to delete row from skyCell"); 17089 return false; 17090 } 17091 if (count > 1) { 17092 // XXX should this be a psAbort() instead? It is possible that 17093 // having an object match multiple rows was by design. 17094 psError(PS_ERR_UNKNOWN, true, "skyCellRow object matched more then one row. Check your database schema"); 17095 return false; 17096 } 17097 17098 return true; 17099 } 17100 long long skyCellDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 17101 { 17102 long long deleted = 0; 17103 17104 for (long long i = 0; i < objects->n; i++) { 17105 skyCellRow *object = objects->data[i]; 17106 psMetadata *where = skyCellMetadataFromObject(object); 17107 long long count = psDBDeleteRows(dbh, SKYCELL_TABLE_NAME, where, limit); 17108 psFree(where); 17109 if (count < 0) { 17110 psError(PS_ERR_UNKNOWN, true, "failed to delete row from skyCell"); 17111 return count; 17112 } 17113 17114 deleted += count; 17115 } 17116 17117 return deleted; 17118 } 17119 bool skyCellPrintObjects(FILE *stream, psArray *objects, bool mdcf) 17120 { 17121 PS_ASSERT_PTR_NON_NULL(objects, false); 17122 17123 psMetadata *output = psMetadataAlloc(); 17124 for (long i = 0; i < psArrayLength(objects); i++) { 17125 psMetadata *md = skyCellMetadataFromObject(objects->data[i]); 17126 if (!psMetadataAddMetadata( 17127 output, 17128 PS_LIST_TAIL, 17129 SKYCELL_TABLE_NAME, 17130 PS_META_DUPLICATE_OK, 17131 NULL, 17132 md 17133 )) { 17134 psError(PS_ERR_UNKNOWN, false, "failed to add metadata"); 17135 psFree(md); 17136 psFree(output); 17137 return false; 17138 } 17139 psFree(md); 17140 } 17141 17142 if (!ippdbPrintMetadataRaw(stream, output, mdcf)) { 17143 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 17144 psFree(output); 17145 } 17146 psFree(output); 17147 17148 return true; 17149 } 17150 bool skyCellPrintObject(FILE *stream, skyCellRow *object, bool mdcf) 17151 { 17152 PS_ASSERT_PTR_NON_NULL(object, false); 17153 17154 psMetadata *md = skyCellMetadataFromObject(object); 17155 17156 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { 17157 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 17158 psFree(md); 17159 } 17160 17161 psFree(md); 17162 17163 return true; 17164 } 17165 static void skyCellMapRowFree(skyCellMapRow *object); 17166 17167 skyCellMapRow *skyCellMapRowAlloc(const char *skycell_id, const char *tess_id, const char *exp_tag, const char *class_id) 17168 { 17169 skyCellMapRow *_object; 17170 17171 _object = psAlloc(sizeof(skyCellMapRow)); 17172 psMemSetDeallocator(_object, (psFreeFunc)skyCellMapRowFree); 17173 17174 _object->skycell_id = psStringCopy(skycell_id); 17175 _object->tess_id = psStringCopy(tess_id); 17176 _object->exp_tag = psStringCopy(exp_tag); 17177 _object->class_id = psStringCopy(class_id); 17178 17179 return _object; 17180 } 17181 17182 static void skyCellMapRowFree(skyCellMapRow *object) 17183 { 17184 psFree(object->skycell_id); 17185 psFree(object->tess_id); 17186 psFree(object->exp_tag); 17187 psFree(object->class_id); 17188 } 17189 17190 bool skyCellMapCreateTable(psDB *dbh) 17191 { 17192 psMetadata *md = psMetadataAlloc(); 17193 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, "Primary Key", "64")) { 17194 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 17195 psFree(md); 17196 return false; 17197 } 17198 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, "Primary Key", "64")) { 17199 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 17200 psFree(md); 17201 return false; 17202 } 17203 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, "Primary Key", "64")) { 17204 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 17205 psFree(md); 17206 return false; 17207 } 17208 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, "Primary Key", "64")) { 17209 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 17210 psFree(md); 17211 return false; 17212 } 17213 17214 bool status = psDBCreateTable(dbh, SKYCELLMAP_TABLE_NAME, md); 17215 17216 psFree(md); 17217 17218 return status; 17219 } 17220 17221 bool skyCellMapDropTable(psDB *dbh) 17222 { 17223 return psDBDropTable(dbh, SKYCELLMAP_TABLE_NAME); 17224 } 17225 17226 bool skyCellMapInsert(psDB * dbh, const char *skycell_id, const char *tess_id, const char *exp_tag, const char *class_id) 17227 { 17228 psMetadata *md = psMetadataAlloc(); 17229 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, skycell_id)) { 17230 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 17231 psFree(md); 17232 return false; 17233 } 17234 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, tess_id)) { 17235 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 17236 psFree(md); 17237 return false; 17238 } 17239 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, exp_tag)) { 17240 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 17241 psFree(md); 17242 return false; 17243 } 17244 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, class_id)) { 17245 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 17246 psFree(md); 17247 return false; 17248 } 17249 17250 bool status = psDBInsertOneRow(dbh, SKYCELLMAP_TABLE_NAME, md); 17251 psFree(md); 17252 17253 return status; 17254 } 17255 17256 long long skyCellMapDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 17257 { 17258 long long deleted = 0; 17259 17260 long long count = psDBDeleteRows(dbh, SKYCELLMAP_TABLE_NAME, where, limit); 17261 if (count < 0) { 17262 psError(PS_ERR_UNKNOWN, true, "failed to delete row from skyCellMap"); 17263 return count; 17264 17265 deleted += count; 17266 } 17267 17268 return deleted; 17269 } 17270 bool skyCellMapInsertObject(psDB *dbh, skyCellMapRow *object) 17271 { 17272 return skyCellMapInsert(dbh, object->skycell_id, object->tess_id, object->exp_tag, object->class_id); 17273 } 17274 17275 bool skyCellMapInsertObjects(psDB *dbh, psArray *objects) 17276 { 17277 for (long i = 0; i < psArrayLength(objects); i++) { 17278 if (!skyCellMapInsertObject(dbh, objects->data[i])) { 17279 return false; 17280 } 17281 } 17282 17283 return true; 17284 } 17285 17286 bool skyCellMapInsertFits(psDB *dbh, const psFits *fits) 17287 { 17288 psArray *rowSet; 17289 17290 // move to (the first?) extension named SKYCELLMAP_TABLE_NAME 17291 if (!psFitsMoveExtName(fits, SKYCELLMAP_TABLE_NAME)) { 17292 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", SKYCELLMAP_TABLE_NAME); 17293 return false; 17294 } 17295 17296 // check HDU type 17297 if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE) { 17298 psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE"); 17299 return false; 17300 } 17301 17302 // read fits table 17303 rowSet = psFitsReadTable(fits); 17304 if (!rowSet) { 17305 psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty"); 17306 psFree(rowSet); 17307 return false; 17308 } 17309 17310 if (!psDBInsertRows(dbh, SKYCELLMAP_TABLE_NAME, rowSet)) { 17311 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 17312 psFree(rowSet); 17313 return false; 17314 } 17315 17316 psFree(rowSet); 17317 17318 return true; 17319 } 17320 17321 bool skyCellMapSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 17322 { 17323 psArray *rowSet; 17324 17325 rowSet = psDBSelectRows(dbh, SKYCELLMAP_TABLE_NAME, where, limit); 17326 if (!rowSet) { 17327 return false; 17328 } 17329 17330 // output to fits 17331 if (!psFitsWriteTable(fits, NULL, rowSet, SKYCELLMAP_TABLE_NAME)) { 17332 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 17333 psFree(rowSet); 17334 return false; 17335 } 17336 17337 psFree(rowSet); 17338 17339 return true; 17340 } 17341 17342 psMetadata *skyCellMapMetadataFromObject(const skyCellMapRow *object) 17343 { 17344 psMetadata *md = psMetadataAlloc(); 17345 if (!psMetadataAdd(md, PS_LIST_TAIL, "skycell_id", PS_DATA_STRING, NULL, object->skycell_id)) { 17346 psError(PS_ERR_UNKNOWN, false, "failed to add item skycell_id"); 17347 psFree(md); 17348 return false; 17349 } 17350 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, object->tess_id)) { 17351 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 17352 psFree(md); 17353 return false; 17354 } 17355 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, object->exp_tag)) { 17356 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 17357 psFree(md); 17358 return false; 17359 } 17360 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, object->class_id)) { 17361 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 17362 psFree(md); 17363 return false; 17364 } 17365 17366 17367 return md; 17368 } 17369 17370 skyCellMapRow *skyCellMapObjectFromMetadata(psMetadata *md) 17371 { 17372 17373 bool status = false; 17374 char* skycell_id = psMetadataLookupPtr(&status, md, "skycell_id"); 17375 if (!status) { 17376 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item skycell_id"); 17377 return false; 17378 } 17379 char* tess_id = psMetadataLookupPtr(&status, md, "tess_id"); 17380 if (!status) { 17381 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item tess_id"); 17382 return false; 17383 } 17384 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag"); 17385 if (!status) { 17386 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag"); 17387 return false; 17388 } 17389 char* class_id = psMetadataLookupPtr(&status, md, "class_id"); 17390 if (!status) { 17391 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id"); 17392 return false; 17393 } 17394 17395 return skyCellMapRowAlloc(skycell_id, tess_id, exp_tag, class_id); 17396 } 17397 psArray *skyCellMapSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 17398 { 17399 psArray *rowSet; 17400 psArray *returnSet; 17401 psU64 i; 17402 17403 rowSet = psDBSelectRows(dbh, SKYCELLMAP_TABLE_NAME, where, limit); 17404 if (!rowSet) { 17405 return NULL; 17406 } 17407 17408 // convert psMetadata rows to row objects 17409 17410 returnSet = psArrayAllocEmpty(rowSet->n); 17411 17412 for (i = 0; i < rowSet->n; i++) { 17413 skyCellMapRow *object = skyCellMapObjectFromMetadata(rowSet->data[i]); 17414 psArrayAdd(returnSet, 0, object); 17415 psFree(object); 17416 } 17417 17418 psFree(rowSet); 17419 17420 return returnSet; 17421 } 17422 bool skyCellMapDeleteObject(psDB *dbh, const skyCellMapRow *object) 17423 { 17424 psMetadata *where = skyCellMapMetadataFromObject(object); 17425 long long count = psDBDeleteRows(dbh, SKYCELLMAP_TABLE_NAME, where, 0); 17426 psFree(where); 17427 if (count < 0) { 17428 psError(PS_ERR_UNKNOWN, true, "failed to delete row from skyCellMap"); 17429 return false; 17430 } 17431 if (count > 1) { 17432 // XXX should this be a psAbort() instead? It is possible that 17433 // having an object match multiple rows was by design. 17434 psError(PS_ERR_UNKNOWN, true, "skyCellMapRow object matched more then one row. Check your database schema"); 17435 return false; 17436 } 17437 17438 return true; 17439 } 17440 long long skyCellMapDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 17441 { 17442 long long deleted = 0; 17443 17444 for (long long i = 0; i < objects->n; i++) { 17445 skyCellMapRow *object = objects->data[i]; 17446 psMetadata *where = skyCellMapMetadataFromObject(object); 17447 long long count = psDBDeleteRows(dbh, SKYCELLMAP_TABLE_NAME, where, limit); 17448 psFree(where); 17449 if (count < 0) { 17450 psError(PS_ERR_UNKNOWN, true, "failed to delete row from skyCellMap"); 17451 return count; 17452 } 17453 17454 deleted += count; 17455 } 17456 17457 return deleted; 17458 } 17459 bool skyCellMapPrintObjects(FILE *stream, psArray *objects, bool mdcf) 17460 { 17461 PS_ASSERT_PTR_NON_NULL(objects, false); 17462 17463 psMetadata *output = psMetadataAlloc(); 17464 for (long i = 0; i < psArrayLength(objects); i++) { 17465 psMetadata *md = skyCellMapMetadataFromObject(objects->data[i]); 17466 if (!psMetadataAddMetadata( 17467 output, 17468 PS_LIST_TAIL, 17469 SKYCELLMAP_TABLE_NAME, 17470 PS_META_DUPLICATE_OK, 17471 NULL, 17472 md 17473 )) { 17474 psError(PS_ERR_UNKNOWN, false, "failed to add metadata"); 17475 psFree(md); 17476 psFree(output); 17477 return false; 17478 } 17479 psFree(md); 17480 } 17481 17482 if (!ippdbPrintMetadataRaw(stream, output, mdcf)) { 17483 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 17484 psFree(output); 17485 } 17486 psFree(output); 17487 17488 return true; 17489 } 17490 bool skyCellMapPrintObject(FILE *stream, skyCellMapRow *object, bool mdcf) 17491 { 17492 PS_ASSERT_PTR_NON_NULL(object, false); 17493 17494 psMetadata *md = skyCellMapMetadataFromObject(object); 17495 17496 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { 17497 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 17498 psFree(md); 17499 } 17500 17501 psFree(md); 17502 17503 return true; 17504 } -
trunk/ippdb/src/ippdb.h
r11635 r11679 20 20 /* 21 21 * 22 * This file was generated by glueforge 1.0022 * This file was generated by glueforge 0.36 23 23 * 24 24 * Do NOT directly edit this file. … … 6830 6830 bool mdcf ///< format as mdconfig or simple 6831 6831 ); 6832 /** p4 RunRow data structure6833 * 6834 * Structure for representing a single row of p4 Run table data.6832 /** p4aRunRow data structure 6833 * 6834 * Structure for representing a single row of p4aRun table data. 6835 6835 */ 6836 6836 6837 6837 typedef struct { 6838 psS32 p4_id; 6839 char *survey_mode; 6838 psS32 p4a_id; 6840 6839 char *state; 6841 6840 char *workdir; 6842 char *filter; 6843 char *skycell_id; 6844 char *tess_id; 6845 psF64 ra; 6846 psF64 decl; 6847 char *input_ss; 6848 char *output_ss; 6849 } p4RunRow; 6850 6851 /** Creates a new p4RunRow object 6852 * 6853 * @return A new p4RunRow object or NULL on failure. 6854 */ 6855 6856 p4RunRow *p4RunRowAlloc( 6857 psS32 p4_id, 6858 const char *survey_mode, 6841 bool magic; 6842 } p4aRunRow; 6843 6844 /** Creates a new p4aRunRow object 6845 * 6846 * @return A new p4aRunRow object or NULL on failure. 6847 */ 6848 6849 p4aRunRow *p4aRunRowAlloc( 6850 psS32 p4a_id, 6859 6851 const char *state, 6860 6852 const char *workdir, 6861 const char *filter, 6862 const char *skycell_id, 6863 const char *tess_id, 6864 psF64 ra, 6865 psF64 decl, 6866 const char *input_ss, 6867 const char *output_ss 6868 ); 6869 6870 /** Creates a new p4Run table 6871 * 6872 * @return true on success 6873 */ 6874 6875 bool p4RunCreateTable( 6853 bool magic 6854 ); 6855 6856 /** Creates a new p4aRun table 6857 * 6858 * @return true on success 6859 */ 6860 6861 bool p4aRunCreateTable( 6876 6862 psDB *dbh ///< Database handle 6877 6863 ); 6878 6864 6879 /** Deletes a p4 Run table6880 * 6881 * @return true on success 6882 */ 6883 6884 bool p4 RunDropTable(6865 /** Deletes a p4aRun table 6866 * 6867 * @return true on success 6868 */ 6869 6870 bool p4aRunDropTable( 6885 6871 psDB *dbh ///< Database handle 6886 6872 ); … … 6893 6879 */ 6894 6880 6895 bool p4RunInsert( 6896 psDB *dbh, ///< Database handle 6897 psS32 p4_id, 6898 const char *survey_mode, 6881 bool p4aRunInsert( 6882 psDB *dbh, ///< Database handle 6883 psS32 p4a_id, 6899 6884 const char *state, 6900 6885 const char *workdir, 6901 const char *filter, 6902 const char *skycell_id, 6903 const char *tess_id, 6904 psF64 ra, 6905 psF64 decl, 6906 const char *input_ss, 6907 const char *output_ss 6886 bool magic 6908 6887 ); 6909 6888 … … 6913 6892 */ 6914 6893 6915 long long p4 RunDelete(6894 long long p4aRunDelete( 6916 6895 psDB *dbh, ///< Database handle 6917 6896 const psMetadata *where, ///< Row match criteria … … 6919 6898 ); 6920 6899 6921 /** Insert a single p4 RunRow object into a table6900 /** Insert a single p4aRunRow object into a table 6922 6901 * 6923 6902 * This function constructs and inserts a single row based on it's parameters. … … 6926 6905 */ 6927 6906 6928 bool p4 RunInsertObject(6929 psDB *dbh, ///< Database handle 6930 p4 RunRow *object ///< p4RunRow object6931 ); 6932 6933 /** Insert an array of p4 RunRow object into a table6907 bool p4aRunInsertObject( 6908 psDB *dbh, ///< Database handle 6909 p4aRunRow *object ///< p4aRunRow object 6910 ); 6911 6912 /** Insert an array of p4aRunRow object into a table 6934 6913 * 6935 6914 * This function constructs and inserts multiple rows based on it's parameters. … … 6938 6917 */ 6939 6918 6940 bool p4 RunInsertObjects(6941 psDB *dbh, ///< Database handle 6942 psArray *objects ///< array of p4 RunRow objects6943 ); 6944 6945 /** Insert data from a binary FITS table p4 RunRow into the database6919 bool p4aRunInsertObjects( 6920 psDB *dbh, ///< Database handle 6921 psArray *objects ///< array of p4aRunRow objects 6922 ); 6923 6924 /** Insert data from a binary FITS table p4aRunRow into the database 6946 6925 * 6947 6926 * This function expects a psFits object with a FITS table as the first … … 6953 6932 */ 6954 6933 6955 bool p4 RunInsertFits(6934 bool p4aRunInsertFits( 6956 6935 psDB *dbh, ///< Database handle 6957 6936 const psFits *fits ///< psFits object … … 6968 6947 */ 6969 6948 6970 bool p4 RunSelectRowsFits(6949 bool p4aRunSelectRowsFits( 6971 6950 psDB *dbh, ///< Database handle 6972 6951 psFits *fits, ///< psFits object … … 6975 6954 ); 6976 6955 6977 /** Convert a p4 RunRow into an equivalent psMetadata6956 /** Convert a p4aRunRow into an equivalent psMetadata 6978 6957 * 6979 6958 * @return A psMetadata pointer or NULL on error 6980 6959 */ 6981 6960 6982 psMetadata *p4 RunMetadataFromObject(6983 const p4 RunRow*object ///< fooRow to convert into a psMetadata6961 psMetadata *p4aRunMetadataFromObject( 6962 const p4aRunRow *object ///< fooRow to convert into a psMetadata 6984 6963 ); 6985 6964 6986 6965 /** Convert a psMetadata into an equivalent fooRow 6987 6966 * 6988 * @return A p4 RunRow pointer or NULL on error6989 */ 6990 6991 p4 RunRow *p4RunObjectFromMetadata(6967 * @return A p4aRunRow pointer or NULL on error 6968 */ 6969 6970 p4aRunRow *p4aRunObjectFromMetadata( 6992 6971 psMetadata *md ///< psMetadata to convert into a fooRow 6993 6972 ); 6994 /** Selects up to limit rows from the database and returns as p4 RunRow objects in a psArray6973 /** Selects up to limit rows from the database and returns as p4aRunRow objects in a psArray 6995 6974 * 6996 6975 * See psDBSelectRows() for documentation on the format of where. … … 6999 6978 */ 7000 6979 7001 psArray *p4 RunSelectRowObjects(6980 psArray *p4aRunSelectRowObjects( 7002 6981 psDB *dbh, ///< Database handle 7003 6982 const psMetadata *where, ///< Row match criteria 7004 6983 unsigned long long limit ///< Maximum number of elements to return 7005 6984 ); 7006 /** Deletes a row from the database coresponding to an p4 Run6985 /** Deletes a row from the database coresponding to an p4aRun 7007 6986 * 7008 6987 * Note that a 'where' search psMetadata is constructed from each object and … … 7012 6991 */ 7013 6992 7014 bool p4 RunDeleteObject(7015 psDB *dbh, ///< Database handle 7016 const p4 RunRow *object ///< Object to delete6993 bool p4aRunDeleteObject( 6994 psDB *dbh, ///< Database handle 6995 const p4aRunRow *object ///< Object to delete 7017 6996 ); 7018 6997 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. … … 7024 7003 */ 7025 7004 7026 long long p4 RunDeleteRowObjects(7005 long long p4aRunDeleteRowObjects( 7027 7006 psDB *dbh, ///< Database handle 7028 7007 const psArray *objects, ///< Array of objects to delete 7029 7008 unsigned long long limit ///< Maximum number of elements to delete 7030 7009 ); 7031 /** Formats and prints an array of p4 RunRow objects7010 /** Formats and prints an array of p4aRunRow objects 7032 7011 * 7033 7012 * When mdcf is set the formated output is in psMetadataConfig … … 7037 7016 */ 7038 7017 7039 bool p4 RunPrintObjects(7018 bool p4aRunPrintObjects( 7040 7019 FILE *stream, ///< a stream 7041 psArray *objects, ///< An array of p4 RunRow objects7020 psArray *objects, ///< An array of p4aRunRow objects 7042 7021 bool mdcf ///< format as mdconfig or simple 7043 7022 ); 7044 /** Formats and prints an p4 RunRow object7023 /** Formats and prints an p4aRunRow object 7045 7024 * 7046 7025 * When mdcf is set the formated output is in psMetadataConfig … … 7050 7029 */ 7051 7030 7052 bool p4 RunPrintObject(7031 bool p4aRunPrintObject( 7053 7032 FILE *stream, ///< a stream 7054 p4 RunRow *object, ///< an p4RunRow object7033 p4aRunRow *object, ///< an p4aRunRow object 7055 7034 bool mdcf ///< format as mdconfig or simple 7056 7035 ); 7057 /** p4 InputImfileRow data structure7058 * 7059 * Structure for representing a single row of p4 InputImfiletable data.7036 /** p4aInputExpRow data structure 7037 * 7038 * Structure for representing a single row of p4aInputExp table data. 7060 7039 */ 7061 7040 7062 7041 typedef struct { 7063 psS32 p4 _id;7042 psS32 p4a_id; 7064 7043 char *exp_tag; 7065 7044 psS32 p3_version; 7066 char *class_id; 7067 } p4InputImfileRow; 7068 7069 /** Creates a new p4InputImfileRow object 7070 * 7071 * @return A new p4InputImfileRow object or NULL on failure. 7072 */ 7073 7074 p4InputImfileRow *p4InputImfileRowAlloc( 7075 psS32 p4_id, 7045 } p4aInputExpRow; 7046 7047 /** Creates a new p4aInputExpRow object 7048 * 7049 * @return A new p4aInputExpRow object or NULL on failure. 7050 */ 7051 7052 p4aInputExpRow *p4aInputExpRowAlloc( 7053 psS32 p4a_id, 7076 7054 const char *exp_tag, 7077 psS32 p3_version, 7078 const char *class_id 7079 ); 7080 7081 /** Creates a new p4InputImfile table 7082 * 7083 * @return true on success 7084 */ 7085 7086 bool p4InputImfileCreateTable( 7055 psS32 p3_version 7056 ); 7057 7058 /** Creates a new p4aInputExp table 7059 * 7060 * @return true on success 7061 */ 7062 7063 bool p4aInputExpCreateTable( 7087 7064 psDB *dbh ///< Database handle 7088 7065 ); 7089 7066 7090 /** Deletes a p4 InputImfiletable7091 * 7092 * @return true on success 7093 */ 7094 7095 bool p4 InputImfileDropTable(7067 /** Deletes a p4aInputExp table 7068 * 7069 * @return true on success 7070 */ 7071 7072 bool p4aInputExpDropTable( 7096 7073 psDB *dbh ///< Database handle 7097 7074 ); … … 7104 7081 */ 7105 7082 7106 bool p4 InputImfileInsert(7107 psDB *dbh, ///< Database handle 7108 psS32 p4 _id,7083 bool p4aInputExpInsert( 7084 psDB *dbh, ///< Database handle 7085 psS32 p4a_id, 7109 7086 const char *exp_tag, 7110 psS32 p3_version, 7111 const char *class_id 7087 psS32 p3_version 7112 7088 ); 7113 7089 … … 7117 7093 */ 7118 7094 7119 long long p4 InputImfileDelete(7095 long long p4aInputExpDelete( 7120 7096 psDB *dbh, ///< Database handle 7121 7097 const psMetadata *where, ///< Row match criteria … … 7123 7099 ); 7124 7100 7125 /** Insert a single p4 InputImfileRow object into a table7101 /** Insert a single p4aInputExpRow object into a table 7126 7102 * 7127 7103 * This function constructs and inserts a single row based on it's parameters. … … 7130 7106 */ 7131 7107 7132 bool p4 InputImfileInsertObject(7133 psDB *dbh, ///< Database handle 7134 p4 InputImfileRow *object ///< p4InputImfileRow object7135 ); 7136 7137 /** Insert an array of p4 InputImfileRow object into a table7108 bool p4aInputExpInsertObject( 7109 psDB *dbh, ///< Database handle 7110 p4aInputExpRow *object ///< p4aInputExpRow object 7111 ); 7112 7113 /** Insert an array of p4aInputExpRow object into a table 7138 7114 * 7139 7115 * This function constructs and inserts multiple rows based on it's parameters. … … 7142 7118 */ 7143 7119 7144 bool p4 InputImfileInsertObjects(7145 psDB *dbh, ///< Database handle 7146 psArray *objects ///< array of p4 InputImfileRow objects7147 ); 7148 7149 /** Insert data from a binary FITS table p4 InputImfileRow into the database7120 bool p4aInputExpInsertObjects( 7121 psDB *dbh, ///< Database handle 7122 psArray *objects ///< array of p4aInputExpRow objects 7123 ); 7124 7125 /** Insert data from a binary FITS table p4aInputExpRow into the database 7150 7126 * 7151 7127 * This function expects a psFits object with a FITS table as the first … … 7157 7133 */ 7158 7134 7159 bool p4 InputImfileInsertFits(7135 bool p4aInputExpInsertFits( 7160 7136 psDB *dbh, ///< Database handle 7161 7137 const psFits *fits ///< psFits object … … 7172 7148 */ 7173 7149 7174 bool p4 InputImfileSelectRowsFits(7150 bool p4aInputExpSelectRowsFits( 7175 7151 psDB *dbh, ///< Database handle 7176 7152 psFits *fits, ///< psFits object … … 7179 7155 ); 7180 7156 7181 /** Convert a p4 InputImfileRow into an equivalent psMetadata7157 /** Convert a p4aInputExpRow into an equivalent psMetadata 7182 7158 * 7183 7159 * @return A psMetadata pointer or NULL on error 7184 7160 */ 7185 7161 7186 psMetadata *p4 InputImfileMetadataFromObject(7187 const p4 InputImfileRow *object ///< fooRow to convert into a psMetadata7162 psMetadata *p4aInputExpMetadataFromObject( 7163 const p4aInputExpRow *object ///< fooRow to convert into a psMetadata 7188 7164 ); 7189 7165 7190 7166 /** Convert a psMetadata into an equivalent fooRow 7191 7167 * 7192 * @return A p4 InputImfileRow pointer or NULL on error7193 */ 7194 7195 p4 InputImfileRow *p4InputImfileObjectFromMetadata(7168 * @return A p4aInputExpRow pointer or NULL on error 7169 */ 7170 7171 p4aInputExpRow *p4aInputExpObjectFromMetadata( 7196 7172 psMetadata *md ///< psMetadata to convert into a fooRow 7197 7173 ); 7198 /** Selects up to limit rows from the database and returns as p4 InputImfileRow objects in a psArray7174 /** Selects up to limit rows from the database and returns as p4aInputExpRow objects in a psArray 7199 7175 * 7200 7176 * See psDBSelectRows() for documentation on the format of where. … … 7203 7179 */ 7204 7180 7205 psArray *p4 InputImfileSelectRowObjects(7181 psArray *p4aInputExpSelectRowObjects( 7206 7182 psDB *dbh, ///< Database handle 7207 7183 const psMetadata *where, ///< Row match criteria 7208 7184 unsigned long long limit ///< Maximum number of elements to return 7209 7185 ); 7210 /** Deletes a row from the database coresponding to an p4 InputImfile7186 /** Deletes a row from the database coresponding to an p4aInputExp 7211 7187 * 7212 7188 * Note that a 'where' search psMetadata is constructed from each object and … … 7216 7192 */ 7217 7193 7218 bool p4 InputImfileDeleteObject(7219 psDB *dbh, ///< Database handle 7220 const p4 InputImfileRow *object ///< Object to delete7194 bool p4aInputExpDeleteObject( 7195 psDB *dbh, ///< Database handle 7196 const p4aInputExpRow *object ///< Object to delete 7221 7197 ); 7222 7198 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. … … 7228 7204 */ 7229 7205 7230 long long p4 InputImfileDeleteRowObjects(7206 long long p4aInputExpDeleteRowObjects( 7231 7207 psDB *dbh, ///< Database handle 7232 7208 const psArray *objects, ///< Array of objects to delete 7233 7209 unsigned long long limit ///< Maximum number of elements to delete 7234 7210 ); 7235 /** Formats and prints an array of p4 InputImfileRow objects7211 /** Formats and prints an array of p4aInputExpRow objects 7236 7212 * 7237 7213 * When mdcf is set the formated output is in psMetadataConfig … … 7241 7217 */ 7242 7218 7243 bool p4 InputImfilePrintObjects(7219 bool p4aInputExpPrintObjects( 7244 7220 FILE *stream, ///< a stream 7245 psArray *objects, ///< An array of p4 InputImfileRow objects7221 psArray *objects, ///< An array of p4aInputExpRow objects 7246 7222 bool mdcf ///< format as mdconfig or simple 7247 7223 ); 7248 /** Formats and prints an p4 InputImfileRow object7224 /** Formats and prints an p4aInputExpRow object 7249 7225 * 7250 7226 * When mdcf is set the formated output is in psMetadataConfig … … 7254 7230 */ 7255 7231 7256 bool p4 InputImfilePrintObject(7232 bool p4aInputExpPrintObject( 7257 7233 FILE *stream, ///< a stream 7258 p4 InputImfileRow *object, ///< an p4InputImfileRow object7234 p4aInputExpRow *object, ///< an p4aInputExpRow object 7259 7235 bool mdcf ///< format as mdconfig or simple 7260 7236 ); 7261 /** p4 WarpedImfileRow data structure7262 * 7263 * Structure for representing a single row of p4 WarpedImfile table data.7237 /** p4aScfileRow data structure 7238 * 7239 * Structure for representing a single row of p4aScfile table data. 7264 7240 */ 7265 7241 7266 7242 typedef struct { 7267 psS32 p4_id; 7243 psS32 p4a_id; 7244 char *skycell_id; 7245 char *tess_id; 7268 7246 char *exp_tag; 7269 7247 psS32 p3_version; 7270 char *class_id;7271 7248 char *uri; 7272 char *b1_uri; 7273 char *b2_uri; 7274 } p4WarpedImfileRow; 7275 7276 /** Creates a new p4WarpedImfileRow object 7277 * 7278 * @return A new p4WarpedImfileRow object or NULL on failure. 7279 */ 7280 7281 p4WarpedImfileRow *p4WarpedImfileRowAlloc( 7282 psS32 p4_id, 7249 psF64 bg; 7250 psF64 bg_mean_stdev; 7251 } p4aScfileRow; 7252 7253 /** Creates a new p4aScfileRow object 7254 * 7255 * @return A new p4aScfileRow object or NULL on failure. 7256 */ 7257 7258 p4aScfileRow *p4aScfileRowAlloc( 7259 psS32 p4a_id, 7260 const char *skycell_id, 7261 const char *tess_id, 7283 7262 const char *exp_tag, 7284 7263 psS32 p3_version, 7285 const char *class_id,7286 7264 const char *uri, 7287 const char *b1_uri,7288 const char *b2_uri7289 ); 7290 7291 /** Creates a new p4 WarpedImfile table7292 * 7293 * @return true on success 7294 */ 7295 7296 bool p4 WarpedImfileCreateTable(7265 psF64 bg, 7266 psF64 bg_mean_stdev 7267 ); 7268 7269 /** Creates a new p4aScfile table 7270 * 7271 * @return true on success 7272 */ 7273 7274 bool p4aScfileCreateTable( 7297 7275 psDB *dbh ///< Database handle 7298 7276 ); 7299 7277 7300 /** Deletes a p4 WarpedImfile table7301 * 7302 * @return true on success 7303 */ 7304 7305 bool p4 WarpedImfileDropTable(7278 /** Deletes a p4aScfile table 7279 * 7280 * @return true on success 7281 */ 7282 7283 bool p4aScfileDropTable( 7306 7284 psDB *dbh ///< Database handle 7307 7285 ); … … 7314 7292 */ 7315 7293 7316 bool p4WarpedImfileInsert( 7317 psDB *dbh, ///< Database handle 7318 psS32 p4_id, 7294 bool p4aScfileInsert( 7295 psDB *dbh, ///< Database handle 7296 psS32 p4a_id, 7297 const char *skycell_id, 7298 const char *tess_id, 7319 7299 const char *exp_tag, 7320 7300 psS32 p3_version, 7321 const char *class_id,7322 7301 const char *uri, 7323 const char *b1_uri,7324 const char *b2_uri7302 psF64 bg, 7303 psF64 bg_mean_stdev 7325 7304 ); 7326 7305 … … 7330 7309 */ 7331 7310 7332 long long p4 WarpedImfileDelete(7311 long long p4aScfileDelete( 7333 7312 psDB *dbh, ///< Database handle 7334 7313 const psMetadata *where, ///< Row match criteria … … 7336 7315 ); 7337 7316 7338 /** Insert a single p4 WarpedImfileRow object into a table7317 /** Insert a single p4aScfileRow object into a table 7339 7318 * 7340 7319 * This function constructs and inserts a single row based on it's parameters. … … 7343 7322 */ 7344 7323 7345 bool p4 WarpedImfileInsertObject(7346 psDB *dbh, ///< Database handle 7347 p4 WarpedImfileRow *object ///< p4WarpedImfileRow object7348 ); 7349 7350 /** Insert an array of p4 WarpedImfileRow object into a table7324 bool p4aScfileInsertObject( 7325 psDB *dbh, ///< Database handle 7326 p4aScfileRow *object ///< p4aScfileRow object 7327 ); 7328 7329 /** Insert an array of p4aScfileRow object into a table 7351 7330 * 7352 7331 * This function constructs and inserts multiple rows based on it's parameters. … … 7355 7334 */ 7356 7335 7357 bool p4 WarpedImfileInsertObjects(7358 psDB *dbh, ///< Database handle 7359 psArray *objects ///< array of p4 WarpedImfileRow objects7360 ); 7361 7362 /** Insert data from a binary FITS table p4 WarpedImfileRow into the database7336 bool p4aScfileInsertObjects( 7337 psDB *dbh, ///< Database handle 7338 psArray *objects ///< array of p4aScfileRow objects 7339 ); 7340 7341 /** Insert data from a binary FITS table p4aScfileRow into the database 7363 7342 * 7364 7343 * This function expects a psFits object with a FITS table as the first … … 7370 7349 */ 7371 7350 7372 bool p4 WarpedImfileInsertFits(7351 bool p4aScfileInsertFits( 7373 7352 psDB *dbh, ///< Database handle 7374 7353 const psFits *fits ///< psFits object … … 7385 7364 */ 7386 7365 7387 bool p4 WarpedImfileSelectRowsFits(7366 bool p4aScfileSelectRowsFits( 7388 7367 psDB *dbh, ///< Database handle 7389 7368 psFits *fits, ///< psFits object … … 7392 7371 ); 7393 7372 7394 /** Convert a p4 WarpedImfileRow into an equivalent psMetadata7373 /** Convert a p4aScfileRow into an equivalent psMetadata 7395 7374 * 7396 7375 * @return A psMetadata pointer or NULL on error 7397 7376 */ 7398 7377 7399 psMetadata *p4 WarpedImfileMetadataFromObject(7400 const p4 WarpedImfileRow *object ///< fooRow to convert into a psMetadata7378 psMetadata *p4aScfileMetadataFromObject( 7379 const p4aScfileRow *object ///< fooRow to convert into a psMetadata 7401 7380 ); 7402 7381 7403 7382 /** Convert a psMetadata into an equivalent fooRow 7404 7383 * 7405 * @return A p4 WarpedImfileRow pointer or NULL on error7406 */ 7407 7408 p4 WarpedImfileRow *p4WarpedImfileObjectFromMetadata(7384 * @return A p4aScfileRow pointer or NULL on error 7385 */ 7386 7387 p4aScfileRow *p4aScfileObjectFromMetadata( 7409 7388 psMetadata *md ///< psMetadata to convert into a fooRow 7410 7389 ); 7411 /** Selects up to limit rows from the database and returns as p4 WarpedImfileRow objects in a psArray7390 /** Selects up to limit rows from the database and returns as p4aScfileRow objects in a psArray 7412 7391 * 7413 7392 * See psDBSelectRows() for documentation on the format of where. … … 7416 7395 */ 7417 7396 7418 psArray *p4 WarpedImfileSelectRowObjects(7397 psArray *p4aScfileSelectRowObjects( 7419 7398 psDB *dbh, ///< Database handle 7420 7399 const psMetadata *where, ///< Row match criteria 7421 7400 unsigned long long limit ///< Maximum number of elements to return 7422 7401 ); 7423 /** Deletes a row from the database coresponding to an p4 WarpedImfile7402 /** Deletes a row from the database coresponding to an p4aScfile 7424 7403 * 7425 7404 * Note that a 'where' search psMetadata is constructed from each object and … … 7429 7408 */ 7430 7409 7431 bool p4 WarpedImfileDeleteObject(7432 psDB *dbh, ///< Database handle 7433 const p4 WarpedImfileRow *object ///< Object to delete7410 bool p4aScfileDeleteObject( 7411 psDB *dbh, ///< Database handle 7412 const p4aScfileRow *object ///< Object to delete 7434 7413 ); 7435 7414 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. … … 7441 7420 */ 7442 7421 7443 long long p4 WarpedImfileDeleteRowObjects(7422 long long p4aScfileDeleteRowObjects( 7444 7423 psDB *dbh, ///< Database handle 7445 7424 const psArray *objects, ///< Array of objects to delete 7446 7425 unsigned long long limit ///< Maximum number of elements to delete 7447 7426 ); 7448 /** Formats and prints an array of p4 WarpedImfileRow objects7427 /** Formats and prints an array of p4aScfileRow objects 7449 7428 * 7450 7429 * When mdcf is set the formated output is in psMetadataConfig … … 7454 7433 */ 7455 7434 7456 bool p4 WarpedImfilePrintObjects(7435 bool p4aScfilePrintObjects( 7457 7436 FILE *stream, ///< a stream 7458 psArray *objects, ///< An array of p4 WarpedImfileRow objects7437 psArray *objects, ///< An array of p4aScfileRow objects 7459 7438 bool mdcf ///< format as mdconfig or simple 7460 7439 ); 7461 /** Formats and prints an p4 WarpedImfileRow object7440 /** Formats and prints an p4aScfileRow object 7462 7441 * 7463 7442 * When mdcf is set the formated output is in psMetadataConfig … … 7467 7446 */ 7468 7447 7469 bool p4 WarpedImfilePrintObject(7448 bool p4aScfilePrintObject( 7470 7449 FILE *stream, ///< a stream 7471 p4 WarpedImfileRow *object, ///< an p4WarpedImfileRow object7450 p4aScfileRow *object, ///< an p4aScfileRow object 7472 7451 bool mdcf ///< format as mdconfig or simple 7473 7452 ); 7474 /** p4 StackedImfileRow data structure7475 * 7476 * Structure for representing a single row of p4 StackedImfiletable data.7453 /** p4bRunRow data structure 7454 * 7455 * Structure for representing a single row of p4bRun table data. 7477 7456 */ 7478 7457 7479 7458 typedef struct { 7480 psS32 p4_id; 7481 char *class_id; 7482 char *uri; 7483 char *b1_uri; 7484 char *b2_uri; 7485 } p4StackedImfileRow; 7486 7487 /** Creates a new p4StackedImfileRow object 7488 * 7489 * @return A new p4StackedImfileRow object or NULL on failure. 7490 */ 7491 7492 p4StackedImfileRow *p4StackedImfileRowAlloc( 7493 psS32 p4_id, 7494 const char *class_id, 7495 const char *uri, 7496 const char *b1_uri, 7497 const char *b2_uri 7498 ); 7499 7500 /** Creates a new p4StackedImfile table 7501 * 7502 * @return true on success 7503 */ 7504 7505 bool p4StackedImfileCreateTable( 7459 psS32 p4b_id; 7460 char *state; 7461 char *workdir; 7462 bool magic; 7463 } p4bRunRow; 7464 7465 /** Creates a new p4bRunRow object 7466 * 7467 * @return A new p4bRunRow object or NULL on failure. 7468 */ 7469 7470 p4bRunRow *p4bRunRowAlloc( 7471 psS32 p4b_id, 7472 const char *state, 7473 const char *workdir, 7474 bool magic 7475 ); 7476 7477 /** Creates a new p4bRun table 7478 * 7479 * @return true on success 7480 */ 7481 7482 bool p4bRunCreateTable( 7506 7483 psDB *dbh ///< Database handle 7507 7484 ); 7508 7485 7509 /** Deletes a p4 StackedImfiletable7510 * 7511 * @return true on success 7512 */ 7513 7514 bool p4 StackedImfileDropTable(7486 /** Deletes a p4bRun table 7487 * 7488 * @return true on success 7489 */ 7490 7491 bool p4bRunDropTable( 7515 7492 psDB *dbh ///< Database handle 7516 7493 ); … … 7523 7500 */ 7524 7501 7525 bool p4StackedImfileInsert( 7526 psDB *dbh, ///< Database handle 7527 psS32 p4_id, 7528 const char *class_id, 7529 const char *uri, 7530 const char *b1_uri, 7531 const char *b2_uri 7502 bool p4bRunInsert( 7503 psDB *dbh, ///< Database handle 7504 psS32 p4b_id, 7505 const char *state, 7506 const char *workdir, 7507 bool magic 7532 7508 ); 7533 7509 … … 7537 7513 */ 7538 7514 7539 long long p4 StackedImfileDelete(7515 long long p4bRunDelete( 7540 7516 psDB *dbh, ///< Database handle 7541 7517 const psMetadata *where, ///< Row match criteria … … 7543 7519 ); 7544 7520 7545 /** Insert a single p4 StackedImfileRow object into a table7521 /** Insert a single p4bRunRow object into a table 7546 7522 * 7547 7523 * This function constructs and inserts a single row based on it's parameters. … … 7550 7526 */ 7551 7527 7552 bool p4 StackedImfileInsertObject(7553 psDB *dbh, ///< Database handle 7554 p4 StackedImfileRow *object ///< p4StackedImfileRow object7555 ); 7556 7557 /** Insert an array of p4 StackedImfileRow object into a table7528 bool p4bRunInsertObject( 7529 psDB *dbh, ///< Database handle 7530 p4bRunRow *object ///< p4bRunRow object 7531 ); 7532 7533 /** Insert an array of p4bRunRow object into a table 7558 7534 * 7559 7535 * This function constructs and inserts multiple rows based on it's parameters. … … 7562 7538 */ 7563 7539 7564 bool p4 StackedImfileInsertObjects(7565 psDB *dbh, ///< Database handle 7566 psArray *objects ///< array of p4 StackedImfileRow objects7567 ); 7568 7569 /** Insert data from a binary FITS table p4 StackedImfileRow into the database7540 bool p4bRunInsertObjects( 7541 psDB *dbh, ///< Database handle 7542 psArray *objects ///< array of p4bRunRow objects 7543 ); 7544 7545 /** Insert data from a binary FITS table p4bRunRow into the database 7570 7546 * 7571 7547 * This function expects a psFits object with a FITS table as the first … … 7577 7553 */ 7578 7554 7579 bool p4 StackedImfileInsertFits(7555 bool p4bRunInsertFits( 7580 7556 psDB *dbh, ///< Database handle 7581 7557 const psFits *fits ///< psFits object … … 7592 7568 */ 7593 7569 7594 bool p4 StackedImfileSelectRowsFits(7570 bool p4bRunSelectRowsFits( 7595 7571 psDB *dbh, ///< Database handle 7596 7572 psFits *fits, ///< psFits object … … 7599 7575 ); 7600 7576 7601 /** Convert a p4 StackedImfileRow into an equivalent psMetadata7577 /** Convert a p4bRunRow into an equivalent psMetadata 7602 7578 * 7603 7579 * @return A psMetadata pointer or NULL on error 7604 7580 */ 7605 7581 7606 psMetadata *p4 StackedImfileMetadataFromObject(7607 const p4 StackedImfileRow *object ///< fooRow to convert into a psMetadata7582 psMetadata *p4bRunMetadataFromObject( 7583 const p4bRunRow *object ///< fooRow to convert into a psMetadata 7608 7584 ); 7609 7585 7610 7586 /** Convert a psMetadata into an equivalent fooRow 7611 7587 * 7612 * @return A p4 StackedImfileRow pointer or NULL on error7613 */ 7614 7615 p4 StackedImfileRow *p4StackedImfileObjectFromMetadata(7588 * @return A p4bRunRow pointer or NULL on error 7589 */ 7590 7591 p4bRunRow *p4bRunObjectFromMetadata( 7616 7592 psMetadata *md ///< psMetadata to convert into a fooRow 7617 7593 ); 7618 /** Selects up to limit rows from the database and returns as p4 StackedImfileRow objects in a psArray7594 /** Selects up to limit rows from the database and returns as p4bRunRow objects in a psArray 7619 7595 * 7620 7596 * See psDBSelectRows() for documentation on the format of where. … … 7623 7599 */ 7624 7600 7625 psArray *p4 StackedImfileSelectRowObjects(7601 psArray *p4bRunSelectRowObjects( 7626 7602 psDB *dbh, ///< Database handle 7627 7603 const psMetadata *where, ///< Row match criteria 7628 7604 unsigned long long limit ///< Maximum number of elements to return 7629 7605 ); 7630 /** Deletes a row from the database coresponding to an p4 StackedImfile7606 /** Deletes a row from the database coresponding to an p4bRun 7631 7607 * 7632 7608 * Note that a 'where' search psMetadata is constructed from each object and … … 7636 7612 */ 7637 7613 7638 bool p4 StackedImfileDeleteObject(7639 psDB *dbh, ///< Database handle 7640 const p4 StackedImfileRow *object ///< Object to delete7614 bool p4bRunDeleteObject( 7615 psDB *dbh, ///< Database handle 7616 const p4bRunRow *object ///< Object to delete 7641 7617 ); 7642 7618 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. … … 7648 7624 */ 7649 7625 7650 long long p4 StackedImfileDeleteRowObjects(7626 long long p4bRunDeleteRowObjects( 7651 7627 psDB *dbh, ///< Database handle 7652 7628 const psArray *objects, ///< Array of objects to delete 7653 7629 unsigned long long limit ///< Maximum number of elements to delete 7654 7630 ); 7655 /** Formats and prints an array of p4 StackedImfileRow objects7631 /** Formats and prints an array of p4bRunRow objects 7656 7632 * 7657 7633 * When mdcf is set the formated output is in psMetadataConfig … … 7661 7637 */ 7662 7638 7663 bool p4 StackedImfilePrintObjects(7639 bool p4bRunPrintObjects( 7664 7640 FILE *stream, ///< a stream 7665 psArray *objects, ///< An array of p4 StackedImfileRow objects7641 psArray *objects, ///< An array of p4bRunRow objects 7666 7642 bool mdcf ///< format as mdconfig or simple 7667 7643 ); 7668 /** Formats and prints an p4 StackedImfileRow object7644 /** Formats and prints an p4bRunRow object 7669 7645 * 7670 7646 * When mdcf is set the formated output is in psMetadataConfig … … 7674 7650 */ 7675 7651 7676 bool p4 StackedImfilePrintObject(7652 bool p4bRunPrintObject( 7677 7653 FILE *stream, ///< a stream 7678 p4 StackedImfileRow *object, ///< an p4StackedImfileRow object7654 p4bRunRow *object, ///< an p4bRunRow object 7679 7655 bool mdcf ///< format as mdconfig or simple 7680 7656 ); 7681 /** p4 DiffImfileRow data structure7682 * 7683 * Structure for representing a single row of p4 DiffImfile table data.7657 /** p4bInputScfileRow data structure 7658 * 7659 * Structure for representing a single row of p4bInputScfile table data. 7684 7660 */ 7685 7661 7686 7662 typedef struct { 7687 psS32 p4_id; 7663 psS32 p4b_id; 7664 char *skycell_id; 7665 char *tess_id; 7688 7666 char *exp_tag; 7689 7667 psS32 p3_version; 7690 char *class_id; 7691 char *uri; 7692 char *b1_uri; 7693 char *b2_uri; 7694 } p4DiffImfileRow; 7695 7696 /** Creates a new p4DiffImfileRow object 7697 * 7698 * @return A new p4DiffImfileRow object or NULL on failure. 7699 */ 7700 7701 p4DiffImfileRow *p4DiffImfileRowAlloc( 7702 psS32 p4_id, 7668 char *kind; 7669 } p4bInputScfileRow; 7670 7671 /** Creates a new p4bInputScfileRow object 7672 * 7673 * @return A new p4bInputScfileRow object or NULL on failure. 7674 */ 7675 7676 p4bInputScfileRow *p4bInputScfileRowAlloc( 7677 psS32 p4b_id, 7678 const char *skycell_id, 7679 const char *tess_id, 7703 7680 const char *exp_tag, 7704 7681 psS32 p3_version, 7705 const char *class_id, 7706 const char *uri, 7707 const char *b1_uri, 7708 const char *b2_uri 7709 ); 7710 7711 /** Creates a new p4DiffImfile table 7712 * 7713 * @return true on success 7714 */ 7715 7716 bool p4DiffImfileCreateTable( 7682 const char *kind 7683 ); 7684 7685 /** Creates a new p4bInputScfile table 7686 * 7687 * @return true on success 7688 */ 7689 7690 bool p4bInputScfileCreateTable( 7717 7691 psDB *dbh ///< Database handle 7718 7692 ); 7719 7693 7720 /** Deletes a p4 DiffImfile table7721 * 7722 * @return true on success 7723 */ 7724 7725 bool p4 DiffImfileDropTable(7694 /** Deletes a p4bInputScfile table 7695 * 7696 * @return true on success 7697 */ 7698 7699 bool p4bInputScfileDropTable( 7726 7700 psDB *dbh ///< Database handle 7727 7701 ); … … 7734 7708 */ 7735 7709 7736 bool p4DiffImfileInsert( 7737 psDB *dbh, ///< Database handle 7738 psS32 p4_id, 7710 bool p4bInputScfileInsert( 7711 psDB *dbh, ///< Database handle 7712 psS32 p4b_id, 7713 const char *skycell_id, 7714 const char *tess_id, 7739 7715 const char *exp_tag, 7740 7716 psS32 p3_version, 7741 const char *class_id, 7742 const char *uri, 7743 const char *b1_uri, 7744 const char *b2_uri 7717 const char *kind 7745 7718 ); 7746 7719 … … 7750 7723 */ 7751 7724 7752 long long p4 DiffImfileDelete(7725 long long p4bInputScfileDelete( 7753 7726 psDB *dbh, ///< Database handle 7754 7727 const psMetadata *where, ///< Row match criteria … … 7756 7729 ); 7757 7730 7758 /** Insert a single p4 DiffImfileRow object into a table7731 /** Insert a single p4bInputScfileRow object into a table 7759 7732 * 7760 7733 * This function constructs and inserts a single row based on it's parameters. … … 7763 7736 */ 7764 7737 7765 bool p4 DiffImfileInsertObject(7766 psDB *dbh, ///< Database handle 7767 p4 DiffImfileRow *object ///< p4DiffImfileRow object7768 ); 7769 7770 /** Insert an array of p4 DiffImfileRow object into a table7738 bool p4bInputScfileInsertObject( 7739 psDB *dbh, ///< Database handle 7740 p4bInputScfileRow *object ///< p4bInputScfileRow object 7741 ); 7742 7743 /** Insert an array of p4bInputScfileRow object into a table 7771 7744 * 7772 7745 * This function constructs and inserts multiple rows based on it's parameters. … … 7775 7748 */ 7776 7749 7777 bool p4 DiffImfileInsertObjects(7778 psDB *dbh, ///< Database handle 7779 psArray *objects ///< array of p4 DiffImfileRow objects7780 ); 7781 7782 /** Insert data from a binary FITS table p4 DiffImfileRow into the database7750 bool p4bInputScfileInsertObjects( 7751 psDB *dbh, ///< Database handle 7752 psArray *objects ///< array of p4bInputScfileRow objects 7753 ); 7754 7755 /** Insert data from a binary FITS table p4bInputScfileRow into the database 7783 7756 * 7784 7757 * This function expects a psFits object with a FITS table as the first … … 7790 7763 */ 7791 7764 7792 bool p4 DiffImfileInsertFits(7765 bool p4bInputScfileInsertFits( 7793 7766 psDB *dbh, ///< Database handle 7794 7767 const psFits *fits ///< psFits object … … 7805 7778 */ 7806 7779 7807 bool p4 DiffImfileSelectRowsFits(7780 bool p4bInputScfileSelectRowsFits( 7808 7781 psDB *dbh, ///< Database handle 7809 7782 psFits *fits, ///< psFits object … … 7812 7785 ); 7813 7786 7814 /** Convert a p4 DiffImfileRow into an equivalent psMetadata7787 /** Convert a p4bInputScfileRow into an equivalent psMetadata 7815 7788 * 7816 7789 * @return A psMetadata pointer or NULL on error 7817 7790 */ 7818 7791 7819 psMetadata *p4 DiffImfileMetadataFromObject(7820 const p4 DiffImfileRow *object ///< fooRow to convert into a psMetadata7792 psMetadata *p4bInputScfileMetadataFromObject( 7793 const p4bInputScfileRow *object ///< fooRow to convert into a psMetadata 7821 7794 ); 7822 7795 7823 7796 /** Convert a psMetadata into an equivalent fooRow 7824 7797 * 7825 * @return A p4 DiffImfileRow pointer or NULL on error7826 */ 7827 7828 p4 DiffImfileRow *p4DiffImfileObjectFromMetadata(7798 * @return A p4bInputScfileRow pointer or NULL on error 7799 */ 7800 7801 p4bInputScfileRow *p4bInputScfileObjectFromMetadata( 7829 7802 psMetadata *md ///< psMetadata to convert into a fooRow 7830 7803 ); 7831 /** Selects up to limit rows from the database and returns as p4 DiffImfileRow objects in a psArray7804 /** Selects up to limit rows from the database and returns as p4bInputScfileRow objects in a psArray 7832 7805 * 7833 7806 * See psDBSelectRows() for documentation on the format of where. … … 7836 7809 */ 7837 7810 7838 psArray *p4 DiffImfileSelectRowObjects(7811 psArray *p4bInputScfileSelectRowObjects( 7839 7812 psDB *dbh, ///< Database handle 7840 7813 const psMetadata *where, ///< Row match criteria 7841 7814 unsigned long long limit ///< Maximum number of elements to return 7842 7815 ); 7843 /** Deletes a row from the database coresponding to an p4 DiffImfile7816 /** Deletes a row from the database coresponding to an p4bInputScfile 7844 7817 * 7845 7818 * Note that a 'where' search psMetadata is constructed from each object and … … 7849 7822 */ 7850 7823 7851 bool p4 DiffImfileDeleteObject(7852 psDB *dbh, ///< Database handle 7853 const p4 DiffImfileRow *object ///< Object to delete7824 bool p4bInputScfileDeleteObject( 7825 psDB *dbh, ///< Database handle 7826 const p4bInputScfileRow *object ///< Object to delete 7854 7827 ); 7855 7828 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. … … 7861 7834 */ 7862 7835 7863 long long p4 DiffImfileDeleteRowObjects(7836 long long p4bInputScfileDeleteRowObjects( 7864 7837 psDB *dbh, ///< Database handle 7865 7838 const psArray *objects, ///< Array of objects to delete 7866 7839 unsigned long long limit ///< Maximum number of elements to delete 7867 7840 ); 7868 /** Formats and prints an array of p4 DiffImfileRow objects7841 /** Formats and prints an array of p4bInputScfileRow objects 7869 7842 * 7870 7843 * When mdcf is set the formated output is in psMetadataConfig … … 7874 7847 */ 7875 7848 7876 bool p4 DiffImfilePrintObjects(7849 bool p4bInputScfilePrintObjects( 7877 7850 FILE *stream, ///< a stream 7878 psArray *objects, ///< An array of p4 DiffImfileRow objects7851 psArray *objects, ///< An array of p4bInputScfileRow objects 7879 7852 bool mdcf ///< format as mdconfig or simple 7880 7853 ); 7881 /** Formats and prints an p4 DiffImfileRow object7854 /** Formats and prints an p4bInputScfileRow object 7882 7855 * 7883 7856 * When mdcf is set the formated output is in psMetadataConfig … … 7887 7860 */ 7888 7861 7889 bool p4 DiffImfilePrintObject(7862 bool p4bInputScfilePrintObject( 7890 7863 FILE *stream, ///< a stream 7891 p4 DiffImfileRow *object, ///< an p4DiffImfileRow object7864 p4bInputScfileRow *object, ///< an p4bInputScfileRow object 7892 7865 bool mdcf ///< format as mdconfig or simple 7893 7866 ); 7867 /** p4bDiffScfileRow data structure 7868 * 7869 * Structure for representing a single row of p4bDiffScfile table data. 7870 */ 7871 7872 typedef struct { 7873 psS32 p4b_id; 7874 char *skycell_id; 7875 char *tess_id; 7876 char *exp_tag; 7877 psS32 p3_version; 7878 char *uri; 7879 psF64 bg; 7880 psF64 bg_mean_stdev; 7881 } p4bDiffScfileRow; 7882 7883 /** Creates a new p4bDiffScfileRow object 7884 * 7885 * @return A new p4bDiffScfileRow object or NULL on failure. 7886 */ 7887 7888 p4bDiffScfileRow *p4bDiffScfileRowAlloc( 7889 psS32 p4b_id, 7890 const char *skycell_id, 7891 const char *tess_id, 7892 const char *exp_tag, 7893 psS32 p3_version, 7894 const char *uri, 7895 psF64 bg, 7896 psF64 bg_mean_stdev 7897 ); 7898 7899 /** Creates a new p4bDiffScfile table 7900 * 7901 * @return true on success 7902 */ 7903 7904 bool p4bDiffScfileCreateTable( 7905 psDB *dbh ///< Database handle 7906 ); 7907 7908 /** Deletes a p4bDiffScfile table 7909 * 7910 * @return true on success 7911 */ 7912 7913 bool p4bDiffScfileDropTable( 7914 psDB *dbh ///< Database handle 7915 ); 7916 7917 /** Insert a single row into a table 7918 * 7919 * This function constructs and inserts a single row based on it's parameters. 7920 * 7921 * @return true on success 7922 */ 7923 7924 bool p4bDiffScfileInsert( 7925 psDB *dbh, ///< Database handle 7926 psS32 p4b_id, 7927 const char *skycell_id, 7928 const char *tess_id, 7929 const char *exp_tag, 7930 psS32 p3_version, 7931 const char *uri, 7932 psF64 bg, 7933 psF64 bg_mean_stdev 7934 ); 7935 7936 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 7937 * 7938 * @return A The number of rows removed or a negative value on error 7939 */ 7940 7941 long long p4bDiffScfileDelete( 7942 psDB *dbh, ///< Database handle 7943 const psMetadata *where, ///< Row match criteria 7944 unsigned long long limit ///< Maximum number of elements to delete 7945 ); 7946 7947 /** Insert a single p4bDiffScfileRow object into a table 7948 * 7949 * This function constructs and inserts a single row based on it's parameters. 7950 * 7951 * @return true on success 7952 */ 7953 7954 bool p4bDiffScfileInsertObject( 7955 psDB *dbh, ///< Database handle 7956 p4bDiffScfileRow *object ///< p4bDiffScfileRow object 7957 ); 7958 7959 /** Insert an array of p4bDiffScfileRow object into a table 7960 * 7961 * This function constructs and inserts multiple rows based on it's parameters. 7962 * 7963 * @return true on success 7964 */ 7965 7966 bool p4bDiffScfileInsertObjects( 7967 psDB *dbh, ///< Database handle 7968 psArray *objects ///< array of p4bDiffScfileRow objects 7969 ); 7970 7971 /** Insert data from a binary FITS table p4bDiffScfileRow into the database 7972 * 7973 * This function expects a psFits object with a FITS table as the first 7974 * extension. The table must have at least one row of data in it, that is of 7975 * the appropriate format (number of columns and their type). All other 7976 * extensions are ignored. 7977 * 7978 * @return true on success 7979 */ 7980 7981 bool p4bDiffScfileInsertFits( 7982 psDB *dbh, ///< Database handle 7983 const psFits *fits ///< psFits object 7984 ); 7985 7986 /** Selects up to limit from the database and returns them in a binary FITS table 7987 * 7988 * This function assumes an empty psFits object and will create a FITS table 7989 * as the first extension. 7990 * 7991 * See psDBSelectRows() for documentation on the format of where. 7992 * 7993 * @return true on success 7994 */ 7995 7996 bool p4bDiffScfileSelectRowsFits( 7997 psDB *dbh, ///< Database handle 7998 psFits *fits, ///< psFits object 7999 const psMetadata *where, ///< Row match criteria 8000 unsigned long long limit ///< Maximum number of elements to return 8001 ); 8002 8003 /** Convert a p4bDiffScfileRow into an equivalent psMetadata 8004 * 8005 * @return A psMetadata pointer or NULL on error 8006 */ 8007 8008 psMetadata *p4bDiffScfileMetadataFromObject( 8009 const p4bDiffScfileRow *object ///< fooRow to convert into a psMetadata 8010 ); 8011 8012 /** Convert a psMetadata into an equivalent fooRow 8013 * 8014 * @return A p4bDiffScfileRow pointer or NULL on error 8015 */ 8016 8017 p4bDiffScfileRow *p4bDiffScfileObjectFromMetadata( 8018 psMetadata *md ///< psMetadata to convert into a fooRow 8019 ); 8020 /** Selects up to limit rows from the database and returns as p4bDiffScfileRow objects in a psArray 8021 * 8022 * See psDBSelectRows() for documentation on the format of where. 8023 * 8024 * @return A psArray pointer or NULL on error 8025 */ 8026 8027 psArray *p4bDiffScfileSelectRowObjects( 8028 psDB *dbh, ///< Database handle 8029 const psMetadata *where, ///< Row match criteria 8030 unsigned long long limit ///< Maximum number of elements to return 8031 ); 8032 /** Deletes a row from the database coresponding to an p4bDiffScfile 8033 * 8034 * Note that a 'where' search psMetadata is constructed from each object and 8035 * used to find rows to delete. 8036 * 8037 * @return A The number of rows removed or a negative value on error 8038 */ 8039 8040 bool p4bDiffScfileDeleteObject( 8041 psDB *dbh, ///< Database handle 8042 const p4bDiffScfileRow *object ///< Object to delete 8043 ); 8044 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 8045 * 8046 * Note that a 'where' search psMetadata is constructed from each object and 8047 * used to find rows to delete. 8048 * 8049 * @return A The number of rows removed or a negative value on error 8050 */ 8051 8052 long long p4bDiffScfileDeleteRowObjects( 8053 psDB *dbh, ///< Database handle 8054 const psArray *objects, ///< Array of objects to delete 8055 unsigned long long limit ///< Maximum number of elements to delete 8056 ); 8057 /** Formats and prints an array of p4bDiffScfileRow objects 8058 * 8059 * When mdcf is set the formated output is in psMetadataConfig 8060 * format, otherwise it is in a simple tabular format. 8061 * 8062 * @return true on success 8063 */ 8064 8065 bool p4bDiffScfilePrintObjects( 8066 FILE *stream, ///< a stream 8067 psArray *objects, ///< An array of p4bDiffScfileRow objects 8068 bool mdcf ///< format as mdconfig or simple 8069 ); 8070 /** Formats and prints an p4bDiffScfileRow object 8071 * 8072 * When mdcf is set the formated output is in psMetadataConfig 8073 * format, otherwise it is in a simple tabular format. 8074 * 8075 * @return true on success 8076 */ 8077 8078 bool p4bDiffScfilePrintObject( 8079 FILE *stream, ///< a stream 8080 p4bDiffScfileRow *object, ///< an p4bDiffScfileRow object 8081 bool mdcf ///< format as mdconfig or simple 8082 ); 8083 /** p4cRunRow data structure 8084 * 8085 * Structure for representing a single row of p4cRun table data. 8086 */ 8087 8088 typedef struct { 8089 psS32 p4c_id; 8090 char *state; 8091 char *workdir; 8092 bool magic; 8093 } p4cRunRow; 8094 8095 /** Creates a new p4cRunRow object 8096 * 8097 * @return A new p4cRunRow object or NULL on failure. 8098 */ 8099 8100 p4cRunRow *p4cRunRowAlloc( 8101 psS32 p4c_id, 8102 const char *state, 8103 const char *workdir, 8104 bool magic 8105 ); 8106 8107 /** Creates a new p4cRun table 8108 * 8109 * @return true on success 8110 */ 8111 8112 bool p4cRunCreateTable( 8113 psDB *dbh ///< Database handle 8114 ); 8115 8116 /** Deletes a p4cRun table 8117 * 8118 * @return true on success 8119 */ 8120 8121 bool p4cRunDropTable( 8122 psDB *dbh ///< Database handle 8123 ); 8124 8125 /** Insert a single row into a table 8126 * 8127 * This function constructs and inserts a single row based on it's parameters. 8128 * 8129 * @return true on success 8130 */ 8131 8132 bool p4cRunInsert( 8133 psDB *dbh, ///< Database handle 8134 psS32 p4c_id, 8135 const char *state, 8136 const char *workdir, 8137 bool magic 8138 ); 8139 8140 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 8141 * 8142 * @return A The number of rows removed or a negative value on error 8143 */ 8144 8145 long long p4cRunDelete( 8146 psDB *dbh, ///< Database handle 8147 const psMetadata *where, ///< Row match criteria 8148 unsigned long long limit ///< Maximum number of elements to delete 8149 ); 8150 8151 /** Insert a single p4cRunRow object into a table 8152 * 8153 * This function constructs and inserts a single row based on it's parameters. 8154 * 8155 * @return true on success 8156 */ 8157 8158 bool p4cRunInsertObject( 8159 psDB *dbh, ///< Database handle 8160 p4cRunRow *object ///< p4cRunRow object 8161 ); 8162 8163 /** Insert an array of p4cRunRow object into a table 8164 * 8165 * This function constructs and inserts multiple rows based on it's parameters. 8166 * 8167 * @return true on success 8168 */ 8169 8170 bool p4cRunInsertObjects( 8171 psDB *dbh, ///< Database handle 8172 psArray *objects ///< array of p4cRunRow objects 8173 ); 8174 8175 /** Insert data from a binary FITS table p4cRunRow into the database 8176 * 8177 * This function expects a psFits object with a FITS table as the first 8178 * extension. The table must have at least one row of data in it, that is of 8179 * the appropriate format (number of columns and their type). All other 8180 * extensions are ignored. 8181 * 8182 * @return true on success 8183 */ 8184 8185 bool p4cRunInsertFits( 8186 psDB *dbh, ///< Database handle 8187 const psFits *fits ///< psFits object 8188 ); 8189 8190 /** Selects up to limit from the database and returns them in a binary FITS table 8191 * 8192 * This function assumes an empty psFits object and will create a FITS table 8193 * as the first extension. 8194 * 8195 * See psDBSelectRows() for documentation on the format of where. 8196 * 8197 * @return true on success 8198 */ 8199 8200 bool p4cRunSelectRowsFits( 8201 psDB *dbh, ///< Database handle 8202 psFits *fits, ///< psFits object 8203 const psMetadata *where, ///< Row match criteria 8204 unsigned long long limit ///< Maximum number of elements to return 8205 ); 8206 8207 /** Convert a p4cRunRow into an equivalent psMetadata 8208 * 8209 * @return A psMetadata pointer or NULL on error 8210 */ 8211 8212 psMetadata *p4cRunMetadataFromObject( 8213 const p4cRunRow *object ///< fooRow to convert into a psMetadata 8214 ); 8215 8216 /** Convert a psMetadata into an equivalent fooRow 8217 * 8218 * @return A p4cRunRow pointer or NULL on error 8219 */ 8220 8221 p4cRunRow *p4cRunObjectFromMetadata( 8222 psMetadata *md ///< psMetadata to convert into a fooRow 8223 ); 8224 /** Selects up to limit rows from the database and returns as p4cRunRow objects in a psArray 8225 * 8226 * See psDBSelectRows() for documentation on the format of where. 8227 * 8228 * @return A psArray pointer or NULL on error 8229 */ 8230 8231 psArray *p4cRunSelectRowObjects( 8232 psDB *dbh, ///< Database handle 8233 const psMetadata *where, ///< Row match criteria 8234 unsigned long long limit ///< Maximum number of elements to return 8235 ); 8236 /** Deletes a row from the database coresponding to an p4cRun 8237 * 8238 * Note that a 'where' search psMetadata is constructed from each object and 8239 * used to find rows to delete. 8240 * 8241 * @return A The number of rows removed or a negative value on error 8242 */ 8243 8244 bool p4cRunDeleteObject( 8245 psDB *dbh, ///< Database handle 8246 const p4cRunRow *object ///< Object to delete 8247 ); 8248 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 8249 * 8250 * Note that a 'where' search psMetadata is constructed from each object and 8251 * used to find rows to delete. 8252 * 8253 * @return A The number of rows removed or a negative value on error 8254 */ 8255 8256 long long p4cRunDeleteRowObjects( 8257 psDB *dbh, ///< Database handle 8258 const psArray *objects, ///< Array of objects to delete 8259 unsigned long long limit ///< Maximum number of elements to delete 8260 ); 8261 /** Formats and prints an array of p4cRunRow objects 8262 * 8263 * When mdcf is set the formated output is in psMetadataConfig 8264 * format, otherwise it is in a simple tabular format. 8265 * 8266 * @return true on success 8267 */ 8268 8269 bool p4cRunPrintObjects( 8270 FILE *stream, ///< a stream 8271 psArray *objects, ///< An array of p4cRunRow objects 8272 bool mdcf ///< format as mdconfig or simple 8273 ); 8274 /** Formats and prints an p4cRunRow object 8275 * 8276 * When mdcf is set the formated output is in psMetadataConfig 8277 * format, otherwise it is in a simple tabular format. 8278 * 8279 * @return true on success 8280 */ 8281 8282 bool p4cRunPrintObject( 8283 FILE *stream, ///< a stream 8284 p4cRunRow *object, ///< an p4cRunRow object 8285 bool mdcf ///< format as mdconfig or simple 8286 ); 8287 /** p4cInputExpRow data structure 8288 * 8289 * Structure for representing a single row of p4cInputExp table data. 8290 */ 8291 8292 typedef struct { 8293 psS32 p4c_id; 8294 char *exp_tag; 8295 psS32 p3_version; 8296 } p4cInputExpRow; 8297 8298 /** Creates a new p4cInputExpRow object 8299 * 8300 * @return A new p4cInputExpRow object or NULL on failure. 8301 */ 8302 8303 p4cInputExpRow *p4cInputExpRowAlloc( 8304 psS32 p4c_id, 8305 const char *exp_tag, 8306 psS32 p3_version 8307 ); 8308 8309 /** Creates a new p4cInputExp table 8310 * 8311 * @return true on success 8312 */ 8313 8314 bool p4cInputExpCreateTable( 8315 psDB *dbh ///< Database handle 8316 ); 8317 8318 /** Deletes a p4cInputExp table 8319 * 8320 * @return true on success 8321 */ 8322 8323 bool p4cInputExpDropTable( 8324 psDB *dbh ///< Database handle 8325 ); 8326 8327 /** Insert a single row into a table 8328 * 8329 * This function constructs and inserts a single row based on it's parameters. 8330 * 8331 * @return true on success 8332 */ 8333 8334 bool p4cInputExpInsert( 8335 psDB *dbh, ///< Database handle 8336 psS32 p4c_id, 8337 const char *exp_tag, 8338 psS32 p3_version 8339 ); 8340 8341 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 8342 * 8343 * @return A The number of rows removed or a negative value on error 8344 */ 8345 8346 long long p4cInputExpDelete( 8347 psDB *dbh, ///< Database handle 8348 const psMetadata *where, ///< Row match criteria 8349 unsigned long long limit ///< Maximum number of elements to delete 8350 ); 8351 8352 /** Insert a single p4cInputExpRow object into a table 8353 * 8354 * This function constructs and inserts a single row based on it's parameters. 8355 * 8356 * @return true on success 8357 */ 8358 8359 bool p4cInputExpInsertObject( 8360 psDB *dbh, ///< Database handle 8361 p4cInputExpRow *object ///< p4cInputExpRow object 8362 ); 8363 8364 /** Insert an array of p4cInputExpRow object into a table 8365 * 8366 * This function constructs and inserts multiple rows based on it's parameters. 8367 * 8368 * @return true on success 8369 */ 8370 8371 bool p4cInputExpInsertObjects( 8372 psDB *dbh, ///< Database handle 8373 psArray *objects ///< array of p4cInputExpRow objects 8374 ); 8375 8376 /** Insert data from a binary FITS table p4cInputExpRow into the database 8377 * 8378 * This function expects a psFits object with a FITS table as the first 8379 * extension. The table must have at least one row of data in it, that is of 8380 * the appropriate format (number of columns and their type). All other 8381 * extensions are ignored. 8382 * 8383 * @return true on success 8384 */ 8385 8386 bool p4cInputExpInsertFits( 8387 psDB *dbh, ///< Database handle 8388 const psFits *fits ///< psFits object 8389 ); 8390 8391 /** Selects up to limit from the database and returns them in a binary FITS table 8392 * 8393 * This function assumes an empty psFits object and will create a FITS table 8394 * as the first extension. 8395 * 8396 * See psDBSelectRows() for documentation on the format of where. 8397 * 8398 * @return true on success 8399 */ 8400 8401 bool p4cInputExpSelectRowsFits( 8402 psDB *dbh, ///< Database handle 8403 psFits *fits, ///< psFits object 8404 const psMetadata *where, ///< Row match criteria 8405 unsigned long long limit ///< Maximum number of elements to return 8406 ); 8407 8408 /** Convert a p4cInputExpRow into an equivalent psMetadata 8409 * 8410 * @return A psMetadata pointer or NULL on error 8411 */ 8412 8413 psMetadata *p4cInputExpMetadataFromObject( 8414 const p4cInputExpRow *object ///< fooRow to convert into a psMetadata 8415 ); 8416 8417 /** Convert a psMetadata into an equivalent fooRow 8418 * 8419 * @return A p4cInputExpRow pointer or NULL on error 8420 */ 8421 8422 p4cInputExpRow *p4cInputExpObjectFromMetadata( 8423 psMetadata *md ///< psMetadata to convert into a fooRow 8424 ); 8425 /** Selects up to limit rows from the database and returns as p4cInputExpRow objects in a psArray 8426 * 8427 * See psDBSelectRows() for documentation on the format of where. 8428 * 8429 * @return A psArray pointer or NULL on error 8430 */ 8431 8432 psArray *p4cInputExpSelectRowObjects( 8433 psDB *dbh, ///< Database handle 8434 const psMetadata *where, ///< Row match criteria 8435 unsigned long long limit ///< Maximum number of elements to return 8436 ); 8437 /** Deletes a row from the database coresponding to an p4cInputExp 8438 * 8439 * Note that a 'where' search psMetadata is constructed from each object and 8440 * used to find rows to delete. 8441 * 8442 * @return A The number of rows removed or a negative value on error 8443 */ 8444 8445 bool p4cInputExpDeleteObject( 8446 psDB *dbh, ///< Database handle 8447 const p4cInputExpRow *object ///< Object to delete 8448 ); 8449 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 8450 * 8451 * Note that a 'where' search psMetadata is constructed from each object and 8452 * used to find rows to delete. 8453 * 8454 * @return A The number of rows removed or a negative value on error 8455 */ 8456 8457 long long p4cInputExpDeleteRowObjects( 8458 psDB *dbh, ///< Database handle 8459 const psArray *objects, ///< Array of objects to delete 8460 unsigned long long limit ///< Maximum number of elements to delete 8461 ); 8462 /** Formats and prints an array of p4cInputExpRow objects 8463 * 8464 * When mdcf is set the formated output is in psMetadataConfig 8465 * format, otherwise it is in a simple tabular format. 8466 * 8467 * @return true on success 8468 */ 8469 8470 bool p4cInputExpPrintObjects( 8471 FILE *stream, ///< a stream 8472 psArray *objects, ///< An array of p4cInputExpRow objects 8473 bool mdcf ///< format as mdconfig or simple 8474 ); 8475 /** Formats and prints an p4cInputExpRow object 8476 * 8477 * When mdcf is set the formated output is in psMetadataConfig 8478 * format, otherwise it is in a simple tabular format. 8479 * 8480 * @return true on success 8481 */ 8482 8483 bool p4cInputExpPrintObject( 8484 FILE *stream, ///< a stream 8485 p4cInputExpRow *object, ///< an p4cInputExpRow object 8486 bool mdcf ///< format as mdconfig or simple 8487 ); 7894 8488 /** p4MagicMaskImfileRow data structure 7895 8489 * … … 7898 8492 7899 8493 typedef struct { 7900 psS32 p4 _id;8494 psS32 p4c_id; 7901 8495 char *exp_tag; 7902 8496 psS32 p3_version; … … 7911 8505 7912 8506 p4MagicMaskImfileRow *p4MagicMaskImfileRowAlloc( 7913 psS32 p4 _id,8507 psS32 p4c_id, 7914 8508 const char *exp_tag, 7915 8509 psS32 p3_version, … … 7945 8539 bool p4MagicMaskImfileInsert( 7946 8540 psDB *dbh, ///< Database handle 7947 psS32 p4 _id,8541 psS32 p4c_id, 7948 8542 const char *exp_tag, 7949 8543 psS32 p3_version, … … 8099 8693 bool mdcf ///< format as mdconfig or simple 8100 8694 ); 8695 /** skyCellRow data structure 8696 * 8697 * Structure for representing a single row of skyCell table data. 8698 */ 8699 8700 typedef struct { 8701 char *skycell_id; 8702 char *tess_id; 8703 psF64 ra1; 8704 psF64 decl1; 8705 psF64 ra2; 8706 psF64 decl2; 8707 psF64 ra3; 8708 psF64 decl3; 8709 psF64 ra4; 8710 psF64 decl4; 8711 } skyCellRow; 8712 8713 /** Creates a new skyCellRow object 8714 * 8715 * @return A new skyCellRow object or NULL on failure. 8716 */ 8717 8718 skyCellRow *skyCellRowAlloc( 8719 const char *skycell_id, 8720 const char *tess_id, 8721 psF64 ra1, 8722 psF64 decl1, 8723 psF64 ra2, 8724 psF64 decl2, 8725 psF64 ra3, 8726 psF64 decl3, 8727 psF64 ra4, 8728 psF64 decl4 8729 ); 8730 8731 /** Creates a new skyCell table 8732 * 8733 * @return true on success 8734 */ 8735 8736 bool skyCellCreateTable( 8737 psDB *dbh ///< Database handle 8738 ); 8739 8740 /** Deletes a skyCell table 8741 * 8742 * @return true on success 8743 */ 8744 8745 bool skyCellDropTable( 8746 psDB *dbh ///< Database handle 8747 ); 8748 8749 /** Insert a single row into a table 8750 * 8751 * This function constructs and inserts a single row based on it's parameters. 8752 * 8753 * @return true on success 8754 */ 8755 8756 bool skyCellInsert( 8757 psDB *dbh, ///< Database handle 8758 const char *skycell_id, 8759 const char *tess_id, 8760 psF64 ra1, 8761 psF64 decl1, 8762 psF64 ra2, 8763 psF64 decl2, 8764 psF64 ra3, 8765 psF64 decl3, 8766 psF64 ra4, 8767 psF64 decl4 8768 ); 8769 8770 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 8771 * 8772 * @return A The number of rows removed or a negative value on error 8773 */ 8774 8775 long long skyCellDelete( 8776 psDB *dbh, ///< Database handle 8777 const psMetadata *where, ///< Row match criteria 8778 unsigned long long limit ///< Maximum number of elements to delete 8779 ); 8780 8781 /** Insert a single skyCellRow object into a table 8782 * 8783 * This function constructs and inserts a single row based on it's parameters. 8784 * 8785 * @return true on success 8786 */ 8787 8788 bool skyCellInsertObject( 8789 psDB *dbh, ///< Database handle 8790 skyCellRow *object ///< skyCellRow object 8791 ); 8792 8793 /** Insert an array of skyCellRow object into a table 8794 * 8795 * This function constructs and inserts multiple rows based on it's parameters. 8796 * 8797 * @return true on success 8798 */ 8799 8800 bool skyCellInsertObjects( 8801 psDB *dbh, ///< Database handle 8802 psArray *objects ///< array of skyCellRow objects 8803 ); 8804 8805 /** Insert data from a binary FITS table skyCellRow into the database 8806 * 8807 * This function expects a psFits object with a FITS table as the first 8808 * extension. The table must have at least one row of data in it, that is of 8809 * the appropriate format (number of columns and their type). All other 8810 * extensions are ignored. 8811 * 8812 * @return true on success 8813 */ 8814 8815 bool skyCellInsertFits( 8816 psDB *dbh, ///< Database handle 8817 const psFits *fits ///< psFits object 8818 ); 8819 8820 /** Selects up to limit from the database and returns them in a binary FITS table 8821 * 8822 * This function assumes an empty psFits object and will create a FITS table 8823 * as the first extension. 8824 * 8825 * See psDBSelectRows() for documentation on the format of where. 8826 * 8827 * @return true on success 8828 */ 8829 8830 bool skyCellSelectRowsFits( 8831 psDB *dbh, ///< Database handle 8832 psFits *fits, ///< psFits object 8833 const psMetadata *where, ///< Row match criteria 8834 unsigned long long limit ///< Maximum number of elements to return 8835 ); 8836 8837 /** Convert a skyCellRow into an equivalent psMetadata 8838 * 8839 * @return A psMetadata pointer or NULL on error 8840 */ 8841 8842 psMetadata *skyCellMetadataFromObject( 8843 const skyCellRow *object ///< fooRow to convert into a psMetadata 8844 ); 8845 8846 /** Convert a psMetadata into an equivalent fooRow 8847 * 8848 * @return A skyCellRow pointer or NULL on error 8849 */ 8850 8851 skyCellRow *skyCellObjectFromMetadata( 8852 psMetadata *md ///< psMetadata to convert into a fooRow 8853 ); 8854 /** Selects up to limit rows from the database and returns as skyCellRow objects in a psArray 8855 * 8856 * See psDBSelectRows() for documentation on the format of where. 8857 * 8858 * @return A psArray pointer or NULL on error 8859 */ 8860 8861 psArray *skyCellSelectRowObjects( 8862 psDB *dbh, ///< Database handle 8863 const psMetadata *where, ///< Row match criteria 8864 unsigned long long limit ///< Maximum number of elements to return 8865 ); 8866 /** Deletes a row from the database coresponding to an skyCell 8867 * 8868 * Note that a 'where' search psMetadata is constructed from each object and 8869 * used to find rows to delete. 8870 * 8871 * @return A The number of rows removed or a negative value on error 8872 */ 8873 8874 bool skyCellDeleteObject( 8875 psDB *dbh, ///< Database handle 8876 const skyCellRow *object ///< Object to delete 8877 ); 8878 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 8879 * 8880 * Note that a 'where' search psMetadata is constructed from each object and 8881 * used to find rows to delete. 8882 * 8883 * @return A The number of rows removed or a negative value on error 8884 */ 8885 8886 long long skyCellDeleteRowObjects( 8887 psDB *dbh, ///< Database handle 8888 const psArray *objects, ///< Array of objects to delete 8889 unsigned long long limit ///< Maximum number of elements to delete 8890 ); 8891 /** Formats and prints an array of skyCellRow objects 8892 * 8893 * When mdcf is set the formated output is in psMetadataConfig 8894 * format, otherwise it is in a simple tabular format. 8895 * 8896 * @return true on success 8897 */ 8898 8899 bool skyCellPrintObjects( 8900 FILE *stream, ///< a stream 8901 psArray *objects, ///< An array of skyCellRow objects 8902 bool mdcf ///< format as mdconfig or simple 8903 ); 8904 /** Formats and prints an skyCellRow object 8905 * 8906 * When mdcf is set the formated output is in psMetadataConfig 8907 * format, otherwise it is in a simple tabular format. 8908 * 8909 * @return true on success 8910 */ 8911 8912 bool skyCellPrintObject( 8913 FILE *stream, ///< a stream 8914 skyCellRow *object, ///< an skyCellRow object 8915 bool mdcf ///< format as mdconfig or simple 8916 ); 8917 /** skyCellMapRow data structure 8918 * 8919 * Structure for representing a single row of skyCellMap table data. 8920 */ 8921 8922 typedef struct { 8923 char *skycell_id; 8924 char *tess_id; 8925 char *exp_tag; 8926 char *class_id; 8927 } skyCellMapRow; 8928 8929 /** Creates a new skyCellMapRow object 8930 * 8931 * @return A new skyCellMapRow object or NULL on failure. 8932 */ 8933 8934 skyCellMapRow *skyCellMapRowAlloc( 8935 const char *skycell_id, 8936 const char *tess_id, 8937 const char *exp_tag, 8938 const char *class_id 8939 ); 8940 8941 /** Creates a new skyCellMap table 8942 * 8943 * @return true on success 8944 */ 8945 8946 bool skyCellMapCreateTable( 8947 psDB *dbh ///< Database handle 8948 ); 8949 8950 /** Deletes a skyCellMap table 8951 * 8952 * @return true on success 8953 */ 8954 8955 bool skyCellMapDropTable( 8956 psDB *dbh ///< Database handle 8957 ); 8958 8959 /** Insert a single row into a table 8960 * 8961 * This function constructs and inserts a single row based on it's parameters. 8962 * 8963 * @return true on success 8964 */ 8965 8966 bool skyCellMapInsert( 8967 psDB *dbh, ///< Database handle 8968 const char *skycell_id, 8969 const char *tess_id, 8970 const char *exp_tag, 8971 const char *class_id 8972 ); 8973 8974 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 8975 * 8976 * @return A The number of rows removed or a negative value on error 8977 */ 8978 8979 long long skyCellMapDelete( 8980 psDB *dbh, ///< Database handle 8981 const psMetadata *where, ///< Row match criteria 8982 unsigned long long limit ///< Maximum number of elements to delete 8983 ); 8984 8985 /** Insert a single skyCellMapRow object into a table 8986 * 8987 * This function constructs and inserts a single row based on it's parameters. 8988 * 8989 * @return true on success 8990 */ 8991 8992 bool skyCellMapInsertObject( 8993 psDB *dbh, ///< Database handle 8994 skyCellMapRow *object ///< skyCellMapRow object 8995 ); 8996 8997 /** Insert an array of skyCellMapRow object into a table 8998 * 8999 * This function constructs and inserts multiple rows based on it's parameters. 9000 * 9001 * @return true on success 9002 */ 9003 9004 bool skyCellMapInsertObjects( 9005 psDB *dbh, ///< Database handle 9006 psArray *objects ///< array of skyCellMapRow objects 9007 ); 9008 9009 /** Insert data from a binary FITS table skyCellMapRow into the database 9010 * 9011 * This function expects a psFits object with a FITS table as the first 9012 * extension. The table must have at least one row of data in it, that is of 9013 * the appropriate format (number of columns and their type). All other 9014 * extensions are ignored. 9015 * 9016 * @return true on success 9017 */ 9018 9019 bool skyCellMapInsertFits( 9020 psDB *dbh, ///< Database handle 9021 const psFits *fits ///< psFits object 9022 ); 9023 9024 /** Selects up to limit from the database and returns them in a binary FITS table 9025 * 9026 * This function assumes an empty psFits object and will create a FITS table 9027 * as the first extension. 9028 * 9029 * See psDBSelectRows() for documentation on the format of where. 9030 * 9031 * @return true on success 9032 */ 9033 9034 bool skyCellMapSelectRowsFits( 9035 psDB *dbh, ///< Database handle 9036 psFits *fits, ///< psFits object 9037 const psMetadata *where, ///< Row match criteria 9038 unsigned long long limit ///< Maximum number of elements to return 9039 ); 9040 9041 /** Convert a skyCellMapRow into an equivalent psMetadata 9042 * 9043 * @return A psMetadata pointer or NULL on error 9044 */ 9045 9046 psMetadata *skyCellMapMetadataFromObject( 9047 const skyCellMapRow *object ///< fooRow to convert into a psMetadata 9048 ); 9049 9050 /** Convert a psMetadata into an equivalent fooRow 9051 * 9052 * @return A skyCellMapRow pointer or NULL on error 9053 */ 9054 9055 skyCellMapRow *skyCellMapObjectFromMetadata( 9056 psMetadata *md ///< psMetadata to convert into a fooRow 9057 ); 9058 /** Selects up to limit rows from the database and returns as skyCellMapRow objects in a psArray 9059 * 9060 * See psDBSelectRows() for documentation on the format of where. 9061 * 9062 * @return A psArray pointer or NULL on error 9063 */ 9064 9065 psArray *skyCellMapSelectRowObjects( 9066 psDB *dbh, ///< Database handle 9067 const psMetadata *where, ///< Row match criteria 9068 unsigned long long limit ///< Maximum number of elements to return 9069 ); 9070 /** Deletes a row from the database coresponding to an skyCellMap 9071 * 9072 * Note that a 'where' search psMetadata is constructed from each object and 9073 * used to find rows to delete. 9074 * 9075 * @return A The number of rows removed or a negative value on error 9076 */ 9077 9078 bool skyCellMapDeleteObject( 9079 psDB *dbh, ///< Database handle 9080 const skyCellMapRow *object ///< Object to delete 9081 ); 9082 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 9083 * 9084 * Note that a 'where' search psMetadata is constructed from each object and 9085 * used to find rows to delete. 9086 * 9087 * @return A The number of rows removed or a negative value on error 9088 */ 9089 9090 long long skyCellMapDeleteRowObjects( 9091 psDB *dbh, ///< Database handle 9092 const psArray *objects, ///< Array of objects to delete 9093 unsigned long long limit ///< Maximum number of elements to delete 9094 ); 9095 /** Formats and prints an array of skyCellMapRow objects 9096 * 9097 * When mdcf is set the formated output is in psMetadataConfig 9098 * format, otherwise it is in a simple tabular format. 9099 * 9100 * @return true on success 9101 */ 9102 9103 bool skyCellMapPrintObjects( 9104 FILE *stream, ///< a stream 9105 psArray *objects, ///< An array of skyCellMapRow objects 9106 bool mdcf ///< format as mdconfig or simple 9107 ); 9108 /** Formats and prints an skyCellMapRow object 9109 * 9110 * When mdcf is set the formated output is in psMetadataConfig 9111 * format, otherwise it is in a simple tabular format. 9112 * 9113 * @return true on success 9114 */ 9115 9116 bool skyCellMapPrintObject( 9117 FILE *stream, ///< a stream 9118 skyCellMapRow *object, ///< an skyCellMapRow object 9119 bool mdcf ///< format as mdconfig or simple 9120 ); 8101 9121 8102 9122 /// @} … … 8106 9126 #endif 8107 9127 8108 #endif // P4MAGICMASKIMFILE_DB_H9128 #endif // SKYCELLMAP_DB_H -
trunk/ippdb/tests/alloc.c
r11193 r11679 17 17 } 18 18 19 if (!object->counter == 64) { 19 20 psFree(object); 20 21 exit(EXIT_FAILURE); … … 399 400 exit(EXIT_FAILURE); 400 401 } 402 if (!object->fault == -16) { 401 403 psFree(object); 402 404 exit(EXIT_FAILURE); … … 490 492 exit(EXIT_FAILURE); 491 493 } 494 if (!object->fault == -16) { 492 495 psFree(object); 493 496 exit(EXIT_FAILURE); … … 691 694 exit(EXIT_FAILURE); 692 695 } 696 if (!object->fault == -16) { 693 697 psFree(object); 694 698 exit(EXIT_FAILURE); … … 800 804 exit(EXIT_FAILURE); 801 805 } 806 if (!object->fault == -16) { 802 807 psFree(object); 803 808 exit(EXIT_FAILURE); … … 1002 1007 exit(EXIT_FAILURE); 1003 1008 } 1009 if (!object->fault == -16) { 1004 1010 psFree(object); 1005 1011 exit(EXIT_FAILURE); … … 1050 1056 exit(EXIT_FAILURE); 1051 1057 } 1058 if (!object->fault == -16) { 1052 1059 psFree(object); 1053 1060 exit(EXIT_FAILURE); … … 1098 1105 exit(EXIT_FAILURE); 1099 1106 } 1107 if (!object->fault == -16) { 1100 1108 psFree(object); 1101 1109 exit(EXIT_FAILURE); … … 1130 1138 exit(EXIT_FAILURE); 1131 1139 } 1140 if (!object->fault == -16) { 1132 1141 psFree(object); 1133 1142 exit(EXIT_FAILURE); … … 1182 1191 exit(EXIT_FAILURE); 1183 1192 } 1193 if (!object->fault == -16) { 1184 1194 psFree(object); 1185 1195 exit(EXIT_FAILURE); … … 1230 1240 exit(EXIT_FAILURE); 1231 1241 } 1242 if (!object->fault == -16) { 1232 1243 psFree(object); 1233 1244 exit(EXIT_FAILURE); … … 1290 1301 exit(EXIT_FAILURE); 1291 1302 } 1303 if (!object->fault == -16) { 1292 1304 psFree(object); 1293 1305 exit(EXIT_FAILURE); … … 1346 1358 exit(EXIT_FAILURE); 1347 1359 } 1360 if (!object->fault == -16) { 1348 1361 psFree(object); 1349 1362 exit(EXIT_FAILURE); … … 1386 1399 exit(EXIT_FAILURE); 1387 1400 } 1388 psFree(object); 1389 exit(EXIT_FAILURE); 1390 } 1391 1392 psFree(object); 1393 } 1394 1395 { 1396 p4RunRow *object; 1397 1398 object = p4RunRowAlloc(-32, "a string", "a string", "a string", "a string", "a string", "a string", 64.64, 64.64, "a string", "a string" ); 1399 1400 if (!object) { 1401 exit(EXIT_FAILURE); 1402 } 1403 1404 if (!object->p4_id == -32) { 1405 psFree(object); 1406 exit(EXIT_FAILURE); 1407 } 1408 if (strncmp(object->survey_mode, "a string", MAX_STRING_LENGTH)) { 1401 if (!object->fault == -16) { 1402 psFree(object); 1403 exit(EXIT_FAILURE); 1404 } 1405 1406 psFree(object); 1407 } 1408 1409 { 1410 p4aRunRow *object; 1411 1412 object = p4aRunRowAlloc(-32, "a string", "a string", true ); 1413 1414 if (!object) { 1415 exit(EXIT_FAILURE); 1416 } 1417 1418 if (!object->p4a_id == -32) { 1409 1419 psFree(object); 1410 1420 exit(EXIT_FAILURE); … … 1418 1428 exit(EXIT_FAILURE); 1419 1429 } 1420 if (strncmp(object->filter, "a string", MAX_STRING_LENGTH)) { 1430 if (!object->magic == true) { 1431 psFree(object); 1432 exit(EXIT_FAILURE); 1433 } 1434 1435 psFree(object); 1436 } 1437 1438 { 1439 p4aInputExpRow *object; 1440 1441 object = p4aInputExpRowAlloc(-32, "a string", -32 ); 1442 1443 if (!object) { 1444 exit(EXIT_FAILURE); 1445 } 1446 1447 if (!object->p4a_id == -32) { 1448 psFree(object); 1449 exit(EXIT_FAILURE); 1450 } 1451 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 1452 psFree(object); 1453 exit(EXIT_FAILURE); 1454 } 1455 if (!object->p3_version == -32) { 1456 psFree(object); 1457 exit(EXIT_FAILURE); 1458 } 1459 1460 psFree(object); 1461 } 1462 1463 { 1464 p4aScfileRow *object; 1465 1466 object = p4aScfileRowAlloc(-32, "a string", "a string", "a string", -32, "a string", 64.64, 64.64 ); 1467 1468 if (!object) { 1469 exit(EXIT_FAILURE); 1470 } 1471 1472 if (!object->p4a_id == -32) { 1421 1473 psFree(object); 1422 1474 exit(EXIT_FAILURE); … … 1430 1482 exit(EXIT_FAILURE); 1431 1483 } 1432 if (!object->ra == 64.64) {1433 psFree(object);1434 exit(EXIT_FAILURE);1435 }1436 if (!object->decl == 64.64) {1437 psFree(object);1438 exit(EXIT_FAILURE);1439 }1440 if (strncmp(object->input_ss, "a string", MAX_STRING_LENGTH)) {1441 psFree(object);1442 exit(EXIT_FAILURE);1443 }1444 if (strncmp(object->output_ss, "a string", MAX_STRING_LENGTH)) {1445 psFree(object);1446 exit(EXIT_FAILURE);1447 }1448 1449 psFree(object);1450 }1451 1452 {1453 p4InputImfileRow *object;1454 1455 object = p4InputImfileRowAlloc(-32, "a string", -32, "a string" );1456 1457 if (!object) {1458 exit(EXIT_FAILURE);1459 }1460 1461 if (!object->p4_id == -32) {1462 psFree(object);1463 exit(EXIT_FAILURE);1464 }1465 1484 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 1466 1485 psFree(object); … … 1471 1490 exit(EXIT_FAILURE); 1472 1491 } 1492 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) { 1493 psFree(object); 1494 exit(EXIT_FAILURE); 1495 } 1496 if (!object->bg == 64.64) { 1497 psFree(object); 1498 exit(EXIT_FAILURE); 1499 } 1500 if (!object->bg_mean_stdev == 64.64) { 1501 psFree(object); 1502 exit(EXIT_FAILURE); 1503 } 1504 1505 psFree(object); 1506 } 1507 1508 { 1509 p4bRunRow *object; 1510 1511 object = p4bRunRowAlloc(-32, "a string", "a string", true ); 1512 1513 if (!object) { 1514 exit(EXIT_FAILURE); 1515 } 1516 1517 if (!object->p4b_id == -32) { 1518 psFree(object); 1519 exit(EXIT_FAILURE); 1520 } 1521 if (strncmp(object->state, "a string", MAX_STRING_LENGTH)) { 1522 psFree(object); 1523 exit(EXIT_FAILURE); 1524 } 1525 if (strncmp(object->workdir, "a string", MAX_STRING_LENGTH)) { 1526 psFree(object); 1527 exit(EXIT_FAILURE); 1528 } 1529 if (!object->magic == true) { 1530 psFree(object); 1531 exit(EXIT_FAILURE); 1532 } 1533 1534 psFree(object); 1535 } 1536 1537 { 1538 p4bInputScfileRow *object; 1539 1540 object = p4bInputScfileRowAlloc(-32, "a string", "a string", "a string", -32, "a string" ); 1541 1542 if (!object) { 1543 exit(EXIT_FAILURE); 1544 } 1545 1546 if (!object->p4b_id == -32) { 1547 psFree(object); 1548 exit(EXIT_FAILURE); 1549 } 1550 if (strncmp(object->skycell_id, "a string", MAX_STRING_LENGTH)) { 1551 psFree(object); 1552 exit(EXIT_FAILURE); 1553 } 1554 if (strncmp(object->tess_id, "a string", MAX_STRING_LENGTH)) { 1555 psFree(object); 1556 exit(EXIT_FAILURE); 1557 } 1558 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 1559 psFree(object); 1560 exit(EXIT_FAILURE); 1561 } 1562 if (!object->p3_version == -32) { 1563 psFree(object); 1564 exit(EXIT_FAILURE); 1565 } 1566 if (strncmp(object->kind, "a string", MAX_STRING_LENGTH)) { 1567 psFree(object); 1568 exit(EXIT_FAILURE); 1569 } 1570 1571 psFree(object); 1572 } 1573 1574 { 1575 p4bDiffScfileRow *object; 1576 1577 object = p4bDiffScfileRowAlloc(-32, "a string", "a string", "a string", -32, "a string", 64.64, 64.64 ); 1578 1579 if (!object) { 1580 exit(EXIT_FAILURE); 1581 } 1582 1583 if (!object->p4b_id == -32) { 1584 psFree(object); 1585 exit(EXIT_FAILURE); 1586 } 1587 if (strncmp(object->skycell_id, "a string", MAX_STRING_LENGTH)) { 1588 psFree(object); 1589 exit(EXIT_FAILURE); 1590 } 1591 if (strncmp(object->tess_id, "a string", MAX_STRING_LENGTH)) { 1592 psFree(object); 1593 exit(EXIT_FAILURE); 1594 } 1595 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 1596 psFree(object); 1597 exit(EXIT_FAILURE); 1598 } 1599 if (!object->p3_version == -32) { 1600 psFree(object); 1601 exit(EXIT_FAILURE); 1602 } 1603 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) { 1604 psFree(object); 1605 exit(EXIT_FAILURE); 1606 } 1607 if (!object->bg == 64.64) { 1608 psFree(object); 1609 exit(EXIT_FAILURE); 1610 } 1611 if (!object->bg_mean_stdev == 64.64) { 1612 psFree(object); 1613 exit(EXIT_FAILURE); 1614 } 1615 1616 psFree(object); 1617 } 1618 1619 { 1620 p4cRunRow *object; 1621 1622 object = p4cRunRowAlloc(-32, "a string", "a string", true ); 1623 1624 if (!object) { 1625 exit(EXIT_FAILURE); 1626 } 1627 1628 if (!object->p4c_id == -32) { 1629 psFree(object); 1630 exit(EXIT_FAILURE); 1631 } 1632 if (strncmp(object->state, "a string", MAX_STRING_LENGTH)) { 1633 psFree(object); 1634 exit(EXIT_FAILURE); 1635 } 1636 if (strncmp(object->workdir, "a string", MAX_STRING_LENGTH)) { 1637 psFree(object); 1638 exit(EXIT_FAILURE); 1639 } 1640 if (!object->magic == true) { 1641 psFree(object); 1642 exit(EXIT_FAILURE); 1643 } 1644 1645 psFree(object); 1646 } 1647 1648 { 1649 p4cInputExpRow *object; 1650 1651 object = p4cInputExpRowAlloc(-32, "a string", -32 ); 1652 1653 if (!object) { 1654 exit(EXIT_FAILURE); 1655 } 1656 1657 if (!object->p4c_id == -32) { 1658 psFree(object); 1659 exit(EXIT_FAILURE); 1660 } 1661 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 1662 psFree(object); 1663 exit(EXIT_FAILURE); 1664 } 1665 if (!object->p3_version == -32) { 1666 psFree(object); 1667 exit(EXIT_FAILURE); 1668 } 1669 1670 psFree(object); 1671 } 1672 1673 { 1674 p4MagicMaskImfileRow *object; 1675 1676 object = p4MagicMaskImfileRowAlloc(-32, "a string", -32, "a string", "a string" ); 1677 1678 if (!object) { 1679 exit(EXIT_FAILURE); 1680 } 1681 1682 if (!object->p4c_id == -32) { 1683 psFree(object); 1684 exit(EXIT_FAILURE); 1685 } 1686 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 1687 psFree(object); 1688 exit(EXIT_FAILURE); 1689 } 1690 if (!object->p3_version == -32) { 1691 psFree(object); 1692 exit(EXIT_FAILURE); 1693 } 1473 1694 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) { 1474 1695 psFree(object); 1475 1696 exit(EXIT_FAILURE); 1476 1697 } 1477 1478 psFree(object); 1479 } 1480 1481 { 1482 p4WarpedImfileRow *object; 1483 1484 object = p4WarpedImfileRowAlloc(-32, "a string", -32, "a string", "a string", "a string", "a string" ); 1485 1486 if (!object) { 1487 exit(EXIT_FAILURE); 1488 } 1489 1490 if (!object->p4_id == -32) { 1491 psFree(object); 1492 exit(EXIT_FAILURE); 1493 } 1494 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 1495 psFree(object); 1496 exit(EXIT_FAILURE); 1497 } 1498 if (!object->p3_version == -32) { 1698 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) { 1699 psFree(object); 1700 exit(EXIT_FAILURE); 1701 } 1702 1703 psFree(object); 1704 } 1705 1706 { 1707 skyCellRow *object; 1708 1709 object = skyCellRowAlloc("a string", "a string", 64.64, 64.64, 64.64, 64.64, 64.64, 64.64, 64.64, 64.64 ); 1710 1711 if (!object) { 1712 exit(EXIT_FAILURE); 1713 } 1714 1715 if (strncmp(object->skycell_id, "a string", MAX_STRING_LENGTH)) { 1716 psFree(object); 1717 exit(EXIT_FAILURE); 1718 } 1719 if (strncmp(object->tess_id, "a string", MAX_STRING_LENGTH)) { 1720 psFree(object); 1721 exit(EXIT_FAILURE); 1722 } 1723 if (!object->ra1 == 64.64) { 1724 psFree(object); 1725 exit(EXIT_FAILURE); 1726 } 1727 if (!object->decl1 == 64.64) { 1728 psFree(object); 1729 exit(EXIT_FAILURE); 1730 } 1731 if (!object->ra2 == 64.64) { 1732 psFree(object); 1733 exit(EXIT_FAILURE); 1734 } 1735 if (!object->decl2 == 64.64) { 1736 psFree(object); 1737 exit(EXIT_FAILURE); 1738 } 1739 if (!object->ra3 == 64.64) { 1740 psFree(object); 1741 exit(EXIT_FAILURE); 1742 } 1743 if (!object->decl3 == 64.64) { 1744 psFree(object); 1745 exit(EXIT_FAILURE); 1746 } 1747 if (!object->ra4 == 64.64) { 1748 psFree(object); 1749 exit(EXIT_FAILURE); 1750 } 1751 if (!object->decl4 == 64.64) { 1752 psFree(object); 1753 exit(EXIT_FAILURE); 1754 } 1755 1756 psFree(object); 1757 } 1758 1759 { 1760 skyCellMapRow *object; 1761 1762 object = skyCellMapRowAlloc("a string", "a string", "a string", "a string" ); 1763 1764 if (!object) { 1765 exit(EXIT_FAILURE); 1766 } 1767 1768 if (strncmp(object->skycell_id, "a string", MAX_STRING_LENGTH)) { 1769 psFree(object); 1770 exit(EXIT_FAILURE); 1771 } 1772 if (strncmp(object->tess_id, "a string", MAX_STRING_LENGTH)) { 1773 psFree(object); 1774 exit(EXIT_FAILURE); 1775 } 1776 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 1499 1777 psFree(object); 1500 1778 exit(EXIT_FAILURE); 1501 1779 } 1502 1780 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) { 1503 psFree(object);1504 exit(EXIT_FAILURE);1505 }1506 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) {1507 psFree(object);1508 exit(EXIT_FAILURE);1509 }1510 if (strncmp(object->b1_uri, "a string", MAX_STRING_LENGTH)) {1511 psFree(object);1512 exit(EXIT_FAILURE);1513 }1514 if (strncmp(object->b2_uri, "a string", MAX_STRING_LENGTH)) {1515 psFree(object);1516 exit(EXIT_FAILURE);1517 }1518 1519 psFree(object);1520 }1521 1522 {1523 p4StackedImfileRow *object;1524 1525 object = p4StackedImfileRowAlloc(-32, "a string", "a string", "a string", "a string" );1526 1527 if (!object) {1528 exit(EXIT_FAILURE);1529 }1530 1531 if (!object->p4_id == -32) {1532 psFree(object);1533 exit(EXIT_FAILURE);1534 }1535 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) {1536 psFree(object);1537 exit(EXIT_FAILURE);1538 }1539 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) {1540 psFree(object);1541 exit(EXIT_FAILURE);1542 }1543 if (strncmp(object->b1_uri, "a string", MAX_STRING_LENGTH)) {1544 psFree(object);1545 exit(EXIT_FAILURE);1546 }1547 if (strncmp(object->b2_uri, "a string", MAX_STRING_LENGTH)) {1548 psFree(object);1549 exit(EXIT_FAILURE);1550 }1551 1552 psFree(object);1553 }1554 1555 {1556 p4DiffImfileRow *object;1557 1558 object = p4DiffImfileRowAlloc(-32, "a string", -32, "a string", "a string", "a string", "a string" );1559 1560 if (!object) {1561 exit(EXIT_FAILURE);1562 }1563 1564 if (!object->p4_id == -32) {1565 psFree(object);1566 exit(EXIT_FAILURE);1567 }1568 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) {1569 psFree(object);1570 exit(EXIT_FAILURE);1571 }1572 if (!object->p3_version == -32) {1573 psFree(object);1574 exit(EXIT_FAILURE);1575 }1576 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) {1577 psFree(object);1578 exit(EXIT_FAILURE);1579 }1580 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) {1581 psFree(object);1582 exit(EXIT_FAILURE);1583 }1584 if (strncmp(object->b1_uri, "a string", MAX_STRING_LENGTH)) {1585 psFree(object);1586 exit(EXIT_FAILURE);1587 }1588 if (strncmp(object->b2_uri, "a string", MAX_STRING_LENGTH)) {1589 psFree(object);1590 exit(EXIT_FAILURE);1591 }1592 1593 psFree(object);1594 }1595 1596 {1597 p4MagicMaskImfileRow *object;1598 1599 object = p4MagicMaskImfileRowAlloc(-32, "a string", -32, "a string", "a string" );1600 1601 if (!object) {1602 exit(EXIT_FAILURE);1603 }1604 1605 if (!object->p4_id == -32) {1606 psFree(object);1607 exit(EXIT_FAILURE);1608 }1609 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) {1610 psFree(object);1611 exit(EXIT_FAILURE);1612 }1613 if (!object->p3_version == -32) {1614 psFree(object);1615 exit(EXIT_FAILURE);1616 }1617 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) {1618 psFree(object);1619 exit(EXIT_FAILURE);1620 }1621 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) {1622 1781 psFree(object); 1623 1782 exit(EXIT_FAILURE); -
trunk/ippdb/tests/createtable.c
r11045 r11679 478 478 } 479 479 480 if(!p4RunCreateTable(dbh)) { 481 exit(EXIT_FAILURE); 482 } 483 484 psDBCleanup(dbh); 485 } 486 487 { 488 psDB *dbh; 489 490 dbh = psDBInit("localhost", "test", NULL, "test"); 491 if (!dbh) { 492 exit(EXIT_FAILURE); 493 } 494 495 if(!p4InputImfileCreateTable(dbh)) { 496 exit(EXIT_FAILURE); 497 } 498 499 psDBCleanup(dbh); 500 } 501 502 { 503 psDB *dbh; 504 505 dbh = psDBInit("localhost", "test", NULL, "test"); 506 if (!dbh) { 507 exit(EXIT_FAILURE); 508 } 509 510 if(!p4WarpedImfileCreateTable(dbh)) { 511 exit(EXIT_FAILURE); 512 } 513 514 psDBCleanup(dbh); 515 } 516 517 { 518 psDB *dbh; 519 520 dbh = psDBInit("localhost", "test", NULL, "test"); 521 if (!dbh) { 522 exit(EXIT_FAILURE); 523 } 524 525 if(!p4StackedImfileCreateTable(dbh)) { 526 exit(EXIT_FAILURE); 527 } 528 529 psDBCleanup(dbh); 530 } 531 532 { 533 psDB *dbh; 534 535 dbh = psDBInit("localhost", "test", NULL, "test"); 536 if (!dbh) { 537 exit(EXIT_FAILURE); 538 } 539 540 if(!p4DiffImfileCreateTable(dbh)) { 480 if(!p4aRunCreateTable(dbh)) { 481 exit(EXIT_FAILURE); 482 } 483 484 psDBCleanup(dbh); 485 } 486 487 { 488 psDB *dbh; 489 490 dbh = psDBInit("localhost", "test", NULL, "test"); 491 if (!dbh) { 492 exit(EXIT_FAILURE); 493 } 494 495 if(!p4aInputExpCreateTable(dbh)) { 496 exit(EXIT_FAILURE); 497 } 498 499 psDBCleanup(dbh); 500 } 501 502 { 503 psDB *dbh; 504 505 dbh = psDBInit("localhost", "test", NULL, "test"); 506 if (!dbh) { 507 exit(EXIT_FAILURE); 508 } 509 510 if(!p4aScfileCreateTable(dbh)) { 511 exit(EXIT_FAILURE); 512 } 513 514 psDBCleanup(dbh); 515 } 516 517 { 518 psDB *dbh; 519 520 dbh = psDBInit("localhost", "test", NULL, "test"); 521 if (!dbh) { 522 exit(EXIT_FAILURE); 523 } 524 525 if(!p4bRunCreateTable(dbh)) { 526 exit(EXIT_FAILURE); 527 } 528 529 psDBCleanup(dbh); 530 } 531 532 { 533 psDB *dbh; 534 535 dbh = psDBInit("localhost", "test", NULL, "test"); 536 if (!dbh) { 537 exit(EXIT_FAILURE); 538 } 539 540 if(!p4bInputScfileCreateTable(dbh)) { 541 exit(EXIT_FAILURE); 542 } 543 544 psDBCleanup(dbh); 545 } 546 547 { 548 psDB *dbh; 549 550 dbh = psDBInit("localhost", "test", NULL, "test"); 551 if (!dbh) { 552 exit(EXIT_FAILURE); 553 } 554 555 if(!p4bDiffScfileCreateTable(dbh)) { 556 exit(EXIT_FAILURE); 557 } 558 559 psDBCleanup(dbh); 560 } 561 562 { 563 psDB *dbh; 564 565 dbh = psDBInit("localhost", "test", NULL, "test"); 566 if (!dbh) { 567 exit(EXIT_FAILURE); 568 } 569 570 if(!p4cRunCreateTable(dbh)) { 571 exit(EXIT_FAILURE); 572 } 573 574 psDBCleanup(dbh); 575 } 576 577 { 578 psDB *dbh; 579 580 dbh = psDBInit("localhost", "test", NULL, "test"); 581 if (!dbh) { 582 exit(EXIT_FAILURE); 583 } 584 585 if(!p4cInputExpCreateTable(dbh)) { 541 586 exit(EXIT_FAILURE); 542 587 } … … 554 599 555 600 if(!p4MagicMaskImfileCreateTable(dbh)) { 601 exit(EXIT_FAILURE); 602 } 603 604 psDBCleanup(dbh); 605 } 606 607 { 608 psDB *dbh; 609 610 dbh = psDBInit("localhost", "test", NULL, "test"); 611 if (!dbh) { 612 exit(EXIT_FAILURE); 613 } 614 615 if(!skyCellCreateTable(dbh)) { 616 exit(EXIT_FAILURE); 617 } 618 619 psDBCleanup(dbh); 620 } 621 622 { 623 psDB *dbh; 624 625 dbh = psDBInit("localhost", "test", NULL, "test"); 626 if (!dbh) { 627 exit(EXIT_FAILURE); 628 } 629 630 if(!skyCellMapCreateTable(dbh)) { 556 631 exit(EXIT_FAILURE); 557 632 } -
trunk/ippdb/tests/dbcleanup.c
r11045 r11679 6 6 psDB *dbh; 7 7 8 dbh = psDBInit("localhost", "test", NULL, "test" );8 dbh = psDBInit("localhost", "test", NULL, "test", 0); 9 9 if (!dbh) { 10 10 exit(EXIT_FAILURE); … … 42 42 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detResidExp"); 43 43 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detRunSummary"); 44 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4Run"); 45 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4InputImfile"); 46 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4WarpedImfile"); 47 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4StackedImfile"); 48 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4DiffImfile"); 44 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4aRun"); 45 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4aInputExp"); 46 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4aScfile"); 47 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4bRun"); 48 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4bInputScfile"); 49 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4bDiffScfile"); 50 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4cRun"); 51 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4cInputExp"); 49 52 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4MagicMaskImfile"); 53 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS skyCell"); 54 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS skyCellMap"); 50 55 51 56 psDBCleanup(dbh); -
trunk/ippdb/tests/dbsetup.c
r11045 r11679 7 7 psDB *dbh; 8 8 9 dbh = psDBInit("localhost", "test", NULL, "test" );9 dbh = psDBInit("localhost", "test", NULL, "test", 0); 10 10 if (!dbh) { 11 11 exit(EXIT_FAILURE); … … 106 106 detRunSummaryCreateTable(dbh); 107 107 108 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4 Run");109 p4 RunCreateTable(dbh);108 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4aRun"); 109 p4aRunCreateTable(dbh); 110 110 111 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4 InputImfile");112 p4 InputImfileCreateTable(dbh);111 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4aInputExp"); 112 p4aInputExpCreateTable(dbh); 113 113 114 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4 WarpedImfile");115 p4 WarpedImfileCreateTable(dbh);114 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4aScfile"); 115 p4aScfileCreateTable(dbh); 116 116 117 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4 StackedImfile");118 p4 StackedImfileCreateTable(dbh);117 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4bRun"); 118 p4bRunCreateTable(dbh); 119 119 120 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4DiffImfile"); 121 p4DiffImfileCreateTable(dbh); 120 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4bInputScfile"); 121 p4bInputScfileCreateTable(dbh); 122 123 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4bDiffScfile"); 124 p4bDiffScfileCreateTable(dbh); 125 126 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4cRun"); 127 p4cRunCreateTable(dbh); 128 129 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4cInputExp"); 130 p4cInputExpCreateTable(dbh); 122 131 123 132 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4MagicMaskImfile"); 124 133 p4MagicMaskImfileCreateTable(dbh); 134 135 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS skyCell"); 136 skyCellCreateTable(dbh); 137 138 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS skyCellMap"); 139 skyCellMapCreateTable(dbh); 125 140 126 141 psDBCleanup(dbh); -
trunk/ippdb/tests/droptable.c
r11045 r11679 478 478 } 479 479 480 if (!p4RunDropTable(dbh)) { 481 exit(EXIT_FAILURE); 482 } 483 484 psDBCleanup(dbh); 485 } 486 487 { 488 psDB *dbh; 489 490 dbh = psDBInit("localhost", "test", NULL, "test"); 491 if (!dbh) { 492 exit(EXIT_FAILURE); 493 } 494 495 if (!p4InputImfileDropTable(dbh)) { 496 exit(EXIT_FAILURE); 497 } 498 499 psDBCleanup(dbh); 500 } 501 502 { 503 psDB *dbh; 504 505 dbh = psDBInit("localhost", "test", NULL, "test"); 506 if (!dbh) { 507 exit(EXIT_FAILURE); 508 } 509 510 if (!p4WarpedImfileDropTable(dbh)) { 511 exit(EXIT_FAILURE); 512 } 513 514 psDBCleanup(dbh); 515 } 516 517 { 518 psDB *dbh; 519 520 dbh = psDBInit("localhost", "test", NULL, "test"); 521 if (!dbh) { 522 exit(EXIT_FAILURE); 523 } 524 525 if (!p4StackedImfileDropTable(dbh)) { 526 exit(EXIT_FAILURE); 527 } 528 529 psDBCleanup(dbh); 530 } 531 532 { 533 psDB *dbh; 534 535 dbh = psDBInit("localhost", "test", NULL, "test"); 536 if (!dbh) { 537 exit(EXIT_FAILURE); 538 } 539 540 if (!p4DiffImfileDropTable(dbh)) { 480 if (!p4aRunDropTable(dbh)) { 481 exit(EXIT_FAILURE); 482 } 483 484 psDBCleanup(dbh); 485 } 486 487 { 488 psDB *dbh; 489 490 dbh = psDBInit("localhost", "test", NULL, "test"); 491 if (!dbh) { 492 exit(EXIT_FAILURE); 493 } 494 495 if (!p4aInputExpDropTable(dbh)) { 496 exit(EXIT_FAILURE); 497 } 498 499 psDBCleanup(dbh); 500 } 501 502 { 503 psDB *dbh; 504 505 dbh = psDBInit("localhost", "test", NULL, "test"); 506 if (!dbh) { 507 exit(EXIT_FAILURE); 508 } 509 510 if (!p4aScfileDropTable(dbh)) { 511 exit(EXIT_FAILURE); 512 } 513 514 psDBCleanup(dbh); 515 } 516 517 { 518 psDB *dbh; 519 520 dbh = psDBInit("localhost", "test", NULL, "test"); 521 if (!dbh) { 522 exit(EXIT_FAILURE); 523 } 524 525 if (!p4bRunDropTable(dbh)) { 526 exit(EXIT_FAILURE); 527 } 528 529 psDBCleanup(dbh); 530 } 531 532 { 533 psDB *dbh; 534 535 dbh = psDBInit("localhost", "test", NULL, "test"); 536 if (!dbh) { 537 exit(EXIT_FAILURE); 538 } 539 540 if (!p4bInputScfileDropTable(dbh)) { 541 exit(EXIT_FAILURE); 542 } 543 544 psDBCleanup(dbh); 545 } 546 547 { 548 psDB *dbh; 549 550 dbh = psDBInit("localhost", "test", NULL, "test"); 551 if (!dbh) { 552 exit(EXIT_FAILURE); 553 } 554 555 if (!p4bDiffScfileDropTable(dbh)) { 556 exit(EXIT_FAILURE); 557 } 558 559 psDBCleanup(dbh); 560 } 561 562 { 563 psDB *dbh; 564 565 dbh = psDBInit("localhost", "test", NULL, "test"); 566 if (!dbh) { 567 exit(EXIT_FAILURE); 568 } 569 570 if (!p4cRunDropTable(dbh)) { 571 exit(EXIT_FAILURE); 572 } 573 574 psDBCleanup(dbh); 575 } 576 577 { 578 psDB *dbh; 579 580 dbh = psDBInit("localhost", "test", NULL, "test"); 581 if (!dbh) { 582 exit(EXIT_FAILURE); 583 } 584 585 if (!p4cInputExpDropTable(dbh)) { 541 586 exit(EXIT_FAILURE); 542 587 } … … 554 599 555 600 if (!p4MagicMaskImfileDropTable(dbh)) { 601 exit(EXIT_FAILURE); 602 } 603 604 psDBCleanup(dbh); 605 } 606 607 { 608 psDB *dbh; 609 610 dbh = psDBInit("localhost", "test", NULL, "test"); 611 if (!dbh) { 612 exit(EXIT_FAILURE); 613 } 614 615 if (!skyCellDropTable(dbh)) { 616 exit(EXIT_FAILURE); 617 } 618 619 psDBCleanup(dbh); 620 } 621 622 { 623 psDB *dbh; 624 625 dbh = psDBInit("localhost", "test", NULL, "test"); 626 if (!dbh) { 627 exit(EXIT_FAILURE); 628 } 629 630 if (!skyCellMapDropTable(dbh)) { 556 631 exit(EXIT_FAILURE); 557 632 } -
trunk/ippdb/tests/insert.c
r11193 r11679 478 478 } 479 479 480 if (!p4RunInsert(dbh, -32, "a string", "a string", "a string", "a string", "a string", "a string", 64.64, 64.64, "a string", "a string")) { 481 exit(EXIT_FAILURE); 482 } 483 484 psDBCleanup(dbh); 485 } 486 487 { 488 psDB *dbh; 489 490 dbh = psDBInit("localhost", "test", NULL, "test"); 491 if (!dbh) { 492 exit(EXIT_FAILURE); 493 } 494 495 if (!p4InputImfileInsert(dbh, -32, "a string", -32, "a string")) { 496 exit(EXIT_FAILURE); 497 } 498 499 psDBCleanup(dbh); 500 } 501 502 { 503 psDB *dbh; 504 505 dbh = psDBInit("localhost", "test", NULL, "test"); 506 if (!dbh) { 507 exit(EXIT_FAILURE); 508 } 509 510 if (!p4WarpedImfileInsert(dbh, -32, "a string", -32, "a string", "a string", "a string", "a string")) { 511 exit(EXIT_FAILURE); 512 } 513 514 psDBCleanup(dbh); 515 } 516 517 { 518 psDB *dbh; 519 520 dbh = psDBInit("localhost", "test", NULL, "test"); 521 if (!dbh) { 522 exit(EXIT_FAILURE); 523 } 524 525 if (!p4StackedImfileInsert(dbh, -32, "a string", "a string", "a string", "a string")) { 526 exit(EXIT_FAILURE); 527 } 528 529 psDBCleanup(dbh); 530 } 531 532 { 533 psDB *dbh; 534 535 dbh = psDBInit("localhost", "test", NULL, "test"); 536 if (!dbh) { 537 exit(EXIT_FAILURE); 538 } 539 540 if (!p4DiffImfileInsert(dbh, -32, "a string", -32, "a string", "a string", "a string", "a string")) { 480 if (!p4aRunInsert(dbh, -32, "a string", "a string", true)) { 481 exit(EXIT_FAILURE); 482 } 483 484 psDBCleanup(dbh); 485 } 486 487 { 488 psDB *dbh; 489 490 dbh = psDBInit("localhost", "test", NULL, "test"); 491 if (!dbh) { 492 exit(EXIT_FAILURE); 493 } 494 495 if (!p4aInputExpInsert(dbh, -32, "a string", -32)) { 496 exit(EXIT_FAILURE); 497 } 498 499 psDBCleanup(dbh); 500 } 501 502 { 503 psDB *dbh; 504 505 dbh = psDBInit("localhost", "test", NULL, "test"); 506 if (!dbh) { 507 exit(EXIT_FAILURE); 508 } 509 510 if (!p4aScfileInsert(dbh, -32, "a string", "a string", "a string", -32, "a string", 64.64, 64.64)) { 511 exit(EXIT_FAILURE); 512 } 513 514 psDBCleanup(dbh); 515 } 516 517 { 518 psDB *dbh; 519 520 dbh = psDBInit("localhost", "test", NULL, "test"); 521 if (!dbh) { 522 exit(EXIT_FAILURE); 523 } 524 525 if (!p4bRunInsert(dbh, -32, "a string", "a string", true)) { 526 exit(EXIT_FAILURE); 527 } 528 529 psDBCleanup(dbh); 530 } 531 532 { 533 psDB *dbh; 534 535 dbh = psDBInit("localhost", "test", NULL, "test"); 536 if (!dbh) { 537 exit(EXIT_FAILURE); 538 } 539 540 if (!p4bInputScfileInsert(dbh, -32, "a string", "a string", "a string", -32, "a string")) { 541 exit(EXIT_FAILURE); 542 } 543 544 psDBCleanup(dbh); 545 } 546 547 { 548 psDB *dbh; 549 550 dbh = psDBInit("localhost", "test", NULL, "test"); 551 if (!dbh) { 552 exit(EXIT_FAILURE); 553 } 554 555 if (!p4bDiffScfileInsert(dbh, -32, "a string", "a string", "a string", -32, "a string", 64.64, 64.64)) { 556 exit(EXIT_FAILURE); 557 } 558 559 psDBCleanup(dbh); 560 } 561 562 { 563 psDB *dbh; 564 565 dbh = psDBInit("localhost", "test", NULL, "test"); 566 if (!dbh) { 567 exit(EXIT_FAILURE); 568 } 569 570 if (!p4cRunInsert(dbh, -32, "a string", "a string", true)) { 571 exit(EXIT_FAILURE); 572 } 573 574 psDBCleanup(dbh); 575 } 576 577 { 578 psDB *dbh; 579 580 dbh = psDBInit("localhost", "test", NULL, "test"); 581 if (!dbh) { 582 exit(EXIT_FAILURE); 583 } 584 585 if (!p4cInputExpInsert(dbh, -32, "a string", -32)) { 541 586 exit(EXIT_FAILURE); 542 587 } … … 554 599 555 600 if (!p4MagicMaskImfileInsert(dbh, -32, "a string", -32, "a string", "a string")) { 601 exit(EXIT_FAILURE); 602 } 603 604 psDBCleanup(dbh); 605 } 606 607 { 608 psDB *dbh; 609 610 dbh = psDBInit("localhost", "test", NULL, "test"); 611 if (!dbh) { 612 exit(EXIT_FAILURE); 613 } 614 615 if (!skyCellInsert(dbh, "a string", "a string", 64.64, 64.64, 64.64, 64.64, 64.64, 64.64, 64.64, 64.64)) { 616 exit(EXIT_FAILURE); 617 } 618 619 psDBCleanup(dbh); 620 } 621 622 { 623 psDB *dbh; 624 625 dbh = psDBInit("localhost", "test", NULL, "test"); 626 if (!dbh) { 627 exit(EXIT_FAILURE); 628 } 629 630 if (!skyCellMapInsert(dbh, "a string", "a string", "a string", "a string")) { 556 631 exit(EXIT_FAILURE); 557 632 } -
trunk/ippdb/tests/insertfits.c
r11045 r11679 830 830 } 831 831 832 if (!p4RunInsertFits(dbh, fits)) { 833 exit(EXIT_FAILURE); 834 } 835 836 if (!psFitsClose(fits)) { 837 exit(EXIT_FAILURE); 838 } 839 840 psDBCleanup(dbh); 841 } 842 843 { 844 psDB *dbh; 845 psFits *fits; 846 847 dbh = psDBInit("localhost", "test", NULL, "test"); 848 if (!dbh) { 849 exit(EXIT_FAILURE); 850 } 851 852 // open a temp 853 fits = psFitsOpen(TMP_FILENAME, "r"); 854 if (!fits) { 855 exit(EXIT_FAILURE); 856 } 857 858 if (!p4InputImfileInsertFits(dbh, fits)) { 859 exit(EXIT_FAILURE); 860 } 861 862 if (!psFitsClose(fits)) { 863 exit(EXIT_FAILURE); 864 } 865 866 psDBCleanup(dbh); 867 } 868 869 { 870 psDB *dbh; 871 psFits *fits; 872 873 dbh = psDBInit("localhost", "test", NULL, "test"); 874 if (!dbh) { 875 exit(EXIT_FAILURE); 876 } 877 878 // open a temp 879 fits = psFitsOpen(TMP_FILENAME, "r"); 880 if (!fits) { 881 exit(EXIT_FAILURE); 882 } 883 884 if (!p4WarpedImfileInsertFits(dbh, fits)) { 885 exit(EXIT_FAILURE); 886 } 887 888 if (!psFitsClose(fits)) { 889 exit(EXIT_FAILURE); 890 } 891 892 psDBCleanup(dbh); 893 } 894 895 { 896 psDB *dbh; 897 psFits *fits; 898 899 dbh = psDBInit("localhost", "test", NULL, "test"); 900 if (!dbh) { 901 exit(EXIT_FAILURE); 902 } 903 904 // open a temp 905 fits = psFitsOpen(TMP_FILENAME, "r"); 906 if (!fits) { 907 exit(EXIT_FAILURE); 908 } 909 910 if (!p4StackedImfileInsertFits(dbh, fits)) { 911 exit(EXIT_FAILURE); 912 } 913 914 if (!psFitsClose(fits)) { 915 exit(EXIT_FAILURE); 916 } 917 918 psDBCleanup(dbh); 919 } 920 921 { 922 psDB *dbh; 923 psFits *fits; 924 925 dbh = psDBInit("localhost", "test", NULL, "test"); 926 if (!dbh) { 927 exit(EXIT_FAILURE); 928 } 929 930 // open a temp 931 fits = psFitsOpen(TMP_FILENAME, "r"); 932 if (!fits) { 933 exit(EXIT_FAILURE); 934 } 935 936 if (!p4DiffImfileInsertFits(dbh, fits)) { 832 if (!p4aRunInsertFits(dbh, fits)) { 833 exit(EXIT_FAILURE); 834 } 835 836 if (!psFitsClose(fits)) { 837 exit(EXIT_FAILURE); 838 } 839 840 psDBCleanup(dbh); 841 } 842 843 { 844 psDB *dbh; 845 psFits *fits; 846 847 dbh = psDBInit("localhost", "test", NULL, "test"); 848 if (!dbh) { 849 exit(EXIT_FAILURE); 850 } 851 852 // open a temp 853 fits = psFitsOpen(TMP_FILENAME, "r"); 854 if (!fits) { 855 exit(EXIT_FAILURE); 856 } 857 858 if (!p4aInputExpInsertFits(dbh, fits)) { 859 exit(EXIT_FAILURE); 860 } 861 862 if (!psFitsClose(fits)) { 863 exit(EXIT_FAILURE); 864 } 865 866 psDBCleanup(dbh); 867 } 868 869 { 870 psDB *dbh; 871 psFits *fits; 872 873 dbh = psDBInit("localhost", "test", NULL, "test"); 874 if (!dbh) { 875 exit(EXIT_FAILURE); 876 } 877 878 // open a temp 879 fits = psFitsOpen(TMP_FILENAME, "r"); 880 if (!fits) { 881 exit(EXIT_FAILURE); 882 } 883 884 if (!p4aScfileInsertFits(dbh, fits)) { 885 exit(EXIT_FAILURE); 886 } 887 888 if (!psFitsClose(fits)) { 889 exit(EXIT_FAILURE); 890 } 891 892 psDBCleanup(dbh); 893 } 894 895 { 896 psDB *dbh; 897 psFits *fits; 898 899 dbh = psDBInit("localhost", "test", NULL, "test"); 900 if (!dbh) { 901 exit(EXIT_FAILURE); 902 } 903 904 // open a temp 905 fits = psFitsOpen(TMP_FILENAME, "r"); 906 if (!fits) { 907 exit(EXIT_FAILURE); 908 } 909 910 if (!p4bRunInsertFits(dbh, fits)) { 911 exit(EXIT_FAILURE); 912 } 913 914 if (!psFitsClose(fits)) { 915 exit(EXIT_FAILURE); 916 } 917 918 psDBCleanup(dbh); 919 } 920 921 { 922 psDB *dbh; 923 psFits *fits; 924 925 dbh = psDBInit("localhost", "test", NULL, "test"); 926 if (!dbh) { 927 exit(EXIT_FAILURE); 928 } 929 930 // open a temp 931 fits = psFitsOpen(TMP_FILENAME, "r"); 932 if (!fits) { 933 exit(EXIT_FAILURE); 934 } 935 936 if (!p4bInputScfileInsertFits(dbh, fits)) { 937 exit(EXIT_FAILURE); 938 } 939 940 if (!psFitsClose(fits)) { 941 exit(EXIT_FAILURE); 942 } 943 944 psDBCleanup(dbh); 945 } 946 947 { 948 psDB *dbh; 949 psFits *fits; 950 951 dbh = psDBInit("localhost", "test", NULL, "test"); 952 if (!dbh) { 953 exit(EXIT_FAILURE); 954 } 955 956 // open a temp 957 fits = psFitsOpen(TMP_FILENAME, "r"); 958 if (!fits) { 959 exit(EXIT_FAILURE); 960 } 961 962 if (!p4bDiffScfileInsertFits(dbh, fits)) { 963 exit(EXIT_FAILURE); 964 } 965 966 if (!psFitsClose(fits)) { 967 exit(EXIT_FAILURE); 968 } 969 970 psDBCleanup(dbh); 971 } 972 973 { 974 psDB *dbh; 975 psFits *fits; 976 977 dbh = psDBInit("localhost", "test", NULL, "test"); 978 if (!dbh) { 979 exit(EXIT_FAILURE); 980 } 981 982 // open a temp 983 fits = psFitsOpen(TMP_FILENAME, "r"); 984 if (!fits) { 985 exit(EXIT_FAILURE); 986 } 987 988 if (!p4cRunInsertFits(dbh, fits)) { 989 exit(EXIT_FAILURE); 990 } 991 992 if (!psFitsClose(fits)) { 993 exit(EXIT_FAILURE); 994 } 995 996 psDBCleanup(dbh); 997 } 998 999 { 1000 psDB *dbh; 1001 psFits *fits; 1002 1003 dbh = psDBInit("localhost", "test", NULL, "test"); 1004 if (!dbh) { 1005 exit(EXIT_FAILURE); 1006 } 1007 1008 // open a temp 1009 fits = psFitsOpen(TMP_FILENAME, "r"); 1010 if (!fits) { 1011 exit(EXIT_FAILURE); 1012 } 1013 1014 if (!p4cInputExpInsertFits(dbh, fits)) { 937 1015 exit(EXIT_FAILURE); 938 1016 } … … 961 1039 962 1040 if (!p4MagicMaskImfileInsertFits(dbh, fits)) { 1041 exit(EXIT_FAILURE); 1042 } 1043 1044 if (!psFitsClose(fits)) { 1045 exit(EXIT_FAILURE); 1046 } 1047 1048 psDBCleanup(dbh); 1049 } 1050 1051 { 1052 psDB *dbh; 1053 psFits *fits; 1054 1055 dbh = psDBInit("localhost", "test", NULL, "test"); 1056 if (!dbh) { 1057 exit(EXIT_FAILURE); 1058 } 1059 1060 // open a temp 1061 fits = psFitsOpen(TMP_FILENAME, "r"); 1062 if (!fits) { 1063 exit(EXIT_FAILURE); 1064 } 1065 1066 if (!skyCellInsertFits(dbh, fits)) { 1067 exit(EXIT_FAILURE); 1068 } 1069 1070 if (!psFitsClose(fits)) { 1071 exit(EXIT_FAILURE); 1072 } 1073 1074 psDBCleanup(dbh); 1075 } 1076 1077 { 1078 psDB *dbh; 1079 psFits *fits; 1080 1081 dbh = psDBInit("localhost", "test", NULL, "test"); 1082 if (!dbh) { 1083 exit(EXIT_FAILURE); 1084 } 1085 1086 // open a temp 1087 fits = psFitsOpen(TMP_FILENAME, "r"); 1088 if (!fits) { 1089 exit(EXIT_FAILURE); 1090 } 1091 1092 if (!skyCellMapInsertFits(dbh, fits)) { 963 1093 exit(EXIT_FAILURE); 964 1094 } -
trunk/ippdb/tests/insertobject.c
r11193 r11679 689 689 { 690 690 psDB *dbh; 691 p4RunRow *object; 692 693 dbh = psDBInit("localhost", "test", NULL, "test"); 694 if (!dbh) { 695 exit(EXIT_FAILURE); 696 } 697 698 object = p4RunRowAlloc(-32, "a string", "a string", "a string", "a string", "a string", "a string", 64.64, 64.64, "a string", "a string"); 699 if (!object) { 700 exit(EXIT_FAILURE); 701 } 702 703 if (!p4RunInsertObject(dbh, object)) { 704 exit(EXIT_FAILURE); 705 } 706 707 psFree(object); 708 psDBCleanup(dbh); 709 } 710 711 { 712 psDB *dbh; 713 p4InputImfileRow *object; 714 715 dbh = psDBInit("localhost", "test", NULL, "test"); 716 if (!dbh) { 717 exit(EXIT_FAILURE); 718 } 719 720 object = p4InputImfileRowAlloc(-32, "a string", -32, "a string"); 721 if (!object) { 722 exit(EXIT_FAILURE); 723 } 724 725 if (!p4InputImfileInsertObject(dbh, object)) { 726 exit(EXIT_FAILURE); 727 } 728 729 psFree(object); 730 psDBCleanup(dbh); 731 } 732 733 { 734 psDB *dbh; 735 p4WarpedImfileRow *object; 736 737 dbh = psDBInit("localhost", "test", NULL, "test"); 738 if (!dbh) { 739 exit(EXIT_FAILURE); 740 } 741 742 object = p4WarpedImfileRowAlloc(-32, "a string", -32, "a string", "a string", "a string", "a string"); 743 if (!object) { 744 exit(EXIT_FAILURE); 745 } 746 747 if (!p4WarpedImfileInsertObject(dbh, object)) { 748 exit(EXIT_FAILURE); 749 } 750 751 psFree(object); 752 psDBCleanup(dbh); 753 } 754 755 { 756 psDB *dbh; 757 p4StackedImfileRow *object; 758 759 dbh = psDBInit("localhost", "test", NULL, "test"); 760 if (!dbh) { 761 exit(EXIT_FAILURE); 762 } 763 764 object = p4StackedImfileRowAlloc(-32, "a string", "a string", "a string", "a string"); 765 if (!object) { 766 exit(EXIT_FAILURE); 767 } 768 769 if (!p4StackedImfileInsertObject(dbh, object)) { 770 exit(EXIT_FAILURE); 771 } 772 773 psFree(object); 774 psDBCleanup(dbh); 775 } 776 777 { 778 psDB *dbh; 779 p4DiffImfileRow *object; 780 781 dbh = psDBInit("localhost", "test", NULL, "test"); 782 if (!dbh) { 783 exit(EXIT_FAILURE); 784 } 785 786 object = p4DiffImfileRowAlloc(-32, "a string", -32, "a string", "a string", "a string", "a string"); 787 if (!object) { 788 exit(EXIT_FAILURE); 789 } 790 791 if (!p4DiffImfileInsertObject(dbh, object)) { 691 p4aRunRow *object; 692 693 dbh = psDBInit("localhost", "test", NULL, "test"); 694 if (!dbh) { 695 exit(EXIT_FAILURE); 696 } 697 698 object = p4aRunRowAlloc(-32, "a string", "a string", true); 699 if (!object) { 700 exit(EXIT_FAILURE); 701 } 702 703 if (!p4aRunInsertObject(dbh, object)) { 704 exit(EXIT_FAILURE); 705 } 706 707 psFree(object); 708 psDBCleanup(dbh); 709 } 710 711 { 712 psDB *dbh; 713 p4aInputExpRow *object; 714 715 dbh = psDBInit("localhost", "test", NULL, "test"); 716 if (!dbh) { 717 exit(EXIT_FAILURE); 718 } 719 720 object = p4aInputExpRowAlloc(-32, "a string", -32); 721 if (!object) { 722 exit(EXIT_FAILURE); 723 } 724 725 if (!p4aInputExpInsertObject(dbh, object)) { 726 exit(EXIT_FAILURE); 727 } 728 729 psFree(object); 730 psDBCleanup(dbh); 731 } 732 733 { 734 psDB *dbh; 735 p4aScfileRow *object; 736 737 dbh = psDBInit("localhost", "test", NULL, "test"); 738 if (!dbh) { 739 exit(EXIT_FAILURE); 740 } 741 742 object = p4aScfileRowAlloc(-32, "a string", "a string", "a string", -32, "a string", 64.64, 64.64); 743 if (!object) { 744 exit(EXIT_FAILURE); 745 } 746 747 if (!p4aScfileInsertObject(dbh, object)) { 748 exit(EXIT_FAILURE); 749 } 750 751 psFree(object); 752 psDBCleanup(dbh); 753 } 754 755 { 756 psDB *dbh; 757 p4bRunRow *object; 758 759 dbh = psDBInit("localhost", "test", NULL, "test"); 760 if (!dbh) { 761 exit(EXIT_FAILURE); 762 } 763 764 object = p4bRunRowAlloc(-32, "a string", "a string", true); 765 if (!object) { 766 exit(EXIT_FAILURE); 767 } 768 769 if (!p4bRunInsertObject(dbh, object)) { 770 exit(EXIT_FAILURE); 771 } 772 773 psFree(object); 774 psDBCleanup(dbh); 775 } 776 777 { 778 psDB *dbh; 779 p4bInputScfileRow *object; 780 781 dbh = psDBInit("localhost", "test", NULL, "test"); 782 if (!dbh) { 783 exit(EXIT_FAILURE); 784 } 785 786 object = p4bInputScfileRowAlloc(-32, "a string", "a string", "a string", -32, "a string"); 787 if (!object) { 788 exit(EXIT_FAILURE); 789 } 790 791 if (!p4bInputScfileInsertObject(dbh, object)) { 792 exit(EXIT_FAILURE); 793 } 794 795 psFree(object); 796 psDBCleanup(dbh); 797 } 798 799 { 800 psDB *dbh; 801 p4bDiffScfileRow *object; 802 803 dbh = psDBInit("localhost", "test", NULL, "test"); 804 if (!dbh) { 805 exit(EXIT_FAILURE); 806 } 807 808 object = p4bDiffScfileRowAlloc(-32, "a string", "a string", "a string", -32, "a string", 64.64, 64.64); 809 if (!object) { 810 exit(EXIT_FAILURE); 811 } 812 813 if (!p4bDiffScfileInsertObject(dbh, object)) { 814 exit(EXIT_FAILURE); 815 } 816 817 psFree(object); 818 psDBCleanup(dbh); 819 } 820 821 { 822 psDB *dbh; 823 p4cRunRow *object; 824 825 dbh = psDBInit("localhost", "test", NULL, "test"); 826 if (!dbh) { 827 exit(EXIT_FAILURE); 828 } 829 830 object = p4cRunRowAlloc(-32, "a string", "a string", true); 831 if (!object) { 832 exit(EXIT_FAILURE); 833 } 834 835 if (!p4cRunInsertObject(dbh, object)) { 836 exit(EXIT_FAILURE); 837 } 838 839 psFree(object); 840 psDBCleanup(dbh); 841 } 842 843 { 844 psDB *dbh; 845 p4cInputExpRow *object; 846 847 dbh = psDBInit("localhost", "test", NULL, "test"); 848 if (!dbh) { 849 exit(EXIT_FAILURE); 850 } 851 852 object = p4cInputExpRowAlloc(-32, "a string", -32); 853 if (!object) { 854 exit(EXIT_FAILURE); 855 } 856 857 if (!p4cInputExpInsertObject(dbh, object)) { 792 858 exit(EXIT_FAILURE); 793 859 } … … 812 878 813 879 if (!p4MagicMaskImfileInsertObject(dbh, object)) { 880 exit(EXIT_FAILURE); 881 } 882 883 psFree(object); 884 psDBCleanup(dbh); 885 } 886 887 { 888 psDB *dbh; 889 skyCellRow *object; 890 891 dbh = psDBInit("localhost", "test", NULL, "test"); 892 if (!dbh) { 893 exit(EXIT_FAILURE); 894 } 895 896 object = skyCellRowAlloc("a string", "a string", 64.64, 64.64, 64.64, 64.64, 64.64, 64.64, 64.64, 64.64); 897 if (!object) { 898 exit(EXIT_FAILURE); 899 } 900 901 if (!skyCellInsertObject(dbh, object)) { 902 exit(EXIT_FAILURE); 903 } 904 905 psFree(object); 906 psDBCleanup(dbh); 907 } 908 909 { 910 psDB *dbh; 911 skyCellMapRow *object; 912 913 dbh = psDBInit("localhost", "test", NULL, "test"); 914 if (!dbh) { 915 exit(EXIT_FAILURE); 916 } 917 918 object = skyCellMapRowAlloc("a string", "a string", "a string", "a string"); 919 if (!object) { 920 exit(EXIT_FAILURE); 921 } 922 923 if (!skyCellMapInsertObject(dbh, object)) { 814 924 exit(EXIT_FAILURE); 815 925 } -
trunk/ippdb/tests/metadatafromobject.c
r11193 r11679 1643 1643 { 1644 1644 psMetadata *md; 1645 p4RunRow *object; 1646 bool status; 1647 1648 object = p4RunRowAlloc(-32, "a string", "a string", "a string", "a string", "a string", "a string", 64.64, 64.64, "a string", "a string"); 1649 if (!object) { 1650 exit(EXIT_FAILURE); 1651 } 1652 1653 md = p4RunMetadataFromObject(object); 1654 if (!md) { 1655 exit(EXIT_FAILURE); 1656 } 1657 1658 psFree(object); 1659 1660 if (!psMetadataLookupS32(&status, md, "p4_id") == -32) { 1661 psFree(md); 1662 exit(EXIT_FAILURE); 1663 } 1664 if (strncmp(psMetadataLookupPtr(&status, md, "survey_mode"), "a string", MAX_STRING_LENGTH)) { 1645 p4aRunRow *object; 1646 bool status; 1647 1648 object = p4aRunRowAlloc(-32, "a string", "a string", true); 1649 if (!object) { 1650 exit(EXIT_FAILURE); 1651 } 1652 1653 md = p4aRunMetadataFromObject(object); 1654 if (!md) { 1655 exit(EXIT_FAILURE); 1656 } 1657 1658 psFree(object); 1659 1660 if (!psMetadataLookupS32(&status, md, "p4a_id") == -32) { 1665 1661 psFree(md); 1666 1662 exit(EXIT_FAILURE); … … 1674 1670 exit(EXIT_FAILURE); 1675 1671 } 1676 if (strncmp(psMetadataLookupPtr(&status, md, "filter"), "a string", MAX_STRING_LENGTH)) { 1672 if (!psMetadataLookupBool(&status, md, "magic") == true) { 1673 psFree(md); 1674 exit(EXIT_FAILURE); 1675 } 1676 1677 psFree(md); 1678 } 1679 1680 { 1681 psMetadata *md; 1682 p4aInputExpRow *object; 1683 bool status; 1684 1685 object = p4aInputExpRowAlloc(-32, "a string", -32); 1686 if (!object) { 1687 exit(EXIT_FAILURE); 1688 } 1689 1690 md = p4aInputExpMetadataFromObject(object); 1691 if (!md) { 1692 exit(EXIT_FAILURE); 1693 } 1694 1695 psFree(object); 1696 1697 if (!psMetadataLookupS32(&status, md, "p4a_id") == -32) { 1698 psFree(md); 1699 exit(EXIT_FAILURE); 1700 } 1701 if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) { 1702 psFree(md); 1703 exit(EXIT_FAILURE); 1704 } 1705 if (!psMetadataLookupS32(&status, md, "p3_version") == -32) { 1706 psFree(md); 1707 exit(EXIT_FAILURE); 1708 } 1709 1710 psFree(md); 1711 } 1712 1713 { 1714 psMetadata *md; 1715 p4aScfileRow *object; 1716 bool status; 1717 1718 object = p4aScfileRowAlloc(-32, "a string", "a string", "a string", -32, "a string", 64.64, 64.64); 1719 if (!object) { 1720 exit(EXIT_FAILURE); 1721 } 1722 1723 md = p4aScfileMetadataFromObject(object); 1724 if (!md) { 1725 exit(EXIT_FAILURE); 1726 } 1727 1728 psFree(object); 1729 1730 if (!psMetadataLookupS32(&status, md, "p4a_id") == -32) { 1677 1731 psFree(md); 1678 1732 exit(EXIT_FAILURE); … … 1686 1740 exit(EXIT_FAILURE); 1687 1741 } 1688 if (!psMetadataLookupF64(&status, md, "ra") == 64.64) {1689 psFree(md);1690 exit(EXIT_FAILURE);1691 }1692 if (!psMetadataLookupF64(&status, md, "decl") == 64.64) {1693 psFree(md);1694 exit(EXIT_FAILURE);1695 }1696 if (strncmp(psMetadataLookupPtr(&status, md, "input_ss"), "a string", MAX_STRING_LENGTH)) {1697 psFree(md);1698 exit(EXIT_FAILURE);1699 }1700 if (strncmp(psMetadataLookupPtr(&status, md, "output_ss"), "a string", MAX_STRING_LENGTH)) {1701 psFree(md);1702 exit(EXIT_FAILURE);1703 }1704 1705 psFree(md);1706 }1707 1708 {1709 psMetadata *md;1710 p4InputImfileRow *object;1711 bool status;1712 1713 object = p4InputImfileRowAlloc(-32, "a string", -32, "a string");1714 if (!object) {1715 exit(EXIT_FAILURE);1716 }1717 1718 md = p4InputImfileMetadataFromObject(object);1719 if (!md) {1720 exit(EXIT_FAILURE);1721 }1722 1723 psFree(object);1724 1725 if (!psMetadataLookupS32(&status, md, "p4_id") == -32) {1726 psFree(md);1727 exit(EXIT_FAILURE);1728 }1729 1742 if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) { 1730 1743 psFree(md); … … 1735 1748 exit(EXIT_FAILURE); 1736 1749 } 1750 if (strncmp(psMetadataLookupPtr(&status, md, "uri"), "a string", MAX_STRING_LENGTH)) { 1751 psFree(md); 1752 exit(EXIT_FAILURE); 1753 } 1754 if (!psMetadataLookupF64(&status, md, "bg") == 64.64) { 1755 psFree(md); 1756 exit(EXIT_FAILURE); 1757 } 1758 if (!psMetadataLookupF64(&status, md, "bg_mean_stdev") == 64.64) { 1759 psFree(md); 1760 exit(EXIT_FAILURE); 1761 } 1762 1763 psFree(md); 1764 } 1765 1766 { 1767 psMetadata *md; 1768 p4bRunRow *object; 1769 bool status; 1770 1771 object = p4bRunRowAlloc(-32, "a string", "a string", true); 1772 if (!object) { 1773 exit(EXIT_FAILURE); 1774 } 1775 1776 md = p4bRunMetadataFromObject(object); 1777 if (!md) { 1778 exit(EXIT_FAILURE); 1779 } 1780 1781 psFree(object); 1782 1783 if (!psMetadataLookupS32(&status, md, "p4b_id") == -32) { 1784 psFree(md); 1785 exit(EXIT_FAILURE); 1786 } 1787 if (strncmp(psMetadataLookupPtr(&status, md, "state"), "a string", MAX_STRING_LENGTH)) { 1788 psFree(md); 1789 exit(EXIT_FAILURE); 1790 } 1791 if (strncmp(psMetadataLookupPtr(&status, md, "workdir"), "a string", MAX_STRING_LENGTH)) { 1792 psFree(md); 1793 exit(EXIT_FAILURE); 1794 } 1795 if (!psMetadataLookupBool(&status, md, "magic") == true) { 1796 psFree(md); 1797 exit(EXIT_FAILURE); 1798 } 1799 1800 psFree(md); 1801 } 1802 1803 { 1804 psMetadata *md; 1805 p4bInputScfileRow *object; 1806 bool status; 1807 1808 object = p4bInputScfileRowAlloc(-32, "a string", "a string", "a string", -32, "a string"); 1809 if (!object) { 1810 exit(EXIT_FAILURE); 1811 } 1812 1813 md = p4bInputScfileMetadataFromObject(object); 1814 if (!md) { 1815 exit(EXIT_FAILURE); 1816 } 1817 1818 psFree(object); 1819 1820 if (!psMetadataLookupS32(&status, md, "p4b_id") == -32) { 1821 psFree(md); 1822 exit(EXIT_FAILURE); 1823 } 1824 if (strncmp(psMetadataLookupPtr(&status, md, "skycell_id"), "a string", MAX_STRING_LENGTH)) { 1825 psFree(md); 1826 exit(EXIT_FAILURE); 1827 } 1828 if (strncmp(psMetadataLookupPtr(&status, md, "tess_id"), "a string", MAX_STRING_LENGTH)) { 1829 psFree(md); 1830 exit(EXIT_FAILURE); 1831 } 1832 if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) { 1833 psFree(md); 1834 exit(EXIT_FAILURE); 1835 } 1836 if (!psMetadataLookupS32(&status, md, "p3_version") == -32) { 1837 psFree(md); 1838 exit(EXIT_FAILURE); 1839 } 1840 if (strncmp(psMetadataLookupPtr(&status, md, "kind"), "a string", MAX_STRING_LENGTH)) { 1841 psFree(md); 1842 exit(EXIT_FAILURE); 1843 } 1844 1845 psFree(md); 1846 } 1847 1848 { 1849 psMetadata *md; 1850 p4bDiffScfileRow *object; 1851 bool status; 1852 1853 object = p4bDiffScfileRowAlloc(-32, "a string", "a string", "a string", -32, "a string", 64.64, 64.64); 1854 if (!object) { 1855 exit(EXIT_FAILURE); 1856 } 1857 1858 md = p4bDiffScfileMetadataFromObject(object); 1859 if (!md) { 1860 exit(EXIT_FAILURE); 1861 } 1862 1863 psFree(object); 1864 1865 if (!psMetadataLookupS32(&status, md, "p4b_id") == -32) { 1866 psFree(md); 1867 exit(EXIT_FAILURE); 1868 } 1869 if (strncmp(psMetadataLookupPtr(&status, md, "skycell_id"), "a string", MAX_STRING_LENGTH)) { 1870 psFree(md); 1871 exit(EXIT_FAILURE); 1872 } 1873 if (strncmp(psMetadataLookupPtr(&status, md, "tess_id"), "a string", MAX_STRING_LENGTH)) { 1874 psFree(md); 1875 exit(EXIT_FAILURE); 1876 } 1877 if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) { 1878 psFree(md); 1879 exit(EXIT_FAILURE); 1880 } 1881 if (!psMetadataLookupS32(&status, md, "p3_version") == -32) { 1882 psFree(md); 1883 exit(EXIT_FAILURE); 1884 } 1885 if (strncmp(psMetadataLookupPtr(&status, md, "uri"), "a string", MAX_STRING_LENGTH)) { 1886 psFree(md); 1887 exit(EXIT_FAILURE); 1888 } 1889 if (!psMetadataLookupF64(&status, md, "bg") == 64.64) { 1890 psFree(md); 1891 exit(EXIT_FAILURE); 1892 } 1893 if (!psMetadataLookupF64(&status, md, "bg_mean_stdev") == 64.64) { 1894 psFree(md); 1895 exit(EXIT_FAILURE); 1896 } 1897 1898 psFree(md); 1899 } 1900 1901 { 1902 psMetadata *md; 1903 p4cRunRow *object; 1904 bool status; 1905 1906 object = p4cRunRowAlloc(-32, "a string", "a string", true); 1907 if (!object) { 1908 exit(EXIT_FAILURE); 1909 } 1910 1911 md = p4cRunMetadataFromObject(object); 1912 if (!md) { 1913 exit(EXIT_FAILURE); 1914 } 1915 1916 psFree(object); 1917 1918 if (!psMetadataLookupS32(&status, md, "p4c_id") == -32) { 1919 psFree(md); 1920 exit(EXIT_FAILURE); 1921 } 1922 if (strncmp(psMetadataLookupPtr(&status, md, "state"), "a string", MAX_STRING_LENGTH)) { 1923 psFree(md); 1924 exit(EXIT_FAILURE); 1925 } 1926 if (strncmp(psMetadataLookupPtr(&status, md, "workdir"), "a string", MAX_STRING_LENGTH)) { 1927 psFree(md); 1928 exit(EXIT_FAILURE); 1929 } 1930 if (!psMetadataLookupBool(&status, md, "magic") == true) { 1931 psFree(md); 1932 exit(EXIT_FAILURE); 1933 } 1934 1935 psFree(md); 1936 } 1937 1938 { 1939 psMetadata *md; 1940 p4cInputExpRow *object; 1941 bool status; 1942 1943 object = p4cInputExpRowAlloc(-32, "a string", -32); 1944 if (!object) { 1945 exit(EXIT_FAILURE); 1946 } 1947 1948 md = p4cInputExpMetadataFromObject(object); 1949 if (!md) { 1950 exit(EXIT_FAILURE); 1951 } 1952 1953 psFree(object); 1954 1955 if (!psMetadataLookupS32(&status, md, "p4c_id") == -32) { 1956 psFree(md); 1957 exit(EXIT_FAILURE); 1958 } 1959 if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) { 1960 psFree(md); 1961 exit(EXIT_FAILURE); 1962 } 1963 if (!psMetadataLookupS32(&status, md, "p3_version") == -32) { 1964 psFree(md); 1965 exit(EXIT_FAILURE); 1966 } 1967 1968 psFree(md); 1969 } 1970 1971 { 1972 psMetadata *md; 1973 p4MagicMaskImfileRow *object; 1974 bool status; 1975 1976 object = p4MagicMaskImfileRowAlloc(-32, "a string", -32, "a string", "a string"); 1977 if (!object) { 1978 exit(EXIT_FAILURE); 1979 } 1980 1981 md = p4MagicMaskImfileMetadataFromObject(object); 1982 if (!md) { 1983 exit(EXIT_FAILURE); 1984 } 1985 1986 psFree(object); 1987 1988 if (!psMetadataLookupS32(&status, md, "p4c_id") == -32) { 1989 psFree(md); 1990 exit(EXIT_FAILURE); 1991 } 1992 if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) { 1993 psFree(md); 1994 exit(EXIT_FAILURE); 1995 } 1996 if (!psMetadataLookupS32(&status, md, "p3_version") == -32) { 1997 psFree(md); 1998 exit(EXIT_FAILURE); 1999 } 1737 2000 if (strncmp(psMetadataLookupPtr(&status, md, "class_id"), "a string", MAX_STRING_LENGTH)) { 1738 2001 psFree(md); 1739 2002 exit(EXIT_FAILURE); 1740 2003 } 1741 1742 psFree(md); 1743 } 1744 1745 { 1746 psMetadata *md; 1747 p4WarpedImfileRow *object; 1748 bool status; 1749 1750 object = p4WarpedImfileRowAlloc(-32, "a string", -32, "a string", "a string", "a string", "a string"); 1751 if (!object) { 1752 exit(EXIT_FAILURE); 1753 } 1754 1755 md = p4WarpedImfileMetadataFromObject(object); 1756 if (!md) { 1757 exit(EXIT_FAILURE); 1758 } 1759 1760 psFree(object); 1761 1762 if (!psMetadataLookupS32(&status, md, "p4_id") == -32) { 1763 psFree(md); 1764 exit(EXIT_FAILURE); 1765 } 1766 if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) { 1767 psFree(md); 1768 exit(EXIT_FAILURE); 1769 } 1770 if (!psMetadataLookupS32(&status, md, "p3_version") == -32) { 2004 if (strncmp(psMetadataLookupPtr(&status, md, "uri"), "a string", MAX_STRING_LENGTH)) { 2005 psFree(md); 2006 exit(EXIT_FAILURE); 2007 } 2008 2009 psFree(md); 2010 } 2011 2012 { 2013 psMetadata *md; 2014 skyCellRow *object; 2015 bool status; 2016 2017 object = skyCellRowAlloc("a string", "a string", 64.64, 64.64, 64.64, 64.64, 64.64, 64.64, 64.64, 64.64); 2018 if (!object) { 2019 exit(EXIT_FAILURE); 2020 } 2021 2022 md = skyCellMetadataFromObject(object); 2023 if (!md) { 2024 exit(EXIT_FAILURE); 2025 } 2026 2027 psFree(object); 2028 2029 if (strncmp(psMetadataLookupPtr(&status, md, "skycell_id"), "a string", MAX_STRING_LENGTH)) { 2030 psFree(md); 2031 exit(EXIT_FAILURE); 2032 } 2033 if (strncmp(psMetadataLookupPtr(&status, md, "tess_id"), "a string", MAX_STRING_LENGTH)) { 2034 psFree(md); 2035 exit(EXIT_FAILURE); 2036 } 2037 if (!psMetadataLookupF64(&status, md, "ra1") == 64.64) { 2038 psFree(md); 2039 exit(EXIT_FAILURE); 2040 } 2041 if (!psMetadataLookupF64(&status, md, "decl1") == 64.64) { 2042 psFree(md); 2043 exit(EXIT_FAILURE); 2044 } 2045 if (!psMetadataLookupF64(&status, md, "ra2") == 64.64) { 2046 psFree(md); 2047 exit(EXIT_FAILURE); 2048 } 2049 if (!psMetadataLookupF64(&status, md, "decl2") == 64.64) { 2050 psFree(md); 2051 exit(EXIT_FAILURE); 2052 } 2053 if (!psMetadataLookupF64(&status, md, "ra3") == 64.64) { 2054 psFree(md); 2055 exit(EXIT_FAILURE); 2056 } 2057 if (!psMetadataLookupF64(&status, md, "decl3") == 64.64) { 2058 psFree(md); 2059 exit(EXIT_FAILURE); 2060 } 2061 if (!psMetadataLookupF64(&status, md, "ra4") == 64.64) { 2062 psFree(md); 2063 exit(EXIT_FAILURE); 2064 } 2065 if (!psMetadataLookupF64(&status, md, "decl4") == 64.64) { 2066 psFree(md); 2067 exit(EXIT_FAILURE); 2068 } 2069 2070 psFree(md); 2071 } 2072 2073 { 2074 psMetadata *md; 2075 skyCellMapRow *object; 2076 bool status; 2077 2078 object = skyCellMapRowAlloc("a string", "a string", "a string", "a string"); 2079 if (!object) { 2080 exit(EXIT_FAILURE); 2081 } 2082 2083 md = skyCellMapMetadataFromObject(object); 2084 if (!md) { 2085 exit(EXIT_FAILURE); 2086 } 2087 2088 psFree(object); 2089 2090 if (strncmp(psMetadataLookupPtr(&status, md, "skycell_id"), "a string", MAX_STRING_LENGTH)) { 2091 psFree(md); 2092 exit(EXIT_FAILURE); 2093 } 2094 if (strncmp(psMetadataLookupPtr(&status, md, "tess_id"), "a string", MAX_STRING_LENGTH)) { 2095 psFree(md); 2096 exit(EXIT_FAILURE); 2097 } 2098 if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) { 1771 2099 psFree(md); 1772 2100 exit(EXIT_FAILURE); 1773 2101 } 1774 2102 if (strncmp(psMetadataLookupPtr(&status, md, "class_id"), "a string", MAX_STRING_LENGTH)) { 1775 psFree(md);1776 exit(EXIT_FAILURE);1777 }1778 if (strncmp(psMetadataLookupPtr(&status, md, "uri"), "a string", MAX_STRING_LENGTH)) {1779 psFree(md);1780 exit(EXIT_FAILURE);1781 }1782 if (strncmp(psMetadataLookupPtr(&status, md, "b1_uri"), "a string", MAX_STRING_LENGTH)) {1783 psFree(md);1784 exit(EXIT_FAILURE);1785 }1786 if (strncmp(psMetadataLookupPtr(&status, md, "b2_uri"), "a string", MAX_STRING_LENGTH)) {1787 psFree(md);1788 exit(EXIT_FAILURE);1789 }1790 1791 psFree(md);1792 }1793 1794 {1795 psMetadata *md;1796 p4StackedImfileRow *object;1797 bool status;1798 1799 object = p4StackedImfileRowAlloc(-32, "a string", "a string", "a string", "a string");1800 if (!object) {1801 exit(EXIT_FAILURE);1802 }1803 1804 md = p4StackedImfileMetadataFromObject(object);1805 if (!md) {1806 exit(EXIT_FAILURE);1807 }1808 1809 psFree(object);1810 1811 if (!psMetadataLookupS32(&status, md, "p4_id") == -32) {1812 psFree(md);1813 exit(EXIT_FAILURE);1814 }1815 if (strncmp(psMetadataLookupPtr(&status, md, "class_id"), "a string", MAX_STRING_LENGTH)) {1816 psFree(md);1817 exit(EXIT_FAILURE);1818 }1819 if (strncmp(psMetadataLookupPtr(&status, md, "uri"), "a string", MAX_STRING_LENGTH)) {1820 psFree(md);1821 exit(EXIT_FAILURE);1822 }1823 if (strncmp(psMetadataLookupPtr(&status, md, "b1_uri"), "a string", MAX_STRING_LENGTH)) {1824 psFree(md);1825 exit(EXIT_FAILURE);1826 }1827 if (strncmp(psMetadataLookupPtr(&status, md, "b2_uri"), "a string", MAX_STRING_LENGTH)) {1828 psFree(md);1829 exit(EXIT_FAILURE);1830 }1831 1832 psFree(md);1833 }1834 1835 {1836 psMetadata *md;1837 p4DiffImfileRow *object;1838 bool status;1839 1840 object = p4DiffImfileRowAlloc(-32, "a string", -32, "a string", "a string", "a string", "a string");1841 if (!object) {1842 exit(EXIT_FAILURE);1843 }1844 1845 md = p4DiffImfileMetadataFromObject(object);1846 if (!md) {1847 exit(EXIT_FAILURE);1848 }1849 1850 psFree(object);1851 1852 if (!psMetadataLookupS32(&status, md, "p4_id") == -32) {1853 psFree(md);1854 exit(EXIT_FAILURE);1855 }1856 if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) {1857 psFree(md);1858 exit(EXIT_FAILURE);1859 }1860 if (!psMetadataLookupS32(&status, md, "p3_version") == -32) {1861 psFree(md);1862 exit(EXIT_FAILURE);1863 }1864 if (strncmp(psMetadataLookupPtr(&status, md, "class_id"), "a string", MAX_STRING_LENGTH)) {1865 psFree(md);1866 exit(EXIT_FAILURE);1867 }1868 if (strncmp(psMetadataLookupPtr(&status, md, "uri"), "a string", MAX_STRING_LENGTH)) {1869 psFree(md);1870 exit(EXIT_FAILURE);1871 }1872 if (strncmp(psMetadataLookupPtr(&status, md, "b1_uri"), "a string", MAX_STRING_LENGTH)) {1873 psFree(md);1874 exit(EXIT_FAILURE);1875 }1876 if (strncmp(psMetadataLookupPtr(&status, md, "b2_uri"), "a string", MAX_STRING_LENGTH)) {1877 psFree(md);1878 exit(EXIT_FAILURE);1879 }1880 1881 psFree(md);1882 }1883 1884 {1885 psMetadata *md;1886 p4MagicMaskImfileRow *object;1887 bool status;1888 1889 object = p4MagicMaskImfileRowAlloc(-32, "a string", -32, "a string", "a string");1890 if (!object) {1891 exit(EXIT_FAILURE);1892 }1893 1894 md = p4MagicMaskImfileMetadataFromObject(object);1895 if (!md) {1896 exit(EXIT_FAILURE);1897 }1898 1899 psFree(object);1900 1901 if (!psMetadataLookupS32(&status, md, "p4_id") == -32) {1902 psFree(md);1903 exit(EXIT_FAILURE);1904 }1905 if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) {1906 psFree(md);1907 exit(EXIT_FAILURE);1908 }1909 if (!psMetadataLookupS32(&status, md, "p3_version") == -32) {1910 psFree(md);1911 exit(EXIT_FAILURE);1912 }1913 if (strncmp(psMetadataLookupPtr(&status, md, "class_id"), "a string", MAX_STRING_LENGTH)) {1914 psFree(md);1915 exit(EXIT_FAILURE);1916 }1917 if (strncmp(psMetadataLookupPtr(&status, md, "uri"), "a string", MAX_STRING_LENGTH)) {1918 2103 psFree(md); 1919 2104 exit(EXIT_FAILURE); -
trunk/ippdb/tests/objectfrommetadata.c
r11193 r11679 2532 2532 { 2533 2533 psMetadata *md; 2534 p4RunRow *object; 2535 2536 md = psMetadataAlloc(); 2537 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4_id", 0, NULL, -32)) { 2538 psFree(md); 2539 exit(EXIT_FAILURE); 2540 } 2541 if (!psMetadataAddStr(md, PS_LIST_TAIL, "survey_mode", 0, NULL, "a string")) { 2534 p4aRunRow *object; 2535 2536 md = psMetadataAlloc(); 2537 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4a_id", 0, NULL, -32)) { 2542 2538 psFree(md); 2543 2539 exit(EXIT_FAILURE); … … 2551 2547 exit(EXIT_FAILURE); 2552 2548 } 2553 if (!psMetadataAddStr(md, PS_LIST_TAIL, "filter", 0, NULL, "a string")) { 2549 if (!psMetadataAdd(md, PS_LIST_TAIL, "magic", PS_DATA_BOOL, NULL, true)) { 2550 psFree(md); 2551 exit(EXIT_FAILURE); 2552 } 2553 2554 object = p4aRunObjectFromMetadata(md); 2555 if (!object) { 2556 psFree(md); 2557 exit(EXIT_FAILURE); 2558 } 2559 2560 psFree(md); 2561 2562 if (!object->p4a_id == -32) { 2563 psFree(object); 2564 exit(EXIT_FAILURE); 2565 } 2566 if (strncmp(object->state, "a string", MAX_STRING_LENGTH)) { 2567 psFree(object); 2568 exit(EXIT_FAILURE); 2569 } 2570 if (strncmp(object->workdir, "a string", MAX_STRING_LENGTH)) { 2571 psFree(object); 2572 exit(EXIT_FAILURE); 2573 } 2574 if (!object->magic == true) { 2575 psFree(object); 2576 exit(EXIT_FAILURE); 2577 } 2578 2579 psFree(object); 2580 } 2581 2582 { 2583 psMetadata *md; 2584 p4aInputExpRow *object; 2585 2586 md = psMetadataAlloc(); 2587 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4a_id", 0, NULL, -32)) { 2588 psFree(md); 2589 exit(EXIT_FAILURE); 2590 } 2591 if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_tag", 0, NULL, "a string")) { 2592 psFree(md); 2593 exit(EXIT_FAILURE); 2594 } 2595 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p3_version", 0, NULL, -32)) { 2596 psFree(md); 2597 exit(EXIT_FAILURE); 2598 } 2599 2600 object = p4aInputExpObjectFromMetadata(md); 2601 if (!object) { 2602 psFree(md); 2603 exit(EXIT_FAILURE); 2604 } 2605 2606 psFree(md); 2607 2608 if (!object->p4a_id == -32) { 2609 psFree(object); 2610 exit(EXIT_FAILURE); 2611 } 2612 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 2613 psFree(object); 2614 exit(EXIT_FAILURE); 2615 } 2616 if (!object->p3_version == -32) { 2617 psFree(object); 2618 exit(EXIT_FAILURE); 2619 } 2620 2621 psFree(object); 2622 } 2623 2624 { 2625 psMetadata *md; 2626 p4aScfileRow *object; 2627 2628 md = psMetadataAlloc(); 2629 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4a_id", 0, NULL, -32)) { 2554 2630 psFree(md); 2555 2631 exit(EXIT_FAILURE); … … 2563 2639 exit(EXIT_FAILURE); 2564 2640 } 2565 if (!psMetadataAddF64(md, PS_LIST_TAIL, "ra", 0, NULL, 64.64)) { 2566 psFree(md); 2567 exit(EXIT_FAILURE); 2568 } 2569 if (!psMetadataAddF64(md, PS_LIST_TAIL, "decl", 0, NULL, 64.64)) { 2570 psFree(md); 2571 exit(EXIT_FAILURE); 2572 } 2573 if (!psMetadataAddStr(md, PS_LIST_TAIL, "input_ss", 0, NULL, "a string")) { 2574 psFree(md); 2575 exit(EXIT_FAILURE); 2576 } 2577 if (!psMetadataAddStr(md, PS_LIST_TAIL, "output_ss", 0, NULL, "a string")) { 2578 psFree(md); 2579 exit(EXIT_FAILURE); 2580 } 2581 2582 object = p4RunObjectFromMetadata(md); 2583 if (!object) { 2584 psFree(md); 2585 exit(EXIT_FAILURE); 2586 } 2587 2588 psFree(md); 2589 2590 if (!object->p4_id == -32) { 2591 psFree(object); 2592 exit(EXIT_FAILURE); 2593 } 2594 if (strncmp(object->survey_mode, "a string", MAX_STRING_LENGTH)) { 2641 if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_tag", 0, NULL, "a string")) { 2642 psFree(md); 2643 exit(EXIT_FAILURE); 2644 } 2645 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p3_version", 0, NULL, -32)) { 2646 psFree(md); 2647 exit(EXIT_FAILURE); 2648 } 2649 if (!psMetadataAddStr(md, PS_LIST_TAIL, "uri", 0, NULL, "a string")) { 2650 psFree(md); 2651 exit(EXIT_FAILURE); 2652 } 2653 if (!psMetadataAddF64(md, PS_LIST_TAIL, "bg", 0, NULL, 64.64)) { 2654 psFree(md); 2655 exit(EXIT_FAILURE); 2656 } 2657 if (!psMetadataAddF64(md, PS_LIST_TAIL, "bg_mean_stdev", 0, NULL, 64.64)) { 2658 psFree(md); 2659 exit(EXIT_FAILURE); 2660 } 2661 2662 object = p4aScfileObjectFromMetadata(md); 2663 if (!object) { 2664 psFree(md); 2665 exit(EXIT_FAILURE); 2666 } 2667 2668 psFree(md); 2669 2670 if (!object->p4a_id == -32) { 2671 psFree(object); 2672 exit(EXIT_FAILURE); 2673 } 2674 if (strncmp(object->skycell_id, "a string", MAX_STRING_LENGTH)) { 2675 psFree(object); 2676 exit(EXIT_FAILURE); 2677 } 2678 if (strncmp(object->tess_id, "a string", MAX_STRING_LENGTH)) { 2679 psFree(object); 2680 exit(EXIT_FAILURE); 2681 } 2682 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 2683 psFree(object); 2684 exit(EXIT_FAILURE); 2685 } 2686 if (!object->p3_version == -32) { 2687 psFree(object); 2688 exit(EXIT_FAILURE); 2689 } 2690 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) { 2691 psFree(object); 2692 exit(EXIT_FAILURE); 2693 } 2694 if (!object->bg == 64.64) { 2695 psFree(object); 2696 exit(EXIT_FAILURE); 2697 } 2698 if (!object->bg_mean_stdev == 64.64) { 2699 psFree(object); 2700 exit(EXIT_FAILURE); 2701 } 2702 2703 psFree(object); 2704 } 2705 2706 { 2707 psMetadata *md; 2708 p4bRunRow *object; 2709 2710 md = psMetadataAlloc(); 2711 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4b_id", 0, NULL, -32)) { 2712 psFree(md); 2713 exit(EXIT_FAILURE); 2714 } 2715 if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, NULL, "a string")) { 2716 psFree(md); 2717 exit(EXIT_FAILURE); 2718 } 2719 if (!psMetadataAddStr(md, PS_LIST_TAIL, "workdir", 0, NULL, "a string")) { 2720 psFree(md); 2721 exit(EXIT_FAILURE); 2722 } 2723 if (!psMetadataAdd(md, PS_LIST_TAIL, "magic", PS_DATA_BOOL, NULL, true)) { 2724 psFree(md); 2725 exit(EXIT_FAILURE); 2726 } 2727 2728 object = p4bRunObjectFromMetadata(md); 2729 if (!object) { 2730 psFree(md); 2731 exit(EXIT_FAILURE); 2732 } 2733 2734 psFree(md); 2735 2736 if (!object->p4b_id == -32) { 2595 2737 psFree(object); 2596 2738 exit(EXIT_FAILURE); … … 2604 2746 exit(EXIT_FAILURE); 2605 2747 } 2606 if (strncmp(object->filter, "a string", MAX_STRING_LENGTH)) { 2748 if (!object->magic == true) { 2749 psFree(object); 2750 exit(EXIT_FAILURE); 2751 } 2752 2753 psFree(object); 2754 } 2755 2756 { 2757 psMetadata *md; 2758 p4bInputScfileRow *object; 2759 2760 md = psMetadataAlloc(); 2761 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4b_id", 0, NULL, -32)) { 2762 psFree(md); 2763 exit(EXIT_FAILURE); 2764 } 2765 if (!psMetadataAddStr(md, PS_LIST_TAIL, "skycell_id", 0, NULL, "a string")) { 2766 psFree(md); 2767 exit(EXIT_FAILURE); 2768 } 2769 if (!psMetadataAddStr(md, PS_LIST_TAIL, "tess_id", 0, NULL, "a string")) { 2770 psFree(md); 2771 exit(EXIT_FAILURE); 2772 } 2773 if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_tag", 0, NULL, "a string")) { 2774 psFree(md); 2775 exit(EXIT_FAILURE); 2776 } 2777 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p3_version", 0, NULL, -32)) { 2778 psFree(md); 2779 exit(EXIT_FAILURE); 2780 } 2781 if (!psMetadataAddStr(md, PS_LIST_TAIL, "kind", 0, NULL, "a string")) { 2782 psFree(md); 2783 exit(EXIT_FAILURE); 2784 } 2785 2786 object = p4bInputScfileObjectFromMetadata(md); 2787 if (!object) { 2788 psFree(md); 2789 exit(EXIT_FAILURE); 2790 } 2791 2792 psFree(md); 2793 2794 if (!object->p4b_id == -32) { 2607 2795 psFree(object); 2608 2796 exit(EXIT_FAILURE); … … 2616 2804 exit(EXIT_FAILURE); 2617 2805 } 2618 if (!object->ra == 64.64) { 2619 psFree(object); 2620 exit(EXIT_FAILURE); 2621 } 2622 if (!object->decl == 64.64) { 2623 psFree(object); 2624 exit(EXIT_FAILURE); 2625 } 2626 if (strncmp(object->input_ss, "a string", MAX_STRING_LENGTH)) { 2627 psFree(object); 2628 exit(EXIT_FAILURE); 2629 } 2630 if (strncmp(object->output_ss, "a string", MAX_STRING_LENGTH)) { 2631 psFree(object); 2632 exit(EXIT_FAILURE); 2633 } 2634 2635 psFree(object); 2636 } 2637 2638 { 2639 psMetadata *md; 2640 p4InputImfileRow *object; 2641 2642 md = psMetadataAlloc(); 2643 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4_id", 0, NULL, -32)) { 2806 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 2807 psFree(object); 2808 exit(EXIT_FAILURE); 2809 } 2810 if (!object->p3_version == -32) { 2811 psFree(object); 2812 exit(EXIT_FAILURE); 2813 } 2814 if (strncmp(object->kind, "a string", MAX_STRING_LENGTH)) { 2815 psFree(object); 2816 exit(EXIT_FAILURE); 2817 } 2818 2819 psFree(object); 2820 } 2821 2822 { 2823 psMetadata *md; 2824 p4bDiffScfileRow *object; 2825 2826 md = psMetadataAlloc(); 2827 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4b_id", 0, NULL, -32)) { 2828 psFree(md); 2829 exit(EXIT_FAILURE); 2830 } 2831 if (!psMetadataAddStr(md, PS_LIST_TAIL, "skycell_id", 0, NULL, "a string")) { 2832 psFree(md); 2833 exit(EXIT_FAILURE); 2834 } 2835 if (!psMetadataAddStr(md, PS_LIST_TAIL, "tess_id", 0, NULL, "a string")) { 2644 2836 psFree(md); 2645 2837 exit(EXIT_FAILURE); … … 2653 2845 exit(EXIT_FAILURE); 2654 2846 } 2847 if (!psMetadataAddStr(md, PS_LIST_TAIL, "uri", 0, NULL, "a string")) { 2848 psFree(md); 2849 exit(EXIT_FAILURE); 2850 } 2851 if (!psMetadataAddF64(md, PS_LIST_TAIL, "bg", 0, NULL, 64.64)) { 2852 psFree(md); 2853 exit(EXIT_FAILURE); 2854 } 2855 if (!psMetadataAddF64(md, PS_LIST_TAIL, "bg_mean_stdev", 0, NULL, 64.64)) { 2856 psFree(md); 2857 exit(EXIT_FAILURE); 2858 } 2859 2860 object = p4bDiffScfileObjectFromMetadata(md); 2861 if (!object) { 2862 psFree(md); 2863 exit(EXIT_FAILURE); 2864 } 2865 2866 psFree(md); 2867 2868 if (!object->p4b_id == -32) { 2869 psFree(object); 2870 exit(EXIT_FAILURE); 2871 } 2872 if (strncmp(object->skycell_id, "a string", MAX_STRING_LENGTH)) { 2873 psFree(object); 2874 exit(EXIT_FAILURE); 2875 } 2876 if (strncmp(object->tess_id, "a string", MAX_STRING_LENGTH)) { 2877 psFree(object); 2878 exit(EXIT_FAILURE); 2879 } 2880 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 2881 psFree(object); 2882 exit(EXIT_FAILURE); 2883 } 2884 if (!object->p3_version == -32) { 2885 psFree(object); 2886 exit(EXIT_FAILURE); 2887 } 2888 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) { 2889 psFree(object); 2890 exit(EXIT_FAILURE); 2891 } 2892 if (!object->bg == 64.64) { 2893 psFree(object); 2894 exit(EXIT_FAILURE); 2895 } 2896 if (!object->bg_mean_stdev == 64.64) { 2897 psFree(object); 2898 exit(EXIT_FAILURE); 2899 } 2900 2901 psFree(object); 2902 } 2903 2904 { 2905 psMetadata *md; 2906 p4cRunRow *object; 2907 2908 md = psMetadataAlloc(); 2909 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4c_id", 0, NULL, -32)) { 2910 psFree(md); 2911 exit(EXIT_FAILURE); 2912 } 2913 if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, NULL, "a string")) { 2914 psFree(md); 2915 exit(EXIT_FAILURE); 2916 } 2917 if (!psMetadataAddStr(md, PS_LIST_TAIL, "workdir", 0, NULL, "a string")) { 2918 psFree(md); 2919 exit(EXIT_FAILURE); 2920 } 2921 if (!psMetadataAdd(md, PS_LIST_TAIL, "magic", PS_DATA_BOOL, NULL, true)) { 2922 psFree(md); 2923 exit(EXIT_FAILURE); 2924 } 2925 2926 object = p4cRunObjectFromMetadata(md); 2927 if (!object) { 2928 psFree(md); 2929 exit(EXIT_FAILURE); 2930 } 2931 2932 psFree(md); 2933 2934 if (!object->p4c_id == -32) { 2935 psFree(object); 2936 exit(EXIT_FAILURE); 2937 } 2938 if (strncmp(object->state, "a string", MAX_STRING_LENGTH)) { 2939 psFree(object); 2940 exit(EXIT_FAILURE); 2941 } 2942 if (strncmp(object->workdir, "a string", MAX_STRING_LENGTH)) { 2943 psFree(object); 2944 exit(EXIT_FAILURE); 2945 } 2946 if (!object->magic == true) { 2947 psFree(object); 2948 exit(EXIT_FAILURE); 2949 } 2950 2951 psFree(object); 2952 } 2953 2954 { 2955 psMetadata *md; 2956 p4cInputExpRow *object; 2957 2958 md = psMetadataAlloc(); 2959 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4c_id", 0, NULL, -32)) { 2960 psFree(md); 2961 exit(EXIT_FAILURE); 2962 } 2963 if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_tag", 0, NULL, "a string")) { 2964 psFree(md); 2965 exit(EXIT_FAILURE); 2966 } 2967 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p3_version", 0, NULL, -32)) { 2968 psFree(md); 2969 exit(EXIT_FAILURE); 2970 } 2971 2972 object = p4cInputExpObjectFromMetadata(md); 2973 if (!object) { 2974 psFree(md); 2975 exit(EXIT_FAILURE); 2976 } 2977 2978 psFree(md); 2979 2980 if (!object->p4c_id == -32) { 2981 psFree(object); 2982 exit(EXIT_FAILURE); 2983 } 2984 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) { 2985 psFree(object); 2986 exit(EXIT_FAILURE); 2987 } 2988 if (!object->p3_version == -32) { 2989 psFree(object); 2990 exit(EXIT_FAILURE); 2991 } 2992 2993 psFree(object); 2994 } 2995 2996 { 2997 psMetadata *md; 2998 p4MagicMaskImfileRow *object; 2999 3000 md = psMetadataAlloc(); 3001 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4c_id", 0, NULL, -32)) { 3002 psFree(md); 3003 exit(EXIT_FAILURE); 3004 } 3005 if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_tag", 0, NULL, "a string")) { 3006 psFree(md); 3007 exit(EXIT_FAILURE); 3008 } 3009 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p3_version", 0, NULL, -32)) { 3010 psFree(md); 3011 exit(EXIT_FAILURE); 3012 } 2655 3013 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "a string")) { 2656 3014 psFree(md); 2657 3015 exit(EXIT_FAILURE); 2658 3016 } 2659 2660 object = p4InputImfileObjectFromMetadata(md); 2661 if (!object) { 2662 psFree(md); 2663 exit(EXIT_FAILURE); 2664 } 2665 2666 psFree(md); 2667 2668 if (!object->p4_id == -32) { 3017 if (!psMetadataAddStr(md, PS_LIST_TAIL, "uri", 0, NULL, "a string")) { 3018 psFree(md); 3019 exit(EXIT_FAILURE); 3020 } 3021 3022 object = p4MagicMaskImfileObjectFromMetadata(md); 3023 if (!object) { 3024 psFree(md); 3025 exit(EXIT_FAILURE); 3026 } 3027 3028 psFree(md); 3029 3030 if (!object->p4c_id == -32) { 2669 3031 psFree(object); 2670 3032 exit(EXIT_FAILURE); … … 2682 3044 exit(EXIT_FAILURE); 2683 3045 } 2684 2685 psFree(object); 2686 } 2687 2688 { 2689 psMetadata *md; 2690 p4WarpedImfileRow *object; 2691 2692 md = psMetadataAlloc(); 2693 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4_id", 0, NULL, -32)) { 3046 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) { 3047 psFree(object); 3048 exit(EXIT_FAILURE); 3049 } 3050 3051 psFree(object); 3052 } 3053 3054 { 3055 psMetadata *md; 3056 skyCellRow *object; 3057 3058 md = psMetadataAlloc(); 3059 if (!psMetadataAddStr(md, PS_LIST_TAIL, "skycell_id", 0, NULL, "a string")) { 3060 psFree(md); 3061 exit(EXIT_FAILURE); 3062 } 3063 if (!psMetadataAddStr(md, PS_LIST_TAIL, "tess_id", 0, NULL, "a string")) { 3064 psFree(md); 3065 exit(EXIT_FAILURE); 3066 } 3067 if (!psMetadataAddF64(md, PS_LIST_TAIL, "ra1", 0, NULL, 64.64)) { 3068 psFree(md); 3069 exit(EXIT_FAILURE); 3070 } 3071 if (!psMetadataAddF64(md, PS_LIST_TAIL, "decl1", 0, NULL, 64.64)) { 3072 psFree(md); 3073 exit(EXIT_FAILURE); 3074 } 3075 if (!psMetadataAddF64(md, PS_LIST_TAIL, "ra2", 0, NULL, 64.64)) { 3076 psFree(md); 3077 exit(EXIT_FAILURE); 3078 } 3079 if (!psMetadataAddF64(md, PS_LIST_TAIL, "decl2", 0, NULL, 64.64)) { 3080 psFree(md); 3081 exit(EXIT_FAILURE); 3082 } 3083 if (!psMetadataAddF64(md, PS_LIST_TAIL, "ra3", 0, NULL, 64.64)) { 3084 psFree(md); 3085 exit(EXIT_FAILURE); 3086 } 3087 if (!psMetadataAddF64(md, PS_LIST_TAIL, "decl3", 0, NULL, 64.64)) { 3088 psFree(md); 3089 exit(EXIT_FAILURE); 3090 } 3091 if (!psMetadataAddF64(md, PS_LIST_TAIL, "ra4", 0, NULL, 64.64)) { 3092 psFree(md); 3093 exit(EXIT_FAILURE); 3094 } 3095 if (!psMetadataAddF64(md, PS_LIST_TAIL, "decl4", 0, NULL, 64.64)) { 3096 psFree(md); 3097 exit(EXIT_FAILURE); 3098 } 3099 3100 object = skyCellObjectFromMetadata(md); 3101 if (!object) { 3102 psFree(md); 3103 exit(EXIT_FAILURE); 3104 } 3105 3106 psFree(md); 3107 3108 if (strncmp(object->skycell_id, "a string", MAX_STRING_LENGTH)) { 3109 psFree(object); 3110 exit(EXIT_FAILURE); 3111 } 3112 if (strncmp(object->tess_id, "a string", MAX_STRING_LENGTH)) { 3113 psFree(object); 3114 exit(EXIT_FAILURE); 3115 } 3116 if (!object->ra1 == 64.64) { 3117 psFree(object); 3118 exit(EXIT_FAILURE); 3119 } 3120 if (!object->decl1 == 64.64) { 3121 psFree(object); 3122 exit(EXIT_FAILURE); 3123 } 3124 if (!object->ra2 == 64.64) { 3125 psFree(object); 3126 exit(EXIT_FAILURE); 3127 } 3128 if (!object->decl2 == 64.64) { 3129 psFree(object); 3130 exit(EXIT_FAILURE); 3131 } 3132 if (!object->ra3 == 64.64) { 3133 psFree(object); 3134 exit(EXIT_FAILURE); 3135 } 3136 if (!object->decl3 == 64.64) { 3137 psFree(object); 3138 exit(EXIT_FAILURE); 3139 } 3140 if (!object->ra4 == 64.64) { 3141 psFree(object); 3142 exit(EXIT_FAILURE); 3143 } 3144 if (!object->decl4 == 64.64) { 3145 psFree(object); 3146 exit(EXIT_FAILURE); 3147 } 3148 3149 psFree(object); 3150 } 3151 3152 { 3153 psMetadata *md; 3154 skyCellMapRow *object; 3155 3156 md = psMetadataAlloc(); 3157 if (!psMetadataAddStr(md, PS_LIST_TAIL, "skycell_id", 0, NULL, "a string")) { 3158 psFree(md); 3159 exit(EXIT_FAILURE); 3160 } 3161 if (!psMetadataAddStr(md, PS_LIST_TAIL, "tess_id", 0, NULL, "a string")) { 2694 3162 psFree(md); 2695 3163 exit(EXIT_FAILURE); … … 2699 3167 exit(EXIT_FAILURE); 2700 3168 } 2701 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p3_version", 0, NULL, -32)) {2702 psFree(md);2703 exit(EXIT_FAILURE);2704 }2705 3169 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "a string")) { 2706 3170 psFree(md); 2707 3171 exit(EXIT_FAILURE); 2708 3172 } 2709 if (!psMetadataAddStr(md, PS_LIST_TAIL, "uri", 0, NULL, "a string")) { 2710 psFree(md); 2711 exit(EXIT_FAILURE); 2712 } 2713 if (!psMetadataAddStr(md, PS_LIST_TAIL, "b1_uri", 0, NULL, "a string")) { 2714 psFree(md); 2715 exit(EXIT_FAILURE); 2716 } 2717 if (!psMetadataAddStr(md, PS_LIST_TAIL, "b2_uri", 0, NULL, "a string")) { 2718 psFree(md); 2719 exit(EXIT_FAILURE); 2720 } 2721 2722 object = p4WarpedImfileObjectFromMetadata(md); 2723 if (!object) { 2724 psFree(md); 2725 exit(EXIT_FAILURE); 2726 } 2727 2728 psFree(md); 2729 2730 if (!object->p4_id == -32) { 3173 3174 object = skyCellMapObjectFromMetadata(md); 3175 if (!object) { 3176 psFree(md); 3177 exit(EXIT_FAILURE); 3178 } 3179 3180 psFree(md); 3181 3182 if (strncmp(object->skycell_id, "a string", MAX_STRING_LENGTH)) { 3183 psFree(object); 3184 exit(EXIT_FAILURE); 3185 } 3186 if (strncmp(object->tess_id, "a string", MAX_STRING_LENGTH)) { 2731 3187 psFree(object); 2732 3188 exit(EXIT_FAILURE); … … 2736 3192 exit(EXIT_FAILURE); 2737 3193 } 2738 if (!object->p3_version == -32) {2739 psFree(object);2740 exit(EXIT_FAILURE);2741 }2742 3194 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) { 2743 psFree(object);2744 exit(EXIT_FAILURE);2745 }2746 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) {2747 psFree(object);2748 exit(EXIT_FAILURE);2749 }2750 if (strncmp(object->b1_uri, "a string", MAX_STRING_LENGTH)) {2751 psFree(object);2752 exit(EXIT_FAILURE);2753 }2754 if (strncmp(object->b2_uri, "a string", MAX_STRING_LENGTH)) {2755 psFree(object);2756 exit(EXIT_FAILURE);2757 }2758 2759 psFree(object);2760 }2761 2762 {2763 psMetadata *md;2764 p4StackedImfileRow *object;2765 2766 md = psMetadataAlloc();2767 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4_id", 0, NULL, -32)) {2768 psFree(md);2769 exit(EXIT_FAILURE);2770 }2771 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "a string")) {2772 psFree(md);2773 exit(EXIT_FAILURE);2774 }2775 if (!psMetadataAddStr(md, PS_LIST_TAIL, "uri", 0, NULL, "a string")) {2776 psFree(md);2777 exit(EXIT_FAILURE);2778 }2779 if (!psMetadataAddStr(md, PS_LIST_TAIL, "b1_uri", 0, NULL, "a string")) {2780 psFree(md);2781 exit(EXIT_FAILURE);2782 }2783 if (!psMetadataAddStr(md, PS_LIST_TAIL, "b2_uri", 0, NULL, "a string")) {2784 psFree(md);2785 exit(EXIT_FAILURE);2786 }2787 2788 object = p4StackedImfileObjectFromMetadata(md);2789 if (!object) {2790 psFree(md);2791 exit(EXIT_FAILURE);2792 }2793 2794 psFree(md);2795 2796 if (!object->p4_id == -32) {2797 psFree(object);2798 exit(EXIT_FAILURE);2799 }2800 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) {2801 psFree(object);2802 exit(EXIT_FAILURE);2803 }2804 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) {2805 psFree(object);2806 exit(EXIT_FAILURE);2807 }2808 if (strncmp(object->b1_uri, "a string", MAX_STRING_LENGTH)) {2809 psFree(object);2810 exit(EXIT_FAILURE);2811 }2812 if (strncmp(object->b2_uri, "a string", MAX_STRING_LENGTH)) {2813 psFree(object);2814 exit(EXIT_FAILURE);2815 }2816 2817 psFree(object);2818 }2819 2820 {2821 psMetadata *md;2822 p4DiffImfileRow *object;2823 2824 md = psMetadataAlloc();2825 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4_id", 0, NULL, -32)) {2826 psFree(md);2827 exit(EXIT_FAILURE);2828 }2829 if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_tag", 0, NULL, "a string")) {2830 psFree(md);2831 exit(EXIT_FAILURE);2832 }2833 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p3_version", 0, NULL, -32)) {2834 psFree(md);2835 exit(EXIT_FAILURE);2836 }2837 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "a string")) {2838 psFree(md);2839 exit(EXIT_FAILURE);2840 }2841 if (!psMetadataAddStr(md, PS_LIST_TAIL, "uri", 0, NULL, "a string")) {2842 psFree(md);2843 exit(EXIT_FAILURE);2844 }2845 if (!psMetadataAddStr(md, PS_LIST_TAIL, "b1_uri", 0, NULL, "a string")) {2846 psFree(md);2847 exit(EXIT_FAILURE);2848 }2849 if (!psMetadataAddStr(md, PS_LIST_TAIL, "b2_uri", 0, NULL, "a string")) {2850 psFree(md);2851 exit(EXIT_FAILURE);2852 }2853 2854 object = p4DiffImfileObjectFromMetadata(md);2855 if (!object) {2856 psFree(md);2857 exit(EXIT_FAILURE);2858 }2859 2860 psFree(md);2861 2862 if (!object->p4_id == -32) {2863 psFree(object);2864 exit(EXIT_FAILURE);2865 }2866 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) {2867 psFree(object);2868 exit(EXIT_FAILURE);2869 }2870 if (!object->p3_version == -32) {2871 psFree(object);2872 exit(EXIT_FAILURE);2873 }2874 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) {2875 psFree(object);2876 exit(EXIT_FAILURE);2877 }2878 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) {2879 psFree(object);2880 exit(EXIT_FAILURE);2881 }2882 if (strncmp(object->b1_uri, "a string", MAX_STRING_LENGTH)) {2883 psFree(object);2884 exit(EXIT_FAILURE);2885 }2886 if (strncmp(object->b2_uri, "a string", MAX_STRING_LENGTH)) {2887 psFree(object);2888 exit(EXIT_FAILURE);2889 }2890 2891 psFree(object);2892 }2893 2894 {2895 psMetadata *md;2896 p4MagicMaskImfileRow *object;2897 2898 md = psMetadataAlloc();2899 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p4_id", 0, NULL, -32)) {2900 psFree(md);2901 exit(EXIT_FAILURE);2902 }2903 if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_tag", 0, NULL, "a string")) {2904 psFree(md);2905 exit(EXIT_FAILURE);2906 }2907 if (!psMetadataAddS32(md, PS_LIST_TAIL, "p3_version", 0, NULL, -32)) {2908 psFree(md);2909 exit(EXIT_FAILURE);2910 }2911 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "a string")) {2912 psFree(md);2913 exit(EXIT_FAILURE);2914 }2915 if (!psMetadataAddStr(md, PS_LIST_TAIL, "uri", 0, NULL, "a string")) {2916 psFree(md);2917 exit(EXIT_FAILURE);2918 }2919 2920 object = p4MagicMaskImfileObjectFromMetadata(md);2921 if (!object) {2922 psFree(md);2923 exit(EXIT_FAILURE);2924 }2925 2926 psFree(md);2927 2928 if (!object->p4_id == -32) {2929 psFree(object);2930 exit(EXIT_FAILURE);2931 }2932 if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) {2933 psFree(object);2934 exit(EXIT_FAILURE);2935 }2936 if (!object->p3_version == -32) {2937 psFree(object);2938 exit(EXIT_FAILURE);2939 }2940 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) {2941 psFree(object);2942 exit(EXIT_FAILURE);2943 }2944 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) {2945 3195 psFree(object); 2946 3196 exit(EXIT_FAILURE); -
trunk/ippdb/tests/selectrowsfits.c
r11045 r11679 703 703 } 704 704 705 if (!p4RunSelectRowsFits(dbh, fits, NULL, 1)) { 706 exit(EXIT_FAILURE); 707 } 708 709 psFree(fits); 710 psDBCleanup(dbh); 711 } 712 713 { 714 psDB *dbh; 715 psFits *fits; 716 717 dbh = psDBInit("localhost", "test", NULL, "test"); 718 if (!dbh) { 719 exit(EXIT_FAILURE); 720 } 721 722 fits = psFitsOpen(TMP_FILENAME, "w"); 723 if (!fits) { 724 exit(EXIT_FAILURE); 725 } 726 727 if (!p4InputImfileSelectRowsFits(dbh, fits, NULL, 1)) { 728 exit(EXIT_FAILURE); 729 } 730 731 psFree(fits); 732 psDBCleanup(dbh); 733 } 734 735 { 736 psDB *dbh; 737 psFits *fits; 738 739 dbh = psDBInit("localhost", "test", NULL, "test"); 740 if (!dbh) { 741 exit(EXIT_FAILURE); 742 } 743 744 fits = psFitsOpen(TMP_FILENAME, "w"); 745 if (!fits) { 746 exit(EXIT_FAILURE); 747 } 748 749 if (!p4WarpedImfileSelectRowsFits(dbh, fits, NULL, 1)) { 750 exit(EXIT_FAILURE); 751 } 752 753 psFree(fits); 754 psDBCleanup(dbh); 755 } 756 757 { 758 psDB *dbh; 759 psFits *fits; 760 761 dbh = psDBInit("localhost", "test", NULL, "test"); 762 if (!dbh) { 763 exit(EXIT_FAILURE); 764 } 765 766 fits = psFitsOpen(TMP_FILENAME, "w"); 767 if (!fits) { 768 exit(EXIT_FAILURE); 769 } 770 771 if (!p4StackedImfileSelectRowsFits(dbh, fits, NULL, 1)) { 772 exit(EXIT_FAILURE); 773 } 774 775 psFree(fits); 776 psDBCleanup(dbh); 777 } 778 779 { 780 psDB *dbh; 781 psFits *fits; 782 783 dbh = psDBInit("localhost", "test", NULL, "test"); 784 if (!dbh) { 785 exit(EXIT_FAILURE); 786 } 787 788 fits = psFitsOpen(TMP_FILENAME, "w"); 789 if (!fits) { 790 exit(EXIT_FAILURE); 791 } 792 793 if (!p4DiffImfileSelectRowsFits(dbh, fits, NULL, 1)) { 705 if (!p4aRunSelectRowsFits(dbh, fits, NULL, 1)) { 706 exit(EXIT_FAILURE); 707 } 708 709 psFree(fits); 710 psDBCleanup(dbh); 711 } 712 713 { 714 psDB *dbh; 715 psFits *fits; 716 717 dbh = psDBInit("localhost", "test", NULL, "test"); 718 if (!dbh) { 719 exit(EXIT_FAILURE); 720 } 721 722 fits = psFitsOpen(TMP_FILENAME, "w"); 723 if (!fits) { 724 exit(EXIT_FAILURE); 725 } 726 727 if (!p4aInputExpSelectRowsFits(dbh, fits, NULL, 1)) { 728 exit(EXIT_FAILURE); 729 } 730 731 psFree(fits); 732 psDBCleanup(dbh); 733 } 734 735 { 736 psDB *dbh; 737 psFits *fits; 738 739 dbh = psDBInit("localhost", "test", NULL, "test"); 740 if (!dbh) { 741 exit(EXIT_FAILURE); 742 } 743 744 fits = psFitsOpen(TMP_FILENAME, "w"); 745 if (!fits) { 746 exit(EXIT_FAILURE); 747 } 748 749 if (!p4aScfileSelectRowsFits(dbh, fits, NULL, 1)) { 750 exit(EXIT_FAILURE); 751 } 752 753 psFree(fits); 754 psDBCleanup(dbh); 755 } 756 757 { 758 psDB *dbh; 759 psFits *fits; 760 761 dbh = psDBInit("localhost", "test", NULL, "test"); 762 if (!dbh) { 763 exit(EXIT_FAILURE); 764 } 765 766 fits = psFitsOpen(TMP_FILENAME, "w"); 767 if (!fits) { 768 exit(EXIT_FAILURE); 769 } 770 771 if (!p4bRunSelectRowsFits(dbh, fits, NULL, 1)) { 772 exit(EXIT_FAILURE); 773 } 774 775 psFree(fits); 776 psDBCleanup(dbh); 777 } 778 779 { 780 psDB *dbh; 781 psFits *fits; 782 783 dbh = psDBInit("localhost", "test", NULL, "test"); 784 if (!dbh) { 785 exit(EXIT_FAILURE); 786 } 787 788 fits = psFitsOpen(TMP_FILENAME, "w"); 789 if (!fits) { 790 exit(EXIT_FAILURE); 791 } 792 793 if (!p4bInputScfileSelectRowsFits(dbh, fits, NULL, 1)) { 794 exit(EXIT_FAILURE); 795 } 796 797 psFree(fits); 798 psDBCleanup(dbh); 799 } 800 801 { 802 psDB *dbh; 803 psFits *fits; 804 805 dbh = psDBInit("localhost", "test", NULL, "test"); 806 if (!dbh) { 807 exit(EXIT_FAILURE); 808 } 809 810 fits = psFitsOpen(TMP_FILENAME, "w"); 811 if (!fits) { 812 exit(EXIT_FAILURE); 813 } 814 815 if (!p4bDiffScfileSelectRowsFits(dbh, fits, NULL, 1)) { 816 exit(EXIT_FAILURE); 817 } 818 819 psFree(fits); 820 psDBCleanup(dbh); 821 } 822 823 { 824 psDB *dbh; 825 psFits *fits; 826 827 dbh = psDBInit("localhost", "test", NULL, "test"); 828 if (!dbh) { 829 exit(EXIT_FAILURE); 830 } 831 832 fits = psFitsOpen(TMP_FILENAME, "w"); 833 if (!fits) { 834 exit(EXIT_FAILURE); 835 } 836 837 if (!p4cRunSelectRowsFits(dbh, fits, NULL, 1)) { 838 exit(EXIT_FAILURE); 839 } 840 841 psFree(fits); 842 psDBCleanup(dbh); 843 } 844 845 { 846 psDB *dbh; 847 psFits *fits; 848 849 dbh = psDBInit("localhost", "test", NULL, "test"); 850 if (!dbh) { 851 exit(EXIT_FAILURE); 852 } 853 854 fits = psFitsOpen(TMP_FILENAME, "w"); 855 if (!fits) { 856 exit(EXIT_FAILURE); 857 } 858 859 if (!p4cInputExpSelectRowsFits(dbh, fits, NULL, 1)) { 794 860 exit(EXIT_FAILURE); 795 861 } … … 814 880 815 881 if (!p4MagicMaskImfileSelectRowsFits(dbh, fits, NULL, 1)) { 882 exit(EXIT_FAILURE); 883 } 884 885 psFree(fits); 886 psDBCleanup(dbh); 887 } 888 889 { 890 psDB *dbh; 891 psFits *fits; 892 893 dbh = psDBInit("localhost", "test", NULL, "test"); 894 if (!dbh) { 895 exit(EXIT_FAILURE); 896 } 897 898 fits = psFitsOpen(TMP_FILENAME, "w"); 899 if (!fits) { 900 exit(EXIT_FAILURE); 901 } 902 903 if (!skyCellSelectRowsFits(dbh, fits, NULL, 1)) { 904 exit(EXIT_FAILURE); 905 } 906 907 psFree(fits); 908 psDBCleanup(dbh); 909 } 910 911 { 912 psDB *dbh; 913 psFits *fits; 914 915 dbh = psDBInit("localhost", "test", NULL, "test"); 916 if (!dbh) { 917 exit(EXIT_FAILURE); 918 } 919 920 fits = psFitsOpen(TMP_FILENAME, "w"); 921 if (!fits) { 922 exit(EXIT_FAILURE); 923 } 924 925 if (!skyCellMapSelectRowsFits(dbh, fits, NULL, 1)) { 816 926 exit(EXIT_FAILURE); 817 927 }
Note:
See TracChangeset
for help on using the changeset viewer.
