Index: trunk/ippTools/src/camtool.c
===================================================================
--- trunk/ippTools/src/camtool.c	(revision 23870)
+++ trunk/ippTools/src/camtool.c	(revision 23873)
@@ -109,6 +109,6 @@
     psMetadata *where = psMetadataAlloc();
     pxcamGetSearchArgs (config, where);
-    PXOPT_COPY_STR(config->args, where, "-label",     "chipRun.label",     "==");
-    PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "==");
+    PXOPT_COPY_STR(config->args, where, "-label",     "camRun.label",     "==");
+    PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "==");
 
     if (!psListLength(where->list) &&
@@ -196,11 +196,11 @@
     }
 
-    // loop over our list of chipRun rows
+    // loop over our list of camRun rows
     for (long i = 0; i < psArrayLength(output); i++) {
         psMetadata *md = output->data[i];
 
-        chipRunRow *row = chipRunObjectFromMetadata(md);
+        camRunRow *row = camRunObjectFromMetadata(md);
         if (!row) {
-            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipRun");
+            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
             psFree(output);
             return false;
@@ -268,5 +268,5 @@
 
     if (state) {
-        // set chipRun.state to state
+        // set camRun.state to state
         if (!pxcamRunSetStateByQuery(config, where, state)) {
             psFree(where);
@@ -276,5 +276,5 @@
 
     if (label) {
-        // set chipRun.label to label
+        // set camRun.label to label
         if (!pxcamRunSetLabelByQuery(config, where, label)) {
             psFree(where);
@@ -362,6 +362,6 @@
     PXOPT_COPY_STR(config->args, where, "-label",     "camRun.label",                 "==");
     PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction",             "==");
-    PXOPT_COPY_S64(config->args, where, "-chip_id",   "chipRun.chip_id",              "==");
-    PXOPT_COPY_STR(config->args, where, "-class_id",  "chipProcessedImfile.class_id", "==");
+    PXOPT_COPY_S64(config->args, where, "-chip_id",   "camRun.chip_id",              "==");
+    PXOPT_COPY_STR(config->args, where, "-class_id",  "camProcessedExp.class_id", "==");
 
     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
@@ -400,5 +400,5 @@
 
     // negate simple so the default is true
-    if (!ippdbPrintMetadatas(stdout, output, "chipProcessedImfile", !simple)) {
+    if (!ippdbPrintMetadatas(stdout, output, "camProcessedExp", !simple)) {
         psError(PS_ERR_UNKNOWN, false, "failed to print array");
         psFree(output);
@@ -1145,4 +1145,5 @@
   PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
   PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
+  PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);
 
   FILE *f = fopen (outfile, "w");
@@ -1193,7 +1194,17 @@
     }
     if (!psArrayLength(output)) {
-      psTrace("regtool", PS_LOG_INFO, "no rows found");
+      psError(PS_ERR_UNKNOWN, true, "no rows found");
       psFree(output);
-      return true;
+      return false;
+    }
+
+    if (clean) {
+        if (!strcmp(tables[i].tableName, "camRun")) {
+            if (!pxSetStateCleaned("camRun", "state", output)) {
+                psFree(output);
+                psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
+                return false;
+            }
+        }
     }
 
Index: trunk/ippTools/src/camtoolConfig.c
===================================================================
--- trunk/ippTools/src/camtoolConfig.c	(revision 23870)
+++ trunk/ippTools/src/camtoolConfig.c	(revision 23873)
@@ -242,4 +242,5 @@
     psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0,          "export to this file (required)", NULL);
     psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit",   0,          "limit result set to N items", 0);
+    psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean",  0,          "export tables as cleaned", false);
 
     // -importrun
Index: trunk/ippTools/src/chiptool.c
===================================================================
--- trunk/ippTools/src/chiptool.c	(revision 23870)
+++ trunk/ippTools/src/chiptool.c	(revision 23873)
@@ -1308,7 +1308,9 @@
   PS_ASSERT_PTR_NON_NULL(config, NULL);
 
-  PXOPT_LOOKUP_S64(det_id, config->args, "-chip_id", true,  false);
+  PXOPT_LOOKUP_S64(dummy, config->args, "-chip_id", true,  false);
   PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
   PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
+  PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);
+
 
   FILE *f = fopen (outfile, "w");
@@ -1361,7 +1363,21 @@
     }
     if (!psArrayLength(output)) {
-      psTrace("regtool", PS_LOG_INFO, "no rows found");
+      psTrace("chiptool", PS_LOG_INFO, "no rows found");
       psFree(output);
-      return true;
+      return false;
+    }
+
+    if (clean) {
+        bool success = true; 
+        if (!strcmp(tables[i].tableName, "chipRun")) {
+            success = pxSetStateCleaned("chipRun", "state", output);
+        } else if (!strcmp(tables[i].tableName, "chipProcessedImfile")) {
+            success = pxSetStateCleaned("chipProcessedImfile", "data_state", output);
+        }
+        if (!success) {
+            psFree(output);
+            psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
+            return false;
+        }
     }
 
@@ -1429,4 +1445,2 @@
     return true;
 }
-
-
Index: trunk/ippTools/src/chiptoolConfig.c
===================================================================
--- trunk/ippTools/src/chiptoolConfig.c	(revision 23870)
+++ trunk/ippTools/src/chiptoolConfig.c	(revision 23873)
@@ -253,4 +253,5 @@
     psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-chip_id", 0,          "export this chip ID (required)", 0);
     psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0,          "export to this file (required)", NULL);
+    psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean",  0,          "mark tables as cleaned", false);
     psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit",   0,          "limit result set to N items", 0);
 
Index: trunk/ippTools/src/difftool.c
===================================================================
--- trunk/ippTools/src/difftool.c	(revision 23870)
+++ trunk/ippTools/src/difftool.c	(revision 23873)
@@ -1748,4 +1748,5 @@
   PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
   PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
+  PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);
 
   FILE *f = fopen (outfile, "w");
@@ -1793,11 +1794,27 @@
     psArray *output = p_psDBFetchResult(config->dbh);
     if (!output) {
-      psError(PS_ERR_UNKNOWN, false, "database error");
       return false;
     }
     if (!psArrayLength(output)) {
-      psTrace("regtool", PS_LOG_INFO, "no rows found");
+      psError(PS_ERR_UNKNOWN, true, "no rows found");
       psFree(output);
-      return true;
+      return false;
+    }
+
+    if (clean) {
+        bool success = true; 
+        if (!strcmp(tables[i].tableName, "diffRun")) {
+            success = pxSetStateCleaned("diffRun", "state", output);
+#ifdef notyet
+        // diffSkyfile doesn't have dataState yet
+        } else if (!strcmp(tables[i].tableName, "diffSkyfile")) {
+            success = pxSetStateCleaned("diffSkyfile", "data_state", output);
+#endif
+        }
+        if (!success) {
+            psFree(output);
+            psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
+            return false;
+        }
     }
 
Index: trunk/ippTools/src/difftoolConfig.c
===================================================================
--- trunk/ippTools/src/difftoolConfig.c	(revision 23870)
+++ trunk/ippTools/src/difftoolConfig.c	(revision 23873)
@@ -215,4 +215,5 @@
     psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0,          "export to this file (required)", NULL);
     psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit",   0,          "limit result set to N items", 0);
+    psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean",  0,          "mark tables as cleaned", false);
 
     // -importrun
Index: trunk/ippTools/src/faketool.c
===================================================================
--- trunk/ippTools/src/faketool.c	(revision 23870)
+++ trunk/ippTools/src/faketool.c	(revision 23873)
@@ -1265,4 +1265,5 @@
   PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
   PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
+  PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);
 
   FILE *f = fopen (outfile, "w");
@@ -1313,7 +1314,17 @@
     }
     if (!psArrayLength(output)) {
-      psTrace("regtool", PS_LOG_INFO, "no rows found");
+      psError(PS_ERR_UNKNOWN, true, "no rows found");
       psFree(output);
-      return true;
+      return false;
+    }
+
+    if (clean) {
+        if (!strcmp(tables[i].tableName, "fakeRun")) {
+            if(!pxSetStateCleaned("fakeRun", "state", output)) {
+                psFree(output);
+                psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
+                return false;
+            }
+        }
     }
 
Index: trunk/ippTools/src/faketoolConfig.c
===================================================================
--- trunk/ippTools/src/faketoolConfig.c	(revision 23870)
+++ trunk/ippTools/src/faketoolConfig.c	(revision 23873)
@@ -306,4 +306,5 @@
     psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0,          "export to this file (required)", NULL);
     psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit",   0,          "limit result set to N items", 0);
+    psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean",  0,          "mark tables as cleaned", false);
 
     // -importrun
Index: trunk/ippTools/src/pxtools.c
===================================================================
--- trunk/ippTools/src/pxtools.c	(revision 23870)
+++ trunk/ippTools/src/pxtools.c	(revision 23873)
@@ -50,2 +50,27 @@
 // 'scrubbed' is a virtual state equivalent to cleaned, but allows files to be removed
 // even if the config files is missing
+
+
+// change the value for tableName.columName from 'full' to 'cleaned' if necessary
+bool pxSetStateCleaned(const psString tableName, const psString columnName, psArray *rows)
+{
+    for (long i = 0; i < psArrayLength(rows); i++) {
+        psMetadata *row = rows->data[i];
+        psString state = psMetadataLookupStr(NULL, row, columnName);
+        if (!state) {
+            psError(PS_ERR_PROGRAMMING, false, "%s not found in row %" PRId64 " of table %s",
+                columnName, i, tableName);
+            return false;
+        }
+        if (!strcmp("full", state)) {
+            // change full to cleaned
+            psMetadataAddStr(row, PS_LIST_TAIL, columnName, PS_META_REPLACE, "", "cleaned");
+        } else if (strcmp("cleaned", state)) {
+            // if state isn't cleaned or full we can't set it to cleaned
+            psError(PS_ERR_PROGRAMMING, true, "%s with state %s may not be exported cleaned",
+                tableName, state);
+            return false;
+        }
+    }
+    return true;
+}
Index: trunk/ippTools/src/pxtools.h
===================================================================
--- trunk/ippTools/src/pxtools.h	(revision 23870)
+++ trunk/ippTools/src/pxtools.h	(revision 23873)
@@ -50,4 +50,5 @@
 
 bool pxIsValidState(const char *state);
+bool pxSetStateCleaned(const psString tableName, const psString columnName, psArray *rows);
 
 bool pxSetFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS16 code);
Index: trunk/ippTools/src/stacktool.c
===================================================================
--- trunk/ippTools/src/stacktool.c	(revision 23870)
+++ trunk/ippTools/src/stacktool.c	(revision 23873)
@@ -1199,4 +1199,5 @@
   PXOPT_LOOKUP_S64(det_id, config->args, "-stack_id", true,  false);
   PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
+  PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);
   PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
 
@@ -1249,8 +1250,19 @@
     }
     if (!psArrayLength(output)) {
-      psTrace("regtool", PS_LOG_INFO, "no rows found");
+      psError(PS_ERR_UNKNOWN, true, "no rows found");
       psFree(output);
-      return true;
-    }
+      return false;
+    }
+
+    if (clean) {
+        if (!strcmp(tables[i].tableName, "stackRun")) {
+            if (!pxSetStateCleaned("stackRun", "state", output)) {
+                psFree(output);
+                psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
+                return false;
+            }
+        }
+    }
+
       // we must write the export table in non-simple (true) format
     if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) {
Index: trunk/ippTools/src/stacktoolConfig.c
===================================================================
--- trunk/ippTools/src/stacktoolConfig.c	(revision 23870)
+++ trunk/ippTools/src/stacktoolConfig.c	(revision 23873)
@@ -193,4 +193,5 @@
     psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0,          "export to this file (required)", NULL);
     psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit",   0,          "limit result set to N items", 0);
+    psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean",  0,          "mark tables as cleaned", false);
 
     // -importrun
Index: trunk/ippTools/src/warptool.c
===================================================================
--- trunk/ippTools/src/warptool.c	(revision 23870)
+++ trunk/ippTools/src/warptool.c	(revision 23873)
@@ -1606,7 +1606,8 @@
     PS_ASSERT_PTR_NON_NULL(config, NULL);
 
-    PXOPT_LOOKUP_S64(det_id, config->args, "-warp_id", true,  false);
+    PXOPT_LOOKUP_S64(det_id,  config->args, "-warp_id", true,  false);
     PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
     PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
+    PXOPT_LOOKUP_BOOL(clean,  config->args, "-clean", false);
 
     FILE *f = fopen (outfile, "w");
@@ -1661,8 +1662,22 @@
       }
       if (!psArrayLength(output)) {
-        psTrace("regtool", PS_LOG_INFO, "no rows found");
+        psError(PS_ERR_UNKNOWN, true, "no rows found");
         psFree(output);
-        return true;
+        return false;
       }
+
+    if (clean) {
+        bool success = true; 
+        if (!strcmp(tables[i].tableName, "warpRun")) {
+            success = pxSetStateCleaned("warpRun", "state", output);
+        } else if (!strcmp(tables[i].tableName, "warpSkyfile")) {
+            success = pxSetStateCleaned("warpSkyfile", "data_state", output);
+        }
+        if (!success) {
+            psFree(output);
+            psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
+            return false;
+        }
+    }
 
       // we must write the export table in non-simple (true) format
Index: trunk/ippTools/src/warptoolConfig.c
===================================================================
--- trunk/ippTools/src/warptoolConfig.c	(revision 23870)
+++ trunk/ippTools/src/warptoolConfig.c	(revision 23873)
@@ -276,4 +276,5 @@
     psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0,          "export to this file (required)", NULL);
     psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit",   0,          "limit result set to N items", 0);
+    psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean",  0,          "export run in cleaned state", false);
 
     // -importrun
