Index: /trunk/ippdb/Makefile.am
===================================================================
--- /trunk/ippdb/Makefile.am	(revision 10109)
+++ /trunk/ippdb/Makefile.am	(revision 10110)
@@ -10,4 +10,5 @@
 man_MANS = \
     $(top_builddir)/docs/man/man3/ippdb.3 \
+    $(top_builddir)/docs/man/man3/expTagCounterRow.3 \
     $(top_builddir)/docs/man/man3/summitExpRow.3 \
     $(top_builddir)/docs/man/man3/summitImfileRow.3 \
@@ -45,5 +46,5 @@
 
 
-docs/man/man3/ippdb.3 docs/man/man3/summitExpRow.3 docs/man/man3/summitImfileRow.3 docs/man/man3/pzPendingExpRow.3 docs/man/man3/pzPendingImfileRow.3 docs/man/man3/pzDoneExpRow.3 docs/man/man3/pzDoneImfileRow.3 docs/man/man3/newExpRow.3 docs/man/man3/newImfileRow.3 docs/man/man3/rawDetrendExpRow.3 docs/man/man3/rawScienceExpRow.3 docs/man/man3/rawImfileRow.3 docs/man/man3/p1PendingExpRow.3 docs/man/man3/p2PendingExpRow.3 docs/man/man3/p2PendingImfileRow.3 docs/man/man3/p2ProcessedExpRow.3 docs/man/man3/p2MaskRow.3 docs/man/man3/p2ProcessedImfileRow.3 docs/man/man3/p3PendingExpRow.3 docs/man/man3/p3ProcessedExpRow.3 docs/man/man3/p3MaskRow.3 docs/man/man3/detRunRow.3 docs/man/man3/detInputExpRow.3 docs/man/man3/detProcessedImfileRow.3 docs/man/man3/detProcessedExpRow.3 docs/man/man3/detStackedImfileRow.3 docs/man/man3/detNormalizedStatImfileRow.3 docs/man/man3/detNormalizedImfileRow.3 docs/man/man3/detNormalizedExpRow.3 docs/man/man3/detMasterFrameRow.3 docs/man/man3/detMasterImfileRow.3 docs/man/man3/detResidImfileRow.3 docs/man/man3/detResidExpRow.3 docs/man/man3/detRunSummaryRow.3:
+docs/man/man3/ippdb.3 docs/man/man3/expTagCounterRow.3 docs/man/man3/summitExpRow.3 docs/man/man3/summitImfileRow.3 docs/man/man3/pzPendingExpRow.3 docs/man/man3/pzPendingImfileRow.3 docs/man/man3/pzDoneExpRow.3 docs/man/man3/pzDoneImfileRow.3 docs/man/man3/newExpRow.3 docs/man/man3/newImfileRow.3 docs/man/man3/rawDetrendExpRow.3 docs/man/man3/rawScienceExpRow.3 docs/man/man3/rawImfileRow.3 docs/man/man3/p1PendingExpRow.3 docs/man/man3/p2PendingExpRow.3 docs/man/man3/p2PendingImfileRow.3 docs/man/man3/p2ProcessedExpRow.3 docs/man/man3/p2MaskRow.3 docs/man/man3/p2ProcessedImfileRow.3 docs/man/man3/p3PendingExpRow.3 docs/man/man3/p3ProcessedExpRow.3 docs/man/man3/p3MaskRow.3 docs/man/man3/detRunRow.3 docs/man/man3/detInputExpRow.3 docs/man/man3/detProcessedImfileRow.3 docs/man/man3/detProcessedExpRow.3 docs/man/man3/detStackedImfileRow.3 docs/man/man3/detNormalizedStatImfileRow.3 docs/man/man3/detNormalizedImfileRow.3 docs/man/man3/detNormalizedExpRow.3 docs/man/man3/detMasterFrameRow.3 docs/man/man3/detMasterImfileRow.3 docs/man/man3/detResidImfileRow.3 docs/man/man3/detResidExpRow.3 docs/man/man3/detRunSummaryRow.3:
 	$(DOXYGEN)
 
Index: /trunk/ippdb/configure.ac
===================================================================
--- /trunk/ippdb/configure.ac	(revision 10109)
+++ /trunk/ippdb/configure.ac	(revision 10110)
@@ -7,5 +7,5 @@
 AC_PREREQ(2.59)
 
