Index: /trunk/ippdb/configure.ac
===================================================================
--- /trunk/ippdb/configure.ac	(revision 9172)
+++ /trunk/ippdb/configure.ac	(revision 9173)
@@ -7,5 +7,5 @@
 AC_PREREQ(2.59)
 
-AC_INIT([ippdb], [0.0.40], [pan-starrs.ifa.hawaii.edu])
+AC_INIT([ippdb], [0.0.41], [pan-starrs.ifa.hawaii.edu])
 AC_CONFIG_SRCDIR([ippdb.pc.in])
 
Index: /trunk/ippdb/src/ippdb.c
===================================================================
--- /trunk/ippdb/src/ippdb.c	(revision 9172)
+++ /trunk/ippdb/src/ippdb.c	(revision 9173)
@@ -12770,5 +12770,5 @@
 static void detRunRowFree(detRunRow *object);
 
-detRunRow *detRunRowAlloc(psS32 iteration, const char *det_type)
+detRunRow *detRunRowAlloc(psS32 iteration, const char *det_type, const char *state)
 {
     detRunRow       *object;
@@ -12779,4 +12779,5 @@
     object->iteration = iteration;
     object->det_type = psStringCopy(det_type);
+    object->state = psStringCopy(state);
 
     return object;
@@ -12786,4 +12787,5 @@
 {
     psFree(object->det_type);
+    psFree(object->state);
 }
 
@@ -12809,4 +12811,9 @@
         return false;
     }
+    if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, "Key", "64")) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item state");
+        psFree(md);
+        return false;
+    }
 
     status = psDBCreateTable(dbh, DETRUN_TABLE_NAME, md);
@@ -12822,5 +12829,5 @@
 }
 
-bool detRunInsert(psDB * dbh, psS32 iteration, const char *det_type)
+bool detRunInsert(psDB * dbh, psS32 iteration, const char *det_type, const char *state)
 {
     psMetadata      *md;
@@ -12835,4 +12842,9 @@
     if (!psMetadataAddStr(md, PS_LIST_TAIL, "det_type", 0, NULL, det_type)) {
         psError(PS_ERR_UNKNOWN, false, "failed to add item det_type");
+        psFree(md);
+        return false;
+    }
+    if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, NULL, state)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item state");
         psFree(md);
         return false;
@@ -12859,5 +12871,5 @@
     return deleted;
 }
-bool detRunPop(psDB *dbh, psS32 *iteration, char **det_type)
+bool detRunPop(psDB *dbh, psS32 *iteration, char **det_type, char **state)
 {
     psArray         *rowSet;
@@ -12915,4 +12927,10 @@
         return false;
     }
+    *state = psMetadataLookupPtr(&status, row, "state");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item state");
+        psFree(row);
+        return false;
+    }
 
     psFree(row);
@@ -12923,5 +12941,5 @@
 bool detRunInsertObject(psDB *dbh, detRunRow *object)
 {
-    return detRunInsert(dbh, object->iteration, object->det_type);
+    return detRunInsert(dbh, object->iteration, object->det_type, object->state);
 }
 
@@ -12941,11 +12959,12 @@
     psS32           iteration;
     char            det_type[256];
-
-    if (!detRunPop(dbh, &iteration, (char **)&det_type)) {
+    char            state[256];
+
+    if (!detRunPop(dbh, &iteration, (char **)&det_type, (char **)&state)) {
         psError(PS_ERR_UNKNOWN, false, "failed to pop a database row");
         return NULL;
     }
 
-    return detRunRowAlloc(iteration, det_type);
+    return detRunRowAlloc(iteration, det_type, state);
 }
 
@@ -13056,4 +13075,9 @@
         return NULL;
     }
+    if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, NULL, object->state)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item state");
+        psFree(md);
+        return NULL;
+    }
 
     return md;
@@ -13065,4 +13089,5 @@
     psS32           iteration;
     char            *det_type;
+    char            *state;
 
     iteration = psMetadataLookupS32(&status, md, "iteration");
@@ -13076,6 +13101,11 @@
         return false;
     }
-
-    return detRunRowAlloc(iteration, det_type);
+    state = psMetadataLookupPtr(&status, md, "state");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item state");
+        return false;
+    }
+
+    return detRunRowAlloc(iteration, det_type, state);
 }
 psArray *detRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
Index: /trunk/ippdb/src/ippdb.h
===================================================================
--- /trunk/ippdb/src/ippdb.h	(revision 9172)
+++ /trunk/ippdb/src/ippdb.h	(revision 9173)
@@ -5395,4 +5395,5 @@
     psS32           iteration;
     char            *det_type;
+    char            *state;
 } detRunRow;
 
@@ -5404,5 +5405,6 @@
 detRunRow *detRunRowAlloc(
     psS32           iteration,
-    const char      *det_type
+    const char      *det_type,
+    const char      *state
 );
 
@@ -5435,5 +5437,6 @@
     psDB            *dbh,               ///< Database handle
     psS32           iteration,
-    const char      *det_type
+    const char      *det_type,
+    const char      *state
 );
 
@@ -5457,5 +5460,6 @@
     psDB            *dbh,               ///< Database handle
     psS32           *iteration,
-    char            **det_type
+    char            **det_type,
+    char            **state
 );
 
Index: /trunk/ippdb/tests/alloc.c
===================================================================
--- /trunk/ippdb/tests/alloc.c	(revision 9172)
+++ /trunk/ippdb/tests/alloc.c	(revision 9173)
@@ -937,5 +937,5 @@
         detRunRow       *object;
 
-        object = detRunRowAlloc(-32, "a string"    );
+        object = detRunRowAlloc(-32, "a string", "a string"    );
 
         if (!object) {
@@ -948,4 +948,8 @@
         }
         if (strncmp(object->det_type, "a string", MAX_STRING_LENGTH)) {
+            psFree(object);
+            exit(EXIT_FAILURE);
+        }
+        if (strncmp(object->state, "a string", MAX_STRING_LENGTH)) {
             psFree(object);
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/insert.c
===================================================================
--- /trunk/ippdb/tests/insert.c	(revision 9172)
+++ /trunk/ippdb/tests/insert.c	(revision 9173)
@@ -343,5 +343,5 @@
         }
 
-        if (!detRunInsert(dbh, -32, "a string")) {
+        if (!detRunInsert(dbh, -32, "a string", "a string")) {
             exit(EXIT_FAILURE);
         }
Index: /trunk/ippdb/tests/insertobject.c
===================================================================
--- /trunk/ippdb/tests/insertobject.c	(revision 9172)
+++ /trunk/ippdb/tests/insertobject.c	(revision 9173)
@@ -498,5 +498,5 @@
         }
 
-        object = detRunRowAlloc(-32, "a string");
+        object = detRunRowAlloc(-32, "a string", "a string");
         if (!object) {
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/metadatafromobject.c
===================================================================
--- /trunk/ippdb/tests/metadatafromobject.c	(revision 9172)
+++ /trunk/ippdb/tests/metadatafromobject.c	(revision 9173)
@@ -1115,5 +1115,5 @@
         bool            status;
 
-        object = detRunRowAlloc(-32, "a string");
+        object = detRunRowAlloc(-32, "a string", "a string");
         if (!object) {
             exit(EXIT_FAILURE);
@@ -1132,4 +1132,8 @@
         }
         if (strncmp(psMetadataLookupPtr(&status, md, "det_type"), "a string", MAX_STRING_LENGTH)) {
+            psFree(md);
+            exit(EXIT_FAILURE);
+        }
+        if (strncmp(psMetadataLookupPtr(&status, md, "state"), "a string", MAX_STRING_LENGTH)) {
             psFree(md);
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/objectfrommetadata.c
===================================================================
--- /trunk/ippdb/tests/objectfrommetadata.c	(revision 9172)
+++ /trunk/ippdb/tests/objectfrommetadata.c	(revision 9173)
@@ -1697,4 +1697,8 @@
             exit(EXIT_FAILURE);
         }
+        if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, NULL, "a string")) {
+            psFree(md);
+            exit(EXIT_FAILURE);
+        }
 
         object = detRunObjectFromMetadata(md);
@@ -1711,4 +1715,8 @@
         }
         if (strncmp(object->det_type, "a string", MAX_STRING_LENGTH)) {
+            psFree(object);
+            exit(EXIT_FAILURE);
+        }
+        if (strncmp(object->state, "a string", MAX_STRING_LENGTH)) {
             psFree(object);
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/pop.c
===================================================================
--- /trunk/ippdb/tests/pop.c	(revision 9172)
+++ /trunk/ippdb/tests/pop.c	(revision 9173)
@@ -499,11 +499,12 @@
         psS32           iteration;
         char            det_type[256];
-
-        dbh = psDBInit("localhost", "test", NULL, "test");
-        if (!dbh) {
-            exit(EXIT_FAILURE);
-        }
-
-        if (!detRunPop(dbh, &iteration, (char **)&det_type)) { 
+        char            state[256];
+
+        dbh = psDBInit("localhost", "test", NULL, "test");
+        if (!dbh) {
+            exit(EXIT_FAILURE);
+        }
+
+        if (!detRunPop(dbh, &iteration, (char **)&det_type, (char **)&state)) { 
             exit(EXIT_FAILURE);
         }
