Index: /trunk/ippTools/src/warptool.c
===================================================================
--- /trunk/ippTools/src/warptool.c	(revision 10771)
+++ /trunk/ippTools/src/warptool.c	(revision 10772)
@@ -332,5 +332,4 @@
     }
     if (!psArrayLength(output)) {
-        // XXX check psError here
         psError(PS_ERR_UNKNOWN, false, "no p4InputImfile rows found");
         psFree(output);
@@ -475,5 +474,4 @@
     }
     if (!psArrayLength(output)) {
-        // XXX check psError here
         psError(PS_ERR_UNKNOWN, false, "no p4WarpedImfile rows found");
         psFree(output);
@@ -509,6 +507,5 @@
     psString query = psStringCopy(
         " SELECT DISTINCT"
-        "   p4InputImfile.p4_id,"
-        "   p2ProcessedImfile.*"
+        "   p4WarpedImfile.*"
         " FROM p4Run"
         " JOIN p4WarpedImfile"
@@ -541,5 +538,4 @@
     }
     if (!psArrayLength(output)) {
-        // XXX check psError here
         psError(PS_ERR_UNKNOWN, false, "no p4WarpedImfile rows found");
         psFree(output);
@@ -665,5 +661,4 @@
     }
     if (!psArrayLength(output)) {
-        // XXX check psError here
         psError(PS_ERR_UNKNOWN, false, "no p4StackedImfile rows found");
         psFree(output);
@@ -696,4 +691,69 @@
 {
     PS_ASSERT_PTR_NON_NULL(config, NULL);
+
+    psString query = psStringCopy(
+        " SELECT DISTINCT"
+        "   p4StackedImfile.*,"
+        "   p4WarpedImfile.uri as warped_uri"
+        " FROM p4Run"
+        " JOIN p4StackedImfile"
+        "   USING(p4_id)"
+        " JOIN p4WarpedImfile"
+        "   USING(p4_id, class_id)"
+        " LEFT JOIN p4DiffImfile"
+        "   ON p4WarpedImfile.p4_id = p4DiffImfile.p4_id"
+        "   AND p4WarpedImfile.exp_tag = p4DiffImfile.exp_tag"
+        "   AND p4WarpedImfile.p3_version = p4DiffImfile.p3_version"
+        "   AND p4WarpedImfile.class_id = p4DiffImfile.class_id"
+        " WHERE"
+        "   p4Run.state = 'run'"
+        "   AND p4DiffImfile.p4_id IS NULL"
+        "   AND p4DiffImfile.exp_tag IS NULL"
+        "   AND p4DiffImfile.p3_version IS NULL"
+        "   AND p4DiffImfile.class_id IS NULL"
+    );
+
+    if (config->where) {
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4StackedImfile");
+        psStringAppend(&query, " AND %s", whereClause);
+        psFree(whereClause);
+    }
+
+    if (!p_psDBRunQuery(config->dbh, query)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        psFree(query);
+        return false;
+    }
+    psFree(query);
+
+    psArray *output = p_psDBFetchResult(config->dbh);
+    if (!output) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        return false;
+    }
+    if (!psArrayLength(output)) {
+        psError(PS_ERR_UNKNOWN, false, "no p4StackedImfile rows found");
+        psFree(output);
+        return true;
+    }
+
+    bool simple = false;
+    {
+        bool status = false;
+        simple = psMetadataLookupBool(&status, config->args, "-simple");
+        if (!status) {
+            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
+            return false;
+        }
+    }
+
+    // negative simple so the default is true
+    if (!ippdbPrintMetadatas(stdout, output, "p4StackedImfile", !simple)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to print array");
+        psFree(output);
+        return false;
+    }
+
+    psFree(output);
 
     return true;
@@ -815,5 +875,4 @@
     }
     if (!psArrayLength(output)) {
-        // XXX check psError here
         psError(PS_ERR_UNKNOWN, false, "no p4DiffImfile rows found");
         psFree(output);