-AC_INIT([ippdb], [0.0.56], [pan-starrs.ifa.hawaii.edu])
+AC_INIT([ippdb], [0.0.57], [pan-starrs.ifa.hawaii.edu])
 AC_CONFIG_SRCDIR([ippdb.pc.in])
 
Index: /trunk/ippdb/src/ippdb.c
===================================================================
--- /trunk/ippdb/src/ippdb.c	(revision 10109)
+++ /trunk/ippdb/src/ippdb.c	(revision 10110)
@@ -31,4 +31,5 @@
 #include "ippdb.h"
 
+#define EXPTAGCOUNTER_TABLE_NAME "expTagCounter"
 #define SUMMITEXP_TABLE_NAME "summitExp"
 #define SUMMITIMFILE_TABLE_NAME "summitImfile"
@@ -235,4 +236,262 @@
 }
 
+static void expTagCounterRowFree(expTagCounterRow *object);
+
+expTagCounterRow *expTagCounterRowAlloc(psU64 counter)
+{
+    expTagCounterRow *_object;
+
+    _object = psAlloc(sizeof(expTagCounterRow));
+    psMemSetDeallocator(_object, (psFreeFunc)expTagCounterRowFree);
+
+    _object->counter = counter;
+
+    return _object;
+}
+
+static void expTagCounterRowFree(expTagCounterRow *object)
+{
+}
+
+bool expTagCounterCreateTable(psDB *dbh)
+{
+    psMetadata *md = psMetadataAlloc();
+    if (!psMetadataAdd(md, PS_LIST_TAIL, "counter", PS_DATA_U64, NULL, 0)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item counter");
+        psFree(md);
+        return false;
+    }
+
+    bool status = psDBCreateTable(dbh, EXPTAGCOUNTER_TABLE_NAME, md);
+
+    psFree(md);
+
+    return status;
+}
+
+bool expTagCounterDropTable(psDB *dbh)
+{
+    return psDBDropTable(dbh, EXPTAGCOUNTER_TABLE_NAME);
+}
+
+bool expTagCounterInsert(psDB * dbh, psU64 counter)
+{
+    psMetadata *md = psMetadataAlloc();
+    if (!psMetadataAdd(md, PS_LIST_TAIL, "counter", PS_DATA_U64, NULL, counter)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item counter");
+        psFree(md);
+        return false;
+    }
+
+    bool status = psDBInsertOneRow(dbh, EXPTAGCOUNTER_TABLE_NAME, md);
+    psFree(md);
+
+    return status;
+}
+
+long long expTagCounterDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
+{
+    long long       deleted = 0;
+
+    long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);
+    if (count < 0) {
+        psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter");
+        return count;
+
+        deleted += count;
+    }
+
+    return deleted;
+}
+bool expTagCounterInsertObject(psDB *dbh, expTagCounterRow *object)
+{
+    return expTagCounterInsert(dbh, object->counter);
+}
+
+bool expTagCounterInsertObjects(psDB *dbh, psArray *objects)
+{
+    for (long i = 0; i < psArrayLength(objects); i++) {
+        if (!expTagCounterInsertObject(dbh, objects->data[i])) {
+            return false;
+        }
+    }
+
+    return true;
+}
+
+bool expTagCounterInsertFits(psDB *dbh, const psFits *fits)
+{
+    psArray         *rowSet;
+
+    // move to (the first?) extension named  EXPTAGCOUNTER_TABLE_NAME
+    if (!psFitsMoveExtName(fits, EXPTAGCOUNTER_TABLE_NAME)) {
+        psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", EXPTAGCOUNTER_TABLE_NAME);
+        return false;
+    }
+
+    // check HDU type
+    if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE)  {
+        psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE");
+        return false;
+    }
+
+    // read fits table
+    rowSet = psFitsReadTable(fits);
+    if (!rowSet) {
+        psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty");
+        psFree(rowSet);
+        return false;
+    }
+
+    if (!psDBInsertRows(dbh, EXPTAGCOUNTER_TABLE_NAME, rowSet)) {
+        psError(PS_ERR_UNKNOWN, false, "databse insert failed");
+        psFree(rowSet);
+        return false;
+    }
+
+    psFree(rowSet);
+
+    return true;
+}
+
+bool expTagCounterSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
+{
+    psArray         *rowSet;
+
+    rowSet = psDBSelectRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);
+    if (!rowSet) {
+        return false;
+    }
+
+    // output to fits
+    if (!psFitsWriteTable(fits, NULL, rowSet, EXPTAGCOUNTER_TABLE_NAME)) {
+        psError(PS_ERR_UNKNOWN, false, "FITS table write failed");
+        psFree(rowSet);
+        return false;
+    }
+
+    psFree(rowSet);
+
+    return true;
+}
+
+psMetadata *expTagCounterMetadataFromObject(const expTagCounterRow *object)
+{
+    psMetadata *md = psMetadataAlloc();
+    if (!psMetadataAdd(md, PS_LIST_TAIL, "counter", PS_DATA_U64, NULL, object->counter)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item counter");
+        psFree(md);
+        return false;
+    }
+
+
+    return md;
+}
+
+expTagCounterRow *expTagCounterObjectFromMetadata(psMetadata *md)
+{
+
+bool status = false;
+    psU64 counter = psMetadataLookupU64(&status, md, "counter");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item counter");
+        return false;
+    }
+
+    return expTagCounterRowAlloc(counter);
+}
+psArray *expTagCounterSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
+{
+    psArray         *rowSet;
+    psArray         *returnSet;
+    psU64           i;
+
+    rowSet = psDBSelectRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);
+    if (!rowSet) {
+        return NULL;
+    }
+
+    // convert psMetadata rows to row objects
+
+    returnSet = psArrayAllocEmpty(rowSet->n);
+
+    for (i = 0; i < rowSet->n; i++) {
+        expTagCounterRow *object = expTagCounterObjectFromMetadata(rowSet->data[i]);
+        psArrayAdd(returnSet, 0, object);
+        psFree(object);
+    }
+
+    psFree(rowSet);
+
+    return returnSet;
+}
+bool expTagCounterDeleteObject(psDB *dbh, const expTagCounterRow *object)
+{
+    psMetadata *where = expTagCounterMetadataFromObject(object);
+    long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, 0);
+    psFree(where)
+    if (count < 0) {
+        psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter");
+        return false;
+    }
+    if (count > 1) {
+        // XXX should this be a psAbort() instead?  It is possible that
+        // having an object match multiple rows was by design.
+        psError(PS_ERR_UNKNOWN, true, "expTagCounterRow object matched more then one row.  Check your database schema");
+        return false;
+    }
+
+    return true;
+}
+long long expTagCounterDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)
+{
+    long long       deleted = 0;
+
+    for (long long i = 0; i < objects->n; i++) {
+        expTagCounterRow *object = objects->data[i];
+        psMetadata *where = expTagCounterMetadataFromObject(object);
+        long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);
+        psFree(where)
+        if (count < 0) {
+            psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter");
+            return count;
+        }
+
+        deleted += count;
+    }
+
+    return deleted;
+}
+bool expTagCounterPrintObjects(FILE *stream, psArray *objects, bool mdcf)
+{
+    PS_ASSERT_PTR_NON_NULL(objects, false);
+
+    psMetadata *output = psMetadataAlloc();
+    for (long i = 0; i < psArrayLength(objects); i++) {
+        psMetadata *md = expTagCounterMetadataFromObject(objects->data[i]);
+        if (!psMetadataAddMetadata(
+            output,
+            PS_LIST_TAIL,
+            EXPTAGCOUNTER_TABLE_NAME,
+            PS_META_DUPLICATE_OK,
+            NULL,
+            md
+        )) {
+            psError(PS_ERR_UNKNOWN, false, "failed to add metadata");
+            psFree(md);
+            psFree(output);
+            return false;
+        }
+        psFree(md);
+    }
+
+    if (!ippdbPrintMetadataRaw(stream, output, mdcf)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to print metadata");
+        psFree(output);
+    }
+    psFree(output);
+
+    return true;
+}
 static void summitExpRowFree(summitExpRow *object);
 
