From 0daae1a62205d2705e61ccc68add702b302e35af Mon Sep 17 00:00:00 2001 From: Joe Conway Date: Sat, 12 Sep 2009 23:21:13 +0000 Subject: [PATCH] plug dblink resource leak dblink generates orphaned connections when called with a connection string, fail_on_error = true, and an ERROR occurs. Discovery and patch by Tatsuhito Kasahara. Introduced in 8.4. --- contrib/dblink/dblink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 6f3cc71f16..b216f02fe4 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.82 2009/06/11 14:48:50 momjian Exp $ + * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.82.2.1 2009/09/12 23:21:13 joe Exp $ * Copyright (c) 2001-2009, PostgreSQL Global Development Group * ALL RIGHTS RESERVED; * @@ -855,9 +855,9 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async) (PQresultStatus(res) != PGRES_COMMAND_OK && PQresultStatus(res) != PGRES_TUPLES_OK)) { - dblink_res_error(conname, res, "could not execute query", fail); if (freeconn) PQfinish(conn); + dblink_res_error(conname, res, "could not execute query", fail); MemoryContextSwitchTo(oldcontext); SRF_RETURN_DONE(funcctx); }