Skip to content

Commit cd1e23e

Browse files
committed
Fix ancient connection leak in dblink
When using unnamed connections with dblink, every time a new connection is made, the old one is leaked. Fix that. This has been an issue probably since dblink was first committed. Someone complained almost ten years ago, but apparently I decided not to pursue it at the time, and neither did anyone else, so it slipped between the cracks. Now that someone else has complained, fix in all supported branches. Discussion: (orig) https://postgr.es/m/flat/F680AB59-6D6F-4026-9599-1BE28880273D%40decibel.org#F680AB59-6D6F-4026-9599-1BE28880273D@decibel.org Discussion: (new) https://postgr.es/m/flat/0A3221C70F24FB45833433255569204D1F6ADF8C@G01JPEXMBYT05 Reported by: Jim Nasby and Takayuki Tsunakawa
1 parent b58fd4a commit cd1e23e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

contrib/dblink/dblink.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ dblink_connect(PG_FUNCTION_ARGS)
304304
createNewConnection(connname, rconn);
305305
}
306306
else
307+
{
308+
if (pconn->conn)
309+
PQfinish(pconn->conn);
307310
pconn->conn = conn;
311+
}
308312

309313
PG_RETURN_TEXT_P(cstring_to_text("OK"));
310314
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy