Index: trunk/ippTools/src/warptool.c
===================================================================
--- trunk/ippTools/src/warptool.c	(revision 10768)
+++ trunk/ippTools/src/warptool.c	(revision 10769)
@@ -289,4 +289,72 @@
     PS_ASSERT_PTR_NON_NULL(config, NULL);
 
+    psString query = psStringCopy(
+        " SELECT DISTINCT"
+        "   p4InputImfile.p4_id,"
+        "   p2ProcessedImfile.*"
+        " FROM p4Run"
+        " JOIN p4InputImfile"
+        "   USING(p4_id)"
+        " LEFT JOIN p4WarpedImfile"
+        "   USING(p4_id, exp_tag, p3_version, class_id)"
+        " JOIN p3ProcessedExp"
+        "   ON p4InputImfile.exp_tag = p3ProcessedExp.exp_tag"
+        "   AND p4InputImfile.p3_version = p3ProcessedExp.p3_version"
+        " JOIN p2ProcessedImfile"
+        "   ON p4InputImfile.exp_tag = p2ProcessedImfile.exp_tag"
+        "   AND p3ProcessedExp.p2_version = p2ProcessedImfile.p2_version"
+        "   AND p4InputImfile.class_id = p2ProcessedImfile.class_id"
+        " WHERE"
+        "   p4Run.state = 'run'"
+        "   AND p4WarpedImfile.p4_id IS NULL"
+        "   AND p4WarpedImfile.exp_tag IS NULL"
+        "   AND p4WarpedImfile.p3_version IS NULL"
+        "   AND p4WarpedImfile.class_id IS NULL"
+    );
+
+    if (config->where) {
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4InputImfile");
+        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)) {
+        // XXX check psError here
+        psError(PS_ERR_UNKNOWN, false, "no p4InputImfile 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, "p4InputImfile", !simple)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to print array");
+        psFree(output);
+        return false;
+    }
+
+    psFree(output);
+
     return true;
 }
