Index: trunk/ippTools/share/magictool_toprocess_inputs.sql
===================================================================
--- trunk/ippTools/share/magictool_toprocess_inputs.sql	(revision 23970)
+++ trunk/ippTools/share/magictool_toprocess_inputs.sql	(revision 23971)
@@ -1,11 +1,14 @@
-SELECT
+SELECT * FROM
+(SELECT
     magicTree.*,
+    rawExp.exp_id,
     rawExp.camera,
-    rawExp.exp_id,
-    diffSkyfile.path_base,
+--    diffSkyfile.path_base,
     magicRun.workdir,
     -- convert magic_id into a boolean value (1 or 0)
     -- note that the type stays a 64 bit int
-    magicNodeResult.magic_id IS TRUE as done
+    magicNodeResult.magic_id IS TRUE as done,
+    magicNodeResult.fault IS TRUE as bad,
+    warpSkyfile.uri as template_uri
 FROM magicTree
 JOIN magicRun USING(magic_id)
@@ -14,4 +17,10 @@
     ON magicInputSkyfile.diff_id = diffSkyfile.diff_id
     AND magicInputSkyfile.node = diffSkyfile.skycell_id
+JOIN diffInputSkyfile 
+    ON diffSkyfile.diff_id = diffInputSkyfile.diff_id
+    AND diffSkyfile.skycell_id = diffInputSkyfile.skycell_id
+JOIN warpSkyfile
+    ON diffInputSkyfile.warp2 = warpSkyfile.warp_id
+    AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id
 JOIN rawExp USING(exp_id)
 LEFT JOIN magicNodeResult
@@ -22,2 +31,36 @@
     AND magicNodeResult.magic_id IS NULL
     AND magicNodeResult.node IS NULL
+    -- where hook 1 %s
+UNION
+SELECT
+    magicTree.*,
+    rawExp.exp_id,
+    rawExp.camera,
+--    diffSkyfile.path_base,
+    magicRun.workdir,
+    -- convert magic_id into a boolean value (1 or 0)
+    -- note that the type stays a 64 bit int
+    magicNodeResult.magic_id IS TRUE as done,
+    magicNodeResult.fault IS TRUE as bad,
+    stackSumSkyfile.uri as template_uri
+FROM magicTree
+JOIN magicRun USING(magic_id)
+JOIN magicInputSkyfile USING(magic_id, node)
+JOIN diffSkyfile 
+    ON magicInputSkyfile.diff_id = diffSkyfile.diff_id
+    AND magicInputSkyfile.node = diffSkyfile.skycell_id
+JOIN diffInputSkyfile 
+    ON diffSkyfile.diff_id = diffInputSkyfile.diff_id
+    AND diffSkyfile.skycell_id = diffInputSkyfile.skycell_id
+JOIN stackSumSkyfile
+    ON diffInputSkyfile.stack2 = stackSumSkyfile.stack_id
+JOIN rawExp USING(exp_id)
+LEFT JOIN magicNodeResult
+    ON magicTree.magic_id = magicNodeResult.magic_id
+    AND magicTree.node = magicNodeResult.node
+WHERE
+    magicRun.state = 'new'
+    AND magicNodeResult.magic_id IS NULL
+    AND magicNodeResult.node IS NULL
+    -- where hook 2 %s
+) as foo
Index: trunk/ippTools/share/magictool_toprocess_tree.sql
===================================================================
--- trunk/ippTools/share/magictool_toprocess_tree.sql	(revision 23970)
+++ trunk/ippTools/share/magictool_toprocess_tree.sql	(revision 23971)
@@ -7,5 +7,6 @@
     -- note that the type stays a 64 bit int
     magicNodeResult.magic_id IS TRUE as done,
-    magicNodeResult.fault IS TRUE as bad
+    magicNodeResult.fault IS TRUE as bad,
+    'notused' as template_uri
 FROM magicTree
 JOIN magicRun USING(magic_id)
