pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix MakeTransitionCaptureState() to return a consistent result
Date: Thu, 13 Feb 2025 07:31:49 +0000
Message-ID: <E1tiThN-006s4N-1L@gemulon.postgresql.org> (raw)

Fix MakeTransitionCaptureState() to return a consistent result

When an UPDATE trigger referencing a new table and a DELETE trigger
referencing an old table are both present, MakeTransitionCaptureState()
returns an inconsistent result for UPDATE commands in its set of flags
and tuplestores holding the TransitionCaptureState for transition
tables.

As proved by the test added here, this issue causes a crash in v14 and
earlier versions (down to 11, actually, older versions do not support
triggers on partitioned tables) during cross-partition updates on a
partitioned table.  v15 and newer versions are safe thanks to
7103ebb7aae8.

This commit fixes the function so that it returns a consistent state
by using portions of the changes made in commit 7103ebb7aae8 for v13 and
v14.  v15 and newer versions are slightly tweaked to match with the
older versions, mainly for consistency across branches.

Author: Kyotaro Horiguchi
Discussion: https://postgr.es/m/20250207.150238.968446820828052276.horikyota.ntt@gmail.com
Backpatch-through: 13

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a37c83d1e465399fb1398507b6634f4dce76964c

Modified Files
--------------
src/backend/commands/trigger.c         |  8 +++---
src/test/regress/expected/triggers.out | 49 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/triggers.sql      | 46 +++++++++++++++++++++++++++++++
3 files changed, 99 insertions(+), 4 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1tiThN-006s4N-1L@gemulon.postgresql.org>
Permalink:  ../E1tiThN-006s4N-1L@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tiThN-006s4N-1L@gemulon.postgresql.org

 · 

reply

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: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix MakeTransitionCaptureState() to return a consistent result
  In-Reply-To: <E1tiThN-006s4N-1L@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