pgsql: Avoid failure when altering state of partitioned foreign-key tri

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid failure when altering state of partitioned foreign-key tri
Date: 2023-03-04 18:32:44
Message-ID: E1pYWgW-001tbz-3v@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6949b921d545809a83f8a6bad4948f9012a76fb6

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

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2023-03-05 14:34:11 pgsql: SQL JSON path enhanced numeric literals
Previous Message Tom Lane 2023-03-04 17:12:03 pgsql: Tighten header pre-inclusions in headerscheck and cpluspluscheck