Index: trunk/ippTools/src/difftool.c
===================================================================
--- trunk/ippTools/src/difftool.c	(revision 11997)
+++ trunk/ippTools/src/difftool.c	(revision 12024)
@@ -39,5 +39,5 @@
 static bool diffskyfileMode(pxConfig *config);
 
-static bool setp5RunState(pxConfig *config, const char *p4_id, const char *state);
+static bool setdiffRunState(pxConfig *config, const char *warp_id, const char *state);
 
 # define MODECASE(caseName, func) \
@@ -139,5 +139,5 @@
     }
 
-    p5RunRow *run = p5RunRowAlloc(
+    diffRunRow *run = diffRunRowAlloc(
             0,          // ID
             "reg",      // state
@@ -150,8 +150,8 @@
     psFree(registered);
     if (!run) {
-        psError(PS_ERR_UNKNOWN, false, "failed to alloc p5Run object");
+        psError(PS_ERR_UNKNOWN, false, "failed to alloc diffRun object");
         return true;
     }
-    if (!p5RunInsertObject(config->dbh, run)) {
+    if (!diffRunInsertObject(config->dbh, run)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         psFree(run);
@@ -159,6 +159,6 @@
     }
 
-    // get the assigned p5_id
-    run->p5_id = psDBLastInsertID(config->dbh);
+    // get the assigned diff_id
+    run->diff_id = psDBLastInsertID(config->dbh);
 
     bool simple = false;
@@ -173,5 +173,5 @@
     }
 
-    if (!p5RunPrintObject(stdout, run, !simple)) {
+    if (!diffRunPrintObject(stdout, run, !simple)) {
             psError(PS_ERR_UNKNOWN, false, "failed to print object");
             psFree(run);
@@ -190,11 +190,11 @@
 
     bool status = false;
-    psString p5_id = psMetadataLookupStr(&status, config->args, "-p5_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p5_id");
-        return false;
-    }
-    if (!p5_id) {
-        psError(PS_ERR_UNKNOWN, true, "-p5_id is required");
+    psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id");
+        return false;
+    }
+    if (!diff_id) {
+        psError(PS_ERR_UNKNOWN, true, "-diff_id is required");
         return false;
     }
@@ -212,5 +212,5 @@
     if (state) {
         // set detRun.state to state
-        return setp5RunState(config, p5_id, state);
+        return setdiffRunState(config, diff_id, state);
     }
 
@@ -224,21 +224,21 @@
 
     bool status = false;
-    psString p5_id = psMetadataLookupStr(&status, config->args, "-p5_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p5_id");
-        return false;
-    }
-    if (!p5_id) {
-        psError(PS_ERR_UNKNOWN, true, "-p5_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 (!p5_id) {
-        psError(PS_ERR_UNKNOWN, true, "-p5_id is required");
+    psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id");
+        return false;
+    }
+    if (!diff_id) {
+        psError(PS_ERR_UNKNOWN, true, "-diff_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 (!diff_id) {
+        psError(PS_ERR_UNKNOWN, true, "-diff_id is required");
         return false;
     }
@@ -277,10 +277,10 @@
     }
 
-    // XXX need to validate the p4_id here
+    // XXX need to validate the warp_id here
     // XXX instead of validiting it here we should just use forgein key
     // constrants
-    if (!p5InputSkyfileInsert(config->dbh, 
-            (psS32)atoi(p5_id),
-            (psS32)atoi(p4_id),
+    if (!diffInputSkyfileInsert(config->dbh, 
+            (psS32)atoi(diff_id),
+            (psS32)atoi(warp_id),
             skycell_id,
             tess_id,
@@ -310,19 +310,19 @@
     psString query = psStringCopy( 
         "SELECT\n"
-        "   p4Skyfile.*,\n"
-        "   p5InputSkyfile.template\n"
-        " FROM p5Run\n"
-        " JOIN p5InputSkyfile\n"
-        "   USING(p5_id)\n"
-        " JOIN p4Skyfile\n"
-        "   ON p5InputSkyfile.p4_id      = p4Skyfile.p4_id\n"
-        "  AND p5InputSkyfile.skycell_id = p4Skyfile.skycell_id\n"
-        "  AND p5InputSkyfile.tess_id    = p4Skyfile.tess_id\n"
+        "   warpSkyfile.*,\n"
+        "   diffInputSkyfile.template\n"
+        " FROM diffRun\n"
+        " JOIN diffInputSkyfile\n"
+        "   USING(diff_id)\n"
+        " JOIN warpSkyfile\n"
+        "   ON diffInputSkyfile.warp_id      = warpSkyfile.warp_id\n"
+        "  AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id\n"
+        "  AND diffInputSkyfile.tess_id    = warpSkyfile.tess_id\n"
         " WHERE\n"
-        "   p5Run.state = 'run'\n" 
+        "   diffRun.state = 'run'\n" 
     );
 
     if (config->where) {
-        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p5InputSkyfile");
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffInputSkyfile");
         psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
@@ -358,5 +358,5 @@
     }
     if (!psArrayLength(output)) {
-        psError(PS_ERR_UNKNOWN, false, "no p5InputSkyfile rows found");
+        psError(PS_ERR_UNKNOWN, false, "no diffInputSkyfile rows found");
         psFree(output);
         return true;
@@ -375,5 +375,5 @@
     if (psArrayLength(output)) {
         // negative simple so the default is true
-        if (!ippdbPrintMetadatas(stdout, output, "p5InputSkyfile", !simple)) {
+        if (!ippdbPrintMetadatas(stdout, output, "diffInputSkyfile", !simple)) {
             psError(PS_ERR_UNKNOWN, false, "failed to print array");
             psFree(output);
@@ -402,21 +402,21 @@
     psString query = psStringCopy( 
         "SELECT DISTINCT\n"
-        "   p5Run.p5_id\n"
-        " FROM p5Run\n"
-        " JOIN p5InputSkyfile\n"
-        "   USING(p5_id)\n"
-        " JOIN p4Skyfile\n"
-        "   ON p5InputSkyfile.p4_id      = p4Skyfile.p4_id\n"
-        "  AND p5InputSkyfile.skycell_id = p4Skyfile.skycell_id\n"
-        "  AND p5InputSkyfile.tess_id    = p4Skyfile.tess_id\n"
-        " LEFT JOIN p5DiffSkyfile\n"
-        "   ON p5InputSkyfile.p5_id      = p5DiffSkyfile.p5_id\n"
+        "   diffRun.diff_id\n"
+        " FROM diffRun\n"
+        " JOIN diffInputSkyfile\n"
+        "   USING(diff_id)\n"
+        " JOIN warpSkyfile\n"
+        "   ON diffInputSkyfile.warp_id      = warpSkyfile.warp_id\n"
+        "  AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id\n"
+        "  AND diffInputSkyfile.tess_id    = warpSkyfile.tess_id\n"
+        " LEFT JOIN diffSkyfile\n"
+        "   ON diffInputSkyfile.diff_id      = diffSkyfile.diff_id\n"
         " WHERE\n"
-        "   p5Run.state = 'run'\n" 
-        "   AND p5DiffSkyfile.p5_id IS NULL\n"
+        "   diffRun.state = 'run'\n" 
+        "   AND diffSkyfile.diff_id IS NULL\n"
     );
 
     if (config->where) {
-        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p5Skyfile");
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffSkyfile");
         psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
@@ -452,5 +452,5 @@
     }
     if (!psArrayLength(output)) {
-        psError(PS_ERR_UNKNOWN, false, "no p5Skyfile rows found");
+        psError(PS_ERR_UNKNOWN, false, "no diffSkyfile rows found");
         psFree(output);
         return true;
@@ -469,5 +469,5 @@
     if (psArrayLength(output)) {
         // negative simple so the default is true
-        if (!ippdbPrintMetadatas(stdout, output, "p5Skyfile", !simple)) {
+        if (!ippdbPrintMetadatas(stdout, output, "diffSkyfile", !simple)) {
             psError(PS_ERR_UNKNOWN, false, "failed to print array");
             psFree(output);
@@ -487,11 +487,11 @@
 
     bool status = false;
-    psString p5_id = psMetadataLookupStr(&status, config->args, "-p5_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p5_id");
-        return false;
-    }
-    if (!p5_id) {
-        psError(PS_ERR_UNKNOWN, true, "-p5_id is required");
+    psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id");
+        return false;
+    }
+    if (!diff_id) {
+        psError(PS_ERR_UNKNOWN, true, "-diff_id is required");
         return false;
     }
@@ -525,6 +525,6 @@
     }
 
-    if (!p5DiffSkyfileInsert(config->dbh, 
-            (psS32)atoi(p5_id),
+    if (!diffSkyfileInsert(config->dbh, 
+            (psS32)atoi(diff_id),
             uri,
             bg,
@@ -538,5 +538,5 @@
     }
 
-    if (!setp5RunState(config, p5_id, "stop")) {
+    if (!setdiffRunState(config, diff_id, "stop")) {
         if (!psDBRollback(config->dbh)) {
             psError(PS_ERR_UNKNOWN, false, "database error");
@@ -570,16 +570,16 @@
     psString query = psStringCopy( 
         "SELECT\n"
-        "   p5Run.skycell_id,\n"
-        "   p5Run.tess_id,\n"
-        "   p5DiffSkyfile.*\n"
-        " FROM p5Run\n"
-        " JOIN p5DiffSkyfile\n"
-        "   USING(p5_id)\n"
+        "   diffRun.skycell_id,\n"
+        "   diffRun.tess_id,\n"
+        "   diffSkyfile.*\n"
+        " FROM diffRun\n"
+        " JOIN diffSkyfile\n"
+        "   USING(diff_id)\n"
         " WHERE\n"
-        "   p5Run.state = 'run'\n" 
+        "   diffRun.state = 'run'\n" 
     );
 
     if (config->where) {
-        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p5DiffSkyfile");
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffSkyfile");
         psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
@@ -615,5 +615,5 @@
     }
     if (!psArrayLength(output)) {
-        psError(PS_ERR_UNKNOWN, false, "no p5DiffSkyfile rows found");
+        psError(PS_ERR_UNKNOWN, false, "no diffSkyfile rows found");
         psFree(output);
         return true;
@@ -632,5 +632,5 @@
     if (psArrayLength(output)) {
         // negative simple so the default is true
-        if (!ippdbPrintMetadatas(stdout, output, "p5DiffSkyfile", !simple)) {
+        if (!ippdbPrintMetadatas(stdout, output, "diffSkyfile", !simple)) {
             psError(PS_ERR_UNKNOWN, false, "failed to print array");
             psFree(output);
@@ -644,7 +644,7 @@
 }
 
-static bool setp5RunState(pxConfig *config, const char *p5_id, const char *state)
-{
-    PS_ASSERT_PTR_NON_NULL(p5_id, false);
+static bool setdiffRunState(pxConfig *config, const char *diff_id, const char *state)
+{
+    PS_ASSERT_PTR_NON_NULL(diff_id, false);
     PS_ASSERT_PTR_NON_NULL(state, false);
 
@@ -657,15 +657,15 @@
     ) {
         psError(PS_ERR_UNKNOWN, false,
-                "invalid p5Run state: %s", state);
-        return false;
-    }
-
-    char *query = "UPDATE p5Run SET state = '%s' WHERE p5_id = '%s'";
-    if (!p_psDBRunQuery(config->dbh, query, state, p5_id)) {
+                "invalid diffRun state: %s", state);
+        return false;
+    }
+
+    char *query = "UPDATE diffRun SET state = '%s' WHERE diff_id = '%s'";
+    if (!p_psDBRunQuery(config->dbh, query, state, diff_id)) {
         psError(PS_ERR_UNKNOWN, false,
-                "failed to change state for p5_id %s", p5_id);
-        return false;
-    }
-
-    return true;
-}
+                "failed to change state for diff_id %s", diff_id);
+        return false;
+    }
+
+    return true;
+}