@@ -2408,5 +2667,5 @@
 static void newExpRowFree(newExpRow *object);
 
-newExpRow *newExpRowAlloc(psU64 exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles)
+newExpRow *newExpRowAlloc(const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles)
 {
     newExpRow       *_object;
@@ -2415,5 +2674,5 @@
     psMemSetDeallocator(_object, (psFreeFunc)newExpRowFree);
 
-    _object->exp_tag = exp_tag;
+    _object->exp_tag = psStringCopy(exp_tag);
     _object->exp_id = psStringCopy(exp_id);
     _object->camera = psStringCopy(camera);
@@ -2428,4 +2687,5 @@
 static void newExpRowFree(newExpRow *object)
 {
+    psFree(object->exp_tag);
     psFree(object->exp_id);
     psFree(object->camera);
@@ -2438,5 +2698,5 @@
 {
     psMetadata *md = psMetadataAlloc();
-    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_U64, "Primary Key AUTO_INCREMENT", 0)) {
+    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, "Primary Key", "64")) {
         psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
         psFree(md);
@@ -2489,8 +2749,8 @@
 }
 
-bool newExpInsert(psDB * dbh, psU64 exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles)
+bool newExpInsert(psDB * dbh, const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles)
 {
     psMetadata *md = psMetadataAlloc();
-    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_U64, NULL, exp_tag)) {
+    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, exp_tag)) {
         psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
         psFree(md);
@@ -2623,5 +2883,5 @@
 {
     psMetadata *md = psMetadataAlloc();
-    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_U64, NULL, object->exp_tag)) {
+    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, object->exp_tag)) {
         psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
         psFree(md);
@@ -2667,5 +2927,5 @@
 
 bool status = false;
-    psU64 exp_tag = psMetadataLookupU64(&status, md, "exp_tag");
+    char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag");
     if (!status) {
         psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag");
Index: /trunk/ippdb/src/ippdb.h
===================================================================
--- /trunk/ippdb/src/ippdb.h	(revision 10109)
+++ /trunk/ippdb/src/ippdb.h	(revision 10110)
@@ -125,4 +125,186 @@
 );
 
+/** expTagCounterRow data structure
+ *
+ * Structure for representing a single row of expTagCounter table data.
+ */
+
+typedef struct {
+    psU64           counter;
+} expTagCounterRow;
+
+/** Creates a new expTagCounterRow object
+ *
+ *  @return A new expTagCounterRow object or NULL on failure.
+ */
+
+expTagCounterRow *expTagCounterRowAlloc(
+    psU64           counter
+);
+
+/** Creates a new expTagCounter table
+ *
+ * @return true on success
+ */
+
+bool expTagCounterCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a expTagCounter table
+ *
+ * @return true on success
+ */
+
+bool expTagCounterDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool expTagCounterInsert(
+    psDB            *dbh,               ///< Database handle
+    psU64           counter
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long expTagCounterDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single expTagCounterRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool expTagCounterInsertObject(
+    psDB            *dbh,               ///< Database handle
+    expTagCounterRow *object             ///< expTagCounterRow object
+);
+
+/** Insert an array of expTagCounterRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool expTagCounterInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of expTagCounterRow objects
+);
+
+/** Insert data from a binary FITS table expTagCounterRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool expTagCounterInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool expTagCounterSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a expTagCounterRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *expTagCounterMetadataFromObject(
+    const expTagCounterRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A expTagCounterRow pointer or NULL on error
+ */
+
+expTagCounterRow *expTagCounterObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as expTagCounterRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *expTagCounterSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an expTagCounter
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool expTagCounterDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const expTagCounterRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long expTagCounterDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of expTagCounterRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool expTagCounterPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of expTagCounterRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
 /** summitExpRow data structure
  *
@@ -1307,5 +1489,5 @@
 
 typedef struct {
-    psU64           exp_tag;
+    char            *exp_tag;
     char            *exp_id;
     char            *camera;
@@ -1322,5 +1504,5 @@
 
 newExpRow *newExpRowAlloc(
-    psU64           exp_tag,
+    const char      *exp_tag,
     const char      *exp_id,
     const char      *camera,
@@ -1358,5 +1540,5 @@
 bool newExpInsert(
     psDB            *dbh,               ///< Database handle
-    psU64           exp_tag,
+    const char      *exp_tag,
     const char      *exp_id,
     const char      *camera,
Index: /trunk/ippdb/tests/alloc.c
===================================================================
--- /trunk/ippdb/tests/alloc.c	(revision 10109)
+++ /trunk/ippdb/tests/alloc.c	(revision 10110)
@@ -9,4 +9,20 @@
 {
     {
+        expTagCounterRow *object;
+
+        object = expTagCounterRowAlloc(64    );
+
+        if (!object) {
+            exit(EXIT_FAILURE);
+        }
+
+            psFree(object);
+            exit(EXIT_FAILURE);
+        }
+
+        psFree(object);
+    }
+
+    {
         summitExpRow    *object;
 
@@ -224,10 +240,11 @@
         newExpRow       *object;
 
-        object = newExpRowAlloc(64, "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32    );
-
-        if (!object) {
-            exit(EXIT_FAILURE);
-        }
-
+        object = newExpRowAlloc("a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32    );
+
+        if (!object) {
+            exit(EXIT_FAILURE);
+        }
+
+        if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) {
             psFree(object);
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/createtable.c
===================================================================
--- /trunk/ippdb/tests/createtable.c	(revision 10109)
+++ /trunk/ippdb/tests/createtable.c	(revision 10110)
@@ -13,4 +13,19 @@
         }
 
+        if(!expTagCounterCreateTable(dbh)) {
+            exit(EXIT_FAILURE);
+        }
+
+        psDBCleanup(dbh);
+    }
+
+    {
+        psDB            *dbh;
+
+        dbh = psDBInit("localhost", "test", NULL, "test");
+        if (!dbh) {
+            exit(EXIT_FAILURE);
+        }
+
         if(!summitExpCreateTable(dbh)) {
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/dbcleanup.c
===================================================================
--- /trunk/ippdb/tests/dbcleanup.c	(revision 10109)
+++ /trunk/ippdb/tests/dbcleanup.c	(revision 10110)
@@ -11,4 +11,5 @@
     }
 
+    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS expTagCounter");
     p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS summitExp");
     p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS summitImfile");
Index: /trunk/ippdb/tests/dbsetup.c
===================================================================
--- /trunk/ippdb/tests/dbsetup.c	(revision 10109)
+++ /trunk/ippdb/tests/dbsetup.c	(revision 10110)
@@ -13,4 +13,7 @@
 
     // remove the table if it already exists
+    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS expTagCounter");
+    expTagCounterCreateTable(dbh);
+
     p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS summitExp");
     summitExpCreateTable(dbh);
Index: /trunk/ippdb/tests/droptable.c
===================================================================
--- /trunk/ippdb/tests/droptable.c	(revision 10109)
+++ /trunk/ippdb/tests/droptable.c	(revision 10110)
@@ -13,4 +13,19 @@
         }
 
+        if (!expTagCounterDropTable(dbh)) {
+            exit(EXIT_FAILURE);
+        }
+
+        psDBCleanup(dbh);
+    }
+
+    {
+        psDB            *dbh;
+
+        dbh = psDBInit("localhost", "test", NULL, "test");
+        if (!dbh) {
+            exit(EXIT_FAILURE);
+        }
+
         if (!summitExpDropTable(dbh)) {
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/insert.c
===================================================================
--- /trunk/ippdb/tests/insert.c	(revision 10109)
+++ /trunk/ippdb/tests/insert.c	(revision 10110)
@@ -13,4 +13,19 @@
         }
 
+        if (!expTagCounterInsert(dbh, 64)) {
+            exit(EXIT_FAILURE);
+        }
+
+        psDBCleanup(dbh);
+    }
+
+    {
+        psDB            *dbh;
+
+        dbh = psDBInit("localhost", "test", NULL, "test");
+        if (!dbh) {
+            exit(EXIT_FAILURE);
+        }
+
         if (!summitExpInsert(dbh, "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", "a string", -32)) {
             exit(EXIT_FAILURE);
@@ -103,5 +118,5 @@
         }
 
-        if (!newExpInsert(dbh, 64, "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32)) {
+        if (!newExpInsert(dbh, "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32)) {
             exit(EXIT_FAILURE);
         }
Index: /trunk/ippdb/tests/insertfits.c
===================================================================
--- /trunk/ippdb/tests/insertfits.c	(revision 10109)
+++ /trunk/ippdb/tests/insertfits.c	(revision 10110)
@@ -24,4 +24,30 @@
         }
 
+        if (!expTagCounterInsertFits(dbh, fits)) {
+            exit(EXIT_FAILURE);
+        }
+
+        if (!psFitsClose(fits)) {
+            exit(EXIT_FAILURE);
+        }
+
+        psDBCleanup(dbh);
+    }
+
+    {
+        psDB            *dbh;
+        psFits          *fits;
+
+        dbh = psDBInit("localhost", "test", NULL, "test");
+        if (!dbh) {
+            exit(EXIT_FAILURE);
+        }
+
+        // open a temp
+        fits = psFitsOpen(TMP_FILENAME, "r");
+        if (!fits) {
+            exit(EXIT_FAILURE);
+        }
+
         if (!summitExpInsertFits(dbh, fits)) {
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/insertobject.c
===================================================================
--- /trunk/ippdb/tests/insertobject.c	(revision 10109)
+++ /trunk/ippdb/tests/insertobject.c	(revision 10110)
@@ -7,4 +7,26 @@
     {
         psDB            *dbh;
+        expTagCounterRow *object;
+
+        dbh = psDBInit("localhost", "test", NULL, "test");
+        if (!dbh) {
+            exit(EXIT_FAILURE);
+        }
+
+        object = expTagCounterRowAlloc(64);
+        if (!object) {
+            exit(EXIT_FAILURE);
+        }
+
+        if (!expTagCounterInsertObject(dbh, object)) {
+            exit(EXIT_FAILURE);
+        }
+
+        psFree(object);
+        psDBCleanup(dbh);
+    }
+
+    {
+        psDB            *dbh;
         summitExpRow    *object;
 
@@ -146,5 +168,5 @@
         }
 
-        object = newExpRowAlloc(64, "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32);
+        object = newExpRowAlloc("a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32);
         if (!object) {
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/metadatafromobject.c
===================================================================
--- /trunk/ippdb/tests/metadatafromobject.c	(revision 10109)
+++ /trunk/ippdb/tests/metadatafromobject.c	(revision 10110)
@@ -10,4 +10,28 @@
     {
         psMetadata      *md;
+        expTagCounterRow *object;
+        bool            status;
+
+        object = expTagCounterRowAlloc(64);
+        if (!object) {
+            exit(EXIT_FAILURE);
+        }
+
+        md = expTagCounterMetadataFromObject(object);
+        if (!md) {
+            exit(EXIT_FAILURE);
+        }
+
+        psFree(object);
+
+            psFree(md);
+            exit(EXIT_FAILURE);
+        }
+
+        psFree(md);
+    }
+
+    {
+        psMetadata      *md;
         summitExpRow    *object;
         bool            status;
@@ -274,5 +298,5 @@
         bool            status;
 
-        object = newExpRowAlloc(64, "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32);
+        object = newExpRowAlloc("a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", -32);
         if (!object) {
             exit(EXIT_FAILURE);
@@ -286,4 +310,5 @@
         psFree(object);
 
+        if (strncmp(psMetadataLookupPtr(&status, md, "exp_tag"), "a string", MAX_STRING_LENGTH)) {
             psFree(md);
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/objectfrommetadata.c
===================================================================
--- /trunk/ippdb/tests/objectfrommetadata.c	(revision 10109)
+++ /trunk/ippdb/tests/objectfrommetadata.c	(revision 10110)
@@ -10,4 +10,28 @@
     {
         psMetadata      *md;
+        expTagCounterRow *object;
+
+        md = psMetadataAlloc();
+            psFree(md);
+            exit(EXIT_FAILURE);
+        }
+
+        object = expTagCounterObjectFromMetadata(md);
+        if (!object) {
+            psFree(md);
+            exit(EXIT_FAILURE);
+        }
+
+        psFree(md);
+
+            psFree(object);
+            exit(EXIT_FAILURE);
+        }
+
+        psFree(object);
+    }
+
+    {
+        psMetadata      *md;
         summitExpRow    *object;
 
@@ -391,4 +415,5 @@
 
         md = psMetadataAlloc();
+        if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_tag", 0, NULL, "a string")) {
             psFree(md);
             exit(EXIT_FAILURE);
@@ -426,4 +451,5 @@
         psFree(md);
 
+        if (strncmp(object->exp_tag, "a string", MAX_STRING_LENGTH)) {
             psFree(object);
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/selectrowsfits.c
===================================================================
--- /trunk/ippdb/tests/selectrowsfits.c	(revision 10109)
+++ /trunk/ippdb/tests/selectrowsfits.c	(revision 10110)
@@ -21,4 +21,26 @@
         }
 
+        if (!expTagCounterSelectRowsFits(dbh, fits, NULL, 1)) {
+            exit(EXIT_FAILURE);
+        }
+
+        psFree(fits);
+        psDBCleanup(dbh);
+    }
+
+    {
+        psDB            *dbh;
+        psFits          *fits;
+
+        dbh = psDBInit("localhost", "test", NULL, "test");
+        if (!dbh) {
+            exit(EXIT_FAILURE);
+        }
+
+        fits = psFitsOpen(TMP_FILENAME, "w");
+        if (!fits) {
+            exit(EXIT_FAILURE);
+        }
+
         if (!summitExpSelectRowsFits(dbh, fits, NULL, 1)) {
             exit(EXIT_FAILURE);
