DBLINK_CLOSE(3)

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

ok so this is a page from the PostgreSQL 14.24 Documentation, section 3, and bestie, it's a short one. Sit down, sip ur drink, we're closing cursors today. πŸŽ€


✨ 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

✨ DESCRIPTION ✨

So picture this: dblink_close closes a cursor. That's the whole plot. 🌸 But not just any cursor β€” one you previously opened with dblink_open. It's the ✨ closing credits ✨ of the cursor story. No cap.


✨ ARGUMENTS ✨

  • connname β€” which connection we're doing this on, bestie. Omit this param and you get the unnamed connection, easy peasy. πŸ’œ
  • cursorname β€” the name of the cursor you're closing. Say bye to it. πŸ‘‹
  • fail_on_error β€” okay so if it's true (which is the default when you just… don't say anything 😌), then an error thrown on the remote side of the connection makes an error get thrown locally too. Matching energy. πŸ”₯ If it's false, the remote error gets reported locally as a NOTICE, and the function's return value is set to ERROR. Chill but noted. πŸ™ˆ

✨ RETURN VALUE ✨

Returns a status β€” either OK or ERROR. That's it. That's the tea. β˜•


✨ NOTES ✨

Okay this part matters πŸ‘‘: if dblink_open started an explicit transaction block, and this is the last remaining open cursor in this connection, then dblink_close will issue the matching COMMIT. So like, it's not just closing a cursor, it's also tying up the loose ends. main character energy, fr fr. πŸ’…


✨ EXAMPLES ✨

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

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

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

Look at that. Connect, open, close. A whole little arc. 🫢✨


⭐ reminder bestie: dblink_close only closes cursors that dblink_open opened. Don't go throwing random cursor names at it and expecting magic, iykyk.

and that's the whole page, bestie!! you ate that πŸ’– This vibe check was brought to you by PostgreSQL 14.24, dated 2026 β€” go close some cursors responsibly, mwah πŸ’…πŸŽ€

πŸ“¦ where this page comes from