postgresql/contrib/postgres_fdw
Etsuro Fujita de28140ded postgres_fdw: Inherit the local transaction's access/deferrable modes.
READ ONLY transactions should prevent modifications to foreign data as
well as local data, but postgres_fdw transactions declared as READ ONLY
that reference foreign tables mapped to a remote view executing volatile
functions would modify data on remote servers, as it would open remote
transactions in READ WRITE mode.

Similarly, DEFERRABLE transactions should not abort due to a
serialization failure even when accessing foreign data, but postgres_fdw
transactions declared as DEFERRABLE would abort due to that failure in a
remote server, as it would open remote transactions in NOT DEFERRABLE
mode.

To fix, modify postgres_fdw to open remote transactions in the same
access/deferrable modes as the local transaction.  This commit also
modifies it to open remote subtransactions in the same access mode as
the local subtransaction.

This commit changes the behavior of READ ONLY/DEFERRABLE transactions
using postgres_fdw; in particular, it doesn't allow the READ ONLY
transactions to modify data on remote servers anymore, so such
transactions should be redeclared as READ WRITE or rewritten using other
tools like dblink.  The release notes should note this as an
incompatibility.

These issues exist since the introduction of postgres_fdw, but to avoid
the incompatibility in the back branches, fix them in master only.

Author: Etsuro Fujita <etsuro.fujita@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAPmGK16n_hcUUWuOdmeUS%2Bw4Q6dZvTEDHb%3DOP%3D5JBzo-M3QmpQ%40mail.gmail.com
Discussion: https://postgr.es/m/E1uLe9X-000zsY-2g%40gemulon.postgresql.org
2026-04-05 18:55:00 +09:00
..
expected postgres_fdw: Inherit the local transaction's access/deferrable modes. 2026-04-05 18:55:00 +09:00
specs postgres_fdw: Add more test coverage for EvalPlanQual testing. 2025-11-06 12:15:00 +09:00
sql postgres_fdw: Inherit the local transaction's access/deferrable modes. 2026-04-05 18:55:00 +09:00
t ALTER SUBSCRIPTION ... SERVER test. 2026-03-18 10:15:51 -07:00
.gitignore Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch. 2025-10-15 17:15:00 +09:00
connection.c postgres_fdw: Inherit the local transaction's access/deferrable modes. 2026-04-05 18:55:00 +09:00
deparse.c Remove bits* typedefs. 2026-03-30 16:12:08 -05:00
Makefile CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
meson.build CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
option.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
postgres_fdw--1.0--1.1.sql postgres_fdw: Add functions to discard cached connections. 2021-01-26 15:35:54 +09:00
postgres_fdw--1.0.sql Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
postgres_fdw--1.1--1.2.sql postgres_fdw: Extend postgres_fdw_get_connections to return remote backend PID. 2025-03-03 08:51:30 +09:00
postgres_fdw--1.2--1.3.sql CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
postgres_fdw.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
postgres_fdw.control CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
postgres_fdw.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
shippable.c Switch SysCacheIdentifier to a typedef enum 2026-02-18 09:58:38 +09:00