pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid failure when altering state of partitioned foreign-key tri
Date: Sat, 04 Mar 2023 18:32:44 +0000
Message-ID: <E1pYWgW-001tc0-5A@gemulon.postgresql.org> (raw)

Avoid failure when altering state of partitioned foreign-key triggers.

Beginning in v15, if you apply ALTER TABLE ENABLE/DISABLE TRIGGER to
a partitioned table, it also affects the partitions' cloned versions
of the affected trigger(s).  The initial implementation of this
located the clones by name, but that fails on foreign-key triggers
which have names incorporating their own OIDs.  We can fix that, and
also make the behavior more bulletproof in the face of user-initiated
trigger renames, by identifying the cloned triggers by tgparentid.

Following the lead of earlier commits in this area, I took care not
to break ABI in the v15 branch, even though I rather doubt there
are any external callers of EnableDisableTrigger.

While here, update the documentation, which was not touched when
the semantics were changed.

Per bug #17817 from Alan Hodgson.  Back-patch to v15; older versions
do not have this behavior.

Discussion: https://postgr.es/m/17817-31dfb7c2100d9f3d@postgresql.org

Branch
------
REL_15_STABLE

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

Modified Files
--------------
doc/src/sgml/ref/alter_table.sgml      | 23 +++++++++++++-------
src/backend/commands/tablecmds.c       |  5 +++--
src/backend/commands/trigger.c         | 38 ++++++++++++++++++++++++----------
src/include/commands/trigger.h         |  3 +++
src/test/regress/expected/triggers.out | 34 ++++++++++++++++++++++++++++++
src/test/regress/sql/triggers.sql      | 15 ++++++++++++++
6 files changed, 98 insertions(+), 20 deletions(-)



view thread (2+ messages)

Message-ID: <E1pYWgW-001tc0-5A@gemulon.postgresql.org>
Permalink:  ../E1pYWgW-001tc0-5A@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pYWgW-001tc0-5A@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Avoid failure when altering state of partitioned foreign-key tri
  In-Reply-To: <E1pYWgW-001tc0-5A@gemulon.postgresql.org>
  References: <E1pYWgW-001tc0-5A@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