postgres.git / summary / log / commit / refs
commit cd777e27e2038f2c39f0f2d5d68d45c67bdf89e8
Author: Fujii Masao <fujii@postgresql.org>
Date: Mon May 25 16:07:24 2026 +0000
First released in: 18.6
dblink: Reject use_scram_passthrough on foreign-data wrappers
Previously, dblink accepted the use_scram_passthrough option on
foreign-data wrappers via ALTER FOREIGN DATA WRAPPER dblink_fdw
OPTIONS, even though the setting had no effect there.
use_scram_passthrough should be only meaningful for foreign servers
and user mappings, so this commit updates dblink to accept the option
only in those contexts.
Backpatch to v18, where use_scram_passthrough was introduced.
Author: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwEJ8rZjmbOvCicyr4vbuLio082bNTde0WNoSWaWr9wVcg@mail.gmail.com
Backpatch-through: 18
contrib/dblink/dblink.c | 11 +++++++++--
contrib/dblink/expected/dblink.out | 5 +++++
contrib/dblink/sql/dblink.sql | 4 ++++
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 4112727fe54..2f803e7ed3c 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -3133,8 +3133,15 @@ static bool
is_valid_dblink_fdw_option(const PQconninfoOption *options, const char *option,
Oid context)
{
- if (strcmp(option, "use_scram_passthrough") == 0)
- return true;
+ /*
+ * These options are only valid for foreign server or user mapping
+ * contexts
+ */
+ if (context == ForeignServerRelationId || context == UserMappingRelationId)
+ {
+ if (strcmp(option, "use_scram_passthrough") == 0)
+ return true;
+ }
return is_valid_dblink_option(options, option, context);
}
diff --git a/contrib/dblink/expected/dblink.out b/contrib/dblink/expected/dblink.out
index c70c79574fd..1d2759def9e 100644
--- a/contrib/dblink/expected/dblink.out
+++ b/contrib/dblink/expected/dblink.out
@@ -1220,6 +1220,11 @@ SHOW intervalstyle;
postgres
(1 row)
+-- Check that adding use_scram_passthrough option on an foreign data wrapper is
+-- not allowed
+ALTER FOREIGN DATA WRAPPER dblink_fdw OPTIONS(add use_scram_passthrough 'true');
+ERROR: invalid option "use_scram_passthrough"
+HINT: There are no valid options in this context.
-- Clean up GUC-setting tests
SELECT dblink_disconnect('myconn');
dblink_disconnect
diff --git a/contrib/dblink/sql/dblink.sql b/contrib/dblink/sql/dblink.sql
index 365b21036e8..d67a0a5992e 100644
--- a/contrib/dblink/sql/dblink.sql
+++ b/contrib/dblink/sql/dblink.sql
@@ -635,6 +635,10 @@ FROM dblink_fetch('myconn','error_cursor', 1) AS t(i int);
SHOW datestyle;
SHOW intervalstyle;
+-- Check that adding use_scram_passthrough option on an foreign data wrapper is
+-- not allowed
+ALTER FOREIGN DATA WRAPPER dblink_fdw OPTIONS(add use_scram_passthrough 'true');
+
-- Clean up GUC-setting tests
SELECT dblink_disconnect('myconn');
RESET datestyle;
[parent: 130396e6c034]