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:
Itagaki Takahiro 2010-06-09 00:59:54 +00:00
parent fe940c624f
commit 7bd31c6715

View File

@ -8,7 +8,7 @@
* Darko Prenosil <Darko.Prenosil@finteh.hr>
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
*
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.60.2.6 2010/06/03 09:43:04 itagaki Exp $
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.60.2.7 2010/06/09 00:59:54 itagaki Exp $
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
* ALL RIGHTS RESERVED;
*
@ -2287,9 +2287,14 @@ createNewConnection(const char *name, remoteConn * rconn)
HASH_ENTER, &found);
if (found)
{
PQfinish(rconn->conn);
pfree(rconn);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("duplicate connection name")));
}
hentry->rconn = rconn;
strncpy(hentry->name, name, NAMEDATALEN - 1);