diff options
author | Andres Freund <andres@anarazel.de> | 2023-01-31 17:36:39 -0800 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2023-01-31 17:47:53 -0800 |
commit | fbed4bc59e362e13fb0d0e0b08c995c18c7e4d5a (patch) | |
tree | 622adab8d6fcf5171c57d70e49417fdd440b05d8 /contrib/dblink | |
parent | c2891175052772b603da6d0ae634e42b63b7f274 (diff) | |
download | postgresql-fbed4bc59e362e13fb0d0e0b08c995c18c7e4d5a.tar.gz |
dblink: Fix variable confusion introduced in e4602483e95
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
Diffstat (limited to 'contrib/dblink')
-rw-r--r-- | contrib/dblink/dblink.c | 2 | ||||
-rw-r--r-- | contrib/dblink/expected/dblink.out | 19 | ||||
-rw-r--r-- | contrib/dblink/sql/dblink.sql | 5 |
3 files changed, 25 insertions, 1 deletions
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 8982d623d3..78a8bcee6e 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -321,7 +321,7 @@ dblink_connect(PG_FUNCTION_ARGS) else { if (pconn->conn) - libpqsrv_disconnect(conn); + libpqsrv_disconnect(pconn->conn); pconn->conn = conn; } diff --git a/contrib/dblink/expected/dblink.out b/contrib/dblink/expected/dblink.out index 14d015e4d5..0f5050b409 100644 --- a/contrib/dblink/expected/dblink.out +++ b/contrib/dblink/expected/dblink.out @@ -938,6 +938,25 @@ DROP SERVER fdtest; ALTER FOREIGN DATA WRAPPER dblink_fdw OPTIONS (nonexistent 'fdw'); ERROR: invalid option "nonexistent" HINT: There are no valid options in this context. +-- test repeated calls to dblink_connect +SELECT dblink_connect(connection_parameters()); + dblink_connect +---------------- + OK +(1 row) + +SELECT dblink_connect(connection_parameters()); + dblink_connect +---------------- + OK +(1 row) + +SELECT dblink_disconnect(); + dblink_disconnect +------------------- + OK +(1 row) + -- test asynchronous notifications SELECT dblink_connect(connection_parameters()); dblink_connect diff --git a/contrib/dblink/sql/dblink.sql b/contrib/dblink/sql/dblink.sql index e560260bfc..7870ce5d5a 100644 --- a/contrib/dblink/sql/dblink.sql +++ b/contrib/dblink/sql/dblink.sql @@ -489,6 +489,11 @@ DROP SERVER fdtest; -- should fail ALTER FOREIGN DATA WRAPPER dblink_fdw OPTIONS (nonexistent 'fdw'); +-- test repeated calls to dblink_connect +SELECT dblink_connect(connection_parameters()); +SELECT dblink_connect(connection_parameters()); +SELECT dblink_disconnect(); + -- test asynchronous notifications SELECT dblink_connect(connection_parameters()); |