DBLINK_CLOSE(3)

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

okay so this is the dblink_close page from the PostgreSQL 17.11 docs (dblink section, section 3), and honestly it's a little icon: it closes a cursor on a remote database. that's it. that's the whole vibe. let's get into it 🫢


🌸 NAME 🌸

dblink_close β€” closes a cursor in a remote database πŸ’–


✨ SYNOPSIS ✨

dblink_close(text cursorname [, bool fail_on_error]) returns text
dblink_close(text connname, text cursorname [, bool fail_on_error]) returns text

two whole forms, both returning text. pick your fighter πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so dblink_close closes a cursor that you previously opened with dblink_open. that's the entire job. open a cursor, live your life, close the cursor. main character energy from start to finish πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • connname β€” the name of the connection you wanna use. omit this parameter entirely and it'll use the unnamed connection. slay, convenient.
  • cursorname β€” the name of the cursor you're closing. literally the thing you came here for 🌟
  • fail_on_error β€” if true (which is the default when you omit it, no cap) then any error thrown on the remote side of the connection causes an error to also be thrown locally. if false, the remote error gets locally reported as a NOTICE instead, and the function's return value is set to ERROR. so like, you still find out, just gently 😌

πŸ’œ RETURN VALUE πŸ’œ

it returns a status, and that status is either OK or ERROR. short king of a return value fr fr.


πŸ”₯ NOTES πŸ”₯

here's the tea πŸ“: if dblink_open started an explicit transaction block, and this dblink_close happens to be closing the last remaining open cursor in that connection, then dblink_close will issue the matching COMMIT. so it's not just closing a cursor, it's also tying up the transaction loose ends. iconic behavior tbh πŸ‘‘


🌈 EXAMPLES 🌈

connect first, obviously:

SELECT dblink_connect('dbname=postgres options=-csearch_path=');
 dblink_connect
----------------
 OK
(1 row)

then open that cursor:

SELECT dblink_open('foo', 'select proname, prosrc from pg_proc');
 dblink_open
-------------
 OK
(1 row)

and now the moment we've all been waiting for β€” close it πŸŽ‰:

SELECT dblink_close('foo');
 dblink_close
--------------
 OK
(1 row)

OK three times in a row. we love a consistent queen πŸ’€βœ¨


⭐ SEE ALSO ⭐

ngl there's no SEE ALSO section on this page β€” that's the whole manpage, bestie. go read dblink_open if you want the other half of the story 🧚


and that's the page!! brought to you by PostgreSQL 17.11, dated 2026, straight out of the DBLINK_CLOSE(3) corner of the manual πŸ’œ close those cursors responsibly, mwah πŸ«ΆπŸ’–

πŸ“¦ where this page comes from