DBLINK_GET_NOTIFY(3)

πŸ“¦ version 13.23, in opensuse-leap 16.0

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 via dblink, you gotta issue LISTEN first, using dblink_exec. that's the whole vibe check. for details see LISTEN(7) and NOTIFY(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