pgq.register_consumer_at: if tick is given, drop open batch
authorMarko Kreen <markokr@gmail.com>
Wed, 14 Dec 2011 12:48:54 +0000 (14:48 +0200)
committerMarko Kreen <markokr@gmail.com>
Wed, 14 Dec 2011 12:48:54 +0000 (14:48 +0200)
Old behaviour could catch (maybe) some bugs, but made
life hard for consumers that know what they are doing.

Basically, non-NULL tick pos is taken as "consumer knows better".

sql/pgq/functions/pgq.register_consumer.sql

index 51342160d6033c7310846e4c5831bc44cc71521b..b0648047a59b191abdf4fee4d3c6cb56f5bf9b90 100644 (file)
@@ -83,12 +83,11 @@ begin
           and sub_queue  = x_queue_id;
     if found then
         if x_tick_pos is not null then
-            if sub.sub_batch is not null then
-                raise exception 'reposition while active not allowed';
-            end if;
-            -- update tick pos if requested
+            -- if requested, update tick pos and drop partial batch
             update pgq.subscription
                 set sub_last_tick = x_tick_pos,
+                    sub_batch = null,
+                    sub_next_tick = null,
                     sub_active = now()
                 where sub_consumer = x_consumer_id
                   and sub_queue = x_queue_id;