mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Implement dblink_get_notify().
Adds the ability to retrieve async notifications using dblink, via the addition of the function dblink_get_notify(). Original patch by Marcus Kempe, suggestions by Tom Lane and Alvaro Herrera, patch review and adjustments by Joe Conway.
This commit is contained in:
@ -827,3 +827,54 @@ DROP USER dblink_regression_test;
|
||||
DROP USER MAPPING FOR public SERVER fdtest;
|
||||
DROP SERVER fdtest;
|
||||
DROP FOREIGN DATA WRAPPER postgresql;
|
||||
-- test asynchronous notifications
|
||||
SELECT dblink_connect('dbname=contrib_regression');
|
||||
dblink_connect
|
||||
----------------
|
||||
OK
|
||||
(1 row)
|
||||
|
||||
--should return listen
|
||||
SELECT dblink_exec('LISTEN regression');
|
||||
dblink_exec
|
||||
-------------
|
||||
LISTEN
|
||||
(1 row)
|
||||
|
||||
--should return listen
|
||||
SELECT dblink_exec('LISTEN foobar');
|
||||
dblink_exec
|
||||
-------------
|
||||
LISTEN
|
||||
(1 row)
|
||||
|
||||
SELECT dblink_exec('NOTIFY regression');
|
||||
dblink_exec
|
||||
-------------
|
||||
NOTIFY
|
||||
(1 row)
|
||||
|
||||
SELECT dblink_exec('NOTIFY foobar');
|
||||
dblink_exec
|
||||
-------------
|
||||
NOTIFY
|
||||
(1 row)
|
||||
|
||||
SELECT notify_name, be_pid = (select t.be_pid from dblink('select pg_backend_pid()') as t(be_pid int)) AS is_self_notify, extra from dblink_get_notify();
|
||||
notify_name | is_self_notify | extra
|
||||
-------------+----------------+-------
|
||||
regression | t |
|
||||
foobar | t |
|
||||
(2 rows)
|
||||
|
||||
SELECT * from dblink_get_notify();
|
||||
notify_name | be_pid | extra
|
||||
-------------+--------+-------
|
||||
(0 rows)
|
||||
|
||||
SELECT dblink_disconnect();
|
||||
dblink_disconnect
|
||||
-------------------
|
||||
OK
|
||||
(1 row)
|
||||
|
||||
|
Reference in New Issue
Block a user