mirror of
https://github.com/postgres/postgres.git
synced 2025-07-23 03:21:12 +03:00
Fix connection leak in dblink when dblink_connect() or dblink_connect_u()
end with "duplicate connection name" errors. Backported to release 7.4.
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
* Darko Prenosil <Darko.Prenosil@finteh.hr>
|
* Darko Prenosil <Darko.Prenosil@finteh.hr>
|
||||||
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
|
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.92 2010/06/03 09:38:33 itagaki Exp $
|
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.93 2010/06/09 00:56:02 itagaki Exp $
|
||||||
* Copyright (c) 2001-2010, PostgreSQL Global Development Group
|
* Copyright (c) 2001-2010, PostgreSQL Global Development Group
|
||||||
* ALL RIGHTS RESERVED;
|
* ALL RIGHTS RESERVED;
|
||||||
*
|
*
|
||||||
@ -2237,9 +2237,14 @@ createNewConnection(const char *name, remoteConn *rconn)
|
|||||||
HASH_ENTER, &found);
|
HASH_ENTER, &found);
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
|
{
|
||||||
|
PQfinish(rconn->conn);
|
||||||
|
pfree(rconn);
|
||||||
|
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
||||||
errmsg("duplicate connection name")));
|
errmsg("duplicate connection name")));
|
||||||
|
}
|
||||||
|
|
||||||
hentry->rconn = rconn;
|
hentry->rconn = rconn;
|
||||||
strlcpy(hentry->name, name, sizeof(hentry->name));
|
strlcpy(hentry->name, name, sizeof(hentry->name));
|
||||||
|
Reference in New Issue
Block a user