Skip to content

Commit fbed4bc

Browse files
committed
dblink: Fix variable confusion introduced in e460248
Thanks to Robins to find the issue and Nathan for promptly writing a test case to prevent future problems like this. Reported-by: Nathan Bossart <nathandbossart@gmail.com> Reported-by: Robins Tharakan <tharakan@gmail.com> Author: Nathan Bossart <nathandbossart@gmail.com> Discussion: https://postgr.es/m/20230130193008.GA2740781@nathanxps13
1 parent c289117 commit fbed4bc

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

contrib/dblink/dblink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ dblink_connect(PG_FUNCTION_ARGS)
321321
else
322322
{
323323
if (pconn->conn)
324-
libpqsrv_disconnect(conn);
324+
libpqsrv_disconnect(pconn->conn);
325325
pconn->conn = conn;
326326
}
327327

contrib/dblink/expected/dblink.out

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,25 @@ DROP SERVER fdtest;
938938
ALTER FOREIGN DATA WRAPPER dblink_fdw OPTIONS (nonexistent 'fdw');
939939
ERROR: invalid option "nonexistent"
940940
HINT: There are no valid options in this context.
941+
-- test repeated calls to dblink_connect
942+
SELECT dblink_connect(connection_parameters());
943+
dblink_connect
944+
----------------
945+
OK
946+
(1 row)
947+
948+
SELECT dblink_connect(connection_parameters());
949+
dblink_connect
950+
----------------
951+
OK
952+
(1 row)
953+
954+
SELECT dblink_disconnect();
955+
dblink_disconnect
956+
-------------------
957+
OK
958+
(1 row)
959+
941960
-- test asynchronous notifications
942961
SELECT dblink_connect(connection_parameters());
943962
dblink_connect

contrib/dblink/sql/dblink.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,11 @@ DROP SERVER fdtest;
489489
-- should fail
490490
ALTER FOREIGN DATA WRAPPER dblink_fdw OPTIONS (nonexistent 'fdw');
491491

492+
-- test repeated calls to dblink_connect
493+
SELECT dblink_connect(connection_parameters());
494+
SELECT dblink_connect(connection_parameters());
495+
SELECT dblink_disconnect();
496+
492497
-- test asynchronous notifications
493498
SELECT dblink_connect(connection_parameters());
494499

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy