DBLINK_GET_NOTIFY(3)

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

okay bestie so this is a PostgreSQL 15.19 moment and you're about to learn how to scoop up async notifications on a connection β€” dblink_get_notify, live and in colour ✨


πŸŽ€ 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)

literally two vibes: no args, or one arg. pick your fighter πŸ’…


🌸 DESCRIPTION 🌸

okay so dblink_get_notify retrieves notifications on either the unnamed connection, or on a named connection if you specified one. that's the whole thing, no cap 🫢

⚠️ but listen β€” to receive notifications via dblink, LISTEN must first be issued, using dblink_exec. don't skip this step bestie, it's giving prerequisites 😭

for the deets, go see LISTEN(7) and NOTIFY(7) β€” iykyk πŸ“š


πŸ¦‹ ARGUMENTS πŸ¦‹

  • connname β€” the name of a named connection you wanna get notifications on. that's it. that's the arg πŸ’œ

πŸ‘‘ RETURN VALUE πŸ‘‘

returns setof (notify_name text, be_pid int, extra text), or an empty set if there are none. so like, either you get rows or you get zero rows, no in-between, periodt ⭐


🌈 EXAMPLES 🌈

first things first β€” you gotta LISTEN, and dblink_exec is the way you do it:

SELECT dblink_exec('LISTEN virtual');
 dblink_exec
-------------
 LISTEN
(1 row)

then vibe check the notifications (spoiler: nothing's there yet, it's giving empty) πŸ’€

SELECT * FROM dblink_get_notify();
 notify_name | be_pid | extra
-------------+--------+-------
(0 rows)

now let's actually send one:

NOTIFY virtual;
NOTIFY

and boom, look at that, a whole row appeared, ate and left no crumbs πŸ”₯

SELECT * FROM dblink_get_notify();
 notify_name | be_pid | extra
-------------+--------+-------
 virtual     |   1229 |
(1 row)

and that's the whole page, bestie!! πŸ§šπŸ’–βœ¨

this lil masterpiece is from PostgreSQL 15.19, dated 2026, and it lives in the DBLINK_GET_NOTIFY(3) section of the manual (section 3, the library-calls girlies πŸŽ€). go forth and notify, main character πŸ’…πŸŒΈ

πŸ“¦ where this page comes from