Index: trunk/ippTools/src/releasetool.c
===================================================================
--- trunk/ippTools/src/releasetool.c	(revision 37131)
+++ trunk/ippTools/src/releasetool.c	(revision 37165)
@@ -1124,4 +1124,5 @@
 
     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
+    PXOPT_LOOKUP_BOOL(replace, config->args, "-replace", false);
 
     psString query = pxDataGet("releasetool_setrelstackcalibratedfromskycal.sql");
@@ -1132,7 +1133,15 @@
     }
 
+    if (replace) {
+        // don't cut on relStack.state
+        psStringAppend(&query, "\nWHERE ");;
+    } else {
+        // normal path only update rows in state processed
+        psStringAppend(&query, "\nWHERE relStack.state = 'processed'\nAND ");;
+    }
+        
     // Add in the where conditions
     psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
-    psStringAppend(&query, "\nAND %s", whereClause);
+    psStringAppend(&query, "%s", whereClause);
     psFree(whereClause);
 
@@ -1233,5 +1242,5 @@
 
     PXOPT_COPY_STR(config->args, where, "-surveyName",  "survey.surveyName", "LIKE");
-    PXOPT_COPY_S32(config->args, where, "-rel_id",      "relExp.rel_id", "==");
+    PXOPT_COPY_S32(config->args, where, "-rel_id",      "relStack.rel_id", "==");
     pxskycellAddWhere(config, where);
 
