]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
dblink: Reject use_scram_passthrough on foreign-data wrappers
authorFujii Masao <fujii@postgresql.org>
Mon, 25 May 2026 16:07:24 +0000 (01:07 +0900)
committerFujii Masao <fujii@postgresql.org>
Mon, 25 May 2026 16:07:24 +0000 (01:07 +0900)
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
contrib/dblink/expected/dblink.out
contrib/dblink/sql/dblink.sql

index c631c1aefcc0fcc93ef02e4e1b3ee105165b4550..448d469aba8cc4c7ffb21f8c771126b00c2916d2 100644 (file)
@@ -3116,8 +3116,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);
 }
index c70c79574fd1d17e1fb161b0865fe9480719cc4d..1d2759def9e792c278729f22c2a2e8bb0d3fcbe6 100644 (file)
@@ -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 
index 365b21036e85420b662854ac6c948f83b403e511..d67a0a5992e24bee02e98108f00a6da874bde16f 100644 (file)
@@ -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;