Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d1824a5

Browse files
committed
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.
1 parent dd01cfe commit d1824a5

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

contrib/dblink/dblink.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ dblink_disconnect(PG_FUNCTION_ARGS)
256256
deleteConnection(conname);
257257
pfree(rcon);
258258
}
259+
else
260+
persistent_conn = NULL;
259261

260262
PG_RETURN_TEXT_P(GET_TEXT("OK"));
261263
}

contrib/dblink/expected/dblink.out

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,11 @@ SELECT dblink_disconnect();
185185
OK
186186
(1 row)
187187

188-
-- should generate "no connection to the server" error
188+
-- should generate "connection not available" error
189189
SELECT *
190190
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
191191
WHERE t.a > 7;
192-
ERROR: sql error
193-
DETAIL: no connection to the server
194-
192+
ERROR: connection not available
195193
-- put more data into our slave table, first using arbitrary connection syntax
196194
-- but truncate the actual return value so we can use diff to check for success
197195
SELECT substr(dblink_exec('dbname=regression','INSERT INTO foo VALUES(10,''k'',''{"a10","b10","c10"}'')'),1,6);

contrib/dblink/sql/dblink.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ FROM dblink_fetch('rmt_foo_cursor',4) AS t(a int, b text, c text[]);
105105
-- close the persistent connection
106106
SELECT dblink_disconnect();
107107

108-
-- should generate "no connection to the server" error
108+
-- should generate "connection not available" error
109109
SELECT *
110110
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
111111
WHERE t.a > 7;

0 commit comments

Comments
 (0)