Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Fix build against 9.6 #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix build against 9.6
parser/keywords.h is now common/keywords.h

The regression expected output files need a new variant because plpgsql
ERRORs will now show an extra CONTEXT line. The net diff for the two
added _1.out files is:

```
--- sql/pgq_node/expected/pgq_node_test.out	2013-02-08 10:44:34.000000000 +0100
+++ sql/pgq_node/expected/pgq_node_test_1.out	2016-09-28 12:36:52.311636581 +0200
@@ -269,6 +269,7 @@

 select * from pgq_node.is_root_node('cqueue');
 ERROR:  queue does not exist: cqueue
+CONTEXT:  PL/pgSQL function pgq_node.is_root_node(text) line 19 at RAISE
 select * from pgq_node.get_consumer_state('bqueue', 'random_consumer');
  ret_code | ret_note | node_type | node_name | completed_tick | provider_node | provider_location | paused | uptodate | cur_error
 ----------+----------+-----------+-----------+----------------+---------------+-------------------+--------+----------+-----------

--- sql/pgq_coop/expected/pgq_coop_test.out	2013-02-08 10:44:34.000000000 +0100
+++ sql/pgq_coop/expected/pgq_coop_test_1.out	2016-09-28 12:36:52.311636581 +0200
@@ -137,6 +137,7 @@

 select pgq_coop.unregister_subconsumer('testqueue', 'maincons', 'subcons2', 0);
 ERROR:  subconsumer has active batch
+CONTEXT:  PL/pgSQL function pgq_coop.unregister_subconsumer(text,text,text,integer) line 42 at RAISE
 select pgq_coop.unregister_subconsumer('testqueue', 'maincons', 'subcons2', 1);
  unregister_subconsumer
 ------------------------
```
  • Loading branch information
df7cb committed Sep 28, 2016
commit 405723e1ce2d13bc0c47b4133f932e48a29d4548
4 changes: 4 additions & 0 deletions sql/pgq/triggers/stringutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
#include <postgres.h>
#include <lib/stringinfo.h>
#include <mb/pg_wchar.h>
#if PG_VERSION_NUM >= 90600
#include <common/keywords.h>
#else
#include <parser/keywords.h>
#endif
#include <utils/memutils.h>

#include "stringutil.h"
Expand Down
193 changes: 193 additions & 0 deletions sql/pgq_coop/expected/pgq_coop_test_1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
select pgq.create_queue('testqueue');
create_queue
--------------
1
(1 row)

update pgq.queue set queue_ticker_max_count = 1 where queue_name = 'testqueue';
-- register
select pgq_coop.register_subconsumer('testqueue', 'maincons', 'subcons1');
register_subconsumer
----------------------
1
(1 row)

select pgq_coop.register_subconsumer('testqueue', 'maincons', 'subcons1');
register_subconsumer
----------------------
0
(1 row)

select pgq_coop.register_subconsumer('testqueue', 'maincons', 'subcons1');
register_subconsumer
----------------------
0
(1 row)

select pgq_coop.register_subconsumer('testqueue', 'maincons', 'subcons2');
register_subconsumer
----------------------
1
(1 row)

-- process events
select pgq_coop.next_batch('testqueue', 'maincons', 'subcons1');
next_batch
------------

(1 row)

select pgq.insert_event('testqueue', 'ev0', 'data');
insert_event
--------------
1
(1 row)

select pgq.insert_event('testqueue', 'ev1', 'data');
insert_event
--------------
2
(1 row)

select pgq.insert_event('testqueue', 'ev2', 'data');
insert_event
--------------
3
(1 row)

select pgq.ticker();
ticker
--------
1
(1 row)

select pgq_coop.next_batch('testqueue', 'maincons', 'subcons1');
next_batch
------------
1
(1 row)

select pgq_coop.next_batch('testqueue', 'maincons', 'subcons1');
next_batch
------------
1
(1 row)

select pgq_coop.next_batch('testqueue', 'maincons', 'subcons2');
next_batch
------------

(1 row)

select pgq.insert_event('testqueue', 'ev3', 'data');
insert_event
--------------
4
(1 row)

select pgq.insert_event('testqueue', 'ev4', 'data');
insert_event
--------------
5
(1 row)

select pgq.insert_event('testqueue', 'ev5', 'data');
insert_event
--------------
6
(1 row)

select pgq.ticker();
ticker
--------
1
(1 row)

select pgq_coop.next_batch('testqueue', 'maincons', 'subcons2');
next_batch
------------
2
(1 row)

select pgq_coop.finish_batch(2);
finish_batch
--------------
1
(1 row)

-- test takeover
select pgq_coop.next_batch('testqueue', 'maincons', 'subcons2', '1 hour');
next_batch
------------

(1 row)

update pgq.subscription set sub_active = '2005-01-01' where sub_batch is not null;
select pgq_coop.next_batch('testqueue', 'maincons', 'subcons2', '1 hour');
next_batch
------------
1
(1 row)

select pgq_coop.unregister_subconsumer('testqueue', 'maincons', 'subcons1', 0);
unregister_subconsumer
------------------------
0
(1 row)

select pgq_coop.unregister_subconsumer('testqueue', 'maincons', 'subcons2', 0);
ERROR: subconsumer has active batch
CONTEXT: PL/pgSQL function pgq_coop.unregister_subconsumer(text,text,text,integer) line 42 at RAISE
select pgq_coop.unregister_subconsumer('testqueue', 'maincons', 'subcons2', 1);
unregister_subconsumer
------------------------
1
(1 row)

select pgq_coop.unregister_subconsumer('testqueue', 'maincons', 'subcons2', 0);
unregister_subconsumer
------------------------
0
(1 row)

-- test auto-creation
select pgq_coop.next_batch('testqueue', 'cmain', 'sc1');
next_batch
------------

(1 row)

select pgq_coop.next_batch('testqueue', 'cmain', 'sc2');
next_batch
------------

(1 row)

select consumer_name, last_tick from pgq.get_consumer_info();
consumer_name | last_tick
---------------+-----------
cmain | 3
cmain.sc1 |
cmain.sc2 |
maincons | 3
(4 rows)

-- test unregistering with pure pgq api
select pgq.unregister_consumer('testqueue', 'cmain.sc2');
unregister_consumer
---------------------
1
(1 row)

select pgq.unregister_consumer('testqueue', 'cmain');
unregister_consumer
---------------------
2
(1 row)

select consumer_name, last_tick from pgq.get_consumer_info();
consumer_name | last_tick
---------------+-----------
maincons | 3
(1 row)

Loading