From: Etsuro Fujita <efujita@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Disallow collecting transition tuples from child foreign tables.
Date: Fri, 08 Aug 2025 01:52:22 +0000
Message-ID: <E1ukCHN-001Jel-3A@gemulon.postgresql.org> (raw)
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
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/d642d23064ea1bf29137336e2a17d1bba988cb41
Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 113 +++++++++++++++++++++++++
contrib/postgres_fdw/sql/postgres_fdw.sql | 78 +++++++++++++++++
src/backend/commands/trigger.c | 28 ++++++
src/backend/optimizer/plan/createplan.c | 18 +++-
src/backend/optimizer/util/plancat.c | 54 ++++++++++++
src/include/optimizer/plancat.h | 2 +
6 files changed, 291 insertions(+), 2 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: efujita@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Disallow collecting transition tuples from child foreign tables.
In-Reply-To: <E1ukCHN-001Jel-3A@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox