1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
create or replace function pgq.current_event_table(x_queue_name text)
returns text as $$
-- ----------------------------------------------------------------------
-- Function: pgq.current_event_table(1)
--
-- Return active event table for particular queue.
-- Event can be added to it without going via functions,
-- e.g. by COPY.
--
-- Note:
-- The result is valid only during current transaction.
--
-- Permissions:
-- Actual insertion requires superuser access.
--
-- Parameters:
-- x_queue_name - Queue name.
-- ----------------------------------------------------------------------
declare
res text;
begin
select queue_data_pfx || '_' || queue_cur_table into res
from pgq.queue where queue_name = x_queue_name;
if not found then
raise exception 'Event queue not found';
end if;
return res;
end;
$$ language plpgsql; -- no perms needed
|