Index: trunk/ippTools/src/warptool.c
===================================================================
--- trunk/ippTools/src/warptool.c	(revision 14105)
+++ trunk/ippTools/src/warptool.c	(revision 14262)
@@ -31,5 +31,6 @@
 #include "warptool.h"
 
-static bool definerunMode(pxConfig *config);
+static psS64 definerunMode(pxConfig *config);
+static bool runoneMode(pxConfig *config);
 static bool updaterunMode(pxConfig *config);
 static bool addinputexpMode(pxConfig *config);
@@ -45,5 +46,5 @@
 
 static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile);
-static bool setwarpRunState(pxConfig *config, const char *warp_id, const char *state);
+static bool setwarpRunState(pxConfig *config, psS64 warp_id, const char *state);
 static bool isValidMode(pxConfig *config, const char *mode);
 bool warpCompletedRuns(pxConfig *config);
@@ -68,4 +69,5 @@
     switch (config->mode) {
         MODECASE(WARPTOOL_MODE_DEFINERUN,         definerunMode);
+        MODECASE(WARPTOOL_MODE_RUNONE,            runoneMode);
         MODECASE(WARPTOOL_MODE_UPDATERUN,         updaterunMode);
         MODECASE(WARPTOOL_MODE_ADDINPUTEXP,       addinputexpMode);
@@ -101,5 +103,5 @@
 
 
-static bool definerunMode(pxConfig *config)
+static psS64 definerunMode(pxConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
@@ -167,5 +169,6 @@
 
     // get the assigned warp_id
-    warpRun->warp_id = psDBLastInsertID(config->dbh);
+    psS64 warp_id = psDBLastInsertID(config->dbh);
+    warpRun->warp_id = warp_id;
 
     bool simple = false;
@@ -188,7 +191,63 @@
     psFree(warpRun);
 
-    return true;
-}
-
+    return warp_id;
+}
+
+static bool runoneMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+
+    if (!psDBTransaction(config->dbh)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        return false;
+    }
+
+    psS64 warp_id = definerunMode(config);
+    if (!warp_id) {
+        // rollback
+        if (!psDBRollback(config->dbh)) {
+            psError(PS_ERR_UNKNOWN, false, "database error");
+        }
+        psError(PS_ERR_UNKNOWN, false, "failed to define warpRun");
+        return false;
+    }
+
+    psString warp_id_str = psDBIntToString(warp_id);
+    if (!psMetadataAddStr(config->args, PS_LIST_TAIL, "-warp_id", 0, NULL, warp_id_str)) {
+        // rollback
+        if (!psDBRollback(config->dbh)) {
+            psError(PS_ERR_UNKNOWN, false, "database error");
+        }
+        psError(PS_ERR_UNKNOWN, false, "failed to add item warp_id");
+        psFree(warp_id_str);
+        return false;
+    }
+    psFree(warp_id_str);
+
+    if (!addinputexpMode(config)) {
+        // rollback
+        if (!psDBRollback(config->dbh)) {
+            psError(PS_ERR_UNKNOWN, false, "database error");
+        }
+        psError(PS_ERR_UNKNOWN, false, "failed to add cam_id to warpRun");
+        return false;
+    }
+    if (!setwarpRunState(config, warp_id, "run")) {
+        // rollback
+        if (!psDBRollback(config->dbh)) {
+            psError(PS_ERR_UNKNOWN, false, "database error");
+        }
+        psError(PS_ERR_UNKNOWN, false, "failed to set warpRun.state to run");
+        return false;
+    }
+
+    // point of no return
+    if (!psDBCommit(config->dbh)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        return false;
+    }
+
+    return true;
+}
 
 static bool updaterunMode(pxConfig *config)
@@ -219,5 +278,5 @@
     if (state) {
         // set detRun.state to state
-        return setwarpRunState(config, warp_id, state);
+        return setwarpRunState(config, (psS64)atoll(warp_id), state);
     }
 
@@ -1161,7 +1220,6 @@
 
 
-static bool setwarpRunState(pxConfig *config, const char *warp_id, const char *state)
-{
-    PS_ASSERT_PTR_NON_NULL(warp_id, false);
+static bool setwarpRunState(pxConfig *config, psS64 warp_id, const char *state)
+{
     PS_ASSERT_PTR_NON_NULL(state, false);
 
@@ -1178,8 +1236,8 @@
     }
 
-    char *query = "UPDATE warpRun SET state = '%s' WHERE warp_id = '%s'";
+    char *query = "UPDATE warpRun SET state = '%s' WHERE warp_id = %" PRId64;
     if (!p_psDBRunQuery(config->dbh, query, state, warp_id)) {
         psError(PS_ERR_UNKNOWN, false,
-                "failed to change state for warp_id %s", warp_id);
+                "failed to change state for warp_id %" PRId64, warp_id);
         return false;
     }
