DBLINK_GET_NOTIFY(3)
π DBLINK_GET_NOTIFY π
ok bestie, so this is the DBLINK_GET_NOTIFY(3) page from the PostgreSQL 13.23 Documentation and it's literally the whole tutorial on how to grab async notifications off a connection. no cap, it's short and iconic. π
β¨ NAME β¨
dblink_get_notify β retrieve async notifications on a connection π¦
πΈ SYNOPSIS πΈ
dblink_get_notify() returns setof (notify_name text, be_pid int, extra text)
dblink_get_notify(text connname) returns setof (notify_name text, be_pid int, extra text)
π«Ά DESCRIPTION π«Ά
okay so dblink_get_notify pulls notifications on either the unnamed connection, or on a named connection if you specify one. slay.
β οΈ but listen β to actually receive notifications viadblink, you gotta issueLISTENfirst, usingdblink_exec. that's the whole vibe check. for details seeLISTEN(7)andNOTIFY(7)π
π§ ARGUMENTS π§
connnameβ the name of a named connection to get notifications on. like, a specific one. π
π RETURN VALUE π
returns setof (notify_name text, be_pid int, extra text), or an empty set if there's literally none. that's it. that's the whole thing. π
π₯ EXAMPLES π₯
first, LISTEN on the virtual channel:
SELECT dblink_exec('LISTEN virtual');
dblink_exec
-------------
LISTEN
(1 row)
then check for notifications β nothing yet, it's giving empty:
SELECT * FROM dblink_get_notify();
notify_name | be_pid | extra
-------------+--------+-------
(0 rows)
now somebody fires off a NOTIFY virtual; (which returns NOTIFY), and we look again:
NOTIFY virtual;
NOTIFY
SELECT * FROM dblink_get_notify();
notify_name | be_pid | extra
-------------+--------+-------
virtual | 1229 |
(1 row)
and that's the notification, right there in the table. ate π β¨
sign-off bestie π«Ά β this little beauty comes to you from PostgreSQL 13.23, dated 2025. go forth and listen, mwah ππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13-docs 13.23-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms