Index: trunk/ippTools/src/stacktool.c
===================================================================
--- trunk/ippTools/src/stacktool.c	(revision 23742)
+++ 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)) {
