
[GrantFu]
roles = pgq_reader, pgq_writer, pgq_admin, public

[1.public]
on.functions = %(pgq_generic_fns)s
public = execute

[2.consumer]
on.functions = %(pgq_read_fns)s
pgq_reader = execute

[3.producer]
on.functions = %(pgq_write_fns)s
pgq_writer = execute

[4.admin]
on.functions = %(pgq_system_fns)s
pgq_admin = execute

[5.meta.tables]
on.tables =
	pgq.consumer,
	pgq.queue,
	pgq.tick,
	pgq.subscription
pgq_admin = select, insert, update, delete
pgq_reader = select
public = select

[5.event.tables]
on.tables = pgq.event_template
pgq_reader = select
pgq_admin = select, insert, truncate

# drop public access to events
public =

[6.retry.event]
on.tables = pgq.retry_queue
pgq_admin = select, insert, update, delete


#
# define various groups of functions
#

[DEFAULT]

pgq_generic_fns = 
	pgq.seq_getval(text),
	pgq.get_queue_info(),
	pgq.get_queue_info(text),
	pgq.get_consumer_info(),
	pgq.get_consumer_info(text),
	pgq.get_consumer_info(text, text),
	pgq.quote_fqname(text),
	pgq.version()

pgq_read_fns =
	pgq.batch_event_sql(bigint),
	pgq.batch_event_tables(bigint),
	pgq.find_tick_helper(int4, int8, timestamptz, int8, int8, interval),
	pgq.register_consumer(text, text),
	pgq.register_consumer_at(text, text, bigint),
	pgq.unregister_consumer(text, text),
	pgq.next_batch_info(text, text),
	pgq.next_batch(text, text),
	pgq.next_batch_custom(text, text, interval, int4, interval),
	pgq.get_batch_events(bigint),
	pgq.get_batch_info(bigint),
	pgq.get_batch_cursor(bigint, text, int4, text),
	pgq.get_batch_cursor(bigint, text, int4),
	pgq.event_retry(bigint, bigint, timestamptz),
	pgq.event_retry(bigint, bigint, integer),
	pgq.batch_retry(bigint, integer),
	pgq.force_tick(text),
	pgq.finish_batch(bigint)

pgq_write_fns =
	pgq.insert_event(text, text, text),
	pgq.insert_event(text, text, text, text, text, text, text),
	pgq.current_event_table(text),
	pgq.jsontriga(),
	pgq.sqltriga(),
	pgq.logutriga()

pgq_system_fns =
	pgq.ticker(text, bigint, timestamptz, bigint),
	pgq.ticker(text),
	pgq.ticker(),
	pgq.maint_retry_events(),
	pgq.maint_rotate_tables_step1(text),
	pgq.maint_rotate_tables_step2(),
	pgq.maint_tables_to_vacuum(),
	pgq.maint_operations(),
	pgq.upgrade_schema(),
	pgq.grant_perms(text),
	pgq._grant_perms_from(text,text,text,text),
	pgq.tune_storage(text),
	pgq.seq_setval(text, int8),
	pgq.create_queue(text),
	pgq.drop_queue(text, bool),
	pgq.drop_queue(text),
	pgq.set_queue_config(text, text, text),
	pgq.insert_event_raw(text, bigint, timestamptz, integer, integer, text, text, text, text, text, text),
	pgq.event_retry_raw(text, text, timestamptz, bigint, timestamptz, integer, text, text, text, text, text, text)

