Index: trunk/ippTools/src/stacktool.c
===================================================================
--- trunk/ippTools/src/stacktool.c	(revision 24664)
+++ trunk/ippTools/src/stacktool.c	(revision 24736)
@@ -247,5 +247,5 @@
             psError(PS_ERR_UNKNOWN, false, "failed to print array");
             psFree(output);
-	    psFree(where);
+            psFree(where);
             return false;
         }
@@ -379,10 +379,10 @@
         psStringSubstitute(&thisInsert, skycell_id, "@SKYCELL_ID@");
 
-	if (randomLimit > 0) {
-	  psString limString = NULL;
-	  psStringAppend(&limString, "%d", randomLimit);
-	  psStringSubstitute(&thisInsert, limString, "@RANDOM_LIMIT@");
-	  psFree(limString);
-	}
+        if (randomLimit > 0) {
+          psString limString = NULL;
+          psStringAppend(&limString, "%d", randomLimit);
+          psStringSubstitute(&thisInsert, limString, "@RANDOM_LIMIT@");
+          psFree(limString);
+        }
 
         // XXX this insert uses a select to generate the list of warp_ids for the stack,
@@ -404,36 +404,36 @@
 
 # if (0)
-	{
-	  psArray *output = p_psDBFetchResult(config->dbh);
-	  if (!output) {
-	    psErrorCode err = psErrorCodeLast();
-	    switch (err) {
-	    case PS_ERR_DB_CLIENT:
-	      psError(PXTOOLS_ERR_SYS, false, "database error");
-	    case PS_ERR_DB_SERVER:
-	      psError(PXTOOLS_ERR_PROG, false, "database error");
-	    default:
-	      psError(PXTOOLS_ERR_PROG, false, "unknown error");
-	    }
-	    psFree(where);
-	    return false;
-	  }
-	  if (!psArrayLength(output)) {
-	    psWarning("stacktool (definebyquery, insert): no rows found");
-	    psFree(output);
-	    psFree(where);
-	    return true;
-	  }
-	  // negative simple so the default is true
-	  if (!ippdbPrintMetadatas(stdout, output, "stackSkycells", !simple)) {
-	    psError(PS_ERR_UNKNOWN, false, "failed to print array");
-	    psFree(output);
-	    psFree(where);
-	    return false;
-	  }
-	  psFree(output);
-	  psFree(where);
-	  return true;
-	}
+        {
+          psArray *output = p_psDBFetchResult(config->dbh);
+          if (!output) {
+            psErrorCode err = psErrorCodeLast();
+            switch (err) {
+            case PS_ERR_DB_CLIENT:
+              psError(PXTOOLS_ERR_SYS, false, "database error");
+            case PS_ERR_DB_SERVER:
+              psError(PXTOOLS_ERR_PROG, false, "database error");
+            default:
+              psError(PXTOOLS_ERR_PROG, false, "unknown error");
+            }
+            psFree(where);
+            return false;
+          }
+          if (!psArrayLength(output)) {
+            psWarning("stacktool (definebyquery, insert): no rows found");
+            psFree(output);
+            psFree(where);
+            return true;
+          }
+          // negative simple so the default is true
+          if (!ippdbPrintMetadatas(stdout, output, "stackSkycells", !simple)) {
+            psError(PS_ERR_UNKNOWN, false, "failed to print array");
+            psFree(output);
+            psFree(where);
+            return false;
+          }
+          psFree(output);
+          psFree(where);
+          return true;
+        }
 # endif
 
@@ -828,10 +828,12 @@
     }
 
-    if (!setstackRunState(config, stack_id, "full")) {
-        if (!psDBRollback(config->dbh)) {
-            psError(PS_ERR_UNKNOWN, false, "database error");
-        }
-        psError(PS_ERR_UNKNOWN, false, "failed to change stackRun's state");
-        return false;
+    if (fault == 0) {
+        if (!setstackRunState(config, stack_id, "full")) {
+            if (!psDBRollback(config->dbh)) {
+                psError(PS_ERR_UNKNOWN, false, "database error");
+            }
+            psError(PS_ERR_UNKNOWN, false, "failed to change stackRun's state");
+            return false;
+        }
     }
 
