DBLINK_CLOSE(3)

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

okay bestie, welcome to the PostgreSQL 18.6 docs, section 3, and today's main character is dblink_close β€” she closes a cursor in a remote database πŸŽ€ no cap, that's literally her whole job and she does it flawlessly.


🌸 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 like, dblink_close closes a cursor that you already opened with dblink_open. That's it. That's the vibe. She's the closer. The one who ends things cleanly. iconic behavior honestly ✨


🫢 ARGUMENTS 🫢

  • connname β€” the name of the connection you wanna use. Omit this parameter and you'll be using the unnamed connection instead, which is giving "we're not labeling this, we're just going with it" energy πŸ™ˆ
  • cursorname β€” the name of the cursor you're closing. say goodbye, wave, it's over πŸ¦‹
  • fail_on_error β€” if it's true (which is the default when you omit it), then when an error gets thrown on the remote side of the connection, an error also gets thrown locally. If it's false, that remote error is instead reported locally as a NOTICE, and the function's return value gets set to ERROR. so like, either it screams at you or it just quietly notes it. your call πŸ’€

⭐ RETURN VALUE ⭐

She returns a status, and it's either OK or ERROR. two options, no in-between, very decisive of her πŸ‘‘


πŸ’œ NOTES πŸ’œ

okay here's the tea, and it's important tea: if dblink_open started an explicit transaction block, and this is the last remaining open cursor on this connection, then dblink_close will issue the matching COMMIT. so she's not just closing a cursor, she's also wrapping up the whole situation when she's the last one standing. main character energy fr fr 🌈

bestie pls note: that COMMIT only happens when BOTH of those things are true β€” the explicit transaction block was started, AND this is the last open cursor on the connection. don't skip that part πŸ™

πŸ“ EXAMPLES πŸ“

look at her go, she ate:

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)

connect, open, close. a whole little arc. she understood the assignment βœ¨πŸ’…


🌈 SEE ALSO 🌈

honestly bestie there's no SEE ALSO section in this one β€” she stands on her own. queen behavior πŸ’–


and that's the page, bestie πŸŽ€ this was DBLINK_CLOSE(3) from the PostgreSQL 18.6 Documentation, dated 2026. go close some cursors, you've got this πŸ«Άβœ¨πŸ’œ

πŸ“¦ where this page comes from