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

Matheus Alcantara <matheusssilv97@gmail.com>

From: "Matheus Alcantara" <matheusssilv97@gmail.com>
To: "Fujii Masao" <masao.fujii@gmail.com>, "PostgreSQL Hackers" <pgsql-hackers@lists.postgresql.org>
Date: 2026-05-14T20:18:58Z
Lists: pgsql-hackers

Attachments

Hi,

On Thu May 14, 2026 at 2:57 PM -03, Fujii Masao wrote:
> use_scram_passthrough can be specified both on a foreign server and
> on a user mapping. I found that when both are specified, currently
> the server-level setting overrides the user mapping setting. Is this
> precedence intentional?
>
> That seems inconsistent with the usual expectation that foreign server
> options act as shared defaults, while user mapping options provide
> per-user overrides. If the same option is specified in both places,
> I would expect the user mapping setting to take precedence. Thoughts?
>
> If the current behavior is intentional, I'd like to document the precedence
> when use_scram_passthrough is specified in both a foreign server and
> a user mapping. Otherwise, I'd like to change postgres_fdw to prefer
> the user mapping setting and update the documentation accordingly.
>

I agree that that user mapping setting should take precedence. The
current behavior seems not correct since we are not able to
enable/disable the scram passthrough to a specific user mapping.

dblink also implement the same behavior, so I think that it should also
be changed as postgres_fdw.

The attached patches implement this change for postgres_fdw and dblink.

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