pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Create foreign key triggers in partitioned tables too
Date: Wed, 05 Jan 2022 22:15:56 +0000
Message-ID: <E1n5EZY-0004Yx-SX@gemulon.postgresql.org> (raw)

Create foreign key triggers in partitioned tables too

While user-defined triggers defined on a partitioned table have
a catalog definition for both it and its partitions, internal
triggers used by foreign keys defined on partitioned tables only
have a catalog definition for its partitions.  This commit fixes
that so that partitioned tables get the foreign key triggers too,
just like user-defined triggers.  Moreover, like user-defined
triggers, partitions' internal triggers will now also have their
tgparentid set appropriately.  This is to allow subsequent commit(s)
to make the foreign key related events to be fired in some cases
using the parent table triggers instead of those of partitions'.

This also changes what tgisinternal means in some cases.  Currently,
it means either that the trigger is an internal implementation object
of a foreign key constraint, or a "child" trigger on a partition
cloned from the trigger on the parent.  This commit changes it to
only mean the former to avoid confusion.  As for the latter, it can
be told by tgparentid being nonzero, which is now true both for user-
defined and foreign key's internal triggers.

Author: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Arne Roland <A.Roland@index.de>
Discussion: https://postgr.es/m/CA+HiwqG7LQSK+n8Bki8tWv7piHD=PnZro2y6ysU2-28JS6cfgQ@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/commands/tablecmds.c       | 413 +++++++++++++++++++++++++++------
src/backend/commands/trigger.c         | 101 +++++++-
src/bin/pg_dump/pg_dump.c              |  46 +++-
src/bin/pg_dump/pg_dump.h              |   2 +-
src/bin/psql/describe.c                |  10 +-
src/include/commands/trigger.h         |   4 +
src/test/regress/expected/triggers.out |   4 +-
7 files changed, 490 insertions(+), 90 deletions(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1n5EZY-0004Yx-SX@gemulon.postgresql.org>
Permalink:  ../E1n5EZY-0004Yx-SX@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1n5EZY-0004Yx-SX@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: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Create foreign key triggers in partitioned tables too
  In-Reply-To: <E1n5EZY-0004Yx-SX@gemulon.postgresql.org>
  References: <E1n5EZY-0004Yx-SX@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