Index: trunk/ippdb/src/ippdb.c
===================================================================
--- trunk/ippdb/src/ippdb.c	(revision 9149)
+++ 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)
