pgq_node.set_global_watermark: fix wm=null check for branch node
authorMarko Kreen <markokr@gmail.com>
Wed, 11 Jan 2012 09:54:59 +0000 (10:54 +0100)
committerMarko Kreen <markokr@gmail.com>
Wed, 11 Jan 2012 09:54:59 +0000 (10:54 +0100)
It was in wrong IF section

sql/pgq_node/functions/pgq_node.set_global_watermark.sql

index 9150ad766174c532a1dabd3a819d40c6c29c4cc9..d0c7d470652de5610bb1c5ca7127bcd98d87c7f2 100644 (file)
@@ -44,10 +44,6 @@ begin
             if _wm is null then
                 raise exception 'local_watermark=NULL from get_node_info()?';
             end if;
-        elsif i_watermark is null then
-            select 500, 'bad usage: wm=null on non-root node'
-                into ret_code, ret_note;
-            return;
         end if;
 
         -- move watermark
@@ -62,6 +58,12 @@ begin
             where queue_name = i_queue_name
                 and consumer_name = this.worker_name;
     elsif this.node_type = 'branch' then
+        if i_watermark is null then
+            select 500, 'bad usage: wm=null on branch node'
+                into ret_code, ret_note;
+            return;
+        end if;
+
         -- tick can be missing if we are processing
         -- old batches that set watermark outside
         -- current range