Index: branches/czw_branch/20101203/ippTools/share/pubtool_definerun.sql
===================================================================
--- branches/czw_branch/20101203/ippTools/share/pubtool_definerun.sql	(revision 29982)
+++ branches/czw_branch/20101203/ippTools/share/pubtool_definerun.sql	(revision 30118)
@@ -3,5 +3,6 @@
     client_id,
     stage_id,
-    src_label
+    src_label,
+    output_format
 FROM (
     -- Get diffs to publish
@@ -9,5 +10,6 @@
         client_id,
         diff_id AS stage_id,
-        diffRun.label AS src_label
+        diffRun.label AS src_label,
+	output_format
     FROM publishClient
     JOIN diffRun
@@ -28,5 +30,6 @@
         client_id,
         cam_id AS stage_id,
-        camRun.label AS src_label
+        camRun.label AS src_label,
+	output_format
     FROM publishClient
     JOIN camRun
@@ -43,5 +46,6 @@
         client_id,
         diff_phot_id AS stage_id,
-        diffPhotRun.label AS src_label
+        diffPhotRun.label AS src_label,
+	output_format
     FROM publishClient
     JOIN diffPhotRun
Index: branches/czw_branch/20101203/ippTools/share/pubtool_pending.sql
===================================================================
--- branches/czw_branch/20101203/ippTools/share/pubtool_pending.sql	(revision 29982)
+++ branches/czw_branch/20101203/ippTools/share/pubtool_pending.sql	(revision 30118)
@@ -9,4 +9,5 @@
         publishClient.stage,
         publishClient.workdir,
+	publishClient.output_format,
         diffRun.diff_id AS stage_id,
         rawExp.camera,
@@ -35,4 +36,5 @@
         publishClient.stage,
         publishClient.workdir,
+	publishClient.output_format,
         camRun.cam_id AS stage_id,
         rawExp.camera,
@@ -56,4 +58,5 @@
         publishClient.stage,
         publishClient.workdir,
+	publishClient.output_format,
         diffPhotRun.diff_phot_id AS stage_id,
         rawExp.camera,
Index: branches/czw_branch/20101203/ippTools/share/pxadmin_create_tables.sql
===================================================================
--- branches/czw_branch/20101203/ippTools/share/pxadmin_create_tables.sql	(revision 29982)
+++ branches/czw_branch/20101203/ippTools/share/pxadmin_create_tables.sql	(revision 30118)
@@ -1645,5 +1645,8 @@
     workdir VARCHAR(255) NOT NULL, -- working directory
     comment VARCHAR(255),            -- for human memory
-    PRIMARY KEY(client_id)
+    name varchar(64) default NULL, -- unique client_id verbose identifier
+    output_format SMALLINT NOT NULL default 1, -- format output versioning
+    PRIMARY KEY(client_id),
+    UNIQUE KEY name (name)
 ) ENGINE=innodb DEFAULT CHARSET=latin1;
 
Index: branches/czw_branch/20101203/ippTools/share/regtool_pendingexp.sql
===================================================================
--- branches/czw_branch/20101203/ippTools/share/regtool_pendingexp.sql	(revision 29982)
+++ branches/czw_branch/20101203/ippTools/share/regtool_pendingexp.sql	(revision 30118)
@@ -1,49 +1,54 @@
 SELECT DISTINCT
-    exp_id,
-    tmp_exp_name,
-    tmp_camera,
-    tmp_telescope,
-    state,
-    workdir,
-    workdir_state,
-    reduction,
-    dvodb,
-    tess_id,
-    end_stage,
-    label,
-    camera,
-    filter,
-    obs_mode,
-    obs_group,
-    epoch,
-    dateobs
-FROM
-    (SELECT
-       newExp.*,
-       newImfile.tmp_class_id,
-       rawImfile.tmp_class_id as raw_tmp_class_id,
-       rawImfile.camera,
-       rawImfile.filter,
-       rawImfile.dateobs,
-       rawImfile.obs_mode,
-       rawImfile.obs_group
-    FROM newExp
-    JOIN newImfile
-       USING(exp_id)
-    LEFT JOIN rawExp
-       USING(exp_id)
-    LEFT JOIN rawImfile
-        ON newImfile.exp_id = rawImfile.exp_id
-        AND newImfile.tmp_class_id = rawImfile.tmp_class_id
-    WHERE
-        newExp.state = 'run'
-        AND rawExp.exp_id IS NULL
-	AND rawImfile.data_state = 'full'
--- where hook %s
-    GROUP BY
-        newExp.exp_id
-    HAVING
-        COUNT(newImfile.tmp_class_id) = COUNT(rawImfile.tmp_class_id)
-        AND SUM(rawImfile.fault) = 0
+     exp_id,
+     tmp_exp_name,
+     tmp_camera,
+     tmp_telescope,
+     state,
+     workdir,
+     workdir_state,
+     reduction,
+     dvodb,
+     tess_id,
+     end_stage,
+     label,
+     camera,
+     filter,
+     obs_mode,
+     obs_group,
+     epoch,
+     dateobs
+FROM 
+        (
+        select DISTINCT * from 
+         (
+          select newExp.*,count(newImfile.tmp_class_id) AS new_count
+          from newExp
+          LEFT JOIN newImfile USING (exp_id)
+          LEFT JOIN rawExp USING (exp_id) 
+          where 
+           newExp.state = 'run' AND rawExp.exp_id IS NULL
+          GROUP BY newExp.exp_id
+         ) AS NEWEXPOSURES
+         JOIN 
+         (
+          select DISTINCT newExp.exp_id,
+	  rawImfile.camera,
+	  rawImfile.filter,
+	  rawImfile.dateobs,
+	  rawImfile.obs_mode,
+	  rawImfile.obs_group,
+	  count(rawImfile.tmp_class_id) AS raw_count
+          from newExp
+          LEFT JOIN rawExp USING (exp_id) 
+          LEFT JOIN rawImfile USING (exp_id)
+          where 
+           newExp.state = 'run' AND rawExp.exp_id IS NULL
+           AND rawImfile.data_state = 'full'
+	   -- where hook %s
+          GROUP BY newExp.exp_id
+          HAVING SUM(rawImfile.fault) = 0
+         ) AS RAWEXPOSURES
+	 USING (exp_id)
+        WHERE raw_count = new_count 
+    ) AS Foo
 -- limit hook %s
-    ) as Foo
