sql/pgq: allow sub_last_tick to be NULL (pgq_coop)
authorMarko Kreen <markokr@gmail.com>
Wed, 8 Apr 2009 13:03:56 +0000 (16:03 +0300)
committerMarko Kreen <markokr@gmail.com>
Wed, 8 Apr 2009 14:11:09 +0000 (17:11 +0300)
sql/pgq/functions/pgq.get_consumer_info.sql
sql/pgq/structure/tables.sql

index a101c9b3387accfb3b701042c13b40c7d13efa5e..6e0f92cd407e95405b0646ba4b297013def2f01b 100644 (file)
@@ -103,10 +103,10 @@ begin
                current_timestamp - t.tick_time,
                current_timestamp - s.sub_active,
                s.sub_last_tick, s.sub_batch, s.sub_next_tick
-          from pgq.subscription s, pgq.tick t, pgq.queue q, pgq.consumer c
-         where t.tick_id = s.sub_last_tick
-           and q.queue_id = s.sub_queue
-           and t.tick_queue = s.sub_queue
+          from pgq.queue q, pgq.consumer c,
+               pgq.subscription s left join pgq.tick t
+               on (t.tick_queue = s.sub_queue and t.tick_id = s.sub_last_tick)
+         where q.queue_id = s.sub_queue
            and c.co_id = s.sub_consumer
            and (i_queue_name is null or q.queue_name = i_queue_name)
            and (i_consumer_name is null or c.co_name = i_consumer_name)
index 6e88c7c5145d026cd15d78c76f7655017700de56..041653cfc8668c1d006223ca56dcb3e2acabe674 100644 (file)
@@ -144,7 +144,7 @@ create table pgq.subscription (
         sub_id                          serial      not null,
         sub_queue                       int4        not null,
         sub_consumer                    int4        not null,
-        sub_last_tick                   bigint      not null,
+        sub_last_tick                   bigint,
         sub_active                      timestamptz not null default now(),
         sub_batch                       bigint,
         sub_next_tick                   bigint,