summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Kreen2010-09-03 14:03:16 +0000
committerMarko Kreen2010-09-03 14:03:16 +0000
commite6507faf61fa9976e0addcf626fa53cb2f9ff938 (patch)
treeef870be2e70d7c0fae42ae759729b9d0520a5877
parent16d7f14a8f367b74053d30d62744ae5c1039f562 (diff)
pgq.maint_operations: don't do rotate_step2, if nothing to rotate
-rw-r--r--sql/pgq/functions/pgq.maint_operations.sql11
1 files changed, 8 insertions, 3 deletions
diff --git a/sql/pgq/functions/pgq.maint_operations.sql b/sql/pgq/functions/pgq.maint_operations.sql
index 53aad8c6..d03b5bd6 100644
--- a/sql/pgq/functions/pgq.maint_operations.sql
+++ b/sql/pgq/functions/pgq.maint_operations.sql
@@ -17,8 +17,10 @@ returns setof record as $$
-- ----------------------------------------------------------------------
declare
ops text[];
+ nrot int4;
begin
-- rotate step 1
+ nrot := 0;
func_name := 'pgq.maint_rotate_tables_step1';
for func_arg in
select queue_name from pgq.queue
@@ -27,13 +29,16 @@ begin
and queue_switch_time + queue_rotation_period < current_timestamp
order by 1
loop
+ nrot := nrot + 1;
return next;
end loop;
-- rotate step 2
- func_name := 'pgq.maint_rotate_tables_step2';
- func_arg := NULL;
- return next;
+ if nrot > 0 then
+ func_name := 'pgq.maint_rotate_tables_step2';
+ func_arg := NULL;
+ return next;
+ end if;
-- check if extra field exists
perform 1 from pg_attribute