possible connection leak in dblink? - Mailing list pgsql-hackers

From Peter Eisentraut
Subject possible connection leak in dblink?
Date
Msg-id 1308083649.29840.5.camel@vanquo.pezone.net
Whole thread Raw
Responses Re: possible connection leak in dblink?
List pgsql-hackers
With gcc 4.6, I get this warning:

dblink.c: In function ‘dblink_send_query’:
dblink.c:620:7: warning: variable ‘freeconn’ set but not used [-Wunused-but-set-variable]

I don't know much about the internals of dblink, but judging from the
surrounding code, I guess that this fix is necessary:

diff --git i/contrib/dblink/dblink.c w/contrib/dblink/dblink.c
index 19b98fb..e014c1a 100644
--- i/contrib/dblink/dblink.c
+++ w/contrib/dblink/dblink.c
@@ -634,6 +634,10 @@ dblink_send_query(PG_FUNCTION_ARGS)       if (retval != 1)               elog(NOTICE, "%s",
PQerrorMessage(conn));
+       /* if needed, close the connection to the database and cleanup */
+       if (freeconn)
+               PQfinish(conn);
+       PG_RETURN_INT32(retval);}
Otherwise the connection might not get freed.  Could someone verify
that?



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: [WIP] cache estimates, cache access cost
Next
From: Tom Lane
Date:
Subject: Re: One-Shot Plans