Re: postgres_fdw: use_scram_passthrough on user mapping is ignored when also set on server

From: "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com>
To: "Fujii Masao" <masao(dot)fujii(at)gmail(dot)com>
Cc: "PostgreSQL Hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: postgres_fdw: use_scram_passthrough on user mapping is ignored when also set on server
Date: 2026-05-15 15:46:44
Message-ID: DIJD8SBZQK54.1L75HI5SLG2LT@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri May 15, 2026 at 1:29 AM -03, Fujii Masao wrote:
>> The attached patches implement this change for postgres_fdw and dblink.
>
> Thanks for the patches! They look good to me.
>
> One minor comment: in UseScramPassthrough() in postgres_fdw/connection.c
> and dblink.c, how about adding a comment like the following to clarify
> the option precedence?
>
> /*
> * Return whether SCRAM pass-through is enabled.
> *
> * If use_scram_passthrough is specified in both the foreign server
> * and the user mapping, the user mapping setting takes precedence.
> */
>

Sounds good, fixed.

> Also, while reviewing the use_scram_passthrough handling in dblink,
> I found a separate issue: the option can be set via
> ALTER FOREIGN DATA WRAPPER dblink_fdw, but that setting does not
> seem to have any effect. Is this a bug? Like postgres_fdw, also in dblink,
> we should disallow the option to be set at the foreign-data-wrapper level?
> If yes, I think it would be better to address that as a separate patch.
> Thought?
>

Yeah, good catch, this is from 3642df265d0. The problem is that
dblink_fdw_validator() was changed to call is_valid_dblink_fdw_option()
instead of is_valid_dblink_option() to make CRETE SERVER ... OPTIONS
(use_scram_passthrough '...'); works but I miss the fact that it's also
used by ALTER FOREIGN DATA WRAPPER. The new attached 0003 fix this by
only checking the fdw options when the validator context is from foreign
server or user mapping.

Are you considering backporting these patches? I think that 0003 is
good, not sure about 0001 and 0002.

--
Matheus Alcantara
EDB: https://www.enterprisedb.com

Attachment Content-Type Size
v2-0001-postgres_fdw-Allow-user-mapping-to-override-use_s.patch text/plain 5.2 KB
v2-0002-dblink-Allow-user-mapping-to-override-use_scram_p.patch text/plain 5.7 KB
v2-0003-dblink-Reject-use_scram_passthrough-option-on-for.patch text/plain 3.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2026-05-15 16:12:36 Re: Track skipped tables during autovacuum and autoanalyze
Previous Message Alexandra Wang 2026-05-15 15:30:31 Re: Is there value in having optimizer stats for joins/foreignkeys?