From d1824a5ccb5ace3080ffa33db55bfd36640633a6 Mon Sep 17 00:00:00 2001 From: Joe Conway Date: Fri, 28 Nov 2003 05:03:02 +0000 Subject: [PATCH] Fix regression in dblink_disconnect() reported by Eduardo Stern: persistent_conn was left dangling after a disconnect in the unnamed connection case, causing a subsequent disconnect to crash the backend. --- contrib/dblink/dblink.c | 2 ++ contrib/dblink/expected/dblink.out | 6 ++---- contrib/dblink/sql/dblink.sql | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index c75f7f0b85..aada47565e 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -256,6 +256,8 @@ dblink_disconnect(PG_FUNCTION_ARGS) deleteConnection(conname); pfree(rcon); } + else + persistent_conn = NULL; PG_RETURN_TEXT_P(GET_TEXT("OK")); } diff --git a/contrib/dblink/expected/dblink.out b/contrib/dblink/expected/dblink.out index 50938b3ef1..7ef40b06d7 100644 --- a/contrib/dblink/expected/dblink.out +++ b/contrib/dblink/expected/dblink.out @@ -185,13 +185,11 @@ SELECT dblink_disconnect(); OK (1 row) --- should generate "no connection to the server" error +-- should generate "connection not available" error SELECT * FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[]) WHERE t.a > 7; -ERROR: sql error -DETAIL: no connection to the server - +ERROR: connection not available -- put more data into our slave table, first using arbitrary connection syntax -- but truncate the actual return value so we can use diff to check for success SELECT substr(dblink_exec('dbname=regression','INSERT INTO foo VALUES(10,''k'',''{"a10","b10","c10"}'')'),1,6); diff --git a/contrib/dblink/sql/dblink.sql b/contrib/dblink/sql/dblink.sql index 6a699769fd..d0e448fc0b 100644 --- a/contrib/dblink/sql/dblink.sql +++ b/contrib/dblink/sql/dblink.sql @@ -105,7 +105,7 @@ FROM dblink_fetch('rmt_foo_cursor',4) AS t(a int, b text, c text[]); -- close the persistent connection SELECT dblink_disconnect(); --- should generate "no connection to the server" error +-- should generate "connection not available" error SELECT * FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[]) WHERE t.a > 7; -- GitLab