]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Disallow collecting transition tuples from child foreign tables.
authorEtsuro Fujita <efujita@postgresql.org>
Fri, 8 Aug 2025 01:50:03 +0000 (10:50 +0900)
committerEtsuro Fujita <efujita@postgresql.org>
Fri, 8 Aug 2025 01:50:03 +0000 (10:50 +0900)
commitd642d23064ea1bf29137336e2a17d1bba988cb41
treee9f24f6f1d5069a92830d2d31ce42c8e3b8363a4
parent769be67a3c7adc733f31239474a08e6da9ed0145
Disallow collecting transition tuples from child foreign tables.

Commit 9e6104c66 disallowed transition tables on foreign tables, but
failed to account for cases where a foreign table is a child table of a
partitioned/inherited table on which transition tables exist, leading to
incorrect transition tuples collected from such foreign tables for
queries on the parent table triggering transition capture.  This
occurred not only for inherited UPDATE/DELETE but for partitioned INSERT
later supported by commit 3d956d956, which should have handled it at
least for the INSERT case, but didn't.

To fix, modify ExecAR*Triggers to throw an error if the given relation
is a foreign table requesting transition capture.  Also, this commit
fixes make_modifytable so that in case of an inherited UPDATE/DELETE
triggering transition capture, FDWs choose normal operations to modify
child foreign tables, not DirectModify; which is needed because they
would otherwise skip the calls to ExecAR*Triggers at execution, causing
unexpected behavior.

Author: Etsuro Fujita <etsuro.fujita@gmail.com>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/CAPmGK14QJYikKzBDCe3jMbpGENnQ7popFmbEgm-XTNuk55oyHg%40mail.gmail.com
Backpatch-through: 13
contrib/postgres_fdw/expected/postgres_fdw.out
contrib/postgres_fdw/sql/postgres_fdw.sql
src/backend/commands/trigger.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/util/plancat.c
src/include/optimizer/plancat.h