Index: trunk/ippTools/src/stacktool.c
===================================================================
--- trunk/ippTools/src/stacktool.c	(revision 11997)
+++ trunk/ippTools/src/stacktool.c	(revision 12024)
@@ -39,5 +39,5 @@
 static bool sumskyfileMode(pxConfig *config);
 
-static bool setp6RunState(pxConfig *config, const char *p6_id, const char *state);
+static bool setstackRunState(pxConfig *config, const char *stack_id, const char *state);
 
 # define MODECASE(caseName, func) \
@@ -125,8 +125,8 @@
 
     // we have to support multipe exp_tags
-    psMetadataItem *p4_ids = psMetadataLookup(config->args, "-p4_id");
-    if (!p4_ids) {
+    psMetadataItem *warp_ids = psMetadataLookup(config->args, "-warp_id");
+    if (!warp_ids) {
         // this shouldn't actually happen when using psArgs
-        psError(PS_ERR_UNKNOWN, true, "-p4_id is required");
+        psError(PS_ERR_UNKNOWN, true, "-warp_id is required");
         return false;
     }
@@ -147,5 +147,5 @@
     }
 
-    p6RunRow *run = p6RunRowAlloc(
+    stackRunRow *run = stackRunRowAlloc(
             0,          // ID
             "run",      // state
@@ -158,5 +158,5 @@
     psFree(registered);
     if (!run) {
-        psError(PS_ERR_UNKNOWN, false, "failed to alloc p6Run object");
+        psError(PS_ERR_UNKNOWN, false, "failed to alloc stackRun object");
         return true;
     }
@@ -167,5 +167,5 @@
     }
 
-    if (!p6RunInsertObject(config->dbh, run)) {
+    if (!stackRunInsertObject(config->dbh, run)) {
         if (!psDBRollback(config->dbh)) {
             psError(PS_ERR_UNKNOWN, false, "database error");
@@ -176,16 +176,16 @@
     }
 
-    // get the assigned p4_id
-    run->p6_id = psDBLastInsertID(config->dbh);
-
-    // insert the p6InputSkyfile rows
-    psListIterator *iter = psListIteratorAlloc(p4_ids->data.list, 0, false);
+    // get the assigned warp_id
+    run->stack_id = psDBLastInsertID(config->dbh);
+
+    // insert the stackInputSkyfile rows
+    psListIterator *iter = psListIteratorAlloc(warp_ids->data.list, 0, false);
     psMetadataItem *item = NULL;
     while ((item = psListGetAndIncrement(iter))) {
-        if (!p6InputSkyfileInsert(config->dbh, run->p6_id, atoi((char *)item->data.V))) {
+        if (!stackInputSkyfileInsert(config->dbh, run->stack_id, atoi((char *)item->data.V))) {
             if (!psDBRollback(config->dbh)) {
                 psError(PS_ERR_UNKNOWN, false, "database error");
             }
-            psError(PS_ERR_UNKNOWN, false, "failed to insert p6InputSkyfile rows");
+            psError(PS_ERR_UNKNOWN, false, "failed to insert stackInputSkyfile rows");
             return false;
         }
@@ -210,5 +210,5 @@
     }
 
-    if (!p6RunPrintObject(stdout, run, !simple)) {
+    if (!stackRunPrintObject(stdout, run, !simple)) {
             psError(PS_ERR_UNKNOWN, false, "failed to print object");
             psFree(run);
@@ -227,11 +227,11 @@
 
     bool status = false;
-    psString p6_id = psMetadataLookupStr(&status, config->args, "-p6_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p6_id");
-        return false;
-    }
-    if (!p6_id) {
-        psError(PS_ERR_UNKNOWN, true, "-p6_id is required");
+    psString stack_id = psMetadataLookupStr(&status, config->args, "-stack_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stack_id");
+        return false;
+    }
+    if (!stack_id) {
+        psError(PS_ERR_UNKNOWN, true, "-stack_id is required");
         return false;
     }
@@ -249,5 +249,5 @@
     if (state) {
         // set detRun.state to state
-        return setp6RunState(config, p6_id, state);
+        return setstackRunState(config, stack_id, state);
     }
 
@@ -261,32 +261,32 @@
 
     bool status = false;
-    psString p6_id = psMetadataLookupStr(&status, config->args, "-p6_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p6_id");
-        return false;
-    }
-    if (!p6_id) {
-        psError(PS_ERR_UNKNOWN, true, "-p6_id is required");
-        return false;
-
-    }
-
-    psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4_id");
-        return false;
-    }
-    if (!p4_id) {
-        psError(PS_ERR_UNKNOWN, true, "-p4_id is required");
-        return false;
-    }
-
-
-    // XXX need to validate the p4_id here
+    psString stack_id = psMetadataLookupStr(&status, config->args, "-stack_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stack_id");
+        return false;
+    }
+    if (!stack_id) {
+        psError(PS_ERR_UNKNOWN, true, "-stack_id is required");
+        return false;
+
+    }
+
+    psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warp_id");
+        return false;
+    }
+    if (!warp_id) {
+        psError(PS_ERR_UNKNOWN, true, "-warp_id is required");
+        return false;
+    }
+
+
+    // XXX need to validate the warp_id here
     // XXX instead of validiting it here we should just use forgein key
     // constrants
-    if (!p6InputSkyfileInsert(config->dbh, 
-            (psS32)atoi(p6_id),
-            (psS32)atoi(p4_id)
+    if (!stackInputSkyfileInsert(config->dbh, 
+            (psS32)atoi(stack_id),
+            (psS32)atoi(warp_id)
         )) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -312,17 +312,17 @@
     psString query = psStringCopy( 
         "SELECT\n"
-        "   p4Skyfile.*\n"
-        " FROM p6Run\n"
-        " JOIN p6InputSkyfile\n"
-        "   USING(p6_id)\n"
-        " JOIN p4Skyfile\n"
-        "   ON  p6InputSkyfile.p4_id = p4Skyfile.p4_id\n"
-        "   AND p6Run.skycell_id    = p4Skyfile.skycell_id\n"
-        "   AND p6Run.tess_id       = p4Skyfile.tess_id\n"
+        "   warpSkyfile.*\n"
+        " FROM stackRun\n"
+        " JOIN stackInputSkyfile\n"
+        "   USING(stack_id)\n"
+        " JOIN warpSkyfile\n"
+        "   ON  stackInputSkyfile.warp_id = warpSkyfile.warp_id\n"
+        "   AND stackRun.skycell_id    = warpSkyfile.skycell_id\n"
+        "   AND stackRun.tess_id       = warpSkyfile.tess_id\n"
         " WHERE\n"
-        "   p6Run.state = 'run'\n" 
+        "   stackRun.state = 'run'\n" 
     );
     if (config->where) {
-        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p6InputSkyfile");
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "stackInputSkyfile");
         psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
@@ -358,5 +358,5 @@
     }
     if (!psArrayLength(output)) {
-        psError(PS_ERR_UNKNOWN, false, "no p6InputSkyfile rows found");
+        psError(PS_ERR_UNKNOWN, false, "no stackInputSkyfile rows found");
         psFree(output);
         return true;
@@ -375,5 +375,5 @@
     if (psArrayLength(output)) {
         // negative simple so the default is true
-        if (!ippdbPrintMetadatas(stdout, output, "p6InputSkyfile", !simple)) {
+        if (!ippdbPrintMetadatas(stdout, output, "stackInputSkyfile", !simple)) {
             psError(PS_ERR_UNKNOWN, false, "failed to print array");
             psFree(output);
@@ -402,15 +402,15 @@
     psString query = psStringCopy( 
         "SELECT\n"
-        "   p6Run.p6_id\n"
-        " FROM p6Run\n"
-        " LEFT JOIN p6SumSkyfile\n"
-        "   USING(p6_id)\n"
+        "   stackRun.stack_id\n"
+        " FROM stackRun\n"
+        " LEFT JOIN stackSumSkyfile\n"
+        "   USING(stack_id)\n"
         " WHERE\n"
-        "   p6Run.state = 'run'\n" 
-        "   AND p6SumSkyfile.p6_id IS NULL\n"
+        "   stackRun.state = 'run'\n" 
+        "   AND stackSumSkyfile.stack_id IS NULL\n"
     );
 
     if (config->where) {
-        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p6SumSkyfile");
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "stackSumSkyfile");
         psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
@@ -446,5 +446,5 @@
     }
     if (!psArrayLength(output)) {
-        psError(PS_ERR_UNKNOWN, false, "no p6SumSkyfile rows found");
+        psError(PS_ERR_UNKNOWN, false, "no stackSumSkyfile rows found");
         psFree(output);
         return true;
@@ -463,5 +463,5 @@
     if (psArrayLength(output)) {
         // negative simple so the default is true
-        if (!ippdbPrintMetadatas(stdout, output, "p6SumSkyfile", !simple)) {
+        if (!ippdbPrintMetadatas(stdout, output, "stackSumSkyfile", !simple)) {
             psError(PS_ERR_UNKNOWN, false, "failed to print array");
             psFree(output);
@@ -481,11 +481,11 @@
 
     bool status = false;
-    psString p6_id = psMetadataLookupStr(&status, config->args, "-p6_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p6_id");
-        return false;
-    }
-    if (!p6_id) {
-        psError(PS_ERR_UNKNOWN, true, "-p6_id is required");
+    psString stack_id = psMetadataLookupStr(&status, config->args, "-stack_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stack_id");
+        return false;
+    }
+    if (!stack_id) {
+        psError(PS_ERR_UNKNOWN, true, "-stack_id is required");
         return false;
 
@@ -520,9 +520,9 @@
     }
 
-    // XXX need to validate the p6_id here
+    // XXX need to validate the stack_id here
     // XXX instead of validiting it here we should just use forgein key
     // constrants
-    if (!p6SumSkyfileInsert(config->dbh, 
-            (psS32)atoi(p6_id),
+    if (!stackSumSkyfileInsert(config->dbh, 
+            (psS32)atoi(stack_id),
             uri,
             bg,
@@ -536,9 +536,9 @@
     }
 
-    if (setp6RunState(config, p6_id, "stop")) {
+    if (setstackRunState(config, stack_id, "stop")) {
         if (!psDBRollback(config->dbh)) {
             psError(PS_ERR_UNKNOWN, false, "database error");
         }
-        psError(PS_ERR_UNKNOWN, false, "failed to change p6Run's state");
+        psError(PS_ERR_UNKNOWN, false, "failed to change stackRun's state");
         return false;
     }
@@ -568,14 +568,14 @@
     psString query = psStringCopy( 
         "SELECT\n"
-        "   p6SumSkyfile.*\n"
-        " FROM p6Run\n"
-        " JOIN p6SumSkyfile\n"
-        "   USING(p6_id)\n"
+        "   stackSumSkyfile.*\n"
+        " FROM stackRun\n"
+        " JOIN stackSumSkyfile\n"
+        "   USING(stack_id)\n"
         " WHERE\n"
-        "   p6Run.state = 'run'\n" 
+        "   stackRun.state = 'run'\n" 
     );
 
     if (config->where) {
-        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p6SumSkyfile");
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "stackSumSkyfile");
         psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
@@ -611,5 +611,5 @@
     }
     if (!psArrayLength(output)) {
-        psError(PS_ERR_UNKNOWN, false, "no p4Skyfile rows found");
+        psError(PS_ERR_UNKNOWN, false, "no warpSkyfile rows found");
         psFree(output);
         return true;
@@ -627,5 +627,5 @@
 
     if (psArrayLength(output)) {
-        if (!ippdbPrintMetadatas(stdout, output, "p6SumSkyfile", !simple)) {
+        if (!ippdbPrintMetadatas(stdout, output, "stackSumSkyfile", !simple)) {
             psError(PS_ERR_UNKNOWN, false, "failed to print array");
             psFree(output);
@@ -640,7 +640,7 @@
 
 
-static bool setp6RunState(pxConfig *config, const char *p6_id, const char *state)
-{
-    PS_ASSERT_PTR_NON_NULL(p6_id, false);
+static bool setstackRunState(pxConfig *config, const char *stack_id, const char *state)
+{
+    PS_ASSERT_PTR_NON_NULL(stack_id, false);
     PS_ASSERT_PTR_NON_NULL(state, false);
 
@@ -653,15 +653,15 @@
     ) {
         psError(PS_ERR_UNKNOWN, false,
-                "invalid p4Run state: %s", state);
-        return false;
-    }
-
-    char *query = "UPDATE p6Run SET state = '%s' WHERE p6_id = '%s'";
-    if (!p_psDBRunQuery(config->dbh, query, state, p6_id)) {
+                "invalid warpRun state: %s", state);
+        return false;
+    }
+
+    char *query = "UPDATE stackRun SET state = '%s' WHERE stack_id = '%s'";
+    if (!p_psDBRunQuery(config->dbh, query, state, stack_id)) {
         psError(PS_ERR_UNKNOWN, false,
-                "failed to change state for p6_id %s", p6_id);
-        return false;
-    }
-
-    return true;
-}
+                "failed to change state for stack_id %s", stack_id);
+        return false;
+    }
+
+    return true;
+}
