Changeset 18044
- Timestamp:
- Jun 9, 2008, 5:11:49 PM (18 years ago)
- Location:
- trunk/ippdb
- Files:
-
- 14 edited
-
Makefile.am (modified) (2 diffs)
-
src/ippdb.c (modified) (28 diffs)
-
src/ippdb.h (modified) (10 diffs)
-
tests/alloc.c (modified) (6 diffs)
-
tests/createtable.c (modified) (1 diff)
-
tests/dbcleanup.c (modified) (1 diff)
-
tests/dbsetup.c (modified) (1 diff)
-
tests/droptable.c (modified) (1 diff)
-
tests/insert.c (modified) (3 diffs)
-
tests/insertfits.c (modified) (1 diff)
-
tests/insertobject.c (modified) (3 diffs)
-
tests/metadatafromobject.c (modified) (5 diffs)
-
tests/objectfrommetadata.c (modified) (5 diffs)
-
tests/selectrowsfits.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippdb/Makefile.am
r17144 r18044 26 26 $(top_builddir)/docs/man/man3/camProcessedExpRow.3 \ 27 27 $(top_builddir)/docs/man/man3/camMaskRow.3 \ 28 $(top_builddir)/docs/man/man3/fakeRunRow.3 \ 29 $(top_builddir)/docs/man/man3/fakeProcessedImfileRow.3 \ 30 $(top_builddir)/docs/man/man3/fakeMaskRow.3 \ 28 31 $(top_builddir)/docs/man/man3/warpRunRow.3 \ 29 32 $(top_builddir)/docs/man/man3/warpSkyCellMapRow.3 \ … … 65 68 66 69 67 docs/man/man3/ippdb.3 docs/man/man3/pzDataStoreRow.3 docs/man/man3/summitExpRow.3 docs/man/man3/summitImfileRow.3 docs/man/man3/pzDownloadExpRow.3 docs/man/man3/pzDownloadImfileRow.3 docs/man/man3/newExpRow.3 docs/man/man3/newImfileRow.3 docs/man/man3/rawExpRow.3 docs/man/man3/rawImfileRow.3 docs/man/man3/guidePendingExpRow.3 docs/man/man3/chipRunRow.3 docs/man/man3/chipProcessedImfileRow.3 docs/man/man3/chipMaskRow.3 docs/man/man3/camRunRow.3 docs/man/man3/camProcessedExpRow.3 docs/man/man3/camMaskRow.3 docs/man/man3/ warpRunRow.3 docs/man/man3/warpSkyCellMapRow.3 docs/man/man3/warpSkyfileRow.3 docs/man/man3/warpMaskRow.3 docs/man/man3/diffRunRow.3 docs/man/man3/diffInputSkyfileRow.3 docs/man/man3/diffSkyfileRow.3 docs/man/man3/stackRunRow.3 docs/man/man3/stackInputSkyfileRow.3 docs/man/man3/stackSumSkyfileRow.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/detRegisteredImfileRow.3 docs/man/man3/detCorrectedExpRow.3 docs/man/man3/detCorrectedImfileRow.3 docs/man/man3/magicRunRow.3 docs/man/man3/magicInputSkyfileRow.3 docs/man/man3/magicTreeRow.3 docs/man/man3/magicNodeResultRow.3 docs/man/man3/magicMaskRow.3 docs/man/man3/magicSkyfileMaskRow.3 docs/man/man3/calDBRow.3 docs/man/man3/calRunRow.3 docs/man/man3/flatcorrRunRow.3 docs/man/man3/flatcorrExpRow.3 docs/man/man3/pstampDataStoreRow.3 docs/man/man3/pstampRequestRow.3 docs/man/man3/pstampJobRow.3:70 docs/man/man3/ippdb.3 docs/man/man3/pzDataStoreRow.3 docs/man/man3/summitExpRow.3 docs/man/man3/summitImfileRow.3 docs/man/man3/pzDownloadExpRow.3 docs/man/man3/pzDownloadImfileRow.3 docs/man/man3/newExpRow.3 docs/man/man3/newImfileRow.3 docs/man/man3/rawExpRow.3 docs/man/man3/rawImfileRow.3 docs/man/man3/guidePendingExpRow.3 docs/man/man3/chipRunRow.3 docs/man/man3/chipProcessedImfileRow.3 docs/man/man3/chipMaskRow.3 docs/man/man3/camRunRow.3 docs/man/man3/camProcessedExpRow.3 docs/man/man3/camMaskRow.3 docs/man/man3/fakeRunRow.3 docs/man/man3/fakeProcessedImfileRow.3 docs/man/man3/fakeMaskRow.3 docs/man/man3/warpRunRow.3 docs/man/man3/warpSkyCellMapRow.3 docs/man/man3/warpSkyfileRow.3 docs/man/man3/warpMaskRow.3 docs/man/man3/diffRunRow.3 docs/man/man3/diffInputSkyfileRow.3 docs/man/man3/diffSkyfileRow.3 docs/man/man3/stackRunRow.3 docs/man/man3/stackInputSkyfileRow.3 docs/man/man3/stackSumSkyfileRow.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/detRegisteredImfileRow.3 docs/man/man3/detCorrectedExpRow.3 docs/man/man3/detCorrectedImfileRow.3 docs/man/man3/magicRunRow.3 docs/man/man3/magicInputSkyfileRow.3 docs/man/man3/magicTreeRow.3 docs/man/man3/magicNodeResultRow.3 docs/man/man3/magicMaskRow.3 docs/man/man3/magicSkyfileMaskRow.3 docs/man/man3/calDBRow.3 docs/man/man3/calRunRow.3 docs/man/man3/flatcorrRunRow.3 docs/man/man3/flatcorrExpRow.3 docs/man/man3/pstampDataStoreRow.3 docs/man/man3/pstampRequestRow.3 docs/man/man3/pstampJobRow.3: 68 71 $(DOXYGEN) 69 72 -
trunk/ippdb/src/ippdb.c
r17872 r18044 47 47 #define CAMPROCESSEDEXP_TABLE_NAME "camProcessedExp" 48 48 #define CAMMASK_TABLE_NAME "camMask" 49 #define FAKERUN_TABLE_NAME "fakeRun" 50 #define FAKEPROCESSEDIMFILE_TABLE_NAME "fakeProcessedImfile" 51 #define FAKEMASK_TABLE_NAME "fakeMask" 49 52 #define WARPRUN_TABLE_NAME "warpRun" 50 53 #define WARPSKYCELLMAP_TABLE_NAME "warpSkyCellMap" … … 8617 8620 static void camProcessedExpRowFree(camProcessedExpRow *object); 8618 8621 8619 camProcessedExpRow *camProcessedExpRowAlloc(psS64 cam_id, psS64 chip_id,const char *uri, psF32 bg, psF32 bg_stdev, psF32 bg_mean_stdev, psF32 bias, psF32 bias_stdev, psF32 fringe_0, psF32 fringe_1, psF32 fringe_2, psF32 sigma_ra, psF32 sigma_dec, psF32 ap_resid, psF32 ap_resid_stdev, psF32 zp_mean, psF32 zp_stdev, psF32 fwhm_major, psF32 fwhm_minor, psF32 dtime_detrend, psF32 dtime_photom, psF32 dtime_astrom, const char *hostname, psS32 n_stars, psS32 n_extended, psS32 n_cr, psS32 n_astrom, const char *path_base, psS16 fault)8622 camProcessedExpRow *camProcessedExpRowAlloc(psS64 cam_id, const char *uri, psF32 bg, psF32 bg_stdev, psF32 bg_mean_stdev, psF32 bias, psF32 bias_stdev, psF32 fringe_0, psF32 fringe_1, psF32 fringe_2, psF32 sigma_ra, psF32 sigma_dec, psF32 ap_resid, psF32 ap_resid_stdev, psF32 zp_mean, psF32 zp_stdev, psF32 fwhm_major, psF32 fwhm_minor, psF32 dtime_detrend, psF32 dtime_photom, psF32 dtime_astrom, const char *hostname, psS32 n_stars, psS32 n_extended, psS32 n_cr, psS32 n_astrom, const char *path_base, psS16 fault) 8620 8623 { 8621 8624 camProcessedExpRow *_object; … … 8625 8628 8626 8629 _object->cam_id = cam_id; 8627 _object->chip_id = chip_id;8628 8630 _object->uri = psStringCopy(uri); 8629 8631 _object->bg = bg; … … 8672 8674 return false; 8673 8675 } 8674 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, "Primary Key fkey(cam_id, chip_id) ref camRun(cam_id, chip_id)", 0)) { 8675 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 8676 psFree(md); 8677 return false; 8678 } 8679 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, "255")) { 8676 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, "fkey(cam_id) ref camRun(cam_id)", "255")) { 8680 8677 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 8681 8678 psFree(md); … … 8825 8822 } 8826 8823 8827 bool camProcessedExpInsert(psDB * dbh, psS64 cam_id, psS64 chip_id,const char *uri, psF32 bg, psF32 bg_stdev, psF32 bg_mean_stdev, psF32 bias, psF32 bias_stdev, psF32 fringe_0, psF32 fringe_1, psF32 fringe_2, psF32 sigma_ra, psF32 sigma_dec, psF32 ap_resid, psF32 ap_resid_stdev, psF32 zp_mean, psF32 zp_stdev, psF32 fwhm_major, psF32 fwhm_minor, psF32 dtime_detrend, psF32 dtime_photom, psF32 dtime_astrom, const char *hostname, psS32 n_stars, psS32 n_extended, psS32 n_cr, psS32 n_astrom, const char *path_base, psS16 fault)8824 bool camProcessedExpInsert(psDB * dbh, psS64 cam_id, const char *uri, psF32 bg, psF32 bg_stdev, psF32 bg_mean_stdev, psF32 bias, psF32 bias_stdev, psF32 fringe_0, psF32 fringe_1, psF32 fringe_2, psF32 sigma_ra, psF32 sigma_dec, psF32 ap_resid, psF32 ap_resid_stdev, psF32 zp_mean, psF32 zp_stdev, psF32 fwhm_major, psF32 fwhm_minor, psF32 dtime_detrend, psF32 dtime_photom, psF32 dtime_astrom, const char *hostname, psS32 n_stars, psS32 n_extended, psS32 n_cr, psS32 n_astrom, const char *path_base, psS16 fault) 8828 8825 { 8829 8826 psMetadata *md = psMetadataAlloc(); 8830 8827 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, NULL, cam_id)) { 8831 8828 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id"); 8832 psFree(md);8833 return false;8834 }8835 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, NULL, chip_id)) {8836 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id");8837 8829 psFree(md); 8838 8830 return false; … … 8996 8988 bool camProcessedExpInsertObject(psDB *dbh, camProcessedExpRow *object) 8997 8989 { 8998 return camProcessedExpInsert(dbh, object->cam_id, object-> chip_id, object->uri, object->bg, object->bg_stdev, object->bg_mean_stdev, object->bias, object->bias_stdev, object->fringe_0, object->fringe_1, object->fringe_2, object->sigma_ra, object->sigma_dec, object->ap_resid, object->ap_resid_stdev, object->zp_mean, object->zp_stdev, object->fwhm_major, object->fwhm_minor, object->dtime_detrend, object->dtime_photom, object->dtime_astrom, object->hostname, object->n_stars, object->n_extended, object->n_cr, object->n_astrom, object->path_base, object->fault);8990 return camProcessedExpInsert(dbh, object->cam_id, object->uri, object->bg, object->bg_stdev, object->bg_mean_stdev, object->bias, object->bias_stdev, object->fringe_0, object->fringe_1, object->fringe_2, object->sigma_ra, object->sigma_dec, object->ap_resid, object->ap_resid_stdev, object->zp_mean, object->zp_stdev, object->fwhm_major, object->fwhm_minor, object->dtime_detrend, object->dtime_photom, object->dtime_astrom, object->hostname, object->n_stars, object->n_extended, object->n_cr, object->n_astrom, object->path_base, object->fault); 8999 8991 } 9000 8992 … … 9074 9066 return false; 9075 9067 } 9076 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, NULL, object->chip_id)) {9077 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id");9078 psFree(md);9079 return false;9080 }9081 9068 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, object->uri)) { 9082 9069 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); … … 9228 9215 return false; 9229 9216 } 9230 psS64 chip_id = psMetadataLookupS64(&status, md, "chip_id");9231 if (!status) {9232 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item chip_id");9233 return false;9234 }9235 9217 char* uri = psMetadataLookupPtr(&status, md, "uri"); 9236 9218 if (!status) { … … 9369 9351 } 9370 9352 9371 return camProcessedExpRowAlloc(cam_id, chip_id,uri, bg, bg_stdev, bg_mean_stdev, bias, bias_stdev, fringe_0, fringe_1, fringe_2, sigma_ra, sigma_dec, ap_resid, ap_resid_stdev, zp_mean, zp_stdev, fwhm_major, fwhm_minor, dtime_detrend, dtime_photom, dtime_astrom, hostname, n_stars, n_extended, n_cr, n_astrom, path_base, fault);9353 return camProcessedExpRowAlloc(cam_id, uri, bg, bg_stdev, bg_mean_stdev, bias, bias_stdev, fringe_0, fringe_1, fringe_2, sigma_ra, sigma_dec, ap_resid, ap_resid_stdev, zp_mean, zp_stdev, fwhm_major, fwhm_minor, dtime_detrend, dtime_photom, dtime_astrom, hostname, n_stars, n_extended, n_cr, n_astrom, path_base, fault); 9372 9354 } 9373 9355 psArray *camProcessedExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 9765 9747 return true; 9766 9748 } 9749 static void fakeRunRowFree(fakeRunRow *object); 9750 9751 fakeRunRow *fakeRunRowAlloc(psS64 fake_id, psS64 cam_id, const char *state, const char *workdir, const char *label, const char *reduction, const char *expgroup, const char *dvodb, const char *tess_id, const char *end_stage, psTime* epoch) 9752 { 9753 fakeRunRow *_object; 9754 9755 _object = psAlloc(sizeof(fakeRunRow)); 9756 psMemSetDeallocator(_object, (psFreeFunc)fakeRunRowFree); 9757 9758 _object->fake_id = fake_id; 9759 _object->cam_id = cam_id; 9760 _object->state = psStringCopy(state); 9761 _object->workdir = psStringCopy(workdir); 9762 _object->label = psStringCopy(label); 9763 _object->reduction = psStringCopy(reduction); 9764 _object->expgroup = psStringCopy(expgroup); 9765 _object->dvodb = psStringCopy(dvodb); 9766 _object->tess_id = psStringCopy(tess_id); 9767 _object->end_stage = psStringCopy(end_stage); 9768 _object->epoch = psTimeCopy(epoch); 9769 9770 return _object; 9771 } 9772 9773 static void fakeRunRowFree(fakeRunRow *object) 9774 { 9775 psFree(object->state); 9776 psFree(object->workdir); 9777 psFree(object->label); 9778 psFree(object->reduction); 9779 psFree(object->expgroup); 9780 psFree(object->dvodb); 9781 psFree(object->tess_id); 9782 psFree(object->end_stage); 9783 psFree(object->epoch); 9784 } 9785 9786 bool fakeRunCreateTable(psDB *dbh) 9787 { 9788 psMetadata *md = psMetadataAlloc(); 9789 if (!psMetadataAdd(md, PS_LIST_TAIL, "fake_id", PS_DATA_S64, "Primary Key AUTO_INCREMENT", 0)) { 9790 psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id"); 9791 psFree(md); 9792 return false; 9793 } 9794 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, "Key INDEX(fake_id, cam_id) fkey (cam_id) ref camRun(cam_id)", 0)) { 9795 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id"); 9796 psFree(md); 9797 return false; 9798 } 9799 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, "Key", "64")) { 9800 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 9801 psFree(md); 9802 return false; 9803 } 9804 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, "255")) { 9805 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 9806 psFree(md); 9807 return false; 9808 } 9809 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, "Key", "64")) { 9810 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); 9811 psFree(md); 9812 return false; 9813 } 9814 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, "Reduction class", "64")) { 9815 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction"); 9816 psFree(md); 9817 return false; 9818 } 9819 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, "Key", "64")) { 9820 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup"); 9821 psFree(md); 9822 return false; 9823 } 9824 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, "255")) { 9825 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb"); 9826 psFree(md); 9827 return false; 9828 } 9829 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, "64")) { 9830 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 9831 psFree(md); 9832 return false; 9833 } 9834 if (!psMetadataAdd(md, PS_LIST_TAIL, "end_stage", PS_DATA_STRING, "Key", "64")) { 9835 psError(PS_ERR_UNKNOWN, false, "failed to add item end_stage"); 9836 psFree(md); 9837 return false; 9838 } 9839 if (!psMetadataAdd(md, PS_LIST_TAIL, "epoch", PS_DATA_TIME, NULL, NULL)) { 9840 psError(PS_ERR_UNKNOWN, false, "failed to add item epoch"); 9841 psFree(md); 9842 return false; 9843 } 9844 9845 bool status = psDBCreateTable(dbh, FAKERUN_TABLE_NAME, md); 9846 9847 psFree(md); 9848 9849 return status; 9850 } 9851 9852 bool fakeRunDropTable(psDB *dbh) 9853 { 9854 return psDBDropTable(dbh, FAKERUN_TABLE_NAME); 9855 } 9856 9857 bool fakeRunInsert(psDB * dbh, psS64 fake_id, psS64 cam_id, const char *state, const char *workdir, const char *label, const char *reduction, const char *expgroup, const char *dvodb, const char *tess_id, const char *end_stage, psTime* epoch) 9858 { 9859 psMetadata *md = psMetadataAlloc(); 9860 if (!psMetadataAdd(md, PS_LIST_TAIL, "fake_id", PS_DATA_S64, NULL, fake_id)) { 9861 psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id"); 9862 psFree(md); 9863 return false; 9864 } 9865 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, NULL, cam_id)) { 9866 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id"); 9867 psFree(md); 9868 return false; 9869 } 9870 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, state)) { 9871 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 9872 psFree(md); 9873 return false; 9874 } 9875 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, workdir)) { 9876 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 9877 psFree(md); 9878 return false; 9879 } 9880 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, label)) { 9881 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); 9882 psFree(md); 9883 return false; 9884 } 9885 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, reduction)) { 9886 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction"); 9887 psFree(md); 9888 return false; 9889 } 9890 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, NULL, expgroup)) { 9891 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup"); 9892 psFree(md); 9893 return false; 9894 } 9895 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, dvodb)) { 9896 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb"); 9897 psFree(md); 9898 return false; 9899 } 9900 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, tess_id)) { 9901 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 9902 psFree(md); 9903 return false; 9904 } 9905 if (!psMetadataAdd(md, PS_LIST_TAIL, "end_stage", PS_DATA_STRING, NULL, end_stage)) { 9906 psError(PS_ERR_UNKNOWN, false, "failed to add item end_stage"); 9907 psFree(md); 9908 return false; 9909 } 9910 if (!psMetadataAdd(md, PS_LIST_TAIL, "epoch", PS_DATA_TIME, NULL, epoch)) { 9911 psError(PS_ERR_UNKNOWN, false, "failed to add item epoch"); 9912 psFree(md); 9913 return false; 9914 } 9915 9916 bool status = psDBInsertOneRow(dbh, FAKERUN_TABLE_NAME, md); 9917 psFree(md); 9918 9919 return status; 9920 } 9921 9922 long long fakeRunDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 9923 { 9924 long long deleted = 0; 9925 9926 long long count = psDBDeleteRows(dbh, FAKERUN_TABLE_NAME, where, limit); 9927 if (count < 0) { 9928 psError(PS_ERR_UNKNOWN, true, "failed to delete row from fakeRun"); 9929 return count; 9930 9931 deleted += count; 9932 } 9933 9934 return deleted; 9935 } 9936 bool fakeRunInsertObject(psDB *dbh, fakeRunRow *object) 9937 { 9938 return fakeRunInsert(dbh, object->fake_id, object->cam_id, object->state, object->workdir, object->label, object->reduction, object->expgroup, object->dvodb, object->tess_id, object->end_stage, object->epoch); 9939 } 9940 9941 bool fakeRunInsertObjects(psDB *dbh, psArray *objects) 9942 { 9943 for (long i = 0; i < psArrayLength(objects); i++) { 9944 if (!fakeRunInsertObject(dbh, objects->data[i])) { 9945 return false; 9946 } 9947 } 9948 9949 return true; 9950 } 9951 9952 bool fakeRunInsertFits(psDB *dbh, const psFits *fits) 9953 { 9954 psArray *rowSet; 9955 9956 // move to (the first?) extension named FAKERUN_TABLE_NAME 9957 if (!psFitsMoveExtName(fits, FAKERUN_TABLE_NAME)) { 9958 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", FAKERUN_TABLE_NAME); 9959 return false; 9960 } 9961 9962 // check HDU type 9963 if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE) { 9964 psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE"); 9965 return false; 9966 } 9967 9968 // read fits table 9969 rowSet = psFitsReadTable(fits); 9970 if (!rowSet) { 9971 psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty"); 9972 psFree(rowSet); 9973 return false; 9974 } 9975 9976 if (!psDBInsertRows(dbh, FAKERUN_TABLE_NAME, rowSet)) { 9977 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 9978 psFree(rowSet); 9979 return false; 9980 } 9981 9982 psFree(rowSet); 9983 9984 return true; 9985 } 9986 9987 bool fakeRunSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 9988 { 9989 psArray *rowSet; 9990 9991 rowSet = psDBSelectRows(dbh, FAKERUN_TABLE_NAME, where, limit); 9992 if (!rowSet) { 9993 return false; 9994 } 9995 9996 // output to fits 9997 if (!psFitsWriteTable(fits, NULL, rowSet, FAKERUN_TABLE_NAME)) { 9998 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 9999 psFree(rowSet); 10000 return false; 10001 } 10002 10003 psFree(rowSet); 10004 10005 return true; 10006 } 10007 10008 psMetadata *fakeRunMetadataFromObject(const fakeRunRow *object) 10009 { 10010 psMetadata *md = psMetadataAlloc(); 10011 if (!psMetadataAdd(md, PS_LIST_TAIL, "fake_id", PS_DATA_S64, NULL, object->fake_id)) { 10012 psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id"); 10013 psFree(md); 10014 return false; 10015 } 10016 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, NULL, object->cam_id)) { 10017 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id"); 10018 psFree(md); 10019 return false; 10020 } 10021 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, object->state)) { 10022 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 10023 psFree(md); 10024 return false; 10025 } 10026 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, object->workdir)) { 10027 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 10028 psFree(md); 10029 return false; 10030 } 10031 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, object->label)) { 10032 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); 10033 psFree(md); 10034 return false; 10035 } 10036 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, object->reduction)) { 10037 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction"); 10038 psFree(md); 10039 return false; 10040 } 10041 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, NULL, object->expgroup)) { 10042 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup"); 10043 psFree(md); 10044 return false; 10045 } 10046 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, object->dvodb)) { 10047 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb"); 10048 psFree(md); 10049 return false; 10050 } 10051 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, object->tess_id)) { 10052 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 10053 psFree(md); 10054 return false; 10055 } 10056 if (!psMetadataAdd(md, PS_LIST_TAIL, "end_stage", PS_DATA_STRING, NULL, object->end_stage)) { 10057 psError(PS_ERR_UNKNOWN, false, "failed to add item end_stage"); 10058 psFree(md); 10059 return false; 10060 } 10061 if (!psMetadataAdd(md, PS_LIST_TAIL, "epoch", PS_DATA_TIME, NULL, object->epoch)) { 10062 psError(PS_ERR_UNKNOWN, false, "failed to add item epoch"); 10063 psFree(md); 10064 return false; 10065 } 10066 10067 10068 return md; 10069 } 10070 10071 fakeRunRow *fakeRunObjectFromMetadata(psMetadata *md) 10072 { 10073 10074 bool status = false; 10075 psS64 fake_id = psMetadataLookupS64(&status, md, "fake_id"); 10076 if (!status) { 10077 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item fake_id"); 10078 return false; 10079 } 10080 psS64 cam_id = psMetadataLookupS64(&status, md, "cam_id"); 10081 if (!status) { 10082 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item cam_id"); 10083 return false; 10084 } 10085 char* state = psMetadataLookupPtr(&status, md, "state"); 10086 if (!status) { 10087 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item state"); 10088 return false; 10089 } 10090 char* workdir = psMetadataLookupPtr(&status, md, "workdir"); 10091 if (!status) { 10092 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item workdir"); 10093 return false; 10094 } 10095 char* label = psMetadataLookupPtr(&status, md, "label"); 10096 if (!status) { 10097 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item label"); 10098 return false; 10099 } 10100 char* reduction = psMetadataLookupPtr(&status, md, "reduction"); 10101 if (!status) { 10102 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item reduction"); 10103 return false; 10104 } 10105 char* expgroup = psMetadataLookupPtr(&status, md, "expgroup"); 10106 if (!status) { 10107 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item expgroup"); 10108 return false; 10109 } 10110 char* dvodb = psMetadataLookupPtr(&status, md, "dvodb"); 10111 if (!status) { 10112 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item dvodb"); 10113 return false; 10114 } 10115 char* tess_id = psMetadataLookupPtr(&status, md, "tess_id"); 10116 if (!status) { 10117 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item tess_id"); 10118 return false; 10119 } 10120 char* end_stage = psMetadataLookupPtr(&status, md, "end_stage"); 10121 if (!status) { 10122 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item end_stage"); 10123 return false; 10124 } 10125 psTime* epoch = psMetadataLookupPtr(&status, md, "epoch"); 10126 if (!status) { 10127 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item epoch"); 10128 return false; 10129 } 10130 10131 return fakeRunRowAlloc(fake_id, cam_id, state, workdir, label, reduction, expgroup, dvodb, tess_id, end_stage, epoch); 10132 } 10133 psArray *fakeRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 10134 { 10135 psArray *rowSet; 10136 psArray *returnSet; 10137 psU64 i; 10138 10139 rowSet = psDBSelectRows(dbh, FAKERUN_TABLE_NAME, where, limit); 10140 if (!rowSet) { 10141 return NULL; 10142 } 10143 10144 // convert psMetadata rows to row objects 10145 10146 returnSet = psArrayAllocEmpty(rowSet->n); 10147 10148 for (i = 0; i < rowSet->n; i++) { 10149 fakeRunRow *object = fakeRunObjectFromMetadata(rowSet->data[i]); 10150 if (!object) { 10151 psFree(object); 10152 psFree(returnSet); 10153 psError(PS_ERR_UNKNOWN, false, "database error"); 10154 return NULL; 10155 } 10156 psArrayAdd(returnSet, 0, object); 10157 psFree(object); 10158 } 10159 10160 psFree(rowSet); 10161 10162 return returnSet; 10163 } 10164 bool fakeRunDeleteObject(psDB *dbh, const fakeRunRow *object) 10165 { 10166 psMetadata *where = fakeRunMetadataFromObject(object); 10167 long long count = psDBDeleteRows(dbh, FAKERUN_TABLE_NAME, where, 0); 10168 psFree(where); 10169 if (count < 0) { 10170 psError(PS_ERR_UNKNOWN, true, "failed to delete row from fakeRun"); 10171 return false; 10172 } 10173 if (count > 1) { 10174 // XXX should this be a psAbort() instead? It is possible that 10175 // having an object match multiple rows was by design. 10176 psError(PS_ERR_UNKNOWN, true, "fakeRunRow object matched more then one row. Check your database schema"); 10177 return false; 10178 } 10179 10180 return true; 10181 } 10182 long long fakeRunDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 10183 { 10184 long long deleted = 0; 10185 10186 for (long long i = 0; i < objects->n; i++) { 10187 fakeRunRow *object = objects->data[i]; 10188 psMetadata *where = fakeRunMetadataFromObject(object); 10189 long long count = psDBDeleteRows(dbh, FAKERUN_TABLE_NAME, where, limit); 10190 psFree(where); 10191 if (count < 0) { 10192 psError(PS_ERR_UNKNOWN, true, "failed to delete row from fakeRun"); 10193 return count; 10194 } 10195 10196 deleted += count; 10197 } 10198 10199 return deleted; 10200 } 10201 bool fakeRunPrintObjects(FILE *stream, psArray *objects, bool mdcf) 10202 { 10203 PS_ASSERT_PTR_NON_NULL(objects, false); 10204 10205 psMetadata *output = psMetadataAlloc(); 10206 for (long i = 0; i < psArrayLength(objects); i++) { 10207 psMetadata *md = fakeRunMetadataFromObject(objects->data[i]); 10208 if (!psMetadataAddMetadata( 10209 output, 10210 PS_LIST_TAIL, 10211 FAKERUN_TABLE_NAME, 10212 PS_META_DUPLICATE_OK, 10213 NULL, 10214 md 10215 )) { 10216 psError(PS_ERR_UNKNOWN, false, "failed to add metadata"); 10217 psFree(md); 10218 psFree(output); 10219 return false; 10220 } 10221 psFree(md); 10222 } 10223 10224 if (!ippdbPrintMetadataRaw(stream, output, mdcf)) { 10225 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 10226 psFree(output); 10227 } 10228 psFree(output); 10229 10230 return true; 10231 } 10232 bool fakeRunPrintObject(FILE *stream, fakeRunRow *object, bool mdcf) 10233 { 10234 PS_ASSERT_PTR_NON_NULL(object, false); 10235 10236 psMetadata *md = fakeRunMetadataFromObject(object); 10237 10238 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { 10239 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 10240 psFree(md); 10241 } 10242 10243 psFree(md); 10244 10245 return true; 10246 } 10247 static void fakeProcessedImfileRowFree(fakeProcessedImfileRow *object); 10248 10249 fakeProcessedImfileRow *fakeProcessedImfileRowAlloc(psS64 fake_id, psS64 exp_id, const char *class_id, const char *uri, psF32 dtime_fake, const char *hostname, const char *path_base, psS16 fault, psTime* epoch) 10250 { 10251 fakeProcessedImfileRow *_object; 10252 10253 _object = psAlloc(sizeof(fakeProcessedImfileRow)); 10254 psMemSetDeallocator(_object, (psFreeFunc)fakeProcessedImfileRowFree); 10255 10256 _object->fake_id = fake_id; 10257 _object->exp_id = exp_id; 10258 _object->class_id = psStringCopy(class_id); 10259 _object->uri = psStringCopy(uri); 10260 _object->dtime_fake = dtime_fake; 10261 _object->hostname = psStringCopy(hostname); 10262 _object->path_base = psStringCopy(path_base); 10263 _object->fault = fault; 10264 _object->epoch = psTimeCopy(epoch); 10265 10266 return _object; 10267 } 10268 10269 static void fakeProcessedImfileRowFree(fakeProcessedImfileRow *object) 10270 { 10271 psFree(object->class_id); 10272 psFree(object->uri); 10273 psFree(object->hostname); 10274 psFree(object->path_base); 10275 psFree(object->epoch); 10276 } 10277 10278 bool fakeProcessedImfileCreateTable(psDB *dbh) 10279 { 10280 psMetadata *md = psMetadataAlloc(); 10281 if (!psMetadataAdd(md, PS_LIST_TAIL, "fake_id", PS_DATA_S64, "Primary Key fkey (fake_id) ref fakeRun(fake_id)", 0)) { 10282 psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id"); 10283 psFree(md); 10284 return false; 10285 } 10286 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Primary Key fkey (exp_id, class_id) ref rawImfile(exp_id, class_id)", 64)) { 10287 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 10288 psFree(md); 10289 return false; 10290 } 10291 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, "Primary Key", "64")) { 10292 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 10293 psFree(md); 10294 return false; 10295 } 10296 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, "255")) { 10297 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 10298 psFree(md); 10299 return false; 10300 } 10301 if (!psMetadataAdd(md, PS_LIST_TAIL, "dtime_fake", PS_DATA_F32, NULL, 0.0)) { 10302 psError(PS_ERR_UNKNOWN, false, "failed to add item dtime_fake"); 10303 psFree(md); 10304 return false; 10305 } 10306 if (!psMetadataAdd(md, PS_LIST_TAIL, "hostname", PS_DATA_STRING, NULL, "64")) { 10307 psError(PS_ERR_UNKNOWN, false, "failed to add item hostname"); 10308 psFree(md); 10309 return false; 10310 } 10311 if (!psMetadataAdd(md, PS_LIST_TAIL, "path_base", PS_DATA_STRING, NULL, "255")) { 10312 psError(PS_ERR_UNKNOWN, false, "failed to add item path_base"); 10313 psFree(md); 10314 return false; 10315 } 10316 if (!psMetadataAdd(md, PS_LIST_TAIL, "fault", PS_DATA_S16, "Key NOT NULL", 0)) { 10317 psError(PS_ERR_UNKNOWN, false, "failed to add item fault"); 10318 psFree(md); 10319 return false; 10320 } 10321 if (!psMetadataAdd(md, PS_LIST_TAIL, "epoch", PS_DATA_TIME, NULL, NULL)) { 10322 psError(PS_ERR_UNKNOWN, false, "failed to add item epoch"); 10323 psFree(md); 10324 return false; 10325 } 10326 10327 bool status = psDBCreateTable(dbh, FAKEPROCESSEDIMFILE_TABLE_NAME, md); 10328 10329 psFree(md); 10330 10331 return status; 10332 } 10333 10334 bool fakeProcessedImfileDropTable(psDB *dbh) 10335 { 10336 return psDBDropTable(dbh, FAKEPROCESSEDIMFILE_TABLE_NAME); 10337 } 10338 10339 bool fakeProcessedImfileInsert(psDB * dbh, psS64 fake_id, psS64 exp_id, const char *class_id, const char *uri, psF32 dtime_fake, const char *hostname, const char *path_base, psS16 fault, psTime* epoch) 10340 { 10341 psMetadata *md = psMetadataAlloc(); 10342 if (!psMetadataAdd(md, PS_LIST_TAIL, "fake_id", PS_DATA_S64, NULL, fake_id)) { 10343 psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id"); 10344 psFree(md); 10345 return false; 10346 } 10347 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 10348 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 10349 psFree(md); 10350 return false; 10351 } 10352 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, class_id)) { 10353 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 10354 psFree(md); 10355 return false; 10356 } 10357 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, uri)) { 10358 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 10359 psFree(md); 10360 return false; 10361 } 10362 if (!psMetadataAdd(md, PS_LIST_TAIL, "dtime_fake", PS_DATA_F32, NULL, dtime_fake)) { 10363 psError(PS_ERR_UNKNOWN, false, "failed to add item dtime_fake"); 10364 psFree(md); 10365 return false; 10366 } 10367 if (!psMetadataAdd(md, PS_LIST_TAIL, "hostname", PS_DATA_STRING, NULL, hostname)) { 10368 psError(PS_ERR_UNKNOWN, false, "failed to add item hostname"); 10369 psFree(md); 10370 return false; 10371 } 10372 if (!psMetadataAdd(md, PS_LIST_TAIL, "path_base", PS_DATA_STRING, NULL, path_base)) { 10373 psError(PS_ERR_UNKNOWN, false, "failed to add item path_base"); 10374 psFree(md); 10375 return false; 10376 } 10377 if (!psMetadataAdd(md, PS_LIST_TAIL, "fault", PS_DATA_S16, NULL, fault)) { 10378 psError(PS_ERR_UNKNOWN, false, "failed to add item fault"); 10379 psFree(md); 10380 return false; 10381 } 10382 if (!psMetadataAdd(md, PS_LIST_TAIL, "epoch", PS_DATA_TIME, NULL, epoch)) { 10383 psError(PS_ERR_UNKNOWN, false, "failed to add item epoch"); 10384 psFree(md); 10385 return false; 10386 } 10387 10388 bool status = psDBInsertOneRow(dbh, FAKEPROCESSEDIMFILE_TABLE_NAME, md); 10389 psFree(md); 10390 10391 return status; 10392 } 10393 10394 long long fakeProcessedImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 10395 { 10396 long long deleted = 0; 10397 10398 long long count = psDBDeleteRows(dbh, FAKEPROCESSEDIMFILE_TABLE_NAME, where, limit); 10399 if (count < 0) { 10400 psError(PS_ERR_UNKNOWN, true, "failed to delete row from fakeProcessedImfile"); 10401 return count; 10402 10403 deleted += count; 10404 } 10405 10406 return deleted; 10407 } 10408 bool fakeProcessedImfileInsertObject(psDB *dbh, fakeProcessedImfileRow *object) 10409 { 10410 return fakeProcessedImfileInsert(dbh, object->fake_id, object->exp_id, object->class_id, object->uri, object->dtime_fake, object->hostname, object->path_base, object->fault, object->epoch); 10411 } 10412 10413 bool fakeProcessedImfileInsertObjects(psDB *dbh, psArray *objects) 10414 { 10415 for (long i = 0; i < psArrayLength(objects); i++) { 10416 if (!fakeProcessedImfileInsertObject(dbh, objects->data[i])) { 10417 return false; 10418 } 10419 } 10420 10421 return true; 10422 } 10423 10424 bool fakeProcessedImfileInsertFits(psDB *dbh, const psFits *fits) 10425 { 10426 psArray *rowSet; 10427 10428 // move to (the first?) extension named FAKEPROCESSEDIMFILE_TABLE_NAME 10429 if (!psFitsMoveExtName(fits, FAKEPROCESSEDIMFILE_TABLE_NAME)) { 10430 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", FAKEPROCESSEDIMFILE_TABLE_NAME); 10431 return false; 10432 } 10433 10434 // check HDU type 10435 if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE) { 10436 psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE"); 10437 return false; 10438 } 10439 10440 // read fits table 10441 rowSet = psFitsReadTable(fits); 10442 if (!rowSet) { 10443 psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty"); 10444 psFree(rowSet); 10445 return false; 10446 } 10447 10448 if (!psDBInsertRows(dbh, FAKEPROCESSEDIMFILE_TABLE_NAME, rowSet)) { 10449 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 10450 psFree(rowSet); 10451 return false; 10452 } 10453 10454 psFree(rowSet); 10455 10456 return true; 10457 } 10458 10459 bool fakeProcessedImfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 10460 { 10461 psArray *rowSet; 10462 10463 rowSet = psDBSelectRows(dbh, FAKEPROCESSEDIMFILE_TABLE_NAME, where, limit); 10464 if (!rowSet) { 10465 return false; 10466 } 10467 10468 // output to fits 10469 if (!psFitsWriteTable(fits, NULL, rowSet, FAKEPROCESSEDIMFILE_TABLE_NAME)) { 10470 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 10471 psFree(rowSet); 10472 return false; 10473 } 10474 10475 psFree(rowSet); 10476 10477 return true; 10478 } 10479 10480 psMetadata *fakeProcessedImfileMetadataFromObject(const fakeProcessedImfileRow *object) 10481 { 10482 psMetadata *md = psMetadataAlloc(); 10483 if (!psMetadataAdd(md, PS_LIST_TAIL, "fake_id", PS_DATA_S64, NULL, object->fake_id)) { 10484 psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id"); 10485 psFree(md); 10486 return false; 10487 } 10488 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 10489 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 10490 psFree(md); 10491 return false; 10492 } 10493 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, object->class_id)) { 10494 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 10495 psFree(md); 10496 return false; 10497 } 10498 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, object->uri)) { 10499 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 10500 psFree(md); 10501 return false; 10502 } 10503 if (!psMetadataAdd(md, PS_LIST_TAIL, "dtime_fake", PS_DATA_F32, NULL, object->dtime_fake)) { 10504 psError(PS_ERR_UNKNOWN, false, "failed to add item dtime_fake"); 10505 psFree(md); 10506 return false; 10507 } 10508 if (!psMetadataAdd(md, PS_LIST_TAIL, "hostname", PS_DATA_STRING, NULL, object->hostname)) { 10509 psError(PS_ERR_UNKNOWN, false, "failed to add item hostname"); 10510 psFree(md); 10511 return false; 10512 } 10513 if (!psMetadataAdd(md, PS_LIST_TAIL, "path_base", PS_DATA_STRING, NULL, object->path_base)) { 10514 psError(PS_ERR_UNKNOWN, false, "failed to add item path_base"); 10515 psFree(md); 10516 return false; 10517 } 10518 if (!psMetadataAdd(md, PS_LIST_TAIL, "fault", PS_DATA_S16, NULL, object->fault)) { 10519 psError(PS_ERR_UNKNOWN, false, "failed to add item fault"); 10520 psFree(md); 10521 return false; 10522 } 10523 if (!psMetadataAdd(md, PS_LIST_TAIL, "epoch", PS_DATA_TIME, NULL, object->epoch)) { 10524 psError(PS_ERR_UNKNOWN, false, "failed to add item epoch"); 10525 psFree(md); 10526 return false; 10527 } 10528 10529 10530 return md; 10531 } 10532 10533 fakeProcessedImfileRow *fakeProcessedImfileObjectFromMetadata(psMetadata *md) 10534 { 10535 10536 bool status = false; 10537 psS64 fake_id = psMetadataLookupS64(&status, md, "fake_id"); 10538 if (!status) { 10539 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item fake_id"); 10540 return false; 10541 } 10542 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 10543 if (!status) { 10544 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 10545 return false; 10546 } 10547 char* class_id = psMetadataLookupPtr(&status, md, "class_id"); 10548 if (!status) { 10549 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id"); 10550 return false; 10551 } 10552 char* uri = psMetadataLookupPtr(&status, md, "uri"); 10553 if (!status) { 10554 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item uri"); 10555 return false; 10556 } 10557 psF32 dtime_fake = psMetadataLookupF32(&status, md, "dtime_fake"); 10558 if (!status) { 10559 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item dtime_fake"); 10560 return false; 10561 } 10562 char* hostname = psMetadataLookupPtr(&status, md, "hostname"); 10563 if (!status) { 10564 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item hostname"); 10565 return false; 10566 } 10567 char* path_base = psMetadataLookupPtr(&status, md, "path_base"); 10568 if (!status) { 10569 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item path_base"); 10570 return false; 10571 } 10572 psS16 fault = psMetadataLookupS16(&status, md, "fault"); 10573 if (!status) { 10574 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item fault"); 10575 return false; 10576 } 10577 psTime* epoch = psMetadataLookupPtr(&status, md, "epoch"); 10578 if (!status) { 10579 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item epoch"); 10580 return false; 10581 } 10582 10583 return fakeProcessedImfileRowAlloc(fake_id, exp_id, class_id, uri, dtime_fake, hostname, path_base, fault, epoch); 10584 } 10585 psArray *fakeProcessedImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 10586 { 10587 psArray *rowSet; 10588 psArray *returnSet; 10589 psU64 i; 10590 10591 rowSet = psDBSelectRows(dbh, FAKEPROCESSEDIMFILE_TABLE_NAME, where, limit); 10592 if (!rowSet) { 10593 return NULL; 10594 } 10595 10596 // convert psMetadata rows to row objects 10597 10598 returnSet = psArrayAllocEmpty(rowSet->n); 10599 10600 for (i = 0; i < rowSet->n; i++) { 10601 fakeProcessedImfileRow *object = fakeProcessedImfileObjectFromMetadata(rowSet->data[i]); 10602 if (!object) { 10603 psFree(object); 10604 psFree(returnSet); 10605 psError(PS_ERR_UNKNOWN, false, "database error"); 10606 return NULL; 10607 } 10608 psArrayAdd(returnSet, 0, object); 10609 psFree(object); 10610 } 10611 10612 psFree(rowSet); 10613 10614 return returnSet; 10615 } 10616 bool fakeProcessedImfileDeleteObject(psDB *dbh, const fakeProcessedImfileRow *object) 10617 { 10618 psMetadata *where = fakeProcessedImfileMetadataFromObject(object); 10619 long long count = psDBDeleteRows(dbh, FAKEPROCESSEDIMFILE_TABLE_NAME, where, 0); 10620 psFree(where); 10621 if (count < 0) { 10622 psError(PS_ERR_UNKNOWN, true, "failed to delete row from fakeProcessedImfile"); 10623 return false; 10624 } 10625 if (count > 1) { 10626 // XXX should this be a psAbort() instead? It is possible that 10627 // having an object match multiple rows was by design. 10628 psError(PS_ERR_UNKNOWN, true, "fakeProcessedImfileRow object matched more then one row. Check your database schema"); 10629 return false; 10630 } 10631 10632 return true; 10633 } 10634 long long fakeProcessedImfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 10635 { 10636 long long deleted = 0; 10637 10638 for (long long i = 0; i < objects->n; i++) { 10639 fakeProcessedImfileRow *object = objects->data[i]; 10640 psMetadata *where = fakeProcessedImfileMetadataFromObject(object); 10641 long long count = psDBDeleteRows(dbh, FAKEPROCESSEDIMFILE_TABLE_NAME, where, limit); 10642 psFree(where); 10643 if (count < 0) { 10644 psError(PS_ERR_UNKNOWN, true, "failed to delete row from fakeProcessedImfile"); 10645 return count; 10646 } 10647 10648 deleted += count; 10649 } 10650 10651 return deleted; 10652 } 10653 bool fakeProcessedImfilePrintObjects(FILE *stream, psArray *objects, bool mdcf) 10654 { 10655 PS_ASSERT_PTR_NON_NULL(objects, false); 10656 10657 psMetadata *output = psMetadataAlloc(); 10658 for (long i = 0; i < psArrayLength(objects); i++) { 10659 psMetadata *md = fakeProcessedImfileMetadataFromObject(objects->data[i]); 10660 if (!psMetadataAddMetadata( 10661 output, 10662 PS_LIST_TAIL, 10663 FAKEPROCESSEDIMFILE_TABLE_NAME, 10664 PS_META_DUPLICATE_OK, 10665 NULL, 10666 md 10667 )) { 10668 psError(PS_ERR_UNKNOWN, false, "failed to add metadata"); 10669 psFree(md); 10670 psFree(output); 10671 return false; 10672 } 10673 psFree(md); 10674 } 10675 10676 if (!ippdbPrintMetadataRaw(stream, output, mdcf)) { 10677 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 10678 psFree(output); 10679 } 10680 psFree(output); 10681 10682 return true; 10683 } 10684 bool fakeProcessedImfilePrintObject(FILE *stream, fakeProcessedImfileRow *object, bool mdcf) 10685 { 10686 PS_ASSERT_PTR_NON_NULL(object, false); 10687 10688 psMetadata *md = fakeProcessedImfileMetadataFromObject(object); 10689 10690 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { 10691 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 10692 psFree(md); 10693 } 10694 10695 psFree(md); 10696 10697 return true; 10698 } 10699 static void fakeMaskRowFree(fakeMaskRow *object); 10700 10701 fakeMaskRow *fakeMaskRowAlloc(const char *label) 10702 { 10703 fakeMaskRow *_object; 10704 10705 _object = psAlloc(sizeof(fakeMaskRow)); 10706 psMemSetDeallocator(_object, (psFreeFunc)fakeMaskRowFree); 10707 10708 _object->label = psStringCopy(label); 10709 10710 return _object; 10711 } 10712 10713 static void fakeMaskRowFree(fakeMaskRow *object) 10714 { 10715 psFree(object->label); 10716 } 10717 10718 bool fakeMaskCreateTable(psDB *dbh) 10719 { 10720 psMetadata *md = psMetadataAlloc(); 10721 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, "Primary Key", "64")) { 10722 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); 10723 psFree(md); 10724 return false; 10725 } 10726 10727 bool status = psDBCreateTable(dbh, FAKEMASK_TABLE_NAME, md); 10728 10729 psFree(md); 10730 10731 return status; 10732 } 10733 10734 bool fakeMaskDropTable(psDB *dbh) 10735 { 10736 return psDBDropTable(dbh, FAKEMASK_TABLE_NAME); 10737 } 10738 10739 bool fakeMaskInsert(psDB * dbh, const char *label) 10740 { 10741 psMetadata *md = psMetadataAlloc(); 10742 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, label)) { 10743 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); 10744 psFree(md); 10745 return false; 10746 } 10747 10748 bool status = psDBInsertOneRow(dbh, FAKEMASK_TABLE_NAME, md); 10749 psFree(md); 10750 10751 return status; 10752 } 10753 10754 long long fakeMaskDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 10755 { 10756 long long deleted = 0; 10757 10758 long long count = psDBDeleteRows(dbh, FAKEMASK_TABLE_NAME, where, limit); 10759 if (count < 0) { 10760 psError(PS_ERR_UNKNOWN, true, "failed to delete row from fakeMask"); 10761 return count; 10762 10763 deleted += count; 10764 } 10765 10766 return deleted; 10767 } 10768 bool fakeMaskInsertObject(psDB *dbh, fakeMaskRow *object) 10769 { 10770 return fakeMaskInsert(dbh, object->label); 10771 } 10772 10773 bool fakeMaskInsertObjects(psDB *dbh, psArray *objects) 10774 { 10775 for (long i = 0; i < psArrayLength(objects); i++) { 10776 if (!fakeMaskInsertObject(dbh, objects->data[i])) { 10777 return false; 10778 } 10779 } 10780 10781 return true; 10782 } 10783 10784 bool fakeMaskInsertFits(psDB *dbh, const psFits *fits) 10785 { 10786 psArray *rowSet; 10787 10788 // move to (the first?) extension named FAKEMASK_TABLE_NAME 10789 if (!psFitsMoveExtName(fits, FAKEMASK_TABLE_NAME)) { 10790 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", FAKEMASK_TABLE_NAME); 10791 return false; 10792 } 10793 10794 // check HDU type 10795 if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE) { 10796 psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE"); 10797 return false; 10798 } 10799 10800 // read fits table 10801 rowSet = psFitsReadTable(fits); 10802 if (!rowSet) { 10803 psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty"); 10804 psFree(rowSet); 10805 return false; 10806 } 10807 10808 if (!psDBInsertRows(dbh, FAKEMASK_TABLE_NAME, rowSet)) { 10809 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 10810 psFree(rowSet); 10811 return false; 10812 } 10813 10814 psFree(rowSet); 10815 10816 return true; 10817 } 10818 10819 bool fakeMaskSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 10820 { 10821 psArray *rowSet; 10822 10823 rowSet = psDBSelectRows(dbh, FAKEMASK_TABLE_NAME, where, limit); 10824 if (!rowSet) { 10825 return false; 10826 } 10827 10828 // output to fits 10829 if (!psFitsWriteTable(fits, NULL, rowSet, FAKEMASK_TABLE_NAME)) { 10830 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 10831 psFree(rowSet); 10832 return false; 10833 } 10834 10835 psFree(rowSet); 10836 10837 return true; 10838 } 10839 10840 psMetadata *fakeMaskMetadataFromObject(const fakeMaskRow *object) 10841 { 10842 psMetadata *md = psMetadataAlloc(); 10843 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, object->label)) { 10844 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); 10845 psFree(md); 10846 return false; 10847 } 10848 10849 10850 return md; 10851 } 10852 10853 fakeMaskRow *fakeMaskObjectFromMetadata(psMetadata *md) 10854 { 10855 10856 bool status = false; 10857 char* label = psMetadataLookupPtr(&status, md, "label"); 10858 if (!status) { 10859 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item label"); 10860 return false; 10861 } 10862 10863 return fakeMaskRowAlloc(label); 10864 } 10865 psArray *fakeMaskSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 10866 { 10867 psArray *rowSet; 10868 psArray *returnSet; 10869 psU64 i; 10870 10871 rowSet = psDBSelectRows(dbh, FAKEMASK_TABLE_NAME, where, limit); 10872 if (!rowSet) { 10873 return NULL; 10874 } 10875 10876 // convert psMetadata rows to row objects 10877 10878 returnSet = psArrayAllocEmpty(rowSet->n); 10879 10880 for (i = 0; i < rowSet->n; i++) { 10881 fakeMaskRow *object = fakeMaskObjectFromMetadata(rowSet->data[i]); 10882 if (!object) { 10883 psFree(object); 10884 psFree(returnSet); 10885 psError(PS_ERR_UNKNOWN, false, "database error"); 10886 return NULL; 10887 } 10888 psArrayAdd(returnSet, 0, object); 10889 psFree(object); 10890 } 10891 10892 psFree(rowSet); 10893 10894 return returnSet; 10895 } 10896 bool fakeMaskDeleteObject(psDB *dbh, const fakeMaskRow *object) 10897 { 10898 psMetadata *where = fakeMaskMetadataFromObject(object); 10899 long long count = psDBDeleteRows(dbh, FAKEMASK_TABLE_NAME, where, 0); 10900 psFree(where); 10901 if (count < 0) { 10902 psError(PS_ERR_UNKNOWN, true, "failed to delete row from fakeMask"); 10903 return false; 10904 } 10905 if (count > 1) { 10906 // XXX should this be a psAbort() instead? It is possible that 10907 // having an object match multiple rows was by design. 10908 psError(PS_ERR_UNKNOWN, true, "fakeMaskRow object matched more then one row. Check your database schema"); 10909 return false; 10910 } 10911 10912 return true; 10913 } 10914 long long fakeMaskDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 10915 { 10916 long long deleted = 0; 10917 10918 for (long long i = 0; i < objects->n; i++) { 10919 fakeMaskRow *object = objects->data[i]; 10920 psMetadata *where = fakeMaskMetadataFromObject(object); 10921 long long count = psDBDeleteRows(dbh, FAKEMASK_TABLE_NAME, where, limit); 10922 psFree(where); 10923 if (count < 0) { 10924 psError(PS_ERR_UNKNOWN, true, "failed to delete row from fakeMask"); 10925 return count; 10926 } 10927 10928 deleted += count; 10929 } 10930 10931 return deleted; 10932 } 10933 bool fakeMaskPrintObjects(FILE *stream, psArray *objects, bool mdcf) 10934 { 10935 PS_ASSERT_PTR_NON_NULL(objects, false); 10936 10937 psMetadata *output = psMetadataAlloc(); 10938 for (long i = 0; i < psArrayLength(objects); i++) { 10939 psMetadata *md = fakeMaskMetadataFromObject(objects->data[i]); 10940 if (!psMetadataAddMetadata( 10941 output, 10942 PS_LIST_TAIL, 10943 FAKEMASK_TABLE_NAME, 10944 PS_META_DUPLICATE_OK, 10945 NULL, 10946 md 10947 )) { 10948 psError(PS_ERR_UNKNOWN, false, "failed to add metadata"); 10949 psFree(md); 10950 psFree(output); 10951 return false; 10952 } 10953 psFree(md); 10954 } 10955 10956 if (!ippdbPrintMetadataRaw(stream, output, mdcf)) { 10957 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 10958 psFree(output); 10959 } 10960 psFree(output); 10961 10962 return true; 10963 } 10964 bool fakeMaskPrintObject(FILE *stream, fakeMaskRow *object, bool mdcf) 10965 { 10966 PS_ASSERT_PTR_NON_NULL(object, false); 10967 10968 psMetadata *md = fakeMaskMetadataFromObject(object); 10969 10970 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { 10971 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 10972 psFree(md); 10973 } 10974 10975 psFree(md); 10976 10977 return true; 10978 } 9767 10979 static void warpRunRowFree(warpRunRow *object); 9768 10980 9769 warpRunRow *warpRunRowAlloc(psS64 warp_id, psS64 cam_id, const char *mode, const char *state, const char *workdir, const char *workdir_state, const char *label, const char *dvodb, const char *tess_id, const char *end_stage, psTime* registered, bool magiced)10981 warpRunRow *warpRunRowAlloc(psS64 warp_id, psS64 fake_id, const char *mode, const char *state, const char *workdir, const char *workdir_state, const char *label, const char *dvodb, const char *tess_id, const char *end_stage, psTime* registered, bool magiced) 9770 10982 { 9771 10983 warpRunRow *_object; … … 9775 10987 9776 10988 _object->warp_id = warp_id; 9777 _object-> cam_id = cam_id;10989 _object->fake_id = fake_id; 9778 10990 _object->mode = psStringCopy(mode); 9779 10991 _object->state = psStringCopy(state); … … 9811 11023 return false; 9812 11024 } 9813 if (!psMetadataAdd(md, PS_LIST_TAIL, " cam_id", PS_DATA_S64, "Key INDEX(warp_id, cam_id) fkey(cam_id) ref camProcessedExp(cam_id)", 0)) {9814 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id");11025 if (!psMetadataAdd(md, PS_LIST_TAIL, "fake_id", PS_DATA_S64, "Key INDEX(warp_id, fake_id) fkey(fake_id) ref camProcessedExp(fake_id)", 0)) { 11026 psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id"); 9815 11027 psFree(md); 9816 11028 return false; … … 9879 11091 } 9880 11092 9881 bool warpRunInsert(psDB * dbh, psS64 warp_id, psS64 cam_id, const char *mode, const char *state, const char *workdir, const char *workdir_state, const char *label, const char *dvodb, const char *tess_id, const char *end_stage, psTime* registered, bool magiced)11093 bool warpRunInsert(psDB * dbh, psS64 warp_id, psS64 fake_id, const char *mode, const char *state, const char *workdir, const char *workdir_state, const char *label, const char *dvodb, const char *tess_id, const char *end_stage, psTime* registered, bool magiced) 9882 11094 { 9883 11095 psMetadata *md = psMetadataAlloc(); … … 9887 11099 return false; 9888 11100 } 9889 if (!psMetadataAdd(md, PS_LIST_TAIL, " cam_id", PS_DATA_S64, NULL, cam_id)) {9890 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id");11101 if (!psMetadataAdd(md, PS_LIST_TAIL, "fake_id", PS_DATA_S64, NULL, fake_id)) { 11102 psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id"); 9891 11103 psFree(md); 9892 11104 return false; … … 9965 11177 bool warpRunInsertObject(psDB *dbh, warpRunRow *object) 9966 11178 { 9967 return warpRunInsert(dbh, object->warp_id, object-> cam_id, object->mode, object->state, object->workdir, object->workdir_state, object->label, object->dvodb, object->tess_id, object->end_stage, object->registered, object->magiced);11179 return warpRunInsert(dbh, object->warp_id, object->fake_id, object->mode, object->state, object->workdir, object->workdir_state, object->label, object->dvodb, object->tess_id, object->end_stage, object->registered, object->magiced); 9968 11180 } 9969 11181 … … 10043 11255 return false; 10044 11256 } 10045 if (!psMetadataAdd(md, PS_LIST_TAIL, " cam_id", PS_DATA_S64, NULL, object->cam_id)) {10046 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id");11257 if (!psMetadataAdd(md, PS_LIST_TAIL, "fake_id", PS_DATA_S64, NULL, object->fake_id)) { 11258 psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id"); 10047 11259 psFree(md); 10048 11260 return false; … … 10112 11324 return false; 10113 11325 } 10114 psS64 cam_id = psMetadataLookupS64(&status, md, "cam_id");10115 if (!status) { 10116 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item cam_id");11326 psS64 fake_id = psMetadataLookupS64(&status, md, "fake_id"); 11327 if (!status) { 11328 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item fake_id"); 10117 11329 return false; 10118 11330 } … … 10168 11380 } 10169 11381 10170 return warpRunRowAlloc(warp_id, cam_id, mode, state, workdir, workdir_state, label, dvodb, tess_id, end_stage, registered, magiced);11382 return warpRunRowAlloc(warp_id, fake_id, mode, state, workdir, workdir_state, label, dvodb, tess_id, end_stage, registered, magiced); 10171 11383 } 10172 11384 psArray *warpRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 10286 11498 static void warpSkyCellMapRowFree(warpSkyCellMapRow *object); 10287 11499 10288 warpSkyCellMapRow *warpSkyCellMapRowAlloc(psS64 warp_id, const char *skycell_id, const char *tess_id, psS64 cam_id,const char *class_id, psS16 fault)11500 warpSkyCellMapRow *warpSkyCellMapRowAlloc(psS64 warp_id, const char *skycell_id, const char *tess_id, const char *class_id, psS16 fault) 10289 11501 { 10290 11502 warpSkyCellMapRow *_object; … … 10296 11508 _object->skycell_id = psStringCopy(skycell_id); 10297 11509 _object->tess_id = psStringCopy(tess_id); 10298 _object->cam_id = cam_id;10299 11510 _object->class_id = psStringCopy(class_id); 10300 11511 _object->fault = fault; … … 10313 11524 { 10314 11525 psMetadata *md = psMetadataAlloc(); 10315 if (!psMetadataAdd(md, PS_LIST_TAIL, "warp_id", PS_DATA_S64, "Primary Key fkey(warp_id , cam_id) ref warpRun(warp_id, cam_id)", 0)) {11526 if (!psMetadataAdd(md, PS_LIST_TAIL, "warp_id", PS_DATA_S64, "Primary Key fkey(warp_id) ref warpRun(warp_id)", 0)) { 10316 11527 psError(PS_ERR_UNKNOWN, false, "failed to add item warp_id"); 10317 11528 psFree(md); … … 10328 11539 return false; 10329 11540 } 10330 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, "Primary Key", 0)) {10331 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id");10332 psFree(md);10333 return false;10334 }10335 11541 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, "Primary Key", "64")) { 10336 11542 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); … … 10356 11562 } 10357 11563 10358 bool warpSkyCellMapInsert(psDB * dbh, psS64 warp_id, const char *skycell_id, const char *tess_id, psS64 cam_id,const char *class_id, psS16 fault)11564 bool warpSkyCellMapInsert(psDB * dbh, psS64 warp_id, const char *skycell_id, const char *tess_id, const char *class_id, psS16 fault) 10359 11565 { 10360 11566 psMetadata *md = psMetadataAlloc(); … … 10371 11577 if (!psMetadataAdd(md, PS_LIST_TAIL, "tess_id", PS_DATA_STRING, NULL, tess_id)) { 10372 11578 psError(PS_ERR_UNKNOWN, false, "failed to add item tess_id"); 10373 psFree(md);10374 return false;10375 }10376 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, NULL, cam_id)) {10377 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id");10378 11579 psFree(md); 10379 11580 return false; … … 10412 11613 bool warpSkyCellMapInsertObject(psDB *dbh, warpSkyCellMapRow *object) 10413 11614 { 10414 return warpSkyCellMapInsert(dbh, object->warp_id, object->skycell_id, object->tess_id, object->c am_id, object->class_id, object->fault);11615 return warpSkyCellMapInsert(dbh, object->warp_id, object->skycell_id, object->tess_id, object->class_id, object->fault); 10415 11616 } 10416 11617 … … 10500 11701 return false; 10501 11702 } 10502 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, NULL, object->cam_id)) {10503 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id");10504 psFree(md);10505 return false;10506 }10507 11703 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, object->class_id)) { 10508 11704 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); … … 10539 11735 return false; 10540 11736 } 10541 psS64 cam_id = psMetadataLookupS64(&status, md, "cam_id");10542 if (!status) {10543 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item cam_id");10544 return false;10545 }10546 11737 char* class_id = psMetadataLookupPtr(&status, md, "class_id"); 10547 11738 if (!status) { … … 10555 11746 } 10556 11747 10557 return warpSkyCellMapRowAlloc(warp_id, skycell_id, tess_id, c am_id, class_id, fault);11748 return warpSkyCellMapRowAlloc(warp_id, skycell_id, tess_id, class_id, fault); 10558 11749 } 10559 11750 psArray *warpSkyCellMapSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) -
trunk/ippdb/src/ippdb.h
r17872 r18044 3483 3483 typedef struct { 3484 3484 psS64 cam_id; 3485 psS64 chip_id;3486 3485 char *uri; 3487 3486 psF32 bg; … … 3520 3519 camProcessedExpRow *camProcessedExpRowAlloc( 3521 3520 psS64 cam_id, 3522 psS64 chip_id,3523 3521 const char *uri, 3524 3522 psF32 bg, … … 3578 3576 psDB *dbh, ///< Database handle 3579 3577 psS64 cam_id, 3580 psS64 chip_id,3581 3578 const char *uri, 3582 3579 psF32 bg, … … 3950 3947 bool mdcf ///< format as mdconfig or simple 3951 3948 ); 3949 /** fakeRunRow data structure 3950 * 3951 * Structure for representing a single row of fakeRun table data. 3952 */ 3953 3954 typedef struct { 3955 psS64 fake_id; 3956 psS64 cam_id; 3957 char *state; 3958 char *workdir; 3959 char *label; 3960 char *reduction; 3961 char *expgroup; 3962 char *dvodb; 3963 char *tess_id; 3964 char *end_stage; 3965 psTime* epoch; 3966 } fakeRunRow; 3967 3968 /** Creates a new fakeRunRow object 3969 * 3970 * @return A new fakeRunRow object or NULL on failure. 3971 */ 3972 3973 fakeRunRow *fakeRunRowAlloc( 3974 psS64 fake_id, 3975 psS64 cam_id, 3976 const char *state, 3977 const char *workdir, 3978 const char *label, 3979 const char *reduction, 3980 const char *expgroup, 3981 const char *dvodb, 3982 const char *tess_id, 3983 const char *end_stage, 3984 psTime* epoch 3985 ); 3986 3987 /** Creates a new fakeRun table 3988 * 3989 * @return true on success 3990 */ 3991 3992 bool fakeRunCreateTable( 3993 psDB *dbh ///< Database handle 3994 ); 3995 3996 /** Deletes a fakeRun table 3997 * 3998 * @return true on success 3999 */ 4000 4001 bool fakeRunDropTable( 4002 psDB *dbh ///< Database handle 4003 ); 4004 4005 /** Insert a single row into a table 4006 * 4007 * This function constructs and inserts a single row based on it's parameters. 4008 * 4009 * @return true on success 4010 */ 4011 4012 bool fakeRunInsert( 4013 psDB *dbh, ///< Database handle 4014 psS64 fake_id, 4015 psS64 cam_id, 4016 const char *state, 4017 const char *workdir, 4018 const char *label, 4019 const char *reduction, 4020 const char *expgroup, 4021 const char *dvodb, 4022 const char *tess_id, 4023 const char *end_stage, 4024 psTime* epoch 4025 ); 4026 4027 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 4028 * 4029 * @return A The number of rows removed or a negative value on error 4030 */ 4031 4032 long long fakeRunDelete( 4033 psDB *dbh, ///< Database handle 4034 const psMetadata *where, ///< Row match criteria 4035 unsigned long long limit ///< Maximum number of elements to delete 4036 ); 4037 4038 /** Insert a single fakeRunRow object into a table 4039 * 4040 * This function constructs and inserts a single row based on it's parameters. 4041 * 4042 * @return true on success 4043 */ 4044 4045 bool fakeRunInsertObject( 4046 psDB *dbh, ///< Database handle 4047 fakeRunRow *object ///< fakeRunRow object 4048 ); 4049 4050 /** Insert an array of fakeRunRow object into a table 4051 * 4052 * This function constructs and inserts multiple rows based on it's parameters. 4053 * 4054 * @return true on success 4055 */ 4056 4057 bool fakeRunInsertObjects( 4058 psDB *dbh, ///< Database handle 4059 psArray *objects ///< array of fakeRunRow objects 4060 ); 4061 4062 /** Insert data from a binary FITS table fakeRunRow into the database 4063 * 4064 * This function expects a psFits object with a FITS table as the first 4065 * extension. The table must have at least one row of data in it, that is of 4066 * the appropriate format (number of columns and their type). All other 4067 * extensions are ignored. 4068 * 4069 * @return true on success 4070 */ 4071 4072 bool fakeRunInsertFits( 4073 psDB *dbh, ///< Database handle 4074 const psFits *fits ///< psFits object 4075 ); 4076 4077 /** Selects up to limit from the database and returns them in a binary FITS table 4078 * 4079 * This function assumes an empty psFits object and will create a FITS table 4080 * as the first extension. 4081 * 4082 * See psDBSelectRows() for documentation on the format of where. 4083 * 4084 * @return true on success 4085 */ 4086 4087 bool fakeRunSelectRowsFits( 4088 psDB *dbh, ///< Database handle 4089 psFits *fits, ///< psFits object 4090 const psMetadata *where, ///< Row match criteria 4091 unsigned long long limit ///< Maximum number of elements to return 4092 ); 4093 4094 /** Convert a fakeRunRow into an equivalent psMetadata 4095 * 4096 * @return A psMetadata pointer or NULL on error 4097 */ 4098 4099 psMetadata *fakeRunMetadataFromObject( 4100 const fakeRunRow *object ///< fooRow to convert into a psMetadata 4101 ); 4102 4103 /** Convert a psMetadata into an equivalent fooRow 4104 * 4105 * @return A fakeRunRow pointer or NULL on error 4106 */ 4107 4108 fakeRunRow *fakeRunObjectFromMetadata( 4109 psMetadata *md ///< psMetadata to convert into a fooRow 4110 ); 4111 /** Selects up to limit rows from the database and returns as fakeRunRow objects in a psArray 4112 * 4113 * See psDBSelectRows() for documentation on the format of where. 4114 * 4115 * @return A psArray pointer or NULL on error 4116 */ 4117 4118 psArray *fakeRunSelectRowObjects( 4119 psDB *dbh, ///< Database handle 4120 const psMetadata *where, ///< Row match criteria 4121 unsigned long long limit ///< Maximum number of elements to return 4122 ); 4123 /** Deletes a row from the database coresponding to an fakeRun 4124 * 4125 * Note that a 'where' search psMetadata is constructed from each object and 4126 * used to find rows to delete. 4127 * 4128 * @return A The number of rows removed or a negative value on error 4129 */ 4130 4131 bool fakeRunDeleteObject( 4132 psDB *dbh, ///< Database handle 4133 const fakeRunRow *object ///< Object to delete 4134 ); 4135 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 4136 * 4137 * Note that a 'where' search psMetadata is constructed from each object and 4138 * used to find rows to delete. 4139 * 4140 * @return A The number of rows removed or a negative value on error 4141 */ 4142 4143 long long fakeRunDeleteRowObjects( 4144 psDB *dbh, ///< Database handle 4145 const psArray *objects, ///< Array of objects to delete 4146 unsigned long long limit ///< Maximum number of elements to delete 4147 ); 4148 /** Formats and prints an array of fakeRunRow objects 4149 * 4150 * When mdcf is set the formated output is in psMetadataConfig 4151 * format, otherwise it is in a simple tabular format. 4152 * 4153 * @return true on success 4154 */ 4155 4156 bool fakeRunPrintObjects( 4157 FILE *stream, ///< a stream 4158 psArray *objects, ///< An array of fakeRunRow objects 4159 bool mdcf ///< format as mdconfig or simple 4160 ); 4161 /** Formats and prints an fakeRunRow object 4162 * 4163 * When mdcf is set the formated output is in psMetadataConfig 4164 * format, otherwise it is in a simple tabular format. 4165 * 4166 * @return true on success 4167 */ 4168 4169 bool fakeRunPrintObject( 4170 FILE *stream, ///< a stream 4171 fakeRunRow *object, ///< an fakeRunRow object 4172 bool mdcf ///< format as mdconfig or simple 4173 ); 4174 /** fakeProcessedImfileRow data structure 4175 * 4176 * Structure for representing a single row of fakeProcessedImfile table data. 4177 */ 4178 4179 typedef struct { 4180 psS64 fake_id; 4181 psS64 exp_id; 4182 char *class_id; 4183 char *uri; 4184 psF32 dtime_fake; 4185 char *hostname; 4186 char *path_base; 4187 psS16 fault; 4188 psTime* epoch; 4189 } fakeProcessedImfileRow; 4190 4191 /** Creates a new fakeProcessedImfileRow object 4192 * 4193 * @return A new fakeProcessedImfileRow object or NULL on failure. 4194 */ 4195 4196 fakeProcessedImfileRow *fakeProcessedImfileRowAlloc( 4197 psS64 fake_id, 4198 psS64 exp_id, 4199 const char *class_id, 4200 const char *uri, 4201 psF32 dtime_fake, 4202 const char *hostname, 4203 const char *path_base, 4204 psS16 fault, 4205 psTime* epoch 4206 ); 4207 4208 /** Creates a new fakeProcessedImfile table 4209 * 4210 * @return true on success 4211 */ 4212 4213 bool fakeProcessedImfileCreateTable( 4214 psDB *dbh ///< Database handle 4215 ); 4216 4217 /** Deletes a fakeProcessedImfile table 4218 * 4219 * @return true on success 4220 */ 4221 4222 bool fakeProcessedImfileDropTable( 4223 psDB *dbh ///< Database handle 4224 ); 4225 4226 /** Insert a single row into a table 4227 * 4228 * This function constructs and inserts a single row based on it's parameters. 4229 * 4230 * @return true on success 4231 */ 4232 4233 bool fakeProcessedImfileInsert( 4234 psDB *dbh, ///< Database handle 4235 psS64 fake_id, 4236 psS64 exp_id, 4237 const char *class_id, 4238 const char *uri, 4239 psF32 dtime_fake, 4240 const char *hostname, 4241 const char *path_base, 4242 psS16 fault, 4243 psTime* epoch 4244 ); 4245 4246 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 4247 * 4248 * @return A The number of rows removed or a negative value on error 4249 */ 4250 4251 long long fakeProcessedImfileDelete( 4252 psDB *dbh, ///< Database handle 4253 const psMetadata *where, ///< Row match criteria 4254 unsigned long long limit ///< Maximum number of elements to delete 4255 ); 4256 4257 /** Insert a single fakeProcessedImfileRow object into a table 4258 * 4259 * This function constructs and inserts a single row based on it's parameters. 4260 * 4261 * @return true on success 4262 */ 4263 4264 bool fakeProcessedImfileInsertObject( 4265 psDB *dbh, ///< Database handle 4266 fakeProcessedImfileRow *object ///< fakeProcessedImfileRow object 4267 ); 4268 4269 /** Insert an array of fakeProcessedImfileRow object into a table 4270 * 4271 * This function constructs and inserts multiple rows based on it's parameters. 4272 * 4273 * @return true on success 4274 */ 4275 4276 bool fakeProcessedImfileInsertObjects( 4277 psDB *dbh, ///< Database handle 4278 psArray *objects ///< array of fakeProcessedImfileRow objects 4279 ); 4280 4281 /** Insert data from a binary FITS table fakeProcessedImfileRow into the database 4282 * 4283 * This function expects a psFits object with a FITS table as the first 4284 * extension. The table must have at least one row of data in it, that is of 4285 * the appropriate format (number of columns and their type). All other 4286 * extensions are ignored. 4287 * 4288 * @return true on success 4289 */ 4290 4291 bool fakeProcessedImfileInsertFits( 4292 psDB *dbh, ///< Database handle 4293 const psFits *fits ///< psFits object 4294 ); 4295 4296 /** Selects up to limit from the database and returns them in a binary FITS table 4297 * 4298 * This function assumes an empty psFits object and will create a FITS table 4299 * as the first extension. 4300 * 4301 * See psDBSelectRows() for documentation on the format of where. 4302 * 4303 * @return true on success 4304 */ 4305 4306 bool fakeProcessedImfileSelectRowsFits( 4307 psDB *dbh, ///< Database handle 4308 psFits *fits, ///< psFits object 4309 const psMetadata *where, ///< Row match criteria 4310 unsigned long long limit ///< Maximum number of elements to return 4311 ); 4312 4313 /** Convert a fakeProcessedImfileRow into an equivalent psMetadata 4314 * 4315 * @return A psMetadata pointer or NULL on error 4316 */ 4317 4318 psMetadata *fakeProcessedImfileMetadataFromObject( 4319 const fakeProcessedImfileRow *object ///< fooRow to convert into a psMetadata 4320 ); 4321 4322 /** Convert a psMetadata into an equivalent fooRow 4323 * 4324 * @return A fakeProcessedImfileRow pointer or NULL on error 4325 */ 4326 4327 fakeProcessedImfileRow *fakeProcessedImfileObjectFromMetadata( 4328 psMetadata *md ///< psMetadata to convert into a fooRow 4329 ); 4330 /** Selects up to limit rows from the database and returns as fakeProcessedImfileRow objects in a psArray 4331 * 4332 * See psDBSelectRows() for documentation on the format of where. 4333 * 4334 * @return A psArray pointer or NULL on error 4335 */ 4336 4337 psArray *fakeProcessedImfileSelectRowObjects( 4338 psDB *dbh, ///< Database handle 4339 const psMetadata *where, ///< Row match criteria 4340 unsigned long long limit ///< Maximum number of elements to return 4341 ); 4342 /** Deletes a row from the database coresponding to an fakeProcessedImfile 4343 * 4344 * Note that a 'where' search psMetadata is constructed from each object and 4345 * used to find rows to delete. 4346 * 4347 * @return A The number of rows removed or a negative value on error 4348 */ 4349 4350 bool fakeProcessedImfileDeleteObject( 4351 psDB *dbh, ///< Database handle 4352 const fakeProcessedImfileRow *object ///< Object to delete 4353 ); 4354 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 4355 * 4356 * Note that a 'where' search psMetadata is constructed from each object and 4357 * used to find rows to delete. 4358 * 4359 * @return A The number of rows removed or a negative value on error 4360 */ 4361 4362 long long fakeProcessedImfileDeleteRowObjects( 4363 psDB *dbh, ///< Database handle 4364 const psArray *objects, ///< Array of objects to delete 4365 unsigned long long limit ///< Maximum number of elements to delete 4366 ); 4367 /** Formats and prints an array of fakeProcessedImfileRow objects 4368 * 4369 * When mdcf is set the formated output is in psMetadataConfig 4370 * format, otherwise it is in a simple tabular format. 4371 * 4372 * @return true on success 4373 */ 4374 4375 bool fakeProcessedImfilePrintObjects( 4376 FILE *stream, ///< a stream 4377 psArray *objects, ///< An array of fakeProcessedImfileRow objects 4378 bool mdcf ///< format as mdconfig or simple 4379 ); 4380 /** Formats and prints an fakeProcessedImfileRow object 4381 * 4382 * When mdcf is set the formated output is in psMetadataConfig 4383 * format, otherwise it is in a simple tabular format. 4384 * 4385 * @return true on success 4386 */ 4387 4388 bool fakeProcessedImfilePrintObject( 4389 FILE *stream, ///< a stream 4390 fakeProcessedImfileRow *object, ///< an fakeProcessedImfileRow object 4391 bool mdcf ///< format as mdconfig or simple 4392 ); 4393 /** fakeMaskRow data structure 4394 * 4395 * Structure for representing a single row of fakeMask table data. 4396 */ 4397 4398 typedef struct { 4399 char *label; 4400 } fakeMaskRow; 4401 4402 /** Creates a new fakeMaskRow object 4403 * 4404 * @return A new fakeMaskRow object or NULL on failure. 4405 */ 4406 4407 fakeMaskRow *fakeMaskRowAlloc( 4408 const char *label 4409 ); 4410 4411 /** Creates a new fakeMask table 4412 * 4413 * @return true on success 4414 */ 4415 4416 bool fakeMaskCreateTable( 4417 psDB *dbh ///< Database handle 4418 ); 4419 4420 /** Deletes a fakeMask table 4421 * 4422 * @return true on success 4423 */ 4424 4425 bool fakeMaskDropTable( 4426 psDB *dbh ///< Database handle 4427 ); 4428 4429 /** Insert a single row into a table 4430 * 4431 * This function constructs and inserts a single row based on it's parameters. 4432 * 4433 * @return true on success 4434 */ 4435 4436 bool fakeMaskInsert( 4437 psDB *dbh, ///< Database handle 4438 const char *label 4439 ); 4440 4441 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 4442 * 4443 * @return A The number of rows removed or a negative value on error 4444 */ 4445 4446 long long fakeMaskDelete( 4447 psDB *dbh, ///< Database handle 4448 const psMetadata *where, ///< Row match criteria 4449 unsigned long long limit ///< Maximum number of elements to delete 4450 ); 4451 4452 /** Insert a single fakeMaskRow object into a table 4453 * 4454 * This function constructs and inserts a single row based on it's parameters. 4455 * 4456 * @return true on success 4457 */ 4458 4459 bool fakeMaskInsertObject( 4460 psDB *dbh, ///< Database handle 4461 fakeMaskRow *object ///< fakeMaskRow object 4462 ); 4463 4464 /** Insert an array of fakeMaskRow object into a table 4465 * 4466 * This function constructs and inserts multiple rows based on it's parameters. 4467 * 4468 * @return true on success 4469 */ 4470 4471 bool fakeMaskInsertObjects( 4472 psDB *dbh, ///< Database handle 4473 psArray *objects ///< array of fakeMaskRow objects 4474 ); 4475 4476 /** Insert data from a binary FITS table fakeMaskRow into the database 4477 * 4478 * This function expects a psFits object with a FITS table as the first 4479 * extension. The table must have at least one row of data in it, that is of 4480 * the appropriate format (number of columns and their type). All other 4481 * extensions are ignored. 4482 * 4483 * @return true on success 4484 */ 4485 4486 bool fakeMaskInsertFits( 4487 psDB *dbh, ///< Database handle 4488 const psFits *fits ///< psFits object 4489 ); 4490 4491 /** Selects up to limit from the database and returns them in a binary FITS table 4492 * 4493 * This function assumes an empty psFits object and will create a FITS table 4494 * as the first extension. 4495 * 4496 * See psDBSelectRows() for documentation on the format of where. 4497 * 4498 * @return true on success 4499 */ 4500 4501 bool fakeMaskSelectRowsFits( 4502 psDB *dbh, ///< Database handle 4503 psFits *fits, ///< psFits object 4504 const psMetadata *where, ///< Row match criteria 4505 unsigned long long limit ///< Maximum number of elements to return 4506 ); 4507 4508 /** Convert a fakeMaskRow into an equivalent psMetadata 4509 * 4510 * @return A psMetadata pointer or NULL on error 4511 */ 4512 4513 psMetadata *fakeMaskMetadataFromObject( 4514 const fakeMaskRow *object ///< fooRow to convert into a psMetadata 4515 ); 4516 4517 /** Convert a psMetadata into an equivalent fooRow 4518 * 4519 * @return A fakeMaskRow pointer or NULL on error 4520 */ 4521 4522 fakeMaskRow *fakeMaskObjectFromMetadata( 4523 psMetadata *md ///< psMetadata to convert into a fooRow 4524 ); 4525 /** Selects up to limit rows from the database and returns as fakeMaskRow objects in a psArray 4526 * 4527 * See psDBSelectRows() for documentation on the format of where. 4528 * 4529 * @return A psArray pointer or NULL on error 4530 */ 4531 4532 psArray *fakeMaskSelectRowObjects( 4533 psDB *dbh, ///< Database handle 4534 const psMetadata *where, ///< Row match criteria 4535 unsigned long long limit ///< Maximum number of elements to return 4536 ); 4537 /** Deletes a row from the database coresponding to an fakeMask 4538 * 4539 * Note that a 'where' search psMetadata is constructed from each object and 4540 * used to find rows to delete. 4541 * 4542 * @return A The number of rows removed or a negative value on error 4543 */ 4544 4545 bool fakeMaskDeleteObject( 4546 psDB *dbh, ///< Database handle 4547 const fakeMaskRow *object ///< Object to delete 4548 ); 4549 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 4550 * 4551 * Note that a 'where' search psMetadata is constructed from each object and 4552 * used to find rows to delete. 4553 * 4554 * @return A The number of rows removed or a negative value on error 4555 */ 4556 4557 long long fakeMaskDeleteRowObjects( 4558 psDB *dbh, ///< Database handle 4559 const psArray *objects, ///< Array of objects to delete 4560 unsigned long long limit ///< Maximum number of elements to delete 4561 ); 4562 /** Formats and prints an array of fakeMaskRow objects 4563 * 4564 * When mdcf is set the formated output is in psMetadataConfig 4565 * format, otherwise it is in a simple tabular format. 4566 * 4567 * @return true on success 4568 */ 4569 4570 bool fakeMaskPrintObjects( 4571 FILE *stream, ///< a stream 4572 psArray *objects, ///< An array of fakeMaskRow objects 4573 bool mdcf ///< format as mdconfig or simple 4574 ); 4575 /** Formats and prints an fakeMaskRow object 4576 * 4577 * When mdcf is set the formated output is in psMetadataConfig 4578 * format, otherwise it is in a simple tabular format. 4579 * 4580 * @return true on success 4581 */ 4582 4583 bool fakeMaskPrintObject( 4584 FILE *stream, ///< a stream 4585 fakeMaskRow *object, ///< an fakeMaskRow object 4586 bool mdcf ///< format as mdconfig or simple 4587 ); 3952 4588 /** warpRunRow data structure 3953 4589 * … … 3957 4593 typedef struct { 3958 4594 psS64 warp_id; 3959 psS64 cam_id;4595 psS64 fake_id; 3960 4596 char *mode; 3961 4597 char *state; … … 3977 4613 warpRunRow *warpRunRowAlloc( 3978 4614 psS64 warp_id, 3979 psS64 cam_id,4615 psS64 fake_id, 3980 4616 const char *mode, 3981 4617 const char *state, … … 4018 4654 psDB *dbh, ///< Database handle 4019 4655 psS64 warp_id, 4020 psS64 cam_id,4656 psS64 fake_id, 4021 4657 const char *mode, 4022 4658 const char *state, … … 4187 4823 char *skycell_id; 4188 4824 char *tess_id; 4189 psS64 cam_id;4190 4825 char *class_id; 4191 4826 psS16 fault; … … 4201 4836 const char *skycell_id, 4202 4837 const char *tess_id, 4203 psS64 cam_id,4204 4838 const char *class_id, 4205 4839 psS16 fault … … 4236 4870 const char *skycell_id, 4237 4871 const char *tess_id, 4238 psS64 cam_id,4239 4872 const char *class_id, 4240 4873 psS16 fault -
trunk/ippdb/tests/alloc.c
r17872 r18044 1065 1065 camProcessedExpRow *object; 1066 1066 1067 object = camProcessedExpRowAlloc(-64, -64,"a string", 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, "a string", -32, -32, -32, -32, "a string", -16 );1067 object = camProcessedExpRowAlloc(-64, "a string", 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, "a string", -32, -32, -32, -32, "a string", -16 ); 1068 1068 1069 1069 if (!object) { … … 1075 1075 exit(EXIT_FAILURE); 1076 1076 } 1077 if (!object->chip_id == -64) {1078 psFree(object);1079 exit(EXIT_FAILURE);1080 }1081 1077 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) { 1082 1078 psFree(object); … … 1209 1205 1210 1206 { 1207 fakeRunRow *object; 1208 1209 object = fakeRunRowAlloc(-64, -64, "a string", "a string", "a string", "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z" ); 1210 1211 if (!object) { 1212 exit(EXIT_FAILURE); 1213 } 1214 1215 if (!object->fake_id == -64) { 1216 psFree(object); 1217 exit(EXIT_FAILURE); 1218 } 1219 if (!object->cam_id == -64) { 1220 psFree(object); 1221 exit(EXIT_FAILURE); 1222 } 1223 if (strncmp(object->state, "a string", MAX_STRING_LENGTH)) { 1224 psFree(object); 1225 exit(EXIT_FAILURE); 1226 } 1227 if (strncmp(object->workdir, "a string", MAX_STRING_LENGTH)) { 1228 psFree(object); 1229 exit(EXIT_FAILURE); 1230 } 1231 if (strncmp(object->label, "a string", MAX_STRING_LENGTH)) { 1232 psFree(object); 1233 exit(EXIT_FAILURE); 1234 } 1235 if (strncmp(object->reduction, "a string", MAX_STRING_LENGTH)) { 1236 psFree(object); 1237 exit(EXIT_FAILURE); 1238 } 1239 if (strncmp(object->expgroup, "a string", MAX_STRING_LENGTH)) { 1240 psFree(object); 1241 exit(EXIT_FAILURE); 1242 } 1243 if (strncmp(object->dvodb, "a string", MAX_STRING_LENGTH)) { 1244 psFree(object); 1245 exit(EXIT_FAILURE); 1246 } 1247 if (strncmp(object->tess_id, "a string", MAX_STRING_LENGTH)) { 1248 psFree(object); 1249 exit(EXIT_FAILURE); 1250 } 1251 if (strncmp(object->end_stage, "a string", MAX_STRING_LENGTH)) { 1252 psFree(object); 1253 exit(EXIT_FAILURE); 1254 } 1255 psFree(object); 1256 exit(EXIT_FAILURE); 1257 } 1258 1259 psFree(object); 1260 } 1261 1262 { 1263 fakeProcessedImfileRow *object; 1264 1265 object = fakeProcessedImfileRowAlloc(-64, -64, "a string", "a string", 32.32, "a string", "a string", -16, "0001-01-01T00:00:00Z" ); 1266 1267 if (!object) { 1268 exit(EXIT_FAILURE); 1269 } 1270 1271 if (!object->fake_id == -64) { 1272 psFree(object); 1273 exit(EXIT_FAILURE); 1274 } 1275 if (!object->exp_id == -64) { 1276 psFree(object); 1277 exit(EXIT_FAILURE); 1278 } 1279 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) { 1280 psFree(object); 1281 exit(EXIT_FAILURE); 1282 } 1283 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) { 1284 psFree(object); 1285 exit(EXIT_FAILURE); 1286 } 1287 if (!object->dtime_fake == 32.32) { 1288 psFree(object); 1289 exit(EXIT_FAILURE); 1290 } 1291 if (strncmp(object->hostname, "a string", MAX_STRING_LENGTH)) { 1292 psFree(object); 1293 exit(EXIT_FAILURE); 1294 } 1295 if (strncmp(object->path_base, "a string", MAX_STRING_LENGTH)) { 1296 psFree(object); 1297 exit(EXIT_FAILURE); 1298 } 1299 if (!object->fault == -16) { 1300 psFree(object); 1301 exit(EXIT_FAILURE); 1302 } 1303 psFree(object); 1304 exit(EXIT_FAILURE); 1305 } 1306 1307 psFree(object); 1308 } 1309 1310 { 1311 fakeMaskRow *object; 1312 1313 object = fakeMaskRowAlloc("a string" ); 1314 1315 if (!object) { 1316 exit(EXIT_FAILURE); 1317 } 1318 1319 if (strncmp(object->label, "a string", MAX_STRING_LENGTH)) { 1320 psFree(object); 1321 exit(EXIT_FAILURE); 1322 } 1323 1324 psFree(object); 1325 } 1326 1327 { 1211 1328 warpRunRow *object; 1212 1329 … … 1221 1338 exit(EXIT_FAILURE); 1222 1339 } 1223 if (!object-> cam_id == -64) {1340 if (!object->fake_id == -64) { 1224 1341 psFree(object); 1225 1342 exit(EXIT_FAILURE); … … 1271 1388 warpSkyCellMapRow *object; 1272 1389 1273 object = warpSkyCellMapRowAlloc(-64, "a string", "a string", -64,"a string", -16 );1390 object = warpSkyCellMapRowAlloc(-64, "a string", "a string", "a string", -16 ); 1274 1391 1275 1392 if (!object) { … … 1286 1403 } 1287 1404 if (strncmp(object->tess_id, "a string", MAX_STRING_LENGTH)) { 1288 psFree(object);1289 exit(EXIT_FAILURE);1290 }1291 if (!object->cam_id == -64) {1292 1405 psFree(object); 1293 1406 exit(EXIT_FAILURE); -
trunk/ippdb/tests/createtable.c
r17144 r18044 253 253 } 254 254 255 if(!fakeRunCreateTable(dbh)) { 256 exit(EXIT_FAILURE); 257 } 258 259 psDBCleanup(dbh); 260 } 261 262 { 263 psDB *dbh; 264 265 dbh = psDBInit("localhost", "test", NULL, "test"); 266 if (!dbh) { 267 exit(EXIT_FAILURE); 268 } 269 270 if(!fakeProcessedImfileCreateTable(dbh)) { 271 exit(EXIT_FAILURE); 272 } 273 274 psDBCleanup(dbh); 275 } 276 277 { 278 psDB *dbh; 279 280 dbh = psDBInit("localhost", "test", NULL, "test"); 281 if (!dbh) { 282 exit(EXIT_FAILURE); 283 } 284 285 if(!fakeMaskCreateTable(dbh)) { 286 exit(EXIT_FAILURE); 287 } 288 289 psDBCleanup(dbh); 290 } 291 292 { 293 psDB *dbh; 294 295 dbh = psDBInit("localhost", "test", NULL, "test"); 296 if (!dbh) { 297 exit(EXIT_FAILURE); 298 } 299 255 300 if(!warpRunCreateTable(dbh)) { 256 301 exit(EXIT_FAILURE); -
trunk/ippdb/tests/dbcleanup.c
r17144 r18044 27 27 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS camProcessedExp"); 28 28 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS camMask"); 29 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS fakeRun"); 30 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS fakeProcessedImfile"); 31 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS fakeMask"); 29 32 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS warpRun"); 30 33 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS warpSkyCellMap"); -
trunk/ippdb/tests/dbsetup.c
r17144 r18044 60 60 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS camMask"); 61 61 camMaskCreateTable(dbh); 62 63 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS fakeRun"); 64 fakeRunCreateTable(dbh); 65 66 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS fakeProcessedImfile"); 67 fakeProcessedImfileCreateTable(dbh); 68 69 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS fakeMask"); 70 fakeMaskCreateTable(dbh); 62 71 63 72 p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS warpRun"); -
trunk/ippdb/tests/droptable.c
r17144 r18044 253 253 } 254 254 255 if (!fakeRunDropTable(dbh)) { 256 exit(EXIT_FAILURE); 257 } 258 259 psDBCleanup(dbh); 260 } 261 262 { 263 psDB *dbh; 264 265 dbh = psDBInit("localhost", "test", NULL, "test"); 266 if (!dbh) { 267 exit(EXIT_FAILURE); 268 } 269 270 if (!fakeProcessedImfileDropTable(dbh)) { 271 exit(EXIT_FAILURE); 272 } 273 274 psDBCleanup(dbh); 275 } 276 277 { 278 psDB *dbh; 279 280 dbh = psDBInit("localhost", "test", NULL, "test"); 281 if (!dbh) { 282 exit(EXIT_FAILURE); 283 } 284 285 if (!fakeMaskDropTable(dbh)) { 286 exit(EXIT_FAILURE); 287 } 288 289 psDBCleanup(dbh); 290 } 291 292 { 293 psDB *dbh; 294 295 dbh = psDBInit("localhost", "test", NULL, "test"); 296 if (!dbh) { 297 exit(EXIT_FAILURE); 298 } 299 255 300 if (!warpRunDropTable(dbh)) { 256 301 exit(EXIT_FAILURE); -
trunk/ippdb/tests/insert.c
r17872 r18044 223 223 } 224 224 225 if (!camProcessedExpInsert(dbh, -64, -64,"a string", 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, "a string", -32, -32, -32, -32, "a string", -16)) {225 if (!camProcessedExpInsert(dbh, -64, "a string", 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, "a string", -32, -32, -32, -32, "a string", -16)) { 226 226 exit(EXIT_FAILURE); 227 227 } … … 253 253 } 254 254 255 if (!fakeRunInsert(dbh, -64, -64, "a string", "a string", "a string", "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z")) { 256 exit(EXIT_FAILURE); 257 } 258 259 psDBCleanup(dbh); 260 } 261 262 { 263 psDB *dbh; 264 265 dbh = psDBInit("localhost", "test", NULL, "test"); 266 if (!dbh) { 267 exit(EXIT_FAILURE); 268 } 269 270 if (!fakeProcessedImfileInsert(dbh, -64, -64, "a string", "a string", 32.32, "a string", "a string", -16, "0001-01-01T00:00:00Z")) { 271 exit(EXIT_FAILURE); 272 } 273 274 psDBCleanup(dbh); 275 } 276 277 { 278 psDB *dbh; 279 280 dbh = psDBInit("localhost", "test", NULL, "test"); 281 if (!dbh) { 282 exit(EXIT_FAILURE); 283 } 284 285 if (!fakeMaskInsert(dbh, "a string")) { 286 exit(EXIT_FAILURE); 287 } 288 289 psDBCleanup(dbh); 290 } 291 292 { 293 psDB *dbh; 294 295 dbh = psDBInit("localhost", "test", NULL, "test"); 296 if (!dbh) { 297 exit(EXIT_FAILURE); 298 } 299 255 300 if (!warpRunInsert(dbh, -64, -64, "a string", "a string", "a string", "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", true)) { 256 301 exit(EXIT_FAILURE); … … 268 313 } 269 314 270 if (!warpSkyCellMapInsert(dbh, -64, "a string", "a string", -64,"a string", -16)) {315 if (!warpSkyCellMapInsert(dbh, -64, "a string", "a string", "a string", -16)) { 271 316 exit(EXIT_FAILURE); 272 317 } -
trunk/ippdb/tests/insertfits.c
r17144 r18044 440 440 } 441 441 442 if (!fakeRunInsertFits(dbh, fits)) { 443 exit(EXIT_FAILURE); 444 } 445 446 if (!psFitsClose(fits)) { 447 exit(EXIT_FAILURE); 448 } 449 450 psDBCleanup(dbh); 451 } 452 453 { 454 psDB *dbh; 455 psFits *fits; 456 457 dbh = psDBInit("localhost", "test", NULL, "test"); 458 if (!dbh) { 459 exit(EXIT_FAILURE); 460 } 461 462 // open a temp 463 fits = psFitsOpen(TMP_FILENAME, "r"); 464 if (!fits) { 465 exit(EXIT_FAILURE); 466 } 467 468 if (!fakeProcessedImfileInsertFits(dbh, fits)) { 469 exit(EXIT_FAILURE); 470 } 471 472 if (!psFitsClose(fits)) { 473 exit(EXIT_FAILURE); 474 } 475 476 psDBCleanup(dbh); 477 } 478 479 { 480 psDB *dbh; 481 psFits *fits; 482 483 dbh = psDBInit("localhost", "test", NULL, "test"); 484 if (!dbh) { 485 exit(EXIT_FAILURE); 486 } 487 488 // open a temp 489 fits = psFitsOpen(TMP_FILENAME, "r"); 490 if (!fits) { 491 exit(EXIT_FAILURE); 492 } 493 494 if (!fakeMaskInsertFits(dbh, fits)) { 495 exit(EXIT_FAILURE); 496 } 497 498 if (!psFitsClose(fits)) { 499 exit(EXIT_FAILURE); 500 } 501 502 psDBCleanup(dbh); 503 } 504 505 { 506 psDB *dbh; 507 psFits *fits; 508 509 dbh = psDBInit("localhost", "test", NULL, "test"); 510 if (!dbh) { 511 exit(EXIT_FAILURE); 512 } 513 514 // open a temp 515 fits = psFitsOpen(TMP_FILENAME, "r"); 516 if (!fits) { 517 exit(EXIT_FAILURE); 518 } 519 442 520 if (!warpRunInsertFits(dbh, fits)) { 443 521 exit(EXIT_FAILURE); -
trunk/ippdb/tests/insertobject.c
r17872 r18044 322 322 } 323 323 324 object = camProcessedExpRowAlloc(-64, -64,"a string", 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, "a string", -32, -32, -32, -32, "a string", -16);324 object = camProcessedExpRowAlloc(-64, "a string", 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, "a string", -32, -32, -32, -32, "a string", -16); 325 325 if (!object) { 326 326 exit(EXIT_FAILURE); … … 359 359 { 360 360 psDB *dbh; 361 fakeRunRow *object; 362 363 dbh = psDBInit("localhost", "test", NULL, "test"); 364 if (!dbh) { 365 exit(EXIT_FAILURE); 366 } 367 368 object = fakeRunRowAlloc(-64, -64, "a string", "a string", "a string", "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z"); 369 if (!object) { 370 exit(EXIT_FAILURE); 371 } 372 373 if (!fakeRunInsertObject(dbh, object)) { 374 exit(EXIT_FAILURE); 375 } 376 377 psFree(object); 378 psDBCleanup(dbh); 379 } 380 381 { 382 psDB *dbh; 383 fakeProcessedImfileRow *object; 384 385 dbh = psDBInit("localhost", "test", NULL, "test"); 386 if (!dbh) { 387 exit(EXIT_FAILURE); 388 } 389 390 object = fakeProcessedImfileRowAlloc(-64, -64, "a string", "a string", 32.32, "a string", "a string", -16, "0001-01-01T00:00:00Z"); 391 if (!object) { 392 exit(EXIT_FAILURE); 393 } 394 395 if (!fakeProcessedImfileInsertObject(dbh, object)) { 396 exit(EXIT_FAILURE); 397 } 398 399 psFree(object); 400 psDBCleanup(dbh); 401 } 402 403 { 404 psDB *dbh; 405 fakeMaskRow *object; 406 407 dbh = psDBInit("localhost", "test", NULL, "test"); 408 if (!dbh) { 409 exit(EXIT_FAILURE); 410 } 411 412 object = fakeMaskRowAlloc("a string"); 413 if (!object) { 414 exit(EXIT_FAILURE); 415 } 416 417 if (!fakeMaskInsertObject(dbh, object)) { 418 exit(EXIT_FAILURE); 419 } 420 421 psFree(object); 422 psDBCleanup(dbh); 423 } 424 425 { 426 psDB *dbh; 361 427 warpRunRow *object; 362 428 … … 388 454 } 389 455 390 object = warpSkyCellMapRowAlloc(-64, "a string", "a string", -64,"a string", -16);456 object = warpSkyCellMapRowAlloc(-64, "a string", "a string", "a string", -16); 391 457 if (!object) { 392 458 exit(EXIT_FAILURE); -
trunk/ippdb/tests/metadatafromobject.c
r17872 r18044 1162 1162 bool status; 1163 1163 1164 object = camProcessedExpRowAlloc(-64, -64,"a string", 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, "a string", -32, -32, -32, -32, "a string", -16);1164 object = camProcessedExpRowAlloc(-64, "a string", 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, 32.32, "a string", -32, -32, -32, -32, "a string", -16); 1165 1165 if (!object) { 1166 1166 exit(EXIT_FAILURE); … … 1177 1177 exit(EXIT_FAILURE); 1178 1178 } 1179 psFree(md);1180 exit(EXIT_FAILURE);1181 }1182 1179 if (strncmp(psMetadataLookupPtr(&status, md, "uri"), "a string", MAX_STRING_LENGTH)) { 1183 1180 psFree(md); … … 1318 1315 { 1319 1316 psMetadata *md; 1317 fakeRunRow *object; 1318 bool status; 1319 1320 object = fakeRunRowAlloc(-64, -64, "a string", "a string", "a string", "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z"); 1321 if (!object) { 1322 exit(EXIT_FAILURE); 1323 } 1324 1325 md = fakeRunMetadataFromObject(object); 1326 if (!md) { 1327 exit(EXIT_FAILURE); 1328 } 1329 1330 psFree(object); 1331 1332 psFree(md); 1333 exit(EXIT_FAILURE); 1334 } 1335 psFree(md); 1336 exit(EXIT_FAILURE); 1337 } 1338 if (strncmp(psMetadataLookupPtr(&status, md, "state"), "a string", MAX_STRING_LENGTH)) { 1339 psFree(md); 1340 exit(EXIT_FAILURE); 1341 } 1342 if (strncmp(psMetadataLookupPtr(&status, md, "workdir"), "a string", MAX_STRING_LENGTH)) { 1343 psFree(md); 1344 exit(EXIT_FAILURE); 1345 } 1346 if (strncmp(psMetadataLookupPtr(&status, md, "label"), "a string", MAX_STRING_LENGTH)) { 1347 psFree(md); 1348 exit(EXIT_FAILURE); 1349 } 1350 if (strncmp(psMetadataLookupPtr(&status, md, "reduction"), "a string", MAX_STRING_LENGTH)) { 1351 psFree(md); 1352 exit(EXIT_FAILURE); 1353 } 1354 if (strncmp(psMetadataLookupPtr(&status, md, "expgroup"), "a string", MAX_STRING_LENGTH)) { 1355 psFree(md); 1356 exit(EXIT_FAILURE); 1357 } 1358 if (strncmp(psMetadataLookupPtr(&status, md, "dvodb"), "a string", MAX_STRING_LENGTH)) { 1359 psFree(md); 1360 exit(EXIT_FAILURE); 1361 } 1362 if (strncmp(psMetadataLookupPtr(&status, md, "tess_id"), "a string", MAX_STRING_LENGTH)) { 1363 psFree(md); 1364 exit(EXIT_FAILURE); 1365 } 1366 if (strncmp(psMetadataLookupPtr(&status, md, "end_stage"), "a string", MAX_STRING_LENGTH)) { 1367 psFree(md); 1368 exit(EXIT_FAILURE); 1369 } 1370 psFree(md); 1371 exit(EXIT_FAILURE); 1372 } 1373 1374 psFree(md); 1375 } 1376 1377 { 1378 psMetadata *md; 1379 fakeProcessedImfileRow *object; 1380 bool status; 1381 1382 object = fakeProcessedImfileRowAlloc(-64, -64, "a string", "a string", 32.32, "a string", "a string", -16, "0001-01-01T00:00:00Z"); 1383 if (!object) { 1384 exit(EXIT_FAILURE); 1385 } 1386 1387 md = fakeProcessedImfileMetadataFromObject(object); 1388 if (!md) { 1389 exit(EXIT_FAILURE); 1390 } 1391 1392 psFree(object); 1393 1394 psFree(md); 1395 exit(EXIT_FAILURE); 1396 } 1397 psFree(md); 1398 exit(EXIT_FAILURE); 1399 } 1400 if (strncmp(psMetadataLookupPtr(&status, md, "class_id"), "a string", MAX_STRING_LENGTH)) { 1401 psFree(md); 1402 exit(EXIT_FAILURE); 1403 } 1404 if (strncmp(psMetadataLookupPtr(&status, md, "uri"), "a string", MAX_STRING_LENGTH)) { 1405 psFree(md); 1406 exit(EXIT_FAILURE); 1407 } 1408 if (!psMetadataLookupF32(&status, md, "dtime_fake") == 32.32) { 1409 psFree(md); 1410 exit(EXIT_FAILURE); 1411 } 1412 if (strncmp(psMetadataLookupPtr(&status, md, "hostname"), "a string", MAX_STRING_LENGTH)) { 1413 psFree(md); 1414 exit(EXIT_FAILURE); 1415 } 1416 if (strncmp(psMetadataLookupPtr(&status, md, "path_base"), "a string", MAX_STRING_LENGTH)) { 1417 psFree(md); 1418 exit(EXIT_FAILURE); 1419 } 1420 psFree(md); 1421 exit(EXIT_FAILURE); 1422 } 1423 psFree(md); 1424 exit(EXIT_FAILURE); 1425 } 1426 1427 psFree(md); 1428 } 1429 1430 { 1431 psMetadata *md; 1432 fakeMaskRow *object; 1433 bool status; 1434 1435 object = fakeMaskRowAlloc("a string"); 1436 if (!object) { 1437 exit(EXIT_FAILURE); 1438 } 1439 1440 md = fakeMaskMetadataFromObject(object); 1441 if (!md) { 1442 exit(EXIT_FAILURE); 1443 } 1444 1445 psFree(object); 1446 1447 if (strncmp(psMetadataLookupPtr(&status, md, "label"), "a string", MAX_STRING_LENGTH)) { 1448 psFree(md); 1449 exit(EXIT_FAILURE); 1450 } 1451 1452 psFree(md); 1453 } 1454 1455 { 1456 psMetadata *md; 1320 1457 warpRunRow *object; 1321 1458 bool status; … … 1387 1524 bool status; 1388 1525 1389 object = warpSkyCellMapRowAlloc(-64, "a string", "a string", -64,"a string", -16);1526 object = warpSkyCellMapRowAlloc(-64, "a string", "a string", "a string", -16); 1390 1527 if (!object) { 1391 1528 exit(EXIT_FAILURE); … … 1407 1544 } 1408 1545 if (strncmp(psMetadataLookupPtr(&status, md, "tess_id"), "a string", MAX_STRING_LENGTH)) { 1409 psFree(md);1410 exit(EXIT_FAILURE);1411 }1412 1546 psFree(md); 1413 1547 exit(EXIT_FAILURE); -
trunk/ippdb/tests/objectfrommetadata.c
r17872 r18044 1978 1978 exit(EXIT_FAILURE); 1979 1979 } 1980 psFree(md);1981 exit(EXIT_FAILURE);1982 }1983 1980 if (!psMetadataAddStr(md, PS_LIST_TAIL, "uri", 0, NULL, "a string")) { 1984 1981 psFree(md); … … 2097 2094 psFree(md); 2098 2095 2099 psFree(object);2100 exit(EXIT_FAILURE);2101 }2102 2096 psFree(object); 2103 2097 exit(EXIT_FAILURE); … … 2242 2236 { 2243 2237 psMetadata *md; 2238 fakeRunRow *object; 2239 2240 md = psMetadataAlloc(); 2241 psFree(md); 2242 exit(EXIT_FAILURE); 2243 } 2244 psFree(md); 2245 exit(EXIT_FAILURE); 2246 } 2247 if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, NULL, "a string")) { 2248 psFree(md); 2249 exit(EXIT_FAILURE); 2250 } 2251 if (!psMetadataAddStr(md, PS_LIST_TAIL, "workdir", 0, NULL, "a string")) { 2252 psFree(md); 2253 exit(EXIT_FAILURE); 2254 } 2255 if (!psMetadataAddStr(md, PS_LIST_TAIL, "label", 0, NULL, "a string")) { 2256 psFree(md); 2257 exit(EXIT_FAILURE); 2258 } 2259 if (!psMetadataAddStr(md, PS_LIST_TAIL, "reduction", 0, NULL, "a string")) { 2260 psFree(md); 2261 exit(EXIT_FAILURE); 2262 } 2263 if (!psMetadataAddStr(md, PS_LIST_TAIL, "expgroup", 0, NULL, "a string")) { 2264 psFree(md); 2265 exit(EXIT_FAILURE); 2266 } 2267 if (!psMetadataAddStr(md, PS_LIST_TAIL, "dvodb", 0, NULL, "a string")) { 2268 psFree(md); 2269 exit(EXIT_FAILURE); 2270 } 2271 if (!psMetadataAddStr(md, PS_LIST_TAIL, "tess_id", 0, NULL, "a string")) { 2272 psFree(md); 2273 exit(EXIT_FAILURE); 2274 } 2275 if (!psMetadataAddStr(md, PS_LIST_TAIL, "end_stage", 0, NULL, "a string")) { 2276 psFree(md); 2277 exit(EXIT_FAILURE); 2278 } 2279 psFree(md); 2280 exit(EXIT_FAILURE); 2281 } 2282 2283 object = fakeRunObjectFromMetadata(md); 2284 if (!object) { 2285 psFree(md); 2286 exit(EXIT_FAILURE); 2287 } 2288 2289 psFree(md); 2290 2291 psFree(object); 2292 exit(EXIT_FAILURE); 2293 } 2294 psFree(object); 2295 exit(EXIT_FAILURE); 2296 } 2297 if (strncmp(object->state, "a string", MAX_STRING_LENGTH)) { 2298 psFree(object); 2299 exit(EXIT_FAILURE); 2300 } 2301 if (strncmp(object->workdir, "a string", MAX_STRING_LENGTH)) { 2302 psFree(object); 2303 exit(EXIT_FAILURE); 2304 } 2305 if (strncmp(object->label, "a string", MAX_STRING_LENGTH)) { 2306 psFree(object); 2307 exit(EXIT_FAILURE); 2308 } 2309 if (strncmp(object->reduction, "a string", MAX_STRING_LENGTH)) { 2310 psFree(object); 2311 exit(EXIT_FAILURE); 2312 } 2313 if (strncmp(object->expgroup, "a string", MAX_STRING_LENGTH)) { 2314 psFree(object); 2315 exit(EXIT_FAILURE); 2316 } 2317 if (strncmp(object->dvodb, "a string", MAX_STRING_LENGTH)) { 2318 psFree(object); 2319 exit(EXIT_FAILURE); 2320 } 2321 if (strncmp(object->tess_id, "a string", MAX_STRING_LENGTH)) { 2322 psFree(object); 2323 exit(EXIT_FAILURE); 2324 } 2325 if (strncmp(object->end_stage, "a string", MAX_STRING_LENGTH)) { 2326 psFree(object); 2327 exit(EXIT_FAILURE); 2328 } 2329 psFree(object); 2330 exit(EXIT_FAILURE); 2331 } 2332 2333 psFree(object); 2334 } 2335 2336 { 2337 psMetadata *md; 2338 fakeProcessedImfileRow *object; 2339 2340 md = psMetadataAlloc(); 2341 psFree(md); 2342 exit(EXIT_FAILURE); 2343 } 2344 psFree(md); 2345 exit(EXIT_FAILURE); 2346 } 2347 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "a string")) { 2348 psFree(md); 2349 exit(EXIT_FAILURE); 2350 } 2351 if (!psMetadataAddStr(md, PS_LIST_TAIL, "uri", 0, NULL, "a string")) { 2352 psFree(md); 2353 exit(EXIT_FAILURE); 2354 } 2355 if (!psMetadataAddF32(md, PS_LIST_TAIL, "dtime_fake", 0, NULL, 32.32)) { 2356 psFree(md); 2357 exit(EXIT_FAILURE); 2358 } 2359 if (!psMetadataAddStr(md, PS_LIST_TAIL, "hostname", 0, NULL, "a string")) { 2360 psFree(md); 2361 exit(EXIT_FAILURE); 2362 } 2363 if (!psMetadataAddStr(md, PS_LIST_TAIL, "path_base", 0, NULL, "a string")) { 2364 psFree(md); 2365 exit(EXIT_FAILURE); 2366 } 2367 psFree(md); 2368 exit(EXIT_FAILURE); 2369 } 2370 psFree(md); 2371 exit(EXIT_FAILURE); 2372 } 2373 2374 object = fakeProcessedImfileObjectFromMetadata(md); 2375 if (!object) { 2376 psFree(md); 2377 exit(EXIT_FAILURE); 2378 } 2379 2380 psFree(md); 2381 2382 psFree(object); 2383 exit(EXIT_FAILURE); 2384 } 2385 psFree(object); 2386 exit(EXIT_FAILURE); 2387 } 2388 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) { 2389 psFree(object); 2390 exit(EXIT_FAILURE); 2391 } 2392 if (strncmp(object->uri, "a string", MAX_STRING_LENGTH)) { 2393 psFree(object); 2394 exit(EXIT_FAILURE); 2395 } 2396 if (!object->dtime_fake == 32.32) { 2397 psFree(object); 2398 exit(EXIT_FAILURE); 2399 } 2400 if (strncmp(object->hostname, "a string", MAX_STRING_LENGTH)) { 2401 psFree(object); 2402 exit(EXIT_FAILURE); 2403 } 2404 if (strncmp(object->path_base, "a string", MAX_STRING_LENGTH)) { 2405 psFree(object); 2406 exit(EXIT_FAILURE); 2407 } 2408 psFree(object); 2409 exit(EXIT_FAILURE); 2410 } 2411 psFree(object); 2412 exit(EXIT_FAILURE); 2413 } 2414 2415 psFree(object); 2416 } 2417 2418 { 2419 psMetadata *md; 2420 fakeMaskRow *object; 2421 2422 md = psMetadataAlloc(); 2423 if (!psMetadataAddStr(md, PS_LIST_TAIL, "label", 0, NULL, "a string")) { 2424 psFree(md); 2425 exit(EXIT_FAILURE); 2426 } 2427 2428 object = fakeMaskObjectFromMetadata(md); 2429 if (!object) { 2430 psFree(md); 2431 exit(EXIT_FAILURE); 2432 } 2433 2434 psFree(md); 2435 2436 if (strncmp(object->label, "a string", MAX_STRING_LENGTH)) { 2437 psFree(object); 2438 exit(EXIT_FAILURE); 2439 } 2440 2441 psFree(object); 2442 } 2443 2444 { 2445 psMetadata *md; 2244 2446 warpRunRow *object; 2245 2447 … … 2364 2566 exit(EXIT_FAILURE); 2365 2567 } 2366 psFree(md);2367 exit(EXIT_FAILURE);2368 }2369 2568 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "a string")) { 2370 2569 psFree(md); … … 2391 2590 } 2392 2591 if (strncmp(object->tess_id, "a string", MAX_STRING_LENGTH)) { 2393 psFree(object);2394 exit(EXIT_FAILURE);2395 }2396 2592 psFree(object); 2397 2593 exit(EXIT_FAILURE); -
trunk/ippdb/tests/selectrowsfits.c
r17144 r18044 373 373 } 374 374 375 if (!fakeRunSelectRowsFits(dbh, fits, NULL, 1)) { 376 exit(EXIT_FAILURE); 377 } 378 379 psFree(fits); 380 psDBCleanup(dbh); 381 } 382 383 { 384 psDB *dbh; 385 psFits *fits; 386 387 dbh = psDBInit("localhost", "test", NULL, "test"); 388 if (!dbh) { 389 exit(EXIT_FAILURE); 390 } 391 392 fits = psFitsOpen(TMP_FILENAME, "w"); 393 if (!fits) { 394 exit(EXIT_FAILURE); 395 } 396 397 if (!fakeProcessedImfileSelectRowsFits(dbh, fits, NULL, 1)) { 398 exit(EXIT_FAILURE); 399 } 400 401 psFree(fits); 402 psDBCleanup(dbh); 403 } 404 405 { 406 psDB *dbh; 407 psFits *fits; 408 409 dbh = psDBInit("localhost", "test", NULL, "test"); 410 if (!dbh) { 411 exit(EXIT_FAILURE); 412 } 413 414 fits = psFitsOpen(TMP_FILENAME, "w"); 415 if (!fits) { 416 exit(EXIT_FAILURE); 417 } 418 419 if (!fakeMaskSelectRowsFits(dbh, fits, NULL, 1)) { 420 exit(EXIT_FAILURE); 421 } 422 423 psFree(fits); 424 psDBCleanup(dbh); 425 } 426 427 { 428 psDB *dbh; 429 psFits *fits; 430 431 dbh = psDBInit("localhost", "test", NULL, "test"); 432 if (!dbh) { 433 exit(EXIT_FAILURE); 434 } 435 436 fits = psFitsOpen(TMP_FILENAME, "w"); 437 if (!fits) { 438 exit(EXIT_FAILURE); 439 } 440 375 441 if (!warpRunSelectRowsFits(dbh, fits, NULL, 1)) { 376 442 exit(EXIT_FAILURE);
Note:
See TracChangeset
for help on using the changeset viewer.
