IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11679


Ignore:
Timestamp:
Feb 6, 2007, 3:46:45 PM (19 years ago)
Author:
jhoblitt
Message:

VERSION 1.1.1

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/dbconfig/config.md

    r11658 r11679  
    22    pkg_name        STR     ippdb
    33    pkg_namespace   STR     ippdb
    4     pkg_version     STR     1.1.0
     4    pkg_version     STR     1.1.1
    55END
  • trunk/ippdb/Makefile.am

    r11045 r11679  
    4141    $(top_builddir)/docs/man/man3/detResidExpRow.3 \
    4242    $(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
    4954
    5055
    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/p4RunRow.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:
     56docs/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:
    5257        $(DOXYGEN)
    5358
  • trunk/ippdb/configure.ac

    r11635 r11679  
    11dnl
    2 dnl This file was generated by glueforge 1.00
     2dnl This file was generated by glueforge 0.36
    33dnl
    44dnl Do NOT directly edit this file.
     
    77AC_PREREQ(2.59)
    88
    9 AC_INIT([ippdb], [1.0.0], [pan-starrs.ifa.hawaii.edu])
     9AC_INIT([ippdb], [1.1.1], [pan-starrs.ifa.hawaii.edu])
    1010AC_CONFIG_SRCDIR([ippdb.pc.in])
    1111
  • trunk/ippdb/src/ippdb.c

    r11635 r11679  
    2020/*
    2121 *
    22  * This file was generated by glueforge 1.00
     22 * This file was generated by glueforge 0.36
    2323 *
    2424 * Do NOT directly edit this file.
     
    6262#define DETRESIDEXP_TABLE_NAME "detResidExp"
    6363#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"
    6972#define P4MAGICMASKIMFILE_TABLE_NAME "p4MagicMaskImfile"
     73#define SKYCELL_TABLE_NAME "skyCell"
     74#define SKYCELLMAP_TABLE_NAME "skyCellMap"
    7075#define MAX_STRING_LENGTH 1024
    7176
     
    438443    psMetadata *where = expTagCounterMetadataFromObject(object);
    439444    long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, 0);
    440     psFree(where)
     445    psFree(where);
    441446    if (count < 0) {
    442447        psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter");
     
    460465        psMetadata *where = expTagCounterMetadataFromObject(object);
    461466        long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);
    462         psFree(where)
     467        psFree(where);
    463468        if (count < 0) {
    464469            psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter");
     
    843848    psMetadata *where = summitExpMetadataFromObject(object);
    844849    long long count = psDBDeleteRows(dbh, SUMMITEXP_TABLE_NAME, where, 0);
    845     psFree(where)
     850    psFree(where);
    846851    if (count < 0) {
    847852        psError(PS_ERR_UNKNOWN, true, "failed to delete row from summitExp");
     
    865870        psMetadata *where = summitExpMetadataFromObject(object);
    866871        long long count = psDBDeleteRows(dbh, SUMMITEXP_TABLE_NAME, where, limit);
    867         psFree(where)
     872        psFree(where);
    868873        if (count < 0) {
    869874            psError(PS_ERR_UNKNOWN, true, "failed to delete row from summitExp");
     
    12921297    psMetadata *where = summitImfileMetadataFromObject(object);
    12931298    long long count = psDBDeleteRows(dbh, SUMMITIMFILE_TABLE_NAME, where, 0);
    1294     psFree(where)
     1299    psFree(where);
    12951300    if (count < 0) {
    12961301        psError(PS_ERR_UNKNOWN, true, "failed to delete row from summitImfile");
     
    13141319        psMetadata *where = summitImfileMetadataFromObject(object);
    13151320        long long count = psDBDeleteRows(dbh, SUMMITIMFILE_TABLE_NAME, where, limit);
    1316         psFree(where)
     1321        psFree(where);
    13171322        if (count < 0) {
    13181323            psError(PS_ERR_UNKNOWN, true, "failed to delete row from summitImfile");
     
    16101615    psMetadata *where = pzPendingExpMetadataFromObject(object);
    16111616    long long count = psDBDeleteRows(dbh, PZPENDINGEXP_TABLE_NAME, where, 0);
    1612     psFree(where)
     1617    psFree(where);
    16131618    if (count < 0) {
    16141619        psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzPendingExp");
     
    16321637        psMetadata *where = pzPendingExpMetadataFromObject(object);
    16331638        long long count = psDBDeleteRows(dbh, PZPENDINGEXP_TABLE_NAME, where, limit);
    1634         psFree(where)
     1639        psFree(where);
    16351640        if (count < 0) {
    16361641            psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzPendingExp");
     
    19941999    psMetadata *where = pzPendingImfileMetadataFromObject(object);
    19952000    long long count = psDBDeleteRows(dbh, PZPENDINGIMFILE_TABLE_NAME, where, 0);
    1996     psFree(where)
     2001    psFree(where);
    19972002    if (count < 0) {
    19982003        psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzPendingImfile");
     
    20162021        psMetadata *where = pzPendingImfileMetadataFromObject(object);
    20172022        long long count = psDBDeleteRows(dbh, PZPENDINGIMFILE_TABLE_NAME, where, limit);
    2018         psFree(where)
     2023        psFree(where);
    20192024        if (count < 0) {
    20202025            psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzPendingImfile");
     
    23122317    psMetadata *where = pzDoneExpMetadataFromObject(object);
    23132318    long long count = psDBDeleteRows(dbh, PZDONEEXP_TABLE_NAME, where, 0);
    2314     psFree(where)
     2319    psFree(where);
    23152320    if (count < 0) {
    23162321        psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzDoneExp");
     
    23342339        psMetadata *where = pzDoneExpMetadataFromObject(object);
    23352340        long long count = psDBDeleteRows(dbh, PZDONEEXP_TABLE_NAME, where, limit);
    2336         psFree(where)
     2341        psFree(where);
    23372342        if (count < 0) {
    23382343            psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzDoneExp");
     
    27182723    psMetadata *where = pzDoneImfileMetadataFromObject(object);
    27192724    long long count = psDBDeleteRows(dbh, PZDONEIMFILE_TABLE_NAME, where, 0);
    2720     psFree(where)
     2725    psFree(where);
    27212726    if (count < 0) {
    27222727        psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzDoneImfile");
     
    27402745        psMetadata *where = pzDoneImfileMetadataFromObject(object);
    27412746        long long count = psDBDeleteRows(dbh, PZDONEIMFILE_TABLE_NAME, where, limit);
    2742         psFree(where)
     2747        psFree(where);
    27432748        if (count < 0) {
    27442749            psError(PS_ERR_UNKNOWN, true, "failed to delete row from pzDoneImfile");
     
    31013106    psMetadata *where = newExpMetadataFromObject(object);
    31023107    long long count = psDBDeleteRows(dbh, NEWEXP_TABLE_NAME, where, 0);
    3103     psFree(where)
     3108    psFree(where);
    31043109    if (count < 0) {
    31053110        psError(PS_ERR_UNKNOWN, true, "failed to delete row from newExp");
     
    31233128        psMetadata *where = newExpMetadataFromObject(object);
    31243129        long long count = psDBDeleteRows(dbh, NEWEXP_TABLE_NAME, where, limit);
    3125         psFree(where)
     3130        psFree(where);
    31263131        if (count < 0) {
    31273132            psError(PS_ERR_UNKNOWN, true, "failed to delete row from newExp");
     
    34413446    psMetadata *where = newImfileMetadataFromObject(object);
    34423447    long long count = psDBDeleteRows(dbh, NEWIMFILE_TABLE_NAME, where, 0);
    3443     psFree(where)
     3448    psFree(where);
    34443449    if (count < 0) {
    34453450        psError(PS_ERR_UNKNOWN, true, "failed to delete row from newImfile");
     
    34633468        psMetadata *where = newImfileMetadataFromObject(object);
    34643469        long long count = psDBDeleteRows(dbh, NEWIMFILE_TABLE_NAME, where, limit);
    3465         psFree(where)
     3470        psFree(where);
    34663471        if (count < 0) {
    34673472            psError(PS_ERR_UNKNOWN, true, "failed to delete row from newImfile");
     
    41644169    psMetadata *where = rawExpMetadataFromObject(object);
    41654170    long long count = psDBDeleteRows(dbh, RAWEXP_TABLE_NAME, where, 0);
    4166     psFree(where)
     4171    psFree(where);
    41674172    if (count < 0) {
    41684173        psError(PS_ERR_UNKNOWN, true, "failed to delete row from rawExp");
     
    41864191        psMetadata *where = rawExpMetadataFromObject(object);
    41874192        long long count = psDBDeleteRows(dbh, RAWEXP_TABLE_NAME, where, limit);
    4188         psFree(where)
     4193        psFree(where);
    41894194        if (count < 0) {
    41904195            psError(PS_ERR_UNKNOWN, true, "failed to delete row from rawExp");
     
    48444849    psMetadata *where = rawImfileMetadataFromObject(object);
    48454850    long long count = psDBDeleteRows(dbh, RAWIMFILE_TABLE_NAME, where, 0);
    4846     psFree(where)
     4851    psFree(where);
    48474852    if (count < 0) {
    48484853        psError(PS_ERR_UNKNOWN, true, "failed to delete row from rawImfile");
     
    48664871        psMetadata *where = rawImfileMetadataFromObject(object);
    48674872        long long count = psDBDeleteRows(dbh, RAWIMFILE_TABLE_NAME, where, limit);
    4868         psFree(where)
     4873        psFree(where);
    48694874        if (count < 0) {
    48704875            psError(PS_ERR_UNKNOWN, true, "failed to delete row from rawImfile");
     
    51615166    psMetadata *where = p1PendingExpMetadataFromObject(object);
    51625167    long long count = psDBDeleteRows(dbh, P1PENDINGEXP_TABLE_NAME, where, 0);
    5163     psFree(where)
     5168    psFree(where);
    51645169    if (count < 0) {
    51655170        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p1PendingExp");
     
    51835188        psMetadata *where = p1PendingExpMetadataFromObject(object);
    51845189        long long count = psDBDeleteRows(dbh, P1PENDINGEXP_TABLE_NAME, where, limit);
    5185         psFree(where)
     5190        psFree(where);
    51865191        if (count < 0) {
    51875192            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p1PendingExp");
     
    55215526    psMetadata *where = p2PendingExpMetadataFromObject(object);
    55225527    long long count = psDBDeleteRows(dbh, P2PENDINGEXP_TABLE_NAME, where, 0);
    5523     psFree(where)
     5528    psFree(where);
    55245529    if (count < 0) {
    55255530        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2PendingExp");
     
    55435548        psMetadata *where = p2PendingExpMetadataFromObject(object);
    55445549        long long count = psDBDeleteRows(dbh, P2PENDINGEXP_TABLE_NAME, where, limit);
    5545         psFree(where)
     5550        psFree(where);
    55465551        if (count < 0) {
    55475552            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2PendingExp");
     
    59035908    psMetadata *where = p2PendingImfileMetadataFromObject(object);
    59045909    long long count = psDBDeleteRows(dbh, P2PENDINGIMFILE_TABLE_NAME, where, 0);
    5905     psFree(where)
     5910    psFree(where);
    59065911    if (count < 0) {
    59075912        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2PendingImfile");
     
    59255930        psMetadata *where = p2PendingImfileMetadataFromObject(object);
    59265931        long long count = psDBDeleteRows(dbh, P2PENDINGIMFILE_TABLE_NAME, where, limit);
    5927         psFree(where)
     5932        psFree(where);
    59285933        if (count < 0) {
    59295934            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2PendingImfile");
     
    62416246    psMetadata *where = p2ProcessedExpMetadataFromObject(object);
    62426247    long long count = psDBDeleteRows(dbh, P2PROCESSEDEXP_TABLE_NAME, where, 0);
    6243     psFree(where)
     6248    psFree(where);
    62446249    if (count < 0) {
    62456250        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2ProcessedExp");
     
    62636268        psMetadata *where = p2ProcessedExpMetadataFromObject(object);
    62646269        long long count = psDBDeleteRows(dbh, P2PROCESSEDEXP_TABLE_NAME, where, limit);
    6265         psFree(where)
     6270        psFree(where);
    62666271        if (count < 0) {
    62676272            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2ProcessedExp");
     
    65156520    psMetadata *where = p2MaskMetadataFromObject(object);
    65166521    long long count = psDBDeleteRows(dbh, P2MASK_TABLE_NAME, where, 0);
    6517     psFree(where)
     6522    psFree(where);
    65186523    if (count < 0) {
    65196524        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2Mask");
     
    65376542        psMetadata *where = p2MaskMetadataFromObject(object);
    65386543        long long count = psDBDeleteRows(dbh, P2MASK_TABLE_NAME, where, limit);
    6539         psFree(where)
     6544        psFree(where);
    65406545        if (count < 0) {
    65416546            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2Mask");
     
    70257030    psMetadata *where = p2ProcessedImfileMetadataFromObject(object);
    70267031    long long count = psDBDeleteRows(dbh, P2PROCESSEDIMFILE_TABLE_NAME, where, 0);
    7027     psFree(where)
     7032    psFree(where);
    70287033    if (count < 0) {
    70297034        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2ProcessedImfile");
     
    70477052        psMetadata *where = p2ProcessedImfileMetadataFromObject(object);
    70487053        long long count = psDBDeleteRows(dbh, P2PROCESSEDIMFILE_TABLE_NAME, where, limit);
    7049         psFree(where)
     7054        psFree(where);
    70507055        if (count < 0) {
    70517056            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p2ProcessedImfile");
     
    73637368    psMetadata *where = p3PendingExpMetadataFromObject(object);
    73647369    long long count = psDBDeleteRows(dbh, P3PENDINGEXP_TABLE_NAME, where, 0);
    7365     psFree(where)
     7370    psFree(where);
    73667371    if (count < 0) {
    73677372        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p3PendingExp");
     
    73857390        psMetadata *where = p3PendingExpMetadataFromObject(object);
    73867391        long long count = psDBDeleteRows(dbh, P3PENDINGEXP_TABLE_NAME, where, limit);
    7387         psFree(where)
     7392        psFree(where);
    73887393        if (count < 0) {
    73897394            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p3PendingExp");
     
    79787983    psMetadata *where = p3ProcessedExpMetadataFromObject(object);
    79797984    long long count = psDBDeleteRows(dbh, P3PROCESSEDEXP_TABLE_NAME, where, 0);
    7980     psFree(where)
     7985    psFree(where);
    79817986    if (count < 0) {
    79827987        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p3ProcessedExp");
     
    80008005        psMetadata *where = p3ProcessedExpMetadataFromObject(object);
    80018006        long long count = psDBDeleteRows(dbh, P3PROCESSEDEXP_TABLE_NAME, where, limit);
    8002         psFree(where)
     8007        psFree(where);
    80038008        if (count < 0) {
    80048009            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p3ProcessedExp");
     
    82528257    psMetadata *where = p3MaskMetadataFromObject(object);
    82538258    long long count = psDBDeleteRows(dbh, P3MASK_TABLE_NAME, where, 0);
    8254     psFree(where)
     8259    psFree(where);
    82558260    if (count < 0) {
    82568261        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p3Mask");
     
    82748279        psMetadata *where = p3MaskMetadataFromObject(object);
    82758280        long long count = psDBDeleteRows(dbh, P3MASK_TABLE_NAME, where, limit);
    8276         psFree(where)
     8281        psFree(where);
    82778282        if (count < 0) {
    82788283            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p3Mask");
     
    90009005    psMetadata *where = detRunMetadataFromObject(object);
    90019006    long long count = psDBDeleteRows(dbh, DETRUN_TABLE_NAME, where, 0);
    9002     psFree(where)
     9007    psFree(where);
    90039008    if (count < 0) {
    90049009        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detRun");
     
    90229027        psMetadata *where = detRunMetadataFromObject(object);
    90239028        long long count = psDBDeleteRows(dbh, DETRUN_TABLE_NAME, where, limit);
    9024         psFree(where)
     9029        psFree(where);
    90259030        if (count < 0) {
    90269031            psError(PS_ERR_UNKNOWN, true, "failed to delete row from detRun");
     
    93379342    psMetadata *where = detInputExpMetadataFromObject(object);
    93389343    long long count = psDBDeleteRows(dbh, DETINPUTEXP_TABLE_NAME, where, 0);
    9339     psFree(where)
     9344    psFree(where);
    93409345    if (count < 0) {
    93419346        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detInputExp");
     
    93599364        psMetadata *where = detInputExpMetadataFromObject(object);
    93609365        long long count = psDBDeleteRows(dbh, DETINPUTEXP_TABLE_NAME, where, limit);
    9361         psFree(where)
     9366        psFree(where);
    93629367        if (count < 0) {
    93639368            psError(PS_ERR_UNKNOWN, true, "failed to delete row from detInputExp");
     
    98269831    psMetadata *where = detProcessedImfileMetadataFromObject(object);
    98279832    long long count = psDBDeleteRows(dbh, DETPROCESSEDIMFILE_TABLE_NAME, where, 0);
    9828     psFree(where)
     9833    psFree(where);
    98299834    if (count < 0) {
    98309835        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detProcessedImfile");
     
    98489853        psMetadata *where = detProcessedImfileMetadataFromObject(object);
    98499854        long long count = psDBDeleteRows(dbh, DETPROCESSEDIMFILE_TABLE_NAME, where, limit);
    9850         psFree(where)
     9855        psFree(where);
    98519856        if (count < 0) {
    98529857            psError(PS_ERR_UNKNOWN, true, "failed to delete row from detProcessedImfile");
     
    1027110276    psMetadata *where = detProcessedExpMetadataFromObject(object);
    1027210277    long long count = psDBDeleteRows(dbh, DETPROCESSEDEXP_TABLE_NAME, where, 0);
    10273     psFree(where)
     10278    psFree(where);
    1027410279    if (count < 0) {
    1027510280        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detProcessedExp");
     
    1029310298        psMetadata *where = detProcessedExpMetadataFromObject(object);
    1029410299        long long count = psDBDeleteRows(dbh, DETPROCESSEDEXP_TABLE_NAME, where, limit);
    10295         psFree(where)
     10300        psFree(where);
    1029610301        if (count < 0) {
    1029710302            psError(PS_ERR_UNKNOWN, true, "failed to delete row from detProcessedExp");
     
    1071510720    psMetadata *where = detStackedImfileMetadataFromObject(object);
    1071610721    long long count = psDBDeleteRows(dbh, DETSTACKEDIMFILE_TABLE_NAME, where, 0);
    10717     psFree(where)
     10722    psFree(where);
    1071810723    if (count < 0) {
    1071910724        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detStackedImfile");
     
    1073710742        psMetadata *where = detStackedImfileMetadataFromObject(object);
    1073810743        long long count = psDBDeleteRows(dbh, DETSTACKEDIMFILE_TABLE_NAME, where, limit);
    10739         psFree(where)
     10744        psFree(where);
    1074010745        if (count < 0) {
    1074110746            psError(PS_ERR_UNKNOWN, true, "failed to delete row from detStackedImfile");
     
    1107311078    psMetadata *where = detNormalizedStatImfileMetadataFromObject(object);
    1107411079    long long count = psDBDeleteRows(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, where, 0);
    11075     psFree(where)
     11080    psFree(where);
    1107611081    if (count < 0) {
    1107711082        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedStatImfile");
     
    1109511100        psMetadata *where = detNormalizedStatImfileMetadataFromObject(object);
    1109611101        long long count = psDBDeleteRows(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, where, limit);
    11097         psFree(where)
     11102        psFree(where);
    1109811103        if (count < 0) {
    1109911104            psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedStatImfile");
     
    1153911544    psMetadata *where = detNormalizedImfileMetadataFromObject(object);
    1154011545    long long count = psDBDeleteRows(dbh, DETNORMALIZEDIMFILE_TABLE_NAME, where, 0);
    11541     psFree(where)
     11546    psFree(where);
    1154211547    if (count < 0) {
    1154311548        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedImfile");
     
    1156111566        psMetadata *where = detNormalizedImfileMetadataFromObject(object);
    1156211567        long long count = psDBDeleteRows(dbh, DETNORMALIZEDIMFILE_TABLE_NAME, where, limit);
    11563         psFree(where)
     11568        psFree(where);
    1156411569        if (count < 0) {
    1156511570            psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedImfile");
     
    1198311988    psMetadata *where = detNormalizedExpMetadataFromObject(object);
    1198411989    long long count = psDBDeleteRows(dbh, DETNORMALIZEDEXP_TABLE_NAME, where, 0);
    11985     psFree(where)
     11990    psFree(where);
    1198611991    if (count < 0) {
    1198711992        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedExp");
     
    1200512010        psMetadata *where = detNormalizedExpMetadataFromObject(object);
    1200612011        long long count = psDBDeleteRows(dbh, DETNORMALIZEDEXP_TABLE_NAME, where, limit);
    12007         psFree(where)
     12012        psFree(where);
    1200812013        if (count < 0) {
    1200912014            psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedExp");
     
    1249312498    psMetadata *where = detResidImfileMetadataFromObject(object);
    1249412499    long long count = psDBDeleteRows(dbh, DETRESIDIMFILE_TABLE_NAME, where, 0);
    12495     psFree(where)
     12500    psFree(where);
    1249612501    if (count < 0) {
    1249712502        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detResidImfile");
     
    1251512520        psMetadata *where = detResidImfileMetadataFromObject(object);
    1251612521        long long count = psDBDeleteRows(dbh, DETRESIDIMFILE_TABLE_NAME, where, limit);
    12517         psFree(where)
     12522        psFree(where);
    1251812523        if (count < 0) {
    1251912524            psError(PS_ERR_UNKNOWN, true, "failed to delete row from detResidImfile");
     
    1298012985    psMetadata *where = detResidExpMetadataFromObject(object);
    1298112986    long long count = psDBDeleteRows(dbh, DETRESIDEXP_TABLE_NAME, where, 0);
    12982     psFree(where)
     12987    psFree(where);
    1298312988    if (count < 0) {
    1298412989        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detResidExp");
     
    1300213007        psMetadata *where = detResidExpMetadataFromObject(object);
    1300313008        long long count = psDBDeleteRows(dbh, DETRESIDEXP_TABLE_NAME, where, limit);
    13004         psFree(where)
     13009        psFree(where);
    1300513010        if (count < 0) {
    1300613011            psError(PS_ERR_UNKNOWN, true, "failed to delete row from detResidExp");
     
    1337913384    psMetadata *where = detRunSummaryMetadataFromObject(object);
    1338013385    long long count = psDBDeleteRows(dbh, DETRUNSUMMARY_TABLE_NAME, where, 0);
    13381     psFree(where)
     13386    psFree(where);
    1338213387    if (count < 0) {
    1338313388        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detRunSummary");
     
    1340113406        psMetadata *where = detRunSummaryMetadataFromObject(object);
    1340213407        long long count = psDBDeleteRows(dbh, DETRUNSUMMARY_TABLE_NAME, where, limit);
    13403         psFree(where)
     13408        psFree(where);
    1340413409        if (count < 0) {
    1340513410            psError(PS_ERR_UNKNOWN, true, "failed to delete row from detRunSummary");
     
    1345813463    return true;
    1345913464}
    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);
     13465static void p4aRunRowFree(p4aRunRow *object);
     13466
     13467p4aRunRow *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;
    1347113475    _object->state = psStringCopy(state);
    1347213476    _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;
    1348013478
    1348113479    return _object;
    1348213480}
    1348313481
    13484 static void p4RunRowFree(p4RunRow *object)
    13485 {
    13486     psFree(object->survey_mode);
     13482static void p4aRunRowFree(p4aRunRow *object)
     13483{
    1348713484    psFree(object->state);
    1348813485    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
     13488bool p4aRunCreateTable(psDB *dbh)
    1349713489{
    1349813490    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");
    1350613493        psFree(md);
    1350713494        return false;
     
    1351713504        return false;
    1351813505    }
    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);
    1355613513
    1355713514    psFree(md);
     
    1356013517}
    1356113518
    13562 bool p4RunDropTable(psDB *dbh)
    13563 {
    13564     return psDBDropTable(dbh, P4RUN_TABLE_NAME);
    13565 }
    13566 
    13567 bool p4RunInsert(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)
     13519bool p4aRunDropTable(psDB *dbh)
     13520{
     13521    return psDBDropTable(dbh, P4ARUN_TABLE_NAME);
     13522}
     13523
     13524bool p4aRunInsert(psDB * dbh, psS32 p4a_id, const char *state, const char *workdir, bool magic)
    1356813525{
    1356913526    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");
    1357713529        psFree(md);
    1357813530        return false;
     
    1358813540        return false;
    1358913541    }
    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);
    1362713549    psFree(md);
    1362813550
     
    1363013552}
    1363113553
    13632 long long p4RunDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
     13554long long p4aRunDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
    1363313555{
    1363413556    long long       deleted = 0;
    1363513557
    13636     long long count = psDBDeleteRows(dbh, P4RUN_TABLE_NAME, where, limit);
     13558    long long count = psDBDeleteRows(dbh, P4ARUN_TABLE_NAME, where, limit);
    1363713559    if (count < 0) {
    13638         psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4Run");
     13560        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aRun");
    1363913561        return count;
    1364013562
     
    1364413566    return deleted;
    1364513567}
    13646 bool p4RunInsertObject(psDB *dbh, p4RunRow *object)
    13647 {
    13648     return p4RunInsert(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 p4RunInsertObjects(psDB *dbh, psArray *objects)
     13568bool p4aRunInsertObject(psDB *dbh, p4aRunRow *object)
     13569{
     13570    return p4aRunInsert(dbh, object->p4a_id, object->state, object->workdir, object->magic);
     13571}
     13572
     13573bool p4aRunInsertObjects(psDB *dbh, psArray *objects)
    1365213574{
    1365313575    for (long i = 0; i < psArrayLength(objects); i++) {
    13654         if (!p4RunInsertObject(dbh, objects->data[i])) {
     13576        if (!p4aRunInsertObject(dbh, objects->data[i])) {
    1365513577            return false;
    1365613578        }
     
    1366013582}
    1366113583
    13662 bool p4RunInsertFits(psDB *dbh, const psFits *fits)
     13584bool p4aRunInsertFits(psDB *dbh, const psFits *fits)
    1366313585{
    1366413586    psArray         *rowSet;
    1366513587
    13666     // move to (the first?) extension named  P4RUN_TABLE_NAME
    13667     if (!psFitsMoveExtName(fits, P4RUN_TABLE_NAME)) {
    13668         psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4RUN_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);
    1366913591        return false;
    1367013592    }
     
    1368413606    }
    1368513607
    13686     if (!psDBInsertRows(dbh, P4RUN_TABLE_NAME, rowSet)) {
     13608    if (!psDBInsertRows(dbh, P4ARUN_TABLE_NAME, rowSet)) {
    1368713609        psError(PS_ERR_UNKNOWN, false, "databse insert failed");
    1368813610        psFree(rowSet);
     
    1369513617}
    1369613618
    13697 bool p4RunSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
     13619bool p4aRunSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
    1369813620{
    1369913621    psArray         *rowSet;
    1370013622
    13701     rowSet = psDBSelectRows(dbh, P4RUN_TABLE_NAME, where, limit);
     13623    rowSet = psDBSelectRows(dbh, P4ARUN_TABLE_NAME, where, limit);
    1370213624    if (!rowSet) {
    1370313625        return false;
     
    1370513627
    1370613628    // output to fits
    13707     if (!psFitsWriteTable(fits, NULL, rowSet, P4RUN_TABLE_NAME)) {
     13629    if (!psFitsWriteTable(fits, NULL, rowSet, P4ARUN_TABLE_NAME)) {
    1370813630        psError(PS_ERR_UNKNOWN, false, "FITS table write failed");
    1370913631        psFree(rowSet);
     
    1371613638}
    1371713639
    13718 psMetadata *p4RunMetadataFromObject(const p4RunRow *object)
     13640psMetadata *p4aRunMetadataFromObject(const p4aRunRow *object)
    1371913641{
    1372013642    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");
    1372813645        psFree(md);
    1372913646        return false;
     
    1373913656        return false;
    1374013657    }
    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");
    1377313660        psFree(md);
    1377413661        return false;
     
    1377913666}
    1378013667
    13781 p4RunRow *p4RunObjectFromMetadata(psMetadata *md)
     13668p4aRunRow *p4aRunObjectFromMetadata(psMetadata *md)
    1378213669{
    1378313670
    1378413671bool 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");
    1379313675        return false;
    1379413676    }
     
    1380313685        return false;
    1380413686    }
    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}
     13695psArray *p4aRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
    1384413696{
    1384513697    psArray         *rowSet;
     
    1384713699    psU64           i;
    1384813700
    13849     rowSet = psDBSelectRows(dbh, P4RUN_TABLE_NAME, where, limit);
     13701    rowSet = psDBSelectRows(dbh, P4ARUN_TABLE_NAME, where, limit);
    1385013702    if (!rowSet) {
    1385113703        return NULL;
     
    1385713709
    1385813710    for (i = 0; i < rowSet->n; i++) {
    13859         p4RunRow *object = p4RunObjectFromMetadata(rowSet->data[i]);
     13711        p4aRunRow *object = p4aRunObjectFromMetadata(rowSet->data[i]);
    1386013712        psArrayAdd(returnSet, 0, object);
    1386113713        psFree(object);
     
    1386613718    return returnSet;
    1386713719}
    13868 bool p4RunDeleteObject(psDB *dbh, const p4RunRow *object)
    13869 {
    13870     psMetadata *where = p4RunMetadataFromObject(object);
    13871     long long count = psDBDeleteRows(dbh, P4RUN_TABLE_NAME, where, 0);
    13872     psFree(where)
     13720bool 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);
    1387313725    if (count < 0) {
    13874         psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4Run");
     13726        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aRun");
    1387513727        return false;
    1387613728    }
     
    1387813730        // XXX should this be a psAbort() instead?  It is possible that
    1387913731        // having an object match multiple rows was by design.
    13880         psError(PS_ERR_UNKNOWN, true, "p4RunRow object matched more then one row.  Check your database schema");
    13881         return false;
    13882     }
    13883 
    13884     return true;
    13885 }
    13886 long long p4RunDeleteRowObjects(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}
     13738long long p4aRunDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)
    1388713739{
    1388813740    long long       deleted = 0;
    1388913741
    1389013742    for (long long i = 0; i < objects->n; i++) {
    13891         p4RunRow *object = objects->data[i];
    13892         psMetadata *where = p4RunMetadataFromObject(object);
    13893         long long count = psDBDeleteRows(dbh, P4RUN_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);
    1389513747        if (count < 0) {
    13896             psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4Run");
     13748            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aRun");
    1389713749            return count;
    1389813750        }
     
    1390313755    return deleted;
    1390413756}
    13905 bool p4RunPrintObjects(FILE *stream, psArray *objects, bool mdcf)
     13757bool p4aRunPrintObjects(FILE *stream, psArray *objects, bool mdcf)
    1390613758{
    1390713759    PS_ASSERT_PTR_NON_NULL(objects, false);
     
    1390913761    psMetadata *output = psMetadataAlloc();
    1391013762    for (long i = 0; i < psArrayLength(objects); i++) {
    13911         psMetadata *md = p4RunMetadataFromObject(objects->data[i]);
     13763        psMetadata *md = p4aRunMetadataFromObject(objects->data[i]);
    1391213764        if (!psMetadataAddMetadata(
    1391313765            output,
    1391413766            PS_LIST_TAIL,
    13915             P4RUN_TABLE_NAME,
     13767            P4ARUN_TABLE_NAME,
    1391613768            PS_META_DUPLICATE_OK,
    1391713769            NULL,
     
    1393413786    return true;
    1393513787}
    13936 bool p4RunPrintObject(FILE *stream, p4RunRow *object, bool mdcf)
     13788bool p4aRunPrintObject(FILE *stream, p4aRunRow *object, bool mdcf)
    1393713789{
    1393813790    PS_ASSERT_PTR_NON_NULL(object, false);
    1393913791
    13940     psMetadata *md = p4RunMetadataFromObject(object);
     13792    psMetadata *md = p4aRunMetadataFromObject(object);
    1394113793
    1394213794    if (!ippdbPrintMetadataRaw(stream, md, mdcf)) {
     
    1394913801    return true;
    1395013802}
    13951 static void p4InputImfileRowFree(p4InputImfileRow *object);
    13952 
    13953 p4InputImfileRow *p4InputImfileRowAlloc(psS32 p4_id, const char *exp_tag, psS32 p3_version, const char *class_id)
    13954 {
    13955     p4InputImfileRow *_object;
    13956 
    13957     _object = psAlloc(sizeof(p4InputImfileRow));
    13958     psMemSetDeallocator(_object, (psFreeFunc)p4InputImfileRowFree);
    13959 
    13960     _object->p4_id = p4_id;
     13803static void p4aInputExpRowFree(p4aInputExpRow *object);
     13804
     13805p4aInputExpRow *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;
    1396113813    _object->exp_tag = psStringCopy(exp_tag);
    1396213814    _object->p3_version = p3_version;
    13963     _object->class_id = psStringCopy(class_id);
    1396413815
    1396513816    return _object;
    1396613817}
    1396713818
    13968 static void p4InputImfileRowFree(p4InputImfileRow *object)
     13819static void p4aInputExpRowFree(p4aInputExpRow *object)
    1396913820{
    1397013821    psFree(object->exp_tag);
    13971     psFree(object->class_id);
    13972 }
    13973 
    13974 bool p4InputImfileCreateTable(psDB *dbh)
     13822}
     13823
     13824bool p4aInputExpCreateTable(psDB *dbh)
    1397513825{
    1397613826    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");
    1397913829        psFree(md);
    1398013830        return false;
     
    1399013840        return false;
    1399113841    }
    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);
    1399913844
    1400013845    psFree(md);
     
    1400313848}
    1400413849
    14005 bool p4InputImfileDropTable(psDB *dbh)
    14006 {
    14007     return psDBDropTable(dbh, P4INPUTIMFILE_TABLE_NAME);
    14008 }
    14009 
    14010 bool p4InputImfileInsert(psDB * dbh, psS32 p4_id, const char *exp_tag, psS32 p3_version, const char *class_id)
     13850bool p4aInputExpDropTable(psDB *dbh)
     13851{
     13852    return psDBDropTable(dbh, P4AINPUTEXP_TABLE_NAME);
     13853}
     13854
     13855bool p4aInputExpInsert(psDB * dbh, psS32 p4a_id, const char *exp_tag, psS32 p3_version)
    1401113856{
    1401213857    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");
    1401513860        psFree(md);
    1401613861        return false;
     
    1402613871        return false;
    1402713872    }
    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);
    1403513875    psFree(md);
    1403613876
     
    1403813878}
    1403913879
    14040 long long p4InputImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
     13880long long p4aInputExpDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
    1404113881{
    1404213882    long long       deleted = 0;
    1404313883
    14044     long long count = psDBDeleteRows(dbh, P4INPUTIMFILE_TABLE_NAME, where, limit);
     13884    long long count = psDBDeleteRows(dbh, P4AINPUTEXP_TABLE_NAME, where, limit);
    1404513885    if (count < 0) {
    14046         psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4InputImfile");
     13886        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aInputExp");
    1404713887        return count;
    1404813888
     
    1405213892    return deleted;
    1405313893}
    14054 bool p4InputImfileInsertObject(psDB *dbh, p4InputImfileRow *object)
    14055 {
    14056     return p4InputImfileInsert(dbh, object->p4_id, object->exp_tag, object->p3_version, object->class_id);
    14057 }
    14058 
    14059 bool p4InputImfileInsertObjects(psDB *dbh, psArray *objects)
     13894bool p4aInputExpInsertObject(psDB *dbh, p4aInputExpRow *object)
     13895{
     13896    return p4aInputExpInsert(dbh, object->p4a_id, object->exp_tag, object->p3_version);
     13897}
     13898
     13899bool p4aInputExpInsertObjects(psDB *dbh, psArray *objects)
    1406013900{
    1406113901    for (long i = 0; i < psArrayLength(objects); i++) {
    14062         if (!p4InputImfileInsertObject(dbh, objects->data[i])) {
     13902        if (!p4aInputExpInsertObject(dbh, objects->data[i])) {
    1406313903            return false;
    1406413904        }
     
    1406813908}
    1406913909
    14070 bool p4InputImfileInsertFits(psDB *dbh, const psFits *fits)
     13910bool p4aInputExpInsertFits(psDB *dbh, const psFits *fits)
    1407113911{
    1407213912    psArray         *rowSet;
    1407313913
    14074     // move to (the first?) extension named  P4INPUTIMFILE_TABLE_NAME
    14075     if (!psFitsMoveExtName(fits, P4INPUTIMFILE_TABLE_NAME)) {
    14076         psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4INPUTIMFILE_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);
    1407713917        return false;
    1407813918    }
     
    1409213932    }
    1409313933
    14094     if (!psDBInsertRows(dbh, P4INPUTIMFILE_TABLE_NAME, rowSet)) {
     13934    if (!psDBInsertRows(dbh, P4AINPUTEXP_TABLE_NAME, rowSet)) {
    1409513935        psError(PS_ERR_UNKNOWN, false, "databse insert failed");
    1409613936        psFree(rowSet);
     
    1410313943}
    1410413944
    14105 bool p4InputImfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
     13945bool p4aInputExpSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
    1410613946{
    1410713947    psArray         *rowSet;
    1410813948
    14109     rowSet = psDBSelectRows(dbh, P4INPUTIMFILE_TABLE_NAME, where, limit);
     13949    rowSet = psDBSelectRows(dbh, P4AINPUTEXP_TABLE_NAME, where, limit);
    1411013950    if (!rowSet) {
    1411113951        return false;
     
    1411313953
    1411413954    // output to fits
    14115     if (!psFitsWriteTable(fits, NULL, rowSet, P4INPUTIMFILE_TABLE_NAME)) {
     13955    if (!psFitsWriteTable(fits, NULL, rowSet, P4AINPUTEXP_TABLE_NAME)) {
    1411613956        psError(PS_ERR_UNKNOWN, false, "FITS table write failed");
    1411713957        psFree(rowSet);
     
    1412413964}
    1412513965
    14126 psMetadata *p4InputImfileMetadataFromObject(const p4InputImfileRow *object)
     13966psMetadata *p4aInputExpMetadataFromObject(const p4aInputExpRow *object)
    1412713967{
    1412813968    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");
    1413113971        psFree(md);
    1413213972        return false;
     
    1414213982        return false;
    1414313983    }
    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     }
    1414913984
    1415013985
     
    1415213987}
    1415313988
    14154 p4InputImfileRow *p4InputImfileObjectFromMetadata(psMetadata *md)
     13989p4aInputExpRow *p4aInputExpObjectFromMetadata(psMetadata *md)
    1415513990{
    1415613991
    1415713992bool 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");
    1416113996        return false;
    1416213997    }
     
    1417114006        return false;
    1417214007    }
    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}
     14011psArray *p4aInputExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
    1418214012{
    1418314013    psArray         *rowSet;
     
    1418514015    psU64           i;
    1418614016
    14187     rowSet = psDBSelectRows(dbh, P4INPUTIMFILE_TABLE_NAME, where, limit);
     14017    rowSet = psDBSelectRows(dbh, P4AINPUTEXP_TABLE_NAME, where, limit);
    1418814018    if (!rowSet) {
    1418914019        return NULL;
     
    1419514025
    1419614026    for (i = 0; i < rowSet->n; i++) {
    14197         p4InputImfileRow *object = p4InputImfileObjectFromMetadata(rowSet->data[i]);
     14027        p4aInputExpRow *object = p4aInputExpObjectFromMetadata(rowSet->data[i]);
    1419814028        psArrayAdd(returnSet, 0, object);
    1419914029        psFree(object);
     
    1420414034    return returnSet;
    1420514035}
    14206 bool p4InputImfileDeleteObject(psDB *dbh, const p4InputImfileRow *object)
    14207 {
    14208     psMetadata *where = p4InputImfileMetadataFromObject(object);
    14209     long long count = psDBDeleteRows(dbh, P4INPUTIMFILE_TABLE_NAME, where, 0);
    14210     psFree(where)
     14036bool 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);
    1421114041    if (count < 0) {
    14212         psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4InputImfile");
     14042        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aInputExp");
    1421314043        return false;
    1421414044    }
     
    1421614046        // XXX should this be a psAbort() instead?  It is possible that
    1421714047        // having an object match multiple rows was by design.
    14218         psError(PS_ERR_UNKNOWN, true, "p4InputImfileRow object matched more then one row.  Check your database schema");
    14219         return false;
    14220     }
    14221 
    14222     return true;
    14223 }
    14224 long long p4InputImfileDeleteRowObjects(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}
     14054long long p4aInputExpDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)
    1422514055{
    1422614056    long long       deleted = 0;
    1422714057
    1422814058    for (long long i = 0; i < objects->n; i++) {
    14229         p4InputImfileRow *object = objects->data[i];
    14230         psMetadata *where = p4InputImfileMetadataFromObject(object);
    14231         long long count = psDBDeleteRows(dbh, P4INPUTIMFILE_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);
    1423314063        if (count < 0) {
    14234             psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4InputImfile");
     14064            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aInputExp");
    1423514065            return count;
    1423614066        }
     
    1424114071    return deleted;
    1424214072}
    14243 bool p4InputImfilePrintObjects(FILE *stream, psArray *objects, bool mdcf)
     14073bool p4aInputExpPrintObjects(FILE *stream, psArray *objects, bool mdcf)
    1424414074{
    1424514075    PS_ASSERT_PTR_NON_NULL(objects, false);
     
    1424714077    psMetadata *output = psMetadataAlloc();
    1424814078    for (long i = 0; i < psArrayLength(objects); i++) {
    14249         psMetadata *md = p4InputImfileMetadataFromObject(objects->data[i]);
     14079        psMetadata *md = p4aInputExpMetadataFromObject(objects->data[i]);
    1425014080        if (!psMetadataAddMetadata(
    1425114081            output,
    1425214082            PS_LIST_TAIL,
    14253             P4INPUTIMFILE_TABLE_NAME,
     14083            P4AINPUTEXP_TABLE_NAME,
    1425414084            PS_META_DUPLICATE_OK,
    1425514085            NULL,
     
    1427214102    return true;
    1427314103}
    14274 bool p4InputImfilePrintObject(FILE *stream, p4InputImfileRow *object, bool mdcf)
     14104bool p4aInputExpPrintObject(FILE *stream, p4aInputExpRow *object, bool mdcf)
    1427514105{
    1427614106    PS_ASSERT_PTR_NON_NULL(object, false);
    1427714107
    14278     psMetadata *md = p4InputImfileMetadataFromObject(object);
     14108    psMetadata *md = p4aInputExpMetadataFromObject(object);
    1427914109
    1428014110    if (!ippdbPrintMetadataRaw(stream, md, mdcf)) {
     
    1428714117    return true;
    1428814118}
    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;
     14119static void p4aScfileRowFree(p4aScfileRow *object);
     14120
     14121p4aScfileRow *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);
    1429914131    _object->exp_tag = psStringCopy(exp_tag);
    1430014132    _object->p3_version = p3_version;
    14301     _object->class_id = psStringCopy(class_id);
    1430214133    _object->uri = psStringCopy(uri);
    14303     _object->b1_uri = psStringCopy(b1_uri);
    14304     _object->b2_uri = psStringCopy(b2_uri);
     14134    _object->bg = bg;
     14135    _object->bg_mean_stdev = bg_mean_stdev;
    1430514136
    1430614137    return _object;
    1430714138}
    1430814139
    14309 static void p4WarpedImfileRowFree(p4WarpedImfileRow *object)
    14310 {
     14140static void p4aScfileRowFree(p4aScfileRow *object)
     14141{
     14142    psFree(object->skycell_id);
     14143    psFree(object->tess_id);
    1431114144    psFree(object->exp_tag);
    14312     psFree(object->class_id);
    1431314145    psFree(object->uri);
    14314     psFree(object->b1_uri);
    14315     psFree(object->b2_uri);
    14316 }
    14317 
    14318 bool p4WarpedImfileCreateTable(psDB *dbh)
     14146}
     14147
     14148bool p4aScfileCreateTable(psDB *dbh)
    1431914149{
    1432014150    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");
    1432314163        psFree(md);
    1432414164        return false;
     
    1433414174        return false;
    1433514175    }
    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     }
    1434114176    if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, "255")) {
    1434214177        psError(PS_ERR_UNKNOWN, false, "failed to add item uri");
     
    1434414179        return false;
    1434514180    }
    14346     if (!psMetadataAdd(md, PS_LIST_TAIL, "b1_uri", PS_DATA_STRING, NULL, "255")) {
    14347         psError(PS_ERR_UNKNOWN, false, "failed to add item b1_uri");
    14348         psFree(md);
    14349         return false;
    14350     }
    14351     if (!psMetadataAdd(md, PS_LIST_TAIL, "b2_uri", PS_DATA_STRING, NULL, "255")) {
    14352         psError(PS_ERR_UNKNOWN, false, "failed to add item b2_uri");
    14353         psFree(md);
    14354         return false;
    14355     }
    14356 
    14357     bool status = psDBCreateTable(dbh, P4WARPEDIMFILE_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);
    1435814193
    1435914194    psFree(md);
     
    1436214197}
    1436314198
    14364 bool p4WarpedImfileDropTable(psDB *dbh)
    14365 {
    14366     return psDBDropTable(dbh, P4WARPEDIMFILE_TABLE_NAME);
    14367 }
    14368 
    14369 bool p4WarpedImfileInsert(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)
     14199bool p4aScfileDropTable(psDB *dbh)
     14200{
     14201    return psDBDropTable(dbh, P4ASCFILE_TABLE_NAME);
     14202}
     14203
     14204bool 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)
    1437014205{
    1437114206    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");
    1437414219        psFree(md);
    1437514220        return false;
     
    1438514230        return false;
    1438614231    }
    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     }
    1439214232    if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, uri)) {
    1439314233        psError(PS_ERR_UNKNOWN, false, "failed to add item uri");
     
    1439514235        return false;
    1439614236    }
    14397     if (!psMetadataAdd(md, PS_LIST_TAIL, "b1_uri", PS_DATA_STRING, NULL, b1_uri)) {
    14398         psError(PS_ERR_UNKNOWN, false, "failed to add item b1_uri");
    14399         psFree(md);
    14400         return false;
    14401     }
    14402     if (!psMetadataAdd(md, PS_LIST_TAIL, "b2_uri", PS_DATA_STRING, NULL, b2_uri)) {
    14403         psError(PS_ERR_UNKNOWN, false, "failed to add item b2_uri");
    14404         psFree(md);
    14405         return false;
    14406     }
    14407 
    14408     bool status = psDBInsertOneRow(dbh, P4WARPEDIMFILE_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);
    1440914249    psFree(md);
    1441014250
     
    1441214252}
    1441314253
    14414 long long p4WarpedImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
     14254long long p4aScfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
    1441514255{
    1441614256    long long       deleted = 0;
    1441714257
    14418     long long count = psDBDeleteRows(dbh, P4WARPEDIMFILE_TABLE_NAME, where, limit);
     14258    long long count = psDBDeleteRows(dbh, P4ASCFILE_TABLE_NAME, where, limit);
    1441914259    if (count < 0) {
    14420         psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4WarpedImfile");
     14260        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aScfile");
    1442114261        return count;
    1442214262
     
    1442614266    return deleted;
    1442714267}
    14428 bool p4WarpedImfileInsertObject(psDB *dbh, p4WarpedImfileRow *object)
    14429 {
    14430     return p4WarpedImfileInsert(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 p4WarpedImfileInsertObjects(psDB *dbh, psArray *objects)
     14268bool 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
     14273bool p4aScfileInsertObjects(psDB *dbh, psArray *objects)
    1443414274{
    1443514275    for (long i = 0; i < psArrayLength(objects); i++) {
    14436         if (!p4WarpedImfileInsertObject(dbh, objects->data[i])) {
     14276        if (!p4aScfileInsertObject(dbh, objects->data[i])) {
    1443714277            return false;
    1443814278        }
     
    1444214282}
    1444314283
    14444 bool p4WarpedImfileInsertFits(psDB *dbh, const psFits *fits)
     14284bool p4aScfileInsertFits(psDB *dbh, const psFits *fits)
    1444514285{
    1444614286    psArray         *rowSet;
    1444714287
    14448     // move to (the first?) extension named  P4WARPEDIMFILE_TABLE_NAME
    14449     if (!psFitsMoveExtName(fits, P4WARPEDIMFILE_TABLE_NAME)) {
    14450         psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4WARPEDIMFILE_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);
    1445114291        return false;
    1445214292    }
     
    1446614306    }
    1446714307
    14468     if (!psDBInsertRows(dbh, P4WARPEDIMFILE_TABLE_NAME, rowSet)) {
     14308    if (!psDBInsertRows(dbh, P4ASCFILE_TABLE_NAME, rowSet)) {
    1446914309        psError(PS_ERR_UNKNOWN, false, "databse insert failed");
    1447014310        psFree(rowSet);
     
    1447714317}
    1447814318
    14479 bool p4WarpedImfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
     14319bool p4aScfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
    1448014320{
    1448114321    psArray         *rowSet;
    1448214322
    14483     rowSet = psDBSelectRows(dbh, P4WARPEDIMFILE_TABLE_NAME, where, limit);
     14323    rowSet = psDBSelectRows(dbh, P4ASCFILE_TABLE_NAME, where, limit);
    1448414324    if (!rowSet) {
    1448514325        return false;
     
    1448714327
    1448814328    // output to fits
    14489     if (!psFitsWriteTable(fits, NULL, rowSet, P4WARPEDIMFILE_TABLE_NAME)) {
     14329    if (!psFitsWriteTable(fits, NULL, rowSet, P4ASCFILE_TABLE_NAME)) {
    1449014330        psError(PS_ERR_UNKNOWN, false, "FITS table write failed");
    1449114331        psFree(rowSet);
     
    1449814338}
    1449914339
    14500 psMetadata *p4WarpedImfileMetadataFromObject(const p4WarpedImfileRow *object)
     14340psMetadata *p4aScfileMetadataFromObject(const p4aScfileRow *object)
    1450114341{
    1450214342    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");
    1450514355        psFree(md);
    1450614356        return false;
     
    1451614366        return false;
    1451714367    }
    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     }
    1452314368    if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, object->uri)) {
    1452414369        psError(PS_ERR_UNKNOWN, false, "failed to add item uri");
     
    1452614371        return false;
    1452714372    }
    14528     if (!psMetadataAdd(md, PS_LIST_TAIL, "b1_uri", PS_DATA_STRING, NULL, object->b1_uri)) {
    14529         psError(PS_ERR_UNKNOWN, false, "failed to add item b1_uri");
    14530         psFree(md);
    14531         return false;
    14532     }
    14533     if (!psMetadataAdd(md, PS_LIST_TAIL, "b2_uri", PS_DATA_STRING, NULL, object->b2_uri)) {
    14534         psError(PS_ERR_UNKNOWN, false, "failed to add item b2_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");
    1453514380        psFree(md);
    1453614381        return false;
     
    1454114386}
    1454214387
    14543 p4WarpedImfileRow *p4WarpedImfileObjectFromMetadata(psMetadata *md)
     14388p4aScfileRow *p4aScfileObjectFromMetadata(psMetadata *md)
    1454414389{
    1454514390
    1454614391bool 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");
    1455014405        return false;
    1455114406    }
     
    1456014415        return false;
    1456114416    }
    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     }
    1456714417    char* uri = psMetadataLookupPtr(&status, md, "uri");
    1456814418    if (!status) {
     
    1457014420        return false;
    1457114421    }
    14572     char* b1_uri = psMetadataLookupPtr(&status, md, "b1_uri");
    14573     if (!status) {
    14574         psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item b1_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 b2_uri");
    14580         return false;
    14581     }
    14582 
    14583     return p4WarpedImfileRowAlloc(p4_id, exp_tag, p3_version, class_id, uri, b1_uri, b2_uri);
    14584 }
    14585 psArray *p4WarpedImfileSelectRowObjects(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}
     14435psArray *p4aScfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
    1458614436{
    1458714437    psArray         *rowSet;
     
    1458914439    psU64           i;
    1459014440
    14591     rowSet = psDBSelectRows(dbh, P4WARPEDIMFILE_TABLE_NAME, where, limit);
     14441    rowSet = psDBSelectRows(dbh, P4ASCFILE_TABLE_NAME, where, limit);
    1459214442    if (!rowSet) {
    1459314443        return NULL;
     
    1459914449
    1460014450    for (i = 0; i < rowSet->n; i++) {
    14601         p4WarpedImfileRow *object = p4WarpedImfileObjectFromMetadata(rowSet->data[i]);
     14451        p4aScfileRow *object = p4aScfileObjectFromMetadata(rowSet->data[i]);
    1460214452        psArrayAdd(returnSet, 0, object);
    1460314453        psFree(object);
     
    1460814458    return returnSet;
    1460914459}
    14610 bool p4WarpedImfileDeleteObject(psDB *dbh, const p4WarpedImfileRow *object)
    14611 {
    14612     psMetadata *where = p4WarpedImfileMetadataFromObject(object);
    14613     long long count = psDBDeleteRows(dbh, P4WARPEDIMFILE_TABLE_NAME, where, 0);
    14614     psFree(where)
     14460bool 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);
    1461514465    if (count < 0) {
    14616         psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4WarpedImfile");
     14466        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aScfile");
    1461714467        return false;
    1461814468    }
     
    1462014470        // XXX should this be a psAbort() instead?  It is possible that
    1462114471        // having an object match multiple rows was by design.
    14622         psError(PS_ERR_UNKNOWN, true, "p4WarpedImfileRow object matched more then one row.  Check your database schema");
    14623         return false;
    14624     }
    14625 
    14626     return true;
    14627 }
    14628 long long p4WarpedImfileDeleteRowObjects(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}
     14478long long p4aScfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)
    1462914479{
    1463014480    long long       deleted = 0;
    1463114481
    1463214482    for (long long i = 0; i < objects->n; i++) {
    14633         p4WarpedImfileRow *object = objects->data[i];
    14634         psMetadata *where = p4WarpedImfileMetadataFromObject(object);
    14635         long long count = psDBDeleteRows(dbh, P4WARPEDIMFILE_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);
    1463714487        if (count < 0) {
    14638             psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4WarpedImfile");
     14488            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4aScfile");
    1463914489            return count;
    1464014490        }
     
    1464514495    return deleted;
    1464614496}
    14647 bool p4WarpedImfilePrintObjects(FILE *stream, psArray *objects, bool mdcf)
     14497bool p4aScfilePrintObjects(FILE *stream, psArray *objects, bool mdcf)
    1464814498{
    1464914499    PS_ASSERT_PTR_NON_NULL(objects, false);
     
    1465114501    psMetadata *output = psMetadataAlloc();
    1465214502    for (long i = 0; i < psArrayLength(objects); i++) {
    14653         psMetadata *md = p4WarpedImfileMetadataFromObject(objects->data[i]);
     14503        psMetadata *md = p4aScfileMetadataFromObject(objects->data[i]);
    1465414504        if (!psMetadataAddMetadata(
    1465514505            output,
    1465614506            PS_LIST_TAIL,
    14657             P4WARPEDIMFILE_TABLE_NAME,
     14507            P4ASCFILE_TABLE_NAME,
    1465814508            PS_META_DUPLICATE_OK,
    1465914509            NULL,
     
    1467614526    return true;
    1467714527}
    14678 bool p4WarpedImfilePrintObject(FILE *stream, p4WarpedImfileRow *object, bool mdcf)
     14528bool p4aScfilePrintObject(FILE *stream, p4aScfileRow *object, bool mdcf)
    1467914529{
    1468014530    PS_ASSERT_PTR_NON_NULL(object, false);
    1468114531
    14682     psMetadata *md = p4WarpedImfileMetadataFromObject(object);
     14532    psMetadata *md = p4aScfileMetadataFromObject(object);
    1468314533
    1468414534    if (!ippdbPrintMetadataRaw(stream, md, mdcf)) {
     
    1469114541    return true;
    1469214542}
    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);
     14543static void p4bRunRowFree(p4bRunRow *object);
     14544
     14545p4bRunRow *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;
    1470714556
    1470814557    return _object;
    1470914558}
    1471014559
    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)
     14560static void p4bRunRowFree(p4bRunRow *object)
     14561{
     14562    psFree(object->state);
     14563    psFree(object->workdir);
     14564}
     14565
     14566bool p4bRunCreateTable(psDB *dbh)
    1472014567{
    1472114568    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);
    1474914591
    1475014592    psFree(md);
     
    1475314595}
    1475414596
    14755 bool p4StackedImfileDropTable(psDB *dbh)
    14756 {
    14757     return psDBDropTable(dbh, P4STACKEDIMFILE_TABLE_NAME);
    14758 }
    14759 
    14760 bool p4StackedImfileInsert(psDB * dbh, psS32 p4_id, const char *class_id, const char *uri, const char *b1_uri, const char *b2_uri)
     14597bool p4bRunDropTable(psDB *dbh)
     14598{
     14599    return psDBDropTable(dbh, P4BRUN_TABLE_NAME);
     14600}
     14601
     14602bool p4bRunInsert(psDB * dbh, psS32 p4b_id, const char *state, const char *workdir, bool magic)
    1476114603{
    1476214604    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);
    1479014627    psFree(md);
    1479114628
     
    1479314630}
    1479414631
    14795 long long p4StackedImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
     14632long long p4bRunDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
    1479614633{
    1479714634    long long       deleted = 0;
    1479814635
    14799     long long count = psDBDeleteRows(dbh, P4STACKEDIMFILE_TABLE_NAME, where, limit);
     14636    long long count = psDBDeleteRows(dbh, P4BRUN_TABLE_NAME, where, limit);
    1480014637    if (count < 0) {
    14801         psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4StackedImfile");
     14638        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bRun");
    1480214639        return count;
    1480314640
     
    1480714644    return deleted;
    1480814645}
    14809 bool p4StackedImfileInsertObject(psDB *dbh, p4StackedImfileRow *object)
    14810 {
    14811     return p4StackedImfileInsert(dbh, object->p4_id, object->class_id, object->uri, object->b1_uri, object->b2_uri);
    14812 }
    14813 
    14814 bool p4StackedImfileInsertObjects(psDB *dbh, psArray *objects)
     14646bool p4bRunInsertObject(psDB *dbh, p4bRunRow *object)
     14647{
     14648    return p4bRunInsert(dbh, object->p4b_id, object->state, object->workdir, object->magic);
     14649}
     14650
     14651bool p4bRunInsertObjects(psDB *dbh, psArray *objects)
    1481514652{
    1481614653    for (long i = 0; i < psArrayLength(objects); i++) {
    14817         if (!p4StackedImfileInsertObject(dbh, objects->data[i])) {
     14654        if (!p4bRunInsertObject(dbh, objects->data[i])) {
    1481814655            return false;
    1481914656        }
     
    1482314660}
    1482414661
    14825 bool p4StackedImfileInsertFits(psDB *dbh, const psFits *fits)
     14662bool p4bRunInsertFits(psDB *dbh, const psFits *fits)
    1482614663{
    1482714664    psArray         *rowSet;
    1482814665
    14829     // move to (the first?) extension named  P4STACKEDIMFILE_TABLE_NAME
    14830     if (!psFitsMoveExtName(fits, P4STACKEDIMFILE_TABLE_NAME)) {
    14831         psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4STACKEDIMFILE_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);
    1483214669        return false;
    1483314670    }
     
    1484714684    }
    1484814685
    14849     if (!psDBInsertRows(dbh, P4STACKEDIMFILE_TABLE_NAME, rowSet)) {
     14686    if (!psDBInsertRows(dbh, P4BRUN_TABLE_NAME, rowSet)) {
    1485014687        psError(PS_ERR_UNKNOWN, false, "databse insert failed");
    1485114688        psFree(rowSet);
     
    1485814695}
    1485914696
    14860 bool p4StackedImfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
     14697bool p4bRunSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
    1486114698{
    1486214699    psArray         *rowSet;
    1486314700
    14864     rowSet = psDBSelectRows(dbh, P4STACKEDIMFILE_TABLE_NAME, where, limit);
     14701    rowSet = psDBSelectRows(dbh, P4BRUN_TABLE_NAME, where, limit);
    1486514702    if (!rowSet) {
    1486614703        return false;
     
    1486814705
    1486914706    // output to fits
    14870     if (!psFitsWriteTable(fits, NULL, rowSet, P4STACKEDIMFILE_TABLE_NAME)) {
     14707    if (!psFitsWriteTable(fits, NULL, rowSet, P4BRUN_TABLE_NAME)) {
    1487114708        psError(PS_ERR_UNKNOWN, false, "FITS table write failed");
    1487214709        psFree(rowSet);
     
    1487914716}
    1488014717
    14881 psMetadata *p4StackedImfileMetadataFromObject(const p4StackedImfileRow *object)
     14718psMetadata *p4bRunMetadataFromObject(const p4bRunRow *object)
    1488214719{
    1488314720    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");
    1490614738        psFree(md);
    1490714739        return false;
     
    1491214744}
    1491314745
    14914 p4StackedImfileRow *p4StackedImfileObjectFromMetadata(psMetadata *md)
     14746p4bRunRow *p4bRunObjectFromMetadata(psMetadata *md)
    1491514747{
    1491614748
    1491714749bool 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}
     14773psArray *p4bRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
    1494714774{
    1494814775    psArray         *rowSet;
     
    1495014777    psU64           i;
    1495114778
    14952     rowSet = psDBSelectRows(dbh, P4STACKEDIMFILE_TABLE_NAME, where, limit);
     14779    rowSet = psDBSelectRows(dbh, P4BRUN_TABLE_NAME, where, limit);
    1495314780    if (!rowSet) {
    1495414781        return NULL;
     
    1496014787
    1496114788    for (i = 0; i < rowSet->n; i++) {
    14962         p4StackedImfileRow *object = p4StackedImfileObjectFromMetadata(rowSet->data[i]);
     14789        p4bRunRow *object = p4bRunObjectFromMetadata(rowSet->data[i]);
    1496314790        psArrayAdd(returnSet, 0, object);
    1496414791        psFree(object);
     
    1496914796    return returnSet;
    1497014797}
    14971 bool p4StackedImfileDeleteObject(psDB *dbh, const p4StackedImfileRow *object)
    14972 {
    14973     psMetadata *where = p4StackedImfileMetadataFromObject(object);
    14974     long long count = psDBDeleteRows(dbh, P4STACKEDIMFILE_TABLE_NAME, where, 0);
    14975     psFree(where)
     14798bool 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);
    1497614803    if (count < 0) {
    14977         psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4StackedImfile");
     14804        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bRun");
    1497814805        return false;
    1497914806    }
     
    1498114808        // XXX should this be a psAbort() instead?  It is possible that
    1498214809        // having an object match multiple rows was by design.
    14983         psError(PS_ERR_UNKNOWN, true, "p4StackedImfileRow object matched more then one row.  Check your database schema");
    14984         return false;
    14985     }
    14986 
    14987     return true;
    14988 }
    14989 long long p4StackedImfileDeleteRowObjects(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}
     14816long long p4bRunDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)
    1499014817{
    1499114818    long long       deleted = 0;
    1499214819
    1499314820    for (long long i = 0; i < objects->n; i++) {
    14994         p4StackedImfileRow *object = objects->data[i];
    14995         psMetadata *where = p4StackedImfileMetadataFromObject(object);
    14996         long long count = psDBDeleteRows(dbh, P4STACKEDIMFILE_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);
    1499814825        if (count < 0) {
    14999             psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4StackedImfile");
     14826            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bRun");
    1500014827            return count;
    1500114828        }
     
    1500614833    return deleted;
    1500714834}
    15008 bool p4StackedImfilePrintObjects(FILE *stream, psArray *objects, bool mdcf)
     14835bool p4bRunPrintObjects(FILE *stream, psArray *objects, bool mdcf)
    1500914836{
    1501014837    PS_ASSERT_PTR_NON_NULL(objects, false);
     
    1501214839    psMetadata *output = psMetadataAlloc();
    1501314840    for (long i = 0; i < psArrayLength(objects); i++) {
    15014         psMetadata *md = p4StackedImfileMetadataFromObject(objects->data[i]);
     14841        psMetadata *md = p4bRunMetadataFromObject(objects->data[i]);
    1501514842        if (!psMetadataAddMetadata(
    1501614843            output,
    1501714844            PS_LIST_TAIL,
    15018             P4STACKEDIMFILE_TABLE_NAME,
     14845            P4BRUN_TABLE_NAME,
    1501914846            PS_META_DUPLICATE_OK,
    1502014847            NULL,
     
    1503714864    return true;
    1503814865}
    15039 bool p4StackedImfilePrintObject(FILE *stream, p4StackedImfileRow *object, bool mdcf)
     14866bool p4bRunPrintObject(FILE *stream, p4bRunRow *object, bool mdcf)
    1504014867{
    1504114868    PS_ASSERT_PTR_NON_NULL(object, false);
    1504214869
    15043     psMetadata *md = p4StackedImfileMetadataFromObject(object);
     14870    psMetadata *md = p4bRunMetadataFromObject(object);
    1504414871
    1504514872    if (!ippdbPrintMetadataRaw(stream, md, mdcf)) {
     
    1505214879    return true;
    1505314880}
    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;
     14881static void p4bInputScfileRowFree(p4bInputScfileRow *object);
     14882
     14883p4bInputScfileRow *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);
    1506414893    _object->exp_tag = psStringCopy(exp_tag);
    1506514894    _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);
    1507014896
    1507114897    return _object;
    1507214898}
    1507314899
    15074 static void p4DiffImfileRowFree(p4DiffImfileRow *object)
    15075 {
     14900static void p4bInputScfileRowFree(p4bInputScfileRow *object)
     14901{
     14902    psFree(object->skycell_id);
     14903    psFree(object->tess_id);
    1507614904    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
     14908bool p4bInputScfileCreateTable(psDB *dbh)
    1508414909{
    1508514910    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");
    1508814923        psFree(md);
    1508914924        return false;
     
    1509914934        return false;
    1510014935    }
    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);
    1512314943
    1512414944    psFree(md);
     
    1512714947}
    1512814948
    15129 bool p4DiffImfileDropTable(psDB *dbh)
    15130 {
    15131     return psDBDropTable(dbh, P4DIFFIMFILE_TABLE_NAME);
    15132 }
    15133 
    15134 bool p4DiffImfileInsert(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)
     14949bool p4bInputScfileDropTable(psDB *dbh)
     14950{
     14951    return psDBDropTable(dbh, P4BINPUTSCFILE_TABLE_NAME);
     14952}
     14953
     14954bool p4bInputScfileInsert(psDB * dbh, psS32 p4b_id, const char *skycell_id, const char *tess_id, const char *exp_tag, psS32 p3_version, const char *kind)
    1513514955{
    1513614956    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");
    1513914969        psFree(md);
    1514014970        return false;
     
    1515014980        return false;
    1515114981    }
    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);
    1517414989    psFree(md);
    1517514990
     
    1517714992}
    1517814993
    15179 long long p4DiffImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
     14994long long p4bInputScfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
    1518014995{
    1518114996    long long       deleted = 0;
    1518214997
    15183     long long count = psDBDeleteRows(dbh, P4DIFFIMFILE_TABLE_NAME, where, limit);
     14998    long long count = psDBDeleteRows(dbh, P4BINPUTSCFILE_TABLE_NAME, where, limit);
    1518414999    if (count < 0) {
    15185         psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4DiffImfile");
     15000        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bInputScfile");
    1518615001        return count;
    1518715002
     
    1519115006    return deleted;
    1519215007}
    15193 bool p4DiffImfileInsertObject(psDB *dbh, p4DiffImfileRow *object)
    15194 {
    15195     return p4DiffImfileInsert(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 p4DiffImfileInsertObjects(psDB *dbh, psArray *objects)
     15008bool 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
     15013bool p4bInputScfileInsertObjects(psDB *dbh, psArray *objects)
    1519915014{
    1520015015    for (long i = 0; i < psArrayLength(objects); i++) {
    15201         if (!p4DiffImfileInsertObject(dbh, objects->data[i])) {
     15016        if (!p4bInputScfileInsertObject(dbh, objects->data[i])) {
    1520215017            return false;
    1520315018        }
     
    1520715022}
    1520815023
    15209 bool p4DiffImfileInsertFits(psDB *dbh, const psFits *fits)
     15024bool p4bInputScfileInsertFits(psDB *dbh, const psFits *fits)
    1521015025{
    1521115026    psArray         *rowSet;
    1521215027
    15213     // move to (the first?) extension named  P4DIFFIMFILE_TABLE_NAME
    15214     if (!psFitsMoveExtName(fits, P4DIFFIMFILE_TABLE_NAME)) {
    15215         psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4DIFFIMFILE_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);
    1521615031        return false;
    1521715032    }
     
    1523115046    }
    1523215047
    15233     if (!psDBInsertRows(dbh, P4DIFFIMFILE_TABLE_NAME, rowSet)) {
     15048    if (!psDBInsertRows(dbh, P4BINPUTSCFILE_TABLE_NAME, rowSet)) {
    1523415049        psError(PS_ERR_UNKNOWN, false, "databse insert failed");
    1523515050        psFree(rowSet);
     
    1524215057}
    1524315058
    15244 bool p4DiffImfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
     15059bool p4bInputScfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
    1524515060{
    1524615061    psArray         *rowSet;
    1524715062
    15248     rowSet = psDBSelectRows(dbh, P4DIFFIMFILE_TABLE_NAME, where, limit);
     15063    rowSet = psDBSelectRows(dbh, P4BINPUTSCFILE_TABLE_NAME, where, limit);
    1524915064    if (!rowSet) {
    1525015065        return false;
     
    1525215067
    1525315068    // output to fits
    15254     if (!psFitsWriteTable(fits, NULL, rowSet, P4DIFFIMFILE_TABLE_NAME)) {
     15069    if (!psFitsWriteTable(fits, NULL, rowSet, P4BINPUTSCFILE_TABLE_NAME)) {
    1525515070        psError(PS_ERR_UNKNOWN, false, "FITS table write failed");
    1525615071        psFree(rowSet);
     
    1526315078}
    1526415079
    15265 psMetadata *p4DiffImfileMetadataFromObject(const p4DiffImfileRow *object)
     15080psMetadata *p4bInputScfileMetadataFromObject(const p4bInputScfileRow *object)
    1526615081{
    1526715082    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");
    1527015095        psFree(md);
    1527115096        return false;
     
    1528115106        return false;
    1528215107    }
    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");
    1530015110        psFree(md);
    1530115111        return false;
     
    1530615116}
    1530715117
    15308 p4DiffImfileRow *p4DiffImfileObjectFromMetadata(psMetadata *md)
     15118p4bInputScfileRow *p4bInputScfileObjectFromMetadata(psMetadata *md)
    1530915119{
    1531015120
    1531115121bool 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");
    1531515135        return false;
    1531615136    }
     
    1532515145        return false;
    1532615146    }
    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}
     15155psArray *p4bInputScfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
    1535115156{
    1535215157    psArray         *rowSet;
     
    1535415159    psU64           i;
    1535515160
    15356     rowSet = psDBSelectRows(dbh, P4DIFFIMFILE_TABLE_NAME, where, limit);
     15161    rowSet = psDBSelectRows(dbh, P4BINPUTSCFILE_TABLE_NAME, where, limit);
    1535715162    if (!rowSet) {
    1535815163        return NULL;
     
    1536415169
    1536515170    for (i = 0; i < rowSet->n; i++) {
    15366         p4DiffImfileRow *object = p4DiffImfileObjectFromMetadata(rowSet->data[i]);
     15171        p4bInputScfileRow *object = p4bInputScfileObjectFromMetadata(rowSet->data[i]);
    1536715172        psArrayAdd(returnSet, 0, object);
    1536815173        psFree(object);
     
    1537315178    return returnSet;
    1537415179}
    15375 bool p4DiffImfileDeleteObject(psDB *dbh, const p4DiffImfileRow *object)
    15376 {
    15377     psMetadata *where = p4DiffImfileMetadataFromObject(object);
    15378     long long count = psDBDeleteRows(dbh, P4DIFFIMFILE_TABLE_NAME, where, 0);
    15379     psFree(where)
     15180bool 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);
    1538015185    if (count < 0) {
    15381         psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4DiffImfile");
     15186        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bInputScfile");
    1538215187        return false;
    1538315188    }
     
    1538515190        // XXX should this be a psAbort() instead?  It is possible that
    1538615191        // having an object match multiple rows was by design.
    15387         psError(PS_ERR_UNKNOWN, true, "p4DiffImfileRow object matched more then one row.  Check your database schema");
    15388         return false;
    15389     }
    15390 
    15391     return true;
    15392 }
    15393 long long p4DiffImfileDeleteRowObjects(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}
     15198long long p4bInputScfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)
    1539415199{
    1539515200    long long       deleted = 0;
    1539615201
    1539715202    for (long long i = 0; i < objects->n; i++) {
    15398         p4DiffImfileRow *object = objects->data[i];
    15399         psMetadata *where = p4DiffImfileMetadataFromObject(object);
    15400         long long count = psDBDeleteRows(dbh, P4DIFFIMFILE_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);
    1540215207        if (count < 0) {
    15403             psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4DiffImfile");
     15208            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bInputScfile");
    1540415209            return count;
    1540515210        }
     
    1541015215    return deleted;
    1541115216}
    15412 bool p4DiffImfilePrintObjects(FILE *stream, psArray *objects, bool mdcf)
     15217bool p4bInputScfilePrintObjects(FILE *stream, psArray *objects, bool mdcf)
    1541315218{
    1541415219    PS_ASSERT_PTR_NON_NULL(objects, false);
     
    1541615221    psMetadata *output = psMetadataAlloc();
    1541715222    for (long i = 0; i < psArrayLength(objects); i++) {
    15418         psMetadata *md = p4DiffImfileMetadataFromObject(objects->data[i]);
     15223        psMetadata *md = p4bInputScfileMetadataFromObject(objects->data[i]);
    1541915224        if (!psMetadataAddMetadata(
    1542015225            output,
    1542115226            PS_LIST_TAIL,
    15422             P4DIFFIMFILE_TABLE_NAME,
     15227            P4BINPUTSCFILE_TABLE_NAME,
    1542315228            PS_META_DUPLICATE_OK,
    1542415229            NULL,
     
    1544115246    return true;
    1544215247}
    15443 bool p4DiffImfilePrintObject(FILE *stream, p4DiffImfileRow *object, bool mdcf)
     15248bool p4bInputScfilePrintObject(FILE *stream, p4bInputScfileRow *object, bool mdcf)
    1544415249{
    1544515250    PS_ASSERT_PTR_NON_NULL(object, false);
    1544615251
    15447     psMetadata *md = p4DiffImfileMetadataFromObject(object);
     15252    psMetadata *md = p4bInputScfileMetadataFromObject(object);
    1544815253
    1544915254    if (!ippdbPrintMetadataRaw(stream, md, mdcf)) {
     
    1545615261    return true;
    1545715262}
    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;
     15263static void p4bDiffScfileRowFree(p4bDiffScfileRow *object);
     15264
     15265p4bDiffScfileRow *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);
    1546815275    _object->exp_tag = psStringCopy(exp_tag);
    1546915276    _object->p3_version = p3_version;
    15470     _object->class_id = psStringCopy(class_id);
    1547115277    _object->uri = psStringCopy(uri);
     15278    _object->bg = bg;
     15279    _object->bg_mean_stdev = bg_mean_stdev;
    1547215280
    1547315281    return _object;
    1547415282}
    1547515283
    15476 static void p4MagicMaskImfileRowFree(p4MagicMaskImfileRow *object)
    15477 {
     15284static void p4bDiffScfileRowFree(p4bDiffScfileRow *object)
     15285{
     15286    psFree(object->skycell_id);
     15287    psFree(object->tess_id);
    1547815288    psFree(object->exp_tag);
    15479     psFree(object->class_id);
    1548015289    psFree(object->uri);
    1548115290}
    1548215291
    15483 bool p4MagicMaskImfileCreateTable(psDB *dbh)
     15292bool p4bDiffScfileCreateTable(psDB *dbh)
    1548415293{
    1548515294    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");
    1548815307        psFree(md);
    1548915308        return false;
     
    1549915318        return false;
    1550015319    }
    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     }
    1550615320    if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, "255")) {
    1550715321        psError(PS_ERR_UNKNOWN, false, "failed to add item uri");
     
    1550915323        return false;
    1551015324    }
    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);
    1551315337
    1551415338    psFree(md);
     
    1551715341}
    1551815342
    15519 bool p4MagicMaskImfileDropTable(psDB *dbh)
    15520 {
    15521     return psDBDropTable(dbh, P4MAGICMASKIMFILE_TABLE_NAME);
    15522 }
    15523 
    15524 bool p4MagicMaskImfileInsert(psDB * dbh, psS32 p4_id, const char *exp_tag, psS32 p3_version, const char *class_id, const char *uri)
     15343bool p4bDiffScfileDropTable(psDB *dbh)
     15344{
     15345    return psDBDropTable(dbh, P4BDIFFSCFILE_TABLE_NAME);
     15346}
     15347
     15348bool 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)
    1552515349{
    1552615350    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");
    1552915363        psFree(md);
    1553015364        return false;
     
    1554015374        return false;
    1554115375    }
    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     }
    1554715376    if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, uri)) {
    1554815377        psError(PS_ERR_UNKNOWN, false, "failed to add item uri");
     
    1555015379        return false;
    1555115380    }
    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);
    1555415393    psFree(md);
    1555515394
     
    1555715396}
    1555815397
    15559 long long p4MagicMaskImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
     15398long long p4bDiffScfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
    1556015399{
    1556115400    long long       deleted = 0;
    1556215401
    15563     long long count = psDBDeleteRows(dbh, P4MAGICMASKIMFILE_TABLE_NAME, where, limit);
     15402    long long count = psDBDeleteRows(dbh, P4BDIFFSCFILE_TABLE_NAME, where, limit);
    1556415403    if (count < 0) {
    15565         psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4MagicMaskImfile");
     15404        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4bDiffScfile");
    1556615405        return count;
    1556715406
     
    1557115410    return deleted;
    1557215411}
    15573 bool p4MagicMaskImfileInsertObject(psDB *dbh, p4MagicMaskImfileRow *object)
    15574 {
    15575     return p4MagicMaskImfileInsert(dbh, object->p4_id, object->exp_tag, object->p3_version, object->class_id, object->uri);
    15576 }
    15577 
    15578 bool p4MagicMaskImfileInsertObjects(psDB *dbh, psArray *objects)
     15412bool 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
     15417bool p4bDiffScfileInsertObjects(psDB *dbh, psArray *objects)
    1557915418{
    1558015419    for (long i = 0; i < psArrayLength(objects); i++) {
    15581         if (!p4MagicMaskImfileInsertObject(dbh, objects->data[i])) {
     15420        if (!p4bDiffScfileInsertObject(dbh, objects->data[i])) {
    1558215421            return false;
    1558315422        }
     
    1558715426}
    1558815427
    15589 bool p4MagicMaskImfileInsertFits(psDB *dbh, const psFits *fits)
     15428bool p4bDiffScfileInsertFits(psDB *dbh, const psFits *fits)
    1559015429{
    1559115430    psArray         *rowSet;
    1559215431
    15593     // move to (the first?) extension named  P4MAGICMASKIMFILE_TABLE_NAME
    15594     if (!psFitsMoveExtName(fits, P4MAGICMASKIMFILE_TABLE_NAME)) {
    15595         psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", P4MAGICMASKIMFILE_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);
    1559615435        return false;
    1559715436    }
     
    1561115450    }
    1561215451
     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
     15463bool 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
     15484psMetadata *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
     15532p4bDiffScfileRow *p4bDiffScfileObjectFromMetadata(psMetadata *md)
     15533{
     15534
     15535bool 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}
     15579psArray *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}
     15604bool 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}
     15622long 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}
     15641bool 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}
     15672bool 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}
     15687static void p4cRunRowFree(p4cRunRow *object);
     15688
     15689p4cRunRow *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
     15704static void p4cRunRowFree(p4cRunRow *object)
     15705{
     15706    psFree(object->state);
     15707    psFree(object->workdir);
     15708}
     15709
     15710bool 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
     15741bool p4cRunDropTable(psDB *dbh)
     15742{
     15743    return psDBDropTable(dbh, P4CRUN_TABLE_NAME);
     15744}
     15745
     15746bool 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
     15776long 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}
     15790bool p4cRunInsertObject(psDB *dbh, p4cRunRow *object)
     15791{
     15792    return p4cRunInsert(dbh, object->p4c_id, object->state, object->workdir, object->magic);
     15793}
     15794
     15795bool 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
     15806bool 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
     15841bool 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
     15862psMetadata *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
     15890p4cRunRow *p4cRunObjectFromMetadata(psMetadata *md)
     15891{
     15892
     15893bool 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}
     15917psArray *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}
     15942bool 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}
     15960long 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}
     15979bool 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}
     16010bool 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}
     16025static void p4cInputExpRowFree(p4cInputExpRow *object);
     16026
     16027p4cInputExpRow *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
     16041static void p4cInputExpRowFree(p4cInputExpRow *object)
     16042{
     16043    psFree(object->exp_tag);
     16044}
     16045
     16046bool 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
     16072bool p4cInputExpDropTable(psDB *dbh)
     16073{
     16074    return psDBDropTable(dbh, P4CINPUTEXP_TABLE_NAME);
     16075}
     16076
     16077bool 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
     16102long 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}
     16116bool p4cInputExpInsertObject(psDB *dbh, p4cInputExpRow *object)
     16117{
     16118    return p4cInputExpInsert(dbh, object->p4c_id, object->exp_tag, object->p3_version);
     16119}
     16120
     16121bool 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
     16132bool 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
     16167bool 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
     16188psMetadata *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
     16211p4cInputExpRow *p4cInputExpObjectFromMetadata(psMetadata *md)
     16212{
     16213
     16214bool 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}
     16233psArray *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}
     16258bool 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}
     16276long 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}
     16295bool 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}
     16326bool 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}
     16341static void p4MagicMaskImfileRowFree(p4MagicMaskImfileRow *object);
     16342
     16343p4MagicMaskImfileRow *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
     16359static void p4MagicMaskImfileRowFree(p4MagicMaskImfileRow *object)
     16360{
     16361    psFree(object->exp_tag);
     16362    psFree(object->class_id);
     16363    psFree(object->uri);
     16364}
     16365
     16366bool 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
     16402bool p4MagicMaskImfileDropTable(psDB *dbh)
     16403{
     16404    return psDBDropTable(dbh, P4MAGICMASKIMFILE_TABLE_NAME);
     16405}
     16406
     16407bool 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
     16442long 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}
     16456bool 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
     16461bool 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
     16472bool 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
    1561316496    if (!psDBInsertRows(dbh, P4MAGICMASKIMFILE_TABLE_NAME, rowSet)) {
    1561416497        psError(PS_ERR_UNKNOWN, false, "databse insert failed");
     
    1564616529{
    1564716530    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");
    1565016533        psFree(md);
    1565116534        return false;
     
    1568016563
    1568116564bool 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");
    1568516568        return false;
    1568616569    }
     
    1570616589    }
    1570716590
    15708     return p4MagicMaskImfileRowAlloc(p4_id, exp_tag, p3_version, class_id, uri);
     16591    return p4MagicMaskImfileRowAlloc(p4c_id, exp_tag, p3_version, class_id, uri);
    1570916592}
    1571016593psArray *p4MagicMaskImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
     
    1573716620    psMetadata *where = p4MagicMaskImfileMetadataFromObject(object);
    1573816621    long long count = psDBDeleteRows(dbh, P4MAGICMASKIMFILE_TABLE_NAME, where, 0);
    15739     psFree(where)
     16622    psFree(where);
    1574016623    if (count < 0) {
    1574116624        psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4MagicMaskImfile");
     
    1575916642        psMetadata *where = p4MagicMaskImfileMetadataFromObject(object);
    1576016643        long long count = psDBDeleteRows(dbh, P4MAGICMASKIMFILE_TABLE_NAME, where, limit);
    15761         psFree(where)
     16644        psFree(where);
    1576216645        if (count < 0) {
    1576316646            psError(PS_ERR_UNKNOWN, true, "failed to delete row from p4MagicMaskImfile");
     
    1581616699    return true;
    1581716700}
     16701static void skyCellRowFree(skyCellRow *object);
     16702
     16703skyCellRow *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
     16724static void skyCellRowFree(skyCellRow *object)
     16725{
     16726    psFree(object->skycell_id);
     16727    psFree(object->tess_id);
     16728}
     16729
     16730bool 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
     16791bool skyCellDropTable(psDB *dbh)
     16792{
     16793    return psDBDropTable(dbh, SKYCELL_TABLE_NAME);
     16794}
     16795
     16796bool 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
     16856long 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}
     16870bool 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
     16875bool 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
     16886bool 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
     16921bool 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
     16942psMetadata *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
     17000skyCellRow *skyCellObjectFromMetadata(psMetadata *md)
     17001{
     17002
     17003bool 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}
     17057psArray *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}
     17082bool 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}
     17100long 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}
     17119bool 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}
     17150bool 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}
     17165static void skyCellMapRowFree(skyCellMapRow *object);
     17166
     17167skyCellMapRow *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
     17182static 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
     17190bool 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
     17221bool skyCellMapDropTable(psDB *dbh)
     17222{
     17223    return psDBDropTable(dbh, SKYCELLMAP_TABLE_NAME);
     17224}
     17225
     17226bool 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
     17256long 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}
     17270bool skyCellMapInsertObject(psDB *dbh, skyCellMapRow *object)
     17271{
     17272    return skyCellMapInsert(dbh, object->skycell_id, object->tess_id, object->exp_tag, object->class_id);
     17273}
     17274
     17275bool 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
     17286bool 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
     17321bool 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
     17342psMetadata *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
     17370skyCellMapRow *skyCellMapObjectFromMetadata(psMetadata *md)
     17371{
     17372
     17373bool 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}
     17397psArray *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}
     17422bool 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}
     17440long 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}
     17459bool 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}
     17490bool 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  
    2020/*
    2121 *
    22  * This file was generated by glueforge 1.00
     22 * This file was generated by glueforge 0.36
    2323 *
    2424 * Do NOT directly edit this file.
     
    68306830    bool            mdcf                ///< format as mdconfig or simple
    68316831);
    6832 /** p4RunRow data structure
    6833  *
    6834  * Structure for representing a single row of p4Run table data.
     6832/** p4aRunRow data structure
     6833 *
     6834 * Structure for representing a single row of p4aRun table data.
    68356835 */
    68366836
    68376837typedef struct {
    6838     psS32           p4_id;
    6839     char            *survey_mode;
     6838    psS32           p4a_id;
    68406839    char            *state;
    68416840    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
     6849p4aRunRow *p4aRunRowAlloc(
     6850    psS32           p4a_id,
    68596851    const char      *state,
    68606852    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
     6861bool p4aRunCreateTable(
    68766862    psDB            *dbh                ///< Database handle
    68776863);
    68786864
    6879 /** Deletes a p4Run table
    6880  *
    6881  * @return true on success
    6882  */
    6883 
    6884 bool p4RunDropTable(
     6865/** Deletes a p4aRun table
     6866 *
     6867 * @return true on success
     6868 */
     6869
     6870bool p4aRunDropTable(
    68856871    psDB            *dbh                ///< Database handle
    68866872);
     
    68936879 */
    68946880
    6895 bool p4RunInsert(
    6896     psDB            *dbh,               ///< Database handle
    6897     psS32           p4_id,
    6898     const char      *survey_mode,
     6881bool p4aRunInsert(
     6882    psDB            *dbh,               ///< Database handle
     6883    psS32           p4a_id,
    68996884    const char      *state,
    69006885    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
    69086887);
    69096888
     
    69136892 */
    69146893
    6915 long long p4RunDelete(
     6894long long p4aRunDelete(
    69166895    psDB            *dbh,               ///< Database handle
    69176896    const psMetadata *where,            ///< Row match criteria
     
    69196898);
    69206899
    6921 /** Insert a single p4RunRow object into a table
     6900/** Insert a single p4aRunRow object into a table
    69226901 *
    69236902 * This function constructs and inserts a single row based on it's parameters.
     
    69266905 */
    69276906
    6928 bool p4RunInsertObject(
    6929     psDB            *dbh,               ///< Database handle
    6930     p4RunRow        *object             ///< p4RunRow object
    6931 );
    6932 
    6933 /** Insert an array of p4RunRow object into a table
     6907bool p4aRunInsertObject(
     6908    psDB            *dbh,               ///< Database handle
     6909    p4aRunRow       *object             ///< p4aRunRow object
     6910);
     6911
     6912/** Insert an array of p4aRunRow object into a table
    69346913 *
    69356914 * This function constructs and inserts multiple rows based on it's parameters.
     
    69386917 */
    69396918
    6940 bool p4RunInsertObjects(
    6941     psDB            *dbh,               ///< Database handle
    6942     psArray         *objects            ///< array of p4RunRow objects
    6943 );
    6944 
    6945 /** Insert data from a binary FITS table p4RunRow into the database
     6919bool 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
    69466925 *
    69476926 * This function expects a psFits object with a FITS table as the first
     
    69536932 */
    69546933
    6955 bool p4RunInsertFits(
     6934bool p4aRunInsertFits(
    69566935    psDB            *dbh,               ///< Database handle
    69576936    const psFits    *fits               ///< psFits object
     
    69686947 */
    69696948
    6970 bool p4RunSelectRowsFits(
     6949bool p4aRunSelectRowsFits(
    69716950    psDB            *dbh,               ///< Database handle
    69726951    psFits          *fits,              ///< psFits object
     
    69756954);
    69766955
    6977 /** Convert a p4RunRow into an equivalent psMetadata
     6956/** Convert a p4aRunRow into an equivalent psMetadata
    69786957 *
    69796958 * @return A psMetadata pointer or NULL on error
    69806959 */
    69816960
    6982 psMetadata *p4RunMetadataFromObject(
    6983     const p4RunRow *object             ///< fooRow to convert into a psMetadata
     6961psMetadata *p4aRunMetadataFromObject(
     6962    const p4aRunRow *object             ///< fooRow to convert into a psMetadata
    69846963);
    69856964
    69866965/** Convert a psMetadata into an equivalent fooRow
    69876966 *
    6988  * @return A p4RunRow pointer or NULL on error
    6989  */
    6990 
    6991 p4RunRow *p4RunObjectFromMetadata(
     6967 * @return A p4aRunRow pointer or NULL on error
     6968 */
     6969
     6970p4aRunRow *p4aRunObjectFromMetadata(
    69926971    psMetadata      *md                 ///< psMetadata to convert into a fooRow
    69936972);
    6994 /** Selects up to limit rows from the database and returns as p4RunRow objects in a psArray
     6973/** Selects up to limit rows from the database and returns as p4aRunRow objects in a psArray
    69956974 *
    69966975 *  See psDBSelectRows() for documentation on the format of where.
     
    69996978 */
    70006979
    7001 psArray *p4RunSelectRowObjects(
     6980psArray *p4aRunSelectRowObjects(
    70026981    psDB            *dbh,               ///< Database handle
    70036982    const psMetadata *where,            ///< Row match criteria
    70046983    unsigned long long limit            ///< Maximum number of elements to return
    70056984);
    7006 /** Deletes a row from the database coresponding to an p4Run
     6985/** Deletes a row from the database coresponding to an p4aRun
    70076986 *
    70086987 *  Note that a 'where' search psMetadata is constructed from each object and
     
    70126991 */
    70136992
    7014 bool p4RunDeleteObject(
    7015     psDB            *dbh,               ///< Database handle
    7016     const p4RunRow *object    ///< Object to delete
     6993bool p4aRunDeleteObject(
     6994    psDB            *dbh,               ///< Database handle
     6995    const p4aRunRow *object    ///< Object to delete
    70176996);
    70186997/** Deletes up to limit rows from the database and returns the number of rows actually deleted.
     
    70247003 */
    70257004
    7026 long long p4RunDeleteRowObjects(
     7005long long p4aRunDeleteRowObjects(
    70277006    psDB            *dbh,               ///< Database handle
    70287007    const psArray   *objects,           ///< Array of objects to delete
    70297008    unsigned long long limit            ///< Maximum number of elements to delete
    70307009);
    7031 /** Formats and prints an array of p4RunRow objects
     7010/** Formats and prints an array of p4aRunRow objects
    70327011 *
    70337012 * When mdcf is set the formated output is in psMetadataConfig
     
    70377016 */
    70387017
    7039 bool p4RunPrintObjects(
     7018bool p4aRunPrintObjects(
    70407019    FILE            *stream,            ///< a stream
    7041     psArray         *objects,           ///< An array of p4RunRow objects
     7020    psArray         *objects,           ///< An array of p4aRunRow objects
    70427021    bool            mdcf                ///< format as mdconfig or simple
    70437022);
    7044 /** Formats and prints an p4RunRow object
     7023/** Formats and prints an p4aRunRow object
    70457024 *
    70467025 * When mdcf is set the formated output is in psMetadataConfig
     
    70507029 */
    70517030
    7052 bool p4RunPrintObject(
     7031bool p4aRunPrintObject(
    70537032    FILE            *stream,            ///< a stream
    7054     p4RunRow *object,    ///< an p4RunRow object
     7033    p4aRunRow *object,    ///< an p4aRunRow object
    70557034    bool            mdcf                ///< format as mdconfig or simple
    70567035);
    7057 /** p4InputImfileRow data structure
    7058  *
    7059  * Structure for representing a single row of p4InputImfile table data.
     7036/** p4aInputExpRow data structure
     7037 *
     7038 * Structure for representing a single row of p4aInputExp table data.
    70607039 */
    70617040
    70627041typedef struct {
    7063     psS32           p4_id;
     7042    psS32           p4a_id;
    70647043    char            *exp_tag;
    70657044    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
     7052p4aInputExpRow *p4aInputExpRowAlloc(
     7053    psS32           p4a_id,
    70767054    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
     7063bool p4aInputExpCreateTable(
    70877064    psDB            *dbh                ///< Database handle
    70887065);
    70897066
    7090 /** Deletes a p4InputImfile table
    7091  *
    7092  * @return true on success
    7093  */
    7094 
    7095 bool p4InputImfileDropTable(
     7067/** Deletes a p4aInputExp table
     7068 *
     7069 * @return true on success
     7070 */
     7071
     7072bool p4aInputExpDropTable(
    70967073    psDB            *dbh                ///< Database handle
    70977074);
     
    71047081 */
    71057082
    7106 bool p4InputImfileInsert(
    7107     psDB            *dbh,               ///< Database handle
    7108     psS32           p4_id,
     7083bool p4aInputExpInsert(
     7084    psDB            *dbh,               ///< Database handle
     7085    psS32           p4a_id,
    71097086    const char      *exp_tag,
    7110     psS32           p3_version,
    7111     const char      *class_id
     7087    psS32           p3_version
    71127088);
    71137089
     
    71177093 */
    71187094
    7119 long long p4InputImfileDelete(
     7095long long p4aInputExpDelete(
    71207096    psDB            *dbh,               ///< Database handle
    71217097    const psMetadata *where,            ///< Row match criteria
     
    71237099);
    71247100
    7125 /** Insert a single p4InputImfileRow object into a table
     7101/** Insert a single p4aInputExpRow object into a table
    71267102 *
    71277103 * This function constructs and inserts a single row based on it's parameters.
     
    71307106 */
    71317107
    7132 bool p4InputImfileInsertObject(
    7133     psDB            *dbh,               ///< Database handle
    7134     p4InputImfileRow *object             ///< p4InputImfileRow object
    7135 );
    7136 
    7137 /** Insert an array of p4InputImfileRow object into a table
     7108bool p4aInputExpInsertObject(
     7109    psDB            *dbh,               ///< Database handle
     7110    p4aInputExpRow  *object             ///< p4aInputExpRow object
     7111);
     7112
     7113/** Insert an array of p4aInputExpRow object into a table
    71387114 *
    71397115 * This function constructs and inserts multiple rows based on it's parameters.
     
    71427118 */
    71437119
    7144 bool p4InputImfileInsertObjects(
    7145     psDB            *dbh,               ///< Database handle
    7146     psArray         *objects            ///< array of p4InputImfileRow objects
    7147 );
    7148 
    7149 /** Insert data from a binary FITS table p4InputImfileRow into the database
     7120bool 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
    71507126 *
    71517127 * This function expects a psFits object with a FITS table as the first
     
    71577133 */
    71587134
    7159 bool p4InputImfileInsertFits(
     7135bool p4aInputExpInsertFits(
    71607136    psDB            *dbh,               ///< Database handle
    71617137    const psFits    *fits               ///< psFits object
     
    71727148 */
    71737149
    7174 bool p4InputImfileSelectRowsFits(
     7150bool p4aInputExpSelectRowsFits(
    71757151    psDB            *dbh,               ///< Database handle
    71767152    psFits          *fits,              ///< psFits object
     
    71797155);
    71807156
    7181 /** Convert a p4InputImfileRow into an equivalent psMetadata
     7157/** Convert a p4aInputExpRow into an equivalent psMetadata
    71827158 *
    71837159 * @return A psMetadata pointer or NULL on error
    71847160 */
    71857161
    7186 psMetadata *p4InputImfileMetadataFromObject(
    7187     const p4InputImfileRow *object             ///< fooRow to convert into a psMetadata
     7162psMetadata *p4aInputExpMetadataFromObject(
     7163    const p4aInputExpRow *object             ///< fooRow to convert into a psMetadata
    71887164);
    71897165
    71907166/** Convert a psMetadata into an equivalent fooRow
    71917167 *
    7192  * @return A p4InputImfileRow pointer or NULL on error
    7193  */
    7194 
    7195 p4InputImfileRow *p4InputImfileObjectFromMetadata(
     7168 * @return A p4aInputExpRow pointer or NULL on error
     7169 */
     7170
     7171p4aInputExpRow *p4aInputExpObjectFromMetadata(
    71967172    psMetadata      *md                 ///< psMetadata to convert into a fooRow
    71977173);
    7198 /** Selects up to limit rows from the database and returns as p4InputImfileRow objects in a psArray
     7174/** Selects up to limit rows from the database and returns as p4aInputExpRow objects in a psArray
    71997175 *
    72007176 *  See psDBSelectRows() for documentation on the format of where.
     
    72037179 */
    72047180
    7205 psArray *p4InputImfileSelectRowObjects(
     7181psArray *p4aInputExpSelectRowObjects(
    72067182    psDB            *dbh,               ///< Database handle
    72077183    const psMetadata *where,            ///< Row match criteria
    72087184    unsigned long long limit            ///< Maximum number of elements to return
    72097185);
    7210 /** Deletes a row from the database coresponding to an p4InputImfile
     7186/** Deletes a row from the database coresponding to an p4aInputExp
    72117187 *
    72127188 *  Note that a 'where' search psMetadata is constructed from each object and
     
    72167192 */
    72177193
    7218 bool p4InputImfileDeleteObject(
    7219     psDB            *dbh,               ///< Database handle
    7220     const p4InputImfileRow *object    ///< Object to delete
     7194bool p4aInputExpDeleteObject(
     7195    psDB            *dbh,               ///< Database handle
     7196    const p4aInputExpRow *object    ///< Object to delete
    72217197);
    72227198/** Deletes up to limit rows from the database and returns the number of rows actually deleted.
     
    72287204 */
    72297205
    7230 long long p4InputImfileDeleteRowObjects(
     7206long long p4aInputExpDeleteRowObjects(
    72317207    psDB            *dbh,               ///< Database handle
    72327208    const psArray   *objects,           ///< Array of objects to delete
    72337209    unsigned long long limit            ///< Maximum number of elements to delete
    72347210);
    7235 /** Formats and prints an array of p4InputImfileRow objects
     7211/** Formats and prints an array of p4aInputExpRow objects
    72367212 *
    72377213 * When mdcf is set the formated output is in psMetadataConfig
     
    72417217 */
    72427218
    7243 bool p4InputImfilePrintObjects(
     7219bool p4aInputExpPrintObjects(
    72447220    FILE            *stream,            ///< a stream
    7245     psArray         *objects,           ///< An array of p4InputImfileRow objects
     7221    psArray         *objects,           ///< An array of p4aInputExpRow objects
    72467222    bool            mdcf                ///< format as mdconfig or simple
    72477223);
    7248 /** Formats and prints an p4InputImfileRow object
     7224/** Formats and prints an p4aInputExpRow object
    72497225 *
    72507226 * When mdcf is set the formated output is in psMetadataConfig
     
    72547230 */
    72557231
    7256 bool p4InputImfilePrintObject(
     7232bool p4aInputExpPrintObject(
    72577233    FILE            *stream,            ///< a stream
    7258     p4InputImfileRow *object,    ///< an p4InputImfileRow object
     7234    p4aInputExpRow *object,    ///< an p4aInputExpRow object
    72597235    bool            mdcf                ///< format as mdconfig or simple
    72607236);
    7261 /** p4WarpedImfileRow data structure
    7262  *
    7263  * Structure for representing a single row of p4WarpedImfile table data.
     7237/** p4aScfileRow data structure
     7238 *
     7239 * Structure for representing a single row of p4aScfile table data.
    72647240 */
    72657241
    72667242typedef struct {
    7267     psS32           p4_id;
     7243    psS32           p4a_id;
     7244    char            *skycell_id;
     7245    char            *tess_id;
    72687246    char            *exp_tag;
    72697247    psS32           p3_version;
    7270     char            *class_id;
    72717248    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
     7258p4aScfileRow *p4aScfileRowAlloc(
     7259    psS32           p4a_id,
     7260    const char      *skycell_id,
     7261    const char      *tess_id,
    72837262    const char      *exp_tag,
    72847263    psS32           p3_version,
    7285     const char      *class_id,
    72867264    const char      *uri,
    7287     const char      *b1_uri,
    7288     const char      *b2_uri
    7289 );
    7290 
    7291 /** Creates a new p4WarpedImfile table
    7292  *
    7293  * @return true on success
    7294  */
    7295 
    7296 bool p4WarpedImfileCreateTable(
     7265    psF64           bg,
     7266    psF64           bg_mean_stdev
     7267);
     7268
     7269/** Creates a new p4aScfile table
     7270 *
     7271 * @return true on success
     7272 */
     7273
     7274bool p4aScfileCreateTable(
    72977275    psDB            *dbh                ///< Database handle
    72987276);
    72997277
    7300 /** Deletes a p4WarpedImfile table
    7301  *
    7302  * @return true on success
    7303  */
    7304 
    7305 bool p4WarpedImfileDropTable(
     7278/** Deletes a p4aScfile table
     7279 *
     7280 * @return true on success
     7281 */
     7282
     7283bool p4aScfileDropTable(
    73067284    psDB            *dbh                ///< Database handle
    73077285);
     
    73147292 */
    73157293
    7316 bool p4WarpedImfileInsert(
    7317     psDB            *dbh,               ///< Database handle
    7318     psS32           p4_id,
     7294bool p4aScfileInsert(
     7295    psDB            *dbh,               ///< Database handle
     7296    psS32           p4a_id,
     7297    const char      *skycell_id,
     7298    const char      *tess_id,
    73197299    const char      *exp_tag,
    73207300    psS32           p3_version,
    7321     const char      *class_id,
    73227301    const char      *uri,
    7323     const char      *b1_uri,
    7324     const char      *b2_uri
     7302    psF64           bg,
     7303    psF64           bg_mean_stdev
    73257304);
    73267305
     
    73307309 */
    73317310
    7332 long long p4WarpedImfileDelete(
     7311long long p4aScfileDelete(
    73337312    psDB            *dbh,               ///< Database handle
    73347313    const psMetadata *where,            ///< Row match criteria
     
    73367315);
    73377316
    7338 /** Insert a single p4WarpedImfileRow object into a table
     7317/** Insert a single p4aScfileRow object into a table
    73397318 *
    73407319 * This function constructs and inserts a single row based on it's parameters.
     
    73437322 */
    73447323
    7345 bool p4WarpedImfileInsertObject(
    7346     psDB            *dbh,               ///< Database handle
    7347     p4WarpedImfileRow *object             ///< p4WarpedImfileRow object
    7348 );
    7349 
    7350 /** Insert an array of p4WarpedImfileRow object into a table
     7324bool p4aScfileInsertObject(
     7325    psDB            *dbh,               ///< Database handle
     7326    p4aScfileRow    *object             ///< p4aScfileRow object
     7327);
     7328
     7329/** Insert an array of p4aScfileRow object into a table
    73517330 *
    73527331 * This function constructs and inserts multiple rows based on it's parameters.
     
    73557334 */
    73567335
    7357 bool p4WarpedImfileInsertObjects(
    7358     psDB            *dbh,               ///< Database handle
    7359     psArray         *objects            ///< array of p4WarpedImfileRow objects
    7360 );
    7361 
    7362 /** Insert data from a binary FITS table p4WarpedImfileRow into the database
     7336bool 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
    73637342 *
    73647343 * This function expects a psFits object with a FITS table as the first
     
    73707349 */
    73717350
    7372 bool p4WarpedImfileInsertFits(
     7351bool p4aScfileInsertFits(
    73737352    psDB            *dbh,               ///< Database handle
    73747353    const psFits    *fits               ///< psFits object
     
    73857364 */
    73867365
    7387 bool p4WarpedImfileSelectRowsFits(
     7366bool p4aScfileSelectRowsFits(
    73887367    psDB            *dbh,               ///< Database handle
    73897368    psFits          *fits,              ///< psFits object
     
    73927371);
    73937372
    7394 /** Convert a p4WarpedImfileRow into an equivalent psMetadata
     7373/** Convert a p4aScfileRow into an equivalent psMetadata
    73957374 *
    73967375 * @return A psMetadata pointer or NULL on error
    73977376 */
    73987377
    7399 psMetadata *p4WarpedImfileMetadataFromObject(
    7400     const p4WarpedImfileRow *object             ///< fooRow to convert into a psMetadata
     7378psMetadata *p4aScfileMetadataFromObject(
     7379    const p4aScfileRow *object             ///< fooRow to convert into a psMetadata
    74017380);
    74027381
    74037382/** Convert a psMetadata into an equivalent fooRow
    74047383 *
    7405  * @return A p4WarpedImfileRow pointer or NULL on error
    7406  */
    7407 
    7408 p4WarpedImfileRow *p4WarpedImfileObjectFromMetadata(
     7384 * @return A p4aScfileRow pointer or NULL on error
     7385 */
     7386
     7387p4aScfileRow *p4aScfileObjectFromMetadata(
    74097388    psMetadata      *md                 ///< psMetadata to convert into a fooRow
    74107389);
    7411 /** Selects up to limit rows from the database and returns as p4WarpedImfileRow objects in a psArray
     7390/** Selects up to limit rows from the database and returns as p4aScfileRow objects in a psArray
    74127391 *
    74137392 *  See psDBSelectRows() for documentation on the format of where.
     
    74167395 */
    74177396
    7418 psArray *p4WarpedImfileSelectRowObjects(
     7397psArray *p4aScfileSelectRowObjects(
    74197398    psDB            *dbh,               ///< Database handle
    74207399    const psMetadata *where,            ///< Row match criteria
    74217400    unsigned long long limit            ///< Maximum number of elements to return
    74227401);
    7423 /** Deletes a row from the database coresponding to an p4WarpedImfile
     7402/** Deletes a row from the database coresponding to an p4aScfile
    74247403 *
    74257404 *  Note that a 'where' search psMetadata is constructed from each object and
     
    74297408 */
    74307409
    7431 bool p4WarpedImfileDeleteObject(
    7432     psDB            *dbh,               ///< Database handle
    7433     const p4WarpedImfileRow *object    ///< Object to delete
     7410bool p4aScfileDeleteObject(
     7411    psDB            *dbh,               ///< Database handle
     7412    const p4aScfileRow *object    ///< Object to delete
    74347413);
    74357414/** Deletes up to limit rows from the database and returns the number of rows actually deleted.
     
    74417420 */
    74427421
    7443 long long p4WarpedImfileDeleteRowObjects(
     7422long long p4aScfileDeleteRowObjects(
    74447423    psDB            *dbh,               ///< Database handle
    74457424    const psArray   *objects,           ///< Array of objects to delete
    74467425    unsigned long long limit            ///< Maximum number of elements to delete
    74477426);
    7448 /** Formats and prints an array of p4WarpedImfileRow objects
     7427/** Formats and prints an array of p4aScfileRow objects
    74497428 *
    74507429 * When mdcf is set the formated output is in psMetadataConfig
     
    74547433 */
    74557434
    7456 bool p4WarpedImfilePrintObjects(
     7435bool p4aScfilePrintObjects(
    74577436    FILE            *stream,            ///< a stream
    7458     psArray         *objects,           ///< An array of p4WarpedImfileRow objects
     7437    psArray         *objects,           ///< An array of p4aScfileRow objects
    74597438    bool            mdcf                ///< format as mdconfig or simple
    74607439);
    7461 /** Formats and prints an p4WarpedImfileRow object
     7440/** Formats and prints an p4aScfileRow object
    74627441 *
    74637442 * When mdcf is set the formated output is in psMetadataConfig
     
    74677446 */
    74687447
    7469 bool p4WarpedImfilePrintObject(
     7448bool p4aScfilePrintObject(
    74707449    FILE            *stream,            ///< a stream
    7471     p4WarpedImfileRow *object,    ///< an p4WarpedImfileRow object
     7450    p4aScfileRow *object,    ///< an p4aScfileRow object
    74727451    bool            mdcf                ///< format as mdconfig or simple
    74737452);
    7474 /** p4StackedImfileRow data structure
    7475  *
    7476  * Structure for representing a single row of p4StackedImfile table data.
     7453/** p4bRunRow data structure
     7454 *
     7455 * Structure for representing a single row of p4bRun table data.
    74777456 */
    74787457
    74797458typedef 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
     7470p4bRunRow *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
     7482bool p4bRunCreateTable(
    75067483    psDB            *dbh                ///< Database handle
    75077484);
    75087485
    7509 /** Deletes a p4StackedImfile table
    7510  *
    7511  * @return true on success
    7512  */
    7513 
    7514 bool p4StackedImfileDropTable(
     7486/** Deletes a p4bRun table
     7487 *
     7488 * @return true on success
     7489 */
     7490
     7491bool p4bRunDropTable(
    75157492    psDB            *dbh                ///< Database handle
    75167493);
     
    75237500 */
    75247501
    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
     7502bool p4bRunInsert(
     7503    psDB            *dbh,               ///< Database handle
     7504    psS32           p4b_id,
     7505    const char      *state,
     7506    const char      *workdir,
     7507    bool            magic
    75327508);
    75337509
     
    75377513 */
    75387514
    7539 long long p4StackedImfileDelete(
     7515long long p4bRunDelete(
    75407516    psDB            *dbh,               ///< Database handle
    75417517    const psMetadata *where,            ///< Row match criteria
     
    75437519);
    75447520
    7545 /** Insert a single p4StackedImfileRow object into a table
     7521/** Insert a single p4bRunRow object into a table
    75467522 *
    75477523 * This function constructs and inserts a single row based on it's parameters.
     
    75507526 */
    75517527
    7552 bool p4StackedImfileInsertObject(
    7553     psDB            *dbh,               ///< Database handle
    7554     p4StackedImfileRow *object             ///< p4StackedImfileRow object
    7555 );
    7556 
    7557 /** Insert an array of p4StackedImfileRow object into a table
     7528bool p4bRunInsertObject(
     7529    psDB            *dbh,               ///< Database handle
     7530    p4bRunRow       *object             ///< p4bRunRow object
     7531);
     7532
     7533/** Insert an array of p4bRunRow object into a table
    75587534 *
    75597535 * This function constructs and inserts multiple rows based on it's parameters.
     
    75627538 */
    75637539
    7564 bool p4StackedImfileInsertObjects(
    7565     psDB            *dbh,               ///< Database handle
    7566     psArray         *objects            ///< array of p4StackedImfileRow objects
    7567 );
    7568 
    7569 /** Insert data from a binary FITS table p4StackedImfileRow into the database
     7540bool 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
    75707546 *
    75717547 * This function expects a psFits object with a FITS table as the first
     
    75777553 */
    75787554
    7579 bool p4StackedImfileInsertFits(
     7555bool p4bRunInsertFits(
    75807556    psDB            *dbh,               ///< Database handle
    75817557    const psFits    *fits               ///< psFits object
     
    75927568 */
    75937569
    7594 bool p4StackedImfileSelectRowsFits(
     7570bool p4bRunSelectRowsFits(
    75957571    psDB            *dbh,               ///< Database handle
    75967572    psFits          *fits,              ///< psFits object
     
    75997575);
    76007576
    7601 /** Convert a p4StackedImfileRow into an equivalent psMetadata
     7577/** Convert a p4bRunRow into an equivalent psMetadata
    76027578 *
    76037579 * @return A psMetadata pointer or NULL on error
    76047580 */
    76057581
    7606 psMetadata *p4StackedImfileMetadataFromObject(
    7607     const p4StackedImfileRow *object             ///< fooRow to convert into a psMetadata
     7582psMetadata *p4bRunMetadataFromObject(
     7583    const p4bRunRow *object             ///< fooRow to convert into a psMetadata
    76087584);
    76097585
    76107586/** Convert a psMetadata into an equivalent fooRow
    76117587 *
    7612  * @return A p4StackedImfileRow pointer or NULL on error
    7613  */
    7614 
    7615 p4StackedImfileRow *p4StackedImfileObjectFromMetadata(
     7588 * @return A p4bRunRow pointer or NULL on error
     7589 */
     7590
     7591p4bRunRow *p4bRunObjectFromMetadata(
    76167592    psMetadata      *md                 ///< psMetadata to convert into a fooRow
    76177593);
    7618 /** Selects up to limit rows from the database and returns as p4StackedImfileRow objects in a psArray
     7594/** Selects up to limit rows from the database and returns as p4bRunRow objects in a psArray
    76197595 *
    76207596 *  See psDBSelectRows() for documentation on the format of where.
     
    76237599 */
    76247600
    7625 psArray *p4StackedImfileSelectRowObjects(
     7601psArray *p4bRunSelectRowObjects(
    76267602    psDB            *dbh,               ///< Database handle
    76277603    const psMetadata *where,            ///< Row match criteria
    76287604    unsigned long long limit            ///< Maximum number of elements to return
    76297605);
    7630 /** Deletes a row from the database coresponding to an p4StackedImfile
     7606/** Deletes a row from the database coresponding to an p4bRun
    76317607 *
    76327608 *  Note that a 'where' search psMetadata is constructed from each object and
     
    76367612 */
    76377613
    7638 bool p4StackedImfileDeleteObject(
    7639     psDB            *dbh,               ///< Database handle
    7640     const p4StackedImfileRow *object    ///< Object to delete
     7614bool p4bRunDeleteObject(
     7615    psDB            *dbh,               ///< Database handle
     7616    const p4bRunRow *object    ///< Object to delete
    76417617);
    76427618/** Deletes up to limit rows from the database and returns the number of rows actually deleted.
     
    76487624 */
    76497625
    7650 long long p4StackedImfileDeleteRowObjects(
     7626long long p4bRunDeleteRowObjects(
    76517627    psDB            *dbh,               ///< Database handle
    76527628    const psArray   *objects,           ///< Array of objects to delete
    76537629    unsigned long long limit            ///< Maximum number of elements to delete
    76547630);
    7655 /** Formats and prints an array of p4StackedImfileRow objects
     7631/** Formats and prints an array of p4bRunRow objects
    76567632 *
    76577633 * When mdcf is set the formated output is in psMetadataConfig
     
    76617637 */
    76627638
    7663 bool p4StackedImfilePrintObjects(
     7639bool p4bRunPrintObjects(
    76647640    FILE            *stream,            ///< a stream
    7665     psArray         *objects,           ///< An array of p4StackedImfileRow objects
     7641    psArray         *objects,           ///< An array of p4bRunRow objects
    76667642    bool            mdcf                ///< format as mdconfig or simple
    76677643);
    7668 /** Formats and prints an p4StackedImfileRow object
     7644/** Formats and prints an p4bRunRow object
    76697645 *
    76707646 * When mdcf is set the formated output is in psMetadataConfig
     
    76747650 */
    76757651
    7676 bool p4StackedImfilePrintObject(
     7652bool p4bRunPrintObject(
    76777653    FILE            *stream,            ///< a stream
    7678     p4StackedImfileRow *object,    ///< an p4StackedImfileRow object
     7654    p4bRunRow *object,    ///< an p4bRunRow object
    76797655    bool            mdcf                ///< format as mdconfig or simple
    76807656);
    7681 /** p4DiffImfileRow data structure
    7682  *
    7683  * Structure for representing a single row of p4DiffImfile table data.
     7657/** p4bInputScfileRow data structure
     7658 *
     7659 * Structure for representing a single row of p4bInputScfile table data.
    76847660 */
    76857661
    76867662typedef struct {
    7687     psS32           p4_id;
     7663    psS32           p4b_id;
     7664    char            *skycell_id;
     7665    char            *tess_id;
    76887666    char            *exp_tag;
    76897667    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
     7676p4bInputScfileRow *p4bInputScfileRowAlloc(
     7677    psS32           p4b_id,
     7678    const char      *skycell_id,
     7679    const char      *tess_id,
    77037680    const char      *exp_tag,
    77047681    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
     7690bool p4bInputScfileCreateTable(
    77177691    psDB            *dbh                ///< Database handle
    77187692);
    77197693
    7720 /** Deletes a p4DiffImfile table
    7721  *
    7722  * @return true on success
    7723  */
    7724 
    7725 bool p4DiffImfileDropTable(
     7694/** Deletes a p4bInputScfile table
     7695 *
     7696 * @return true on success
     7697 */
     7698
     7699bool p4bInputScfileDropTable(
    77267700    psDB            *dbh                ///< Database handle
    77277701);
     
    77347708 */
    77357709
    7736 bool p4DiffImfileInsert(
    7737     psDB            *dbh,               ///< Database handle
    7738     psS32           p4_id,
     7710bool p4bInputScfileInsert(
     7711    psDB            *dbh,               ///< Database handle
     7712    psS32           p4b_id,
     7713    const char      *skycell_id,
     7714    const char      *tess_id,
    77397715    const char      *exp_tag,
    77407716    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
    77457718);
    77467719
     
    77507723 */
    77517724
    7752 long long p4DiffImfileDelete(
     7725long long p4bInputScfileDelete(
    77537726    psDB            *dbh,               ///< Database handle
    77547727    const psMetadata *where,            ///< Row match criteria
     
    77567729);
    77577730
    7758 /** Insert a single p4DiffImfileRow object into a table
     7731/** Insert a single p4bInputScfileRow object into a table
    77597732 *
    77607733 * This function constructs and inserts a single row based on it's parameters.
     
    77637736 */
    77647737
    7765 bool p4DiffImfileInsertObject(
    7766     psDB            *dbh,               ///< Database handle
    7767     p4DiffImfileRow *object             ///< p4DiffImfileRow object
    7768 );
    7769 
    7770 /** Insert an array of p4DiffImfileRow object into a table
     7738bool p4bInputScfileInsertObject(
     7739    psDB            *dbh,               ///< Database handle
     7740    p4bInputScfileRow *object             ///< p4bInputScfileRow object
     7741);
     7742
     7743/** Insert an array of p4bInputScfileRow object into a table
    77717744 *
    77727745 * This function constructs and inserts multiple rows based on it's parameters.
     
    77757748 */
    77767749
    7777 bool p4DiffImfileInsertObjects(
    7778     psDB            *dbh,               ///< Database handle
    7779     psArray         *objects            ///< array of p4DiffImfileRow objects
    7780 );
    7781 
    7782 /** Insert data from a binary FITS table p4DiffImfileRow into the database
     7750bool 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
    77837756 *
    77847757 * This function expects a psFits object with a FITS table as the first
     
    77907763 */
    77917764
    7792 bool p4DiffImfileInsertFits(
     7765bool p4bInputScfileInsertFits(
    77937766    psDB            *dbh,               ///< Database handle
    77947767    const psFits    *fits               ///< psFits object
     
    78057778 */
    78067779
    7807 bool p4DiffImfileSelectRowsFits(
     7780bool p4bInputScfileSelectRowsFits(
    78087781    psDB            *dbh,               ///< Database handle
    78097782    psFits          *fits,              ///< psFits object
     
    78127785);
    78137786
    7814 /** Convert a p4DiffImfileRow into an equivalent psMetadata
     7787/** Convert a p4bInputScfileRow into an equivalent psMetadata
    78157788 *
    78167789 * @return A psMetadata pointer or NULL on error
    78177790 */
    78187791
    7819 psMetadata *p4DiffImfileMetadataFromObject(
    7820     const p4DiffImfileRow *object             ///< fooRow to convert into a psMetadata
     7792psMetadata *p4bInputScfileMetadataFromObject(
     7793    const p4bInputScfileRow *object             ///< fooRow to convert into a psMetadata
    78217794);
    78227795
    78237796/** Convert a psMetadata into an equivalent fooRow
    78247797 *
    7825  * @return A p4DiffImfileRow pointer or NULL on error
    7826  */
    7827 
    7828 p4DiffImfileRow *p4DiffImfileObjectFromMetadata(
     7798 * @return A p4bInputScfileRow pointer or NULL on error
     7799 */
     7800
     7801p4bInputScfileRow *p4bInputScfileObjectFromMetadata(
    78297802    psMetadata      *md                 ///< psMetadata to convert into a fooRow
    78307803);
    7831 /** Selects up to limit rows from the database and returns as p4DiffImfileRow objects in a psArray
     7804/** Selects up to limit rows from the database and returns as p4bInputScfileRow objects in a psArray
    78327805 *
    78337806 *  See psDBSelectRows() for documentation on the format of where.
     
    78367809 */
    78377810
    7838 psArray *p4DiffImfileSelectRowObjects(
     7811psArray *p4bInputScfileSelectRowObjects(
    78397812    psDB            *dbh,               ///< Database handle
    78407813    const psMetadata *where,            ///< Row match criteria
    78417814    unsigned long long limit            ///< Maximum number of elements to return
    78427815);
    7843 /** Deletes a row from the database coresponding to an p4DiffImfile
     7816/** Deletes a row from the database coresponding to an p4bInputScfile
    78447817 *
    78457818 *  Note that a 'where' search psMetadata is constructed from each object and
     
    78497822 */
    78507823
    7851 bool p4DiffImfileDeleteObject(
    7852     psDB            *dbh,               ///< Database handle
    7853     const p4DiffImfileRow *object    ///< Object to delete
     7824bool p4bInputScfileDeleteObject(
     7825    psDB            *dbh,               ///< Database handle
     7826    const p4bInputScfileRow *object    ///< Object to delete
    78547827);
    78557828/** Deletes up to limit rows from the database and returns the number of rows actually deleted.
     
    78617834 */
    78627835
    7863 long long p4DiffImfileDeleteRowObjects(
     7836long long p4bInputScfileDeleteRowObjects(
    78647837    psDB            *dbh,               ///< Database handle
    78657838    const psArray   *objects,           ///< Array of objects to delete
    78667839    unsigned long long limit            ///< Maximum number of elements to delete
    78677840);
    7868 /** Formats and prints an array of p4DiffImfileRow objects
     7841/** Formats and prints an array of p4bInputScfileRow objects
    78697842 *
    78707843 * When mdcf is set the formated output is in psMetadataConfig
     
    78747847 */
    78757848
    7876 bool p4DiffImfilePrintObjects(
     7849bool p4bInputScfilePrintObjects(
    78777850    FILE            *stream,            ///< a stream
    7878     psArray         *objects,           ///< An array of p4DiffImfileRow objects
     7851    psArray         *objects,           ///< An array of p4bInputScfileRow objects
    78797852    bool            mdcf                ///< format as mdconfig or simple
    78807853);
    7881 /** Formats and prints an p4DiffImfileRow object
     7854/** Formats and prints an p4bInputScfileRow object
    78827855 *
    78837856 * When mdcf is set the formated output is in psMetadataConfig
     
    78877860 */
    78887861
    7889 bool p4DiffImfilePrintObject(
     7862bool p4bInputScfilePrintObject(
    78907863    FILE            *stream,            ///< a stream
    7891     p4DiffImfileRow *object,    ///< an p4DiffImfileRow object
     7864    p4bInputScfileRow *object,    ///< an p4bInputScfileRow object
    78927865    bool            mdcf                ///< format as mdconfig or simple
    78937866);
     7867/** p4bDiffScfileRow data structure
     7868 *
     7869 * Structure for representing a single row of p4bDiffScfile table data.
     7870 */
     7871
     7872typedef 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
     7888p4bDiffScfileRow *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
     7904bool p4bDiffScfileCreateTable(
     7905    psDB            *dbh                ///< Database handle
     7906);
     7907
     7908/** Deletes a p4bDiffScfile table
     7909 *
     7910 * @return true on success
     7911 */
     7912
     7913bool 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
     7924bool 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
     7941long 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
     7954bool 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
     7966bool 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
     7981bool 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
     7996bool 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
     8008psMetadata *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
     8017p4bDiffScfileRow *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
     8027psArray *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
     8040bool 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
     8052long 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
     8065bool 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
     8078bool 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
     8088typedef 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
     8100p4cRunRow *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
     8112bool p4cRunCreateTable(
     8113    psDB            *dbh                ///< Database handle
     8114);
     8115
     8116/** Deletes a p4cRun table
     8117 *
     8118 * @return true on success
     8119 */
     8120
     8121bool 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
     8132bool 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
     8145long 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
     8158bool 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
     8170bool 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
     8185bool 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
     8200bool 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
     8212psMetadata *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
     8221p4cRunRow *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
     8231psArray *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
     8244bool 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
     8256long 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
     8269bool 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
     8282bool 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
     8292typedef 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
     8303p4cInputExpRow *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
     8314bool p4cInputExpCreateTable(
     8315    psDB            *dbh                ///< Database handle
     8316);
     8317
     8318/** Deletes a p4cInputExp table
     8319 *
     8320 * @return true on success
     8321 */
     8322
     8323bool 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
     8334bool 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
     8346long 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
     8359bool 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
     8371bool 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
     8386bool 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
     8401bool 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
     8413psMetadata *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
     8422p4cInputExpRow *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
     8432psArray *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
     8445bool 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
     8457long 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
     8470bool 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
     8483bool p4cInputExpPrintObject(
     8484    FILE            *stream,            ///< a stream
     8485    p4cInputExpRow *object,    ///< an p4cInputExpRow object
     8486    bool            mdcf                ///< format as mdconfig or simple
     8487);
    78948488/** p4MagicMaskImfileRow data structure
    78958489 *
     
    78988492
    78998493typedef struct {
    7900     psS32           p4_id;
     8494    psS32           p4c_id;
    79018495    char            *exp_tag;
    79028496    psS32           p3_version;
     
    79118505
    79128506p4MagicMaskImfileRow *p4MagicMaskImfileRowAlloc(
    7913     psS32           p4_id,
     8507    psS32           p4c_id,
    79148508    const char      *exp_tag,
    79158509    psS32           p3_version,
     
    79458539bool p4MagicMaskImfileInsert(
    79468540    psDB            *dbh,               ///< Database handle
    7947     psS32           p4_id,
     8541    psS32           p4c_id,
    79488542    const char      *exp_tag,
    79498543    psS32           p3_version,
     
    80998693    bool            mdcf                ///< format as mdconfig or simple
    81008694);
     8695/** skyCellRow data structure
     8696 *
     8697 * Structure for representing a single row of skyCell table data.
     8698 */
     8699
     8700typedef 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
     8718skyCellRow *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
     8736bool skyCellCreateTable(
     8737    psDB            *dbh                ///< Database handle
     8738);
     8739
     8740/** Deletes a skyCell table
     8741 *
     8742 * @return true on success
     8743 */
     8744
     8745bool 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
     8756bool 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
     8775long 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
     8788bool 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
     8800bool 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
     8815bool 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
     8830bool 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
     8842psMetadata *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
     8851skyCellRow *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
     8861psArray *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
     8874bool 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
     8886long 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
     8899bool 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
     8912bool 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
     8922typedef 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
     8934skyCellMapRow *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
     8946bool skyCellMapCreateTable(
     8947    psDB            *dbh                ///< Database handle
     8948);
     8949
     8950/** Deletes a skyCellMap table
     8951 *
     8952 * @return true on success
     8953 */
     8954
     8955bool 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
     8966bool 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
     8979long 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
     8992bool 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
     9004bool 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
     9019bool 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
     9034bool 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
     9046psMetadata *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
     9055skyCellMapRow *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
     9065psArray *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
     9078bool 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
     9090long 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
     9103bool 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
     9116bool skyCellMapPrintObject(
     9117    FILE            *stream,            ///< a stream
     9118    skyCellMapRow *object,    ///< an skyCellMapRow object
     9119    bool            mdcf                ///< format as mdconfig or simple
     9120);
    81019121
    81029122/// @}
     
    81069126#endif
    81079127
    8108 #endif // P4MAGICMASKIMFILE_DB_H
     9128#endif // SKYCELLMAP_DB_H
  • trunk/ippdb/tests/alloc.c

    r11193 r11679  
    1717        }
    1818
     19        if (!object->counter == 64) {
    1920            psFree(object);
    2021            exit(EXIT_FAILURE);
     
    399400            exit(EXIT_FAILURE);
    400401        }
     402        if (!object->fault == -16) {
    401403            psFree(object);
    402404            exit(EXIT_FAILURE);
     
    490492            exit(EXIT_FAILURE);
    491493        }
     494        if (!object->fault == -16) {
    492495            psFree(object);
    493496            exit(EXIT_FAILURE);
     
    691694            exit(EXIT_FAILURE);
    692695        }
     696        if (!object->fault == -16) {
    693697            psFree(object);
    694698            exit(EXIT_FAILURE);
     
    800804            exit(EXIT_FAILURE);
    801805        }
     806        if (!object->fault == -16) {
    802807            psFree(object);
    803808            exit(EXIT_FAILURE);
     
    10021007            exit(EXIT_FAILURE);
    10031008        }
     1009        if (!object->fault == -16) {
    10041010            psFree(object);
    10051011            exit(EXIT_FAILURE);
     
    10501056            exit(EXIT_FAILURE);
    10511057        }
     1058        if (!object->fault == -16) {
    10521059            psFree(object);
    10531060            exit(EXIT_FAILURE);
     
    10981105            exit(EXIT_FAILURE);
    10991106        }
     1107        if (!object->fault == -16) {
    11001108            psFree(object);
    11011109            exit(EXIT_FAILURE);
     
    11301138            exit(EXIT_FAILURE);
    11311139        }
     1140        if (!object->fault == -16) {
    11321141            psFree(object);
    11331142            exit(EXIT_FAILURE);
     
    11821191            exit(EXIT_FAILURE);
    11831192        }
     1193        if (!object->fault == -16) {
    11841194            psFree(object);
    11851195            exit(EXIT_FAILURE);
     
    12301240            exit(EXIT_FAILURE);
    12311241        }
     1242        if (!object->fault == -16) {
    12321243            psFree(object);
    12331244            exit(EXIT_FAILURE);
     
    12901301            exit(EXIT_FAILURE);
    12911302        }
     1303        if (!object->fault == -16) {
    12921304            psFree(object);
    12931305            exit(EXIT_FAILURE);
     
    13461358            exit(EXIT_FAILURE);
    13471359        }
     1360        if (!object->fault == -16) {
    13481361            psFree(object);
    13491362            exit(EXIT_FAILURE);
     
    13861399            exit(EXIT_FAILURE);
    13871400        }
    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) {
    14091419            psFree(object);
    14101420            exit(EXIT_FAILURE);
     
    14181428            exit(EXIT_FAILURE);
    14191429        }
    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) {
    14211473            psFree(object);
    14221474            exit(EXIT_FAILURE);
     
    14301482            exit(EXIT_FAILURE);
    14311483        }
    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         }
    14651484        if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) {
    14661485            psFree(object);
     
    14711490            exit(EXIT_FAILURE);
    14721491        }
     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        }
    14731694        if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) {
    14741695            psFree(object);
    14751696            exit(EXIT_FAILURE);
    14761697        }
    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)) {
    14991777            psFree(object);
    15001778            exit(EXIT_FAILURE);
    15011779        }
    15021780        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)) {
    16221781            psFree(object);
    16231782            exit(EXIT_FAILURE);
  • trunk/ippdb/tests/createtable.c

    r11045 r11679  
    478478        }
    479479
    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)) {
    541586            exit(EXIT_FAILURE);
    542587        }
     
    554599
    555600        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)) {
    556631            exit(EXIT_FAILURE);
    557632        }
  • trunk/ippdb/tests/dbcleanup.c

    r11045 r11679  
    66    psDB            *dbh;
    77
    8     dbh = psDBInit("localhost", "test", NULL, "test");
     8    dbh = psDBInit("localhost", "test", NULL, "test", 0);
    99    if (!dbh) {
    1010        exit(EXIT_FAILURE);
     
    4242    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detResidExp");
    4343    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");
    4952    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");
    5055
    5156    psDBCleanup(dbh);
  • trunk/ippdb/tests/dbsetup.c

    r11045 r11679  
    77    psDB            *dbh;
    88
    9     dbh = psDBInit("localhost", "test", NULL, "test");
     9    dbh = psDBInit("localhost", "test", NULL, "test", 0);
    1010    if (!dbh) {
    1111        exit(EXIT_FAILURE);
     
    106106    detRunSummaryCreateTable(dbh);
    107107
    108     p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4Run");
    109     p4RunCreateTable(dbh);
     108    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4aRun");
     109    p4aRunCreateTable(dbh);
    110110
    111     p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4InputImfile");
    112     p4InputImfileCreateTable(dbh);
     111    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4aInputExp");
     112    p4aInputExpCreateTable(dbh);
    113113
    114     p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4WarpedImfile");
    115     p4WarpedImfileCreateTable(dbh);
     114    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4aScfile");
     115    p4aScfileCreateTable(dbh);
    116116
    117     p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4StackedImfile");
    118     p4StackedImfileCreateTable(dbh);
     117    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4bRun");
     118    p4bRunCreateTable(dbh);
    119119
    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);
    122131
    123132    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4MagicMaskImfile");
    124133    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);
    125140
    126141    psDBCleanup(dbh);
  • trunk/ippdb/tests/droptable.c

    r11045 r11679  
    478478        }
    479479
    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)) {
    541586            exit(EXIT_FAILURE);
    542587        }
     
    554599
    555600        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)) {
    556631            exit(EXIT_FAILURE);
    557632        }
  • trunk/ippdb/tests/insert.c

    r11193 r11679  
    478478        }
    479479
    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)) {
    541586            exit(EXIT_FAILURE);
    542587        }
     
    554599
    555600        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")) {
    556631            exit(EXIT_FAILURE);
    557632        }
  • trunk/ippdb/tests/insertfits.c

    r11045 r11679  
    830830        }
    831831
    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)) {
    9371015            exit(EXIT_FAILURE);
    9381016        }
     
    9611039
    9621040        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)) {
    9631093            exit(EXIT_FAILURE);
    9641094        }
  • trunk/ippdb/tests/insertobject.c

    r11193 r11679  
    689689    {
    690690        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)) {
    792858            exit(EXIT_FAILURE);
    793859        }
     
    812878
    813879        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)) {
    814924            exit(EXIT_FAILURE);
    815925        }
  • trunk/ippdb/tests/metadatafromobject.c

    r11193 r11679  
    16431643    {
    16441644        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) {
    16651661            psFree(md);
    16661662            exit(EXIT_FAILURE);
     
    16741670            exit(EXIT_FAILURE);
    16751671        }
    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) {
    16771731            psFree(md);
    16781732            exit(EXIT_FAILURE);
     
    16861740            exit(EXIT_FAILURE);
    16871741        }
    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         }
    17291742        if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) {
    17301743            psFree(md);
     
    17351748            exit(EXIT_FAILURE);
    17361749        }
     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        }
    17372000        if (strncmp(psMetadataLookupPtr(&status, md, "class_id"), "a string", MAX_STRING_LENGTH)) {
    17382001            psFree(md);
    17392002            exit(EXIT_FAILURE);
    17402003        }
    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)) {
    17712099            psFree(md);
    17722100            exit(EXIT_FAILURE);
    17732101        }
    17742102        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)) {
    19182103            psFree(md);
    19192104            exit(EXIT_FAILURE);
  • trunk/ippdb/tests/objectfrommetadata.c

    r11193 r11679  
    25322532    {
    25332533        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)) {
    25422538            psFree(md);
    25432539            exit(EXIT_FAILURE);
     
    25512547            exit(EXIT_FAILURE);
    25522548        }
    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)) {
    25542630            psFree(md);
    25552631            exit(EXIT_FAILURE);
     
    25632639            exit(EXIT_FAILURE);
    25642640        }
    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) {
    25952737            psFree(object);
    25962738            exit(EXIT_FAILURE);
     
    26042746            exit(EXIT_FAILURE);
    26052747        }
    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) {
    26072795            psFree(object);
    26082796            exit(EXIT_FAILURE);
     
    26162804            exit(EXIT_FAILURE);
    26172805        }
    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")) {
    26442836            psFree(md);
    26452837            exit(EXIT_FAILURE);
     
    26532845            exit(EXIT_FAILURE);
    26542846        }
     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        }
    26553013        if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "a string")) {
    26563014            psFree(md);
    26573015            exit(EXIT_FAILURE);
    26583016        }
    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) {
    26693031            psFree(object);
    26703032            exit(EXIT_FAILURE);
     
    26823044            exit(EXIT_FAILURE);
    26833045        }
    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")) {
    26943162            psFree(md);
    26953163            exit(EXIT_FAILURE);
     
    26993167            exit(EXIT_FAILURE);
    27003168        }
    2701         if (!psMetadataAddS32(md, PS_LIST_TAIL, "p3_version", 0, NULL, -32)) {
    2702             psFree(md);
    2703             exit(EXIT_FAILURE);
    2704         }
    27053169        if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "a string")) {
    27063170            psFree(md);
    27073171            exit(EXIT_FAILURE);
    27083172        }
    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)) {
    27313187            psFree(object);
    27323188            exit(EXIT_FAILURE);
     
    27363192            exit(EXIT_FAILURE);
    27373193        }
    2738         if (!object->p3_version == -32) {
    2739             psFree(object);
    2740             exit(EXIT_FAILURE);
    2741         }
    27423194        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)) {
    29453195            psFree(object);
    29463196            exit(EXIT_FAILURE);
  • trunk/ippdb/tests/selectrowsfits.c

    r11045 r11679  
    703703        }
    704704
    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)) {
    794860            exit(EXIT_FAILURE);
    795861        }
     
    814880
    815881        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)) {
    816926            exit(EXIT_FAILURE);
    817927        }
Note: See TracChangeset for help on using the changeset viewer.