\set VERBOSITY 'terse'
set client_min_messages = 'warning';
select pgq.create_queue('queue_tx_limit');
 create_queue 
--------------
            1
(1 row)

-- test limit
update pgq.queue set queue_per_tx_limit = 2 where queue_name = 'queue_tx_limit';
begin;
select pgq.insert_event('queue_tx_limit', 'test', 'event1');
 insert_event 
--------------
            1
(1 row)

select pgq.insert_event('queue_tx_limit', 'test', 'event2');
 insert_event 
--------------
            2
(1 row)

select pgq.insert_event('queue_tx_limit', 'test', 'event3');
ERROR:  Queue 'queue_tx_limit' allows max 2 events from one TX
end;
update pgq.queue set queue_per_tx_limit = 0 where queue_name = 'queue_tx_limit';
begin;
select pgq.insert_event('queue_tx_limit', 'test', 'event1');
ERROR:  Queue 'queue_tx_limit' allows max 0 events from one TX
end;
update pgq.queue set queue_per_tx_limit = null where queue_name = 'queue_tx_limit';
begin;
select pgq.insert_event('queue_tx_limit', 'test', 'event1');
 insert_event 
--------------
            5
(1 row)

select pgq.insert_event('queue_tx_limit', 'test', 'event2');
 insert_event 
--------------
            6
(1 row)

select pgq.insert_event('queue_tx_limit', 'test', 'event3');
 insert_event 
--------------
            7
(1 row)

end;
select pgq.drop_queue('queue_tx_limit');
 drop_queue 
------------
          1
(1 row)

