DBLINK_CLOSE(3)
π DBLINK_CLOSE(3) π
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'strue(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'sfalse, the remote error gets reported locally as aNOTICE, and the function's return value is set toERROR. 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_closeonly closes cursors thatdblink_openopened. 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
- opensuse-leap 16.0: postgresql14-docs 14.24-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms