diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index bbe40060a2..e5db663ec4 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -8,7 +8,7 @@ * Darko Prenosil * Shridhar Daithankar * - * $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);