diff options
author | Alvaro Herrera | 2022-01-05 22:00:13 +0000 |
---|---|---|
committer | Alvaro Herrera | 2022-01-05 22:00:13 +0000 |
commit | f4566345cf40b068368cb5617e61318da60676ec (patch) | |
tree | e60b0eb8f9dc977e14e17aed4f3b689ebd86e587 /src/bin/psql/describe.c | |
parent | c2e8bd27519f47ff56987b30eb34a01969b9a9e8 (diff) |
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 <[email protected]>
Reviewed-by: Masahiko Sawada <[email protected]>
Reviewed-by: Arne Roland <[email protected]>
Discussion: https://postgr.es/m/CA+HiwqG7LQSK+n8Bki8tWv7piHD=PnZro2y6ysU2-28JS6cfgQ@mail.gmail.com
Diffstat (limited to 'src/bin/psql/describe.c')
-rw-r--r-- | src/bin/psql/describe.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index c28788e84fa..0615de53255 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3001,7 +3001,15 @@ describeOneTableDetails(const char *schemaname, " AND u.tgparentid = 0) AS parent" : "NULL AS parent"), oid); - if (pset.sversion >= 110000) + + /* + * tgisinternal is set true for inherited triggers of partitions in + * servers between v11 and v14, though these must still be shown to + * the user. So we use another property that is true for such + * inherited triggers to avoid them being hidden, which is their + * dependendence on another trigger. + */ + if (pset.sversion >= 110000 && pset.sversion < 150000) appendPQExpBufferStr(&buf, "(NOT t.tgisinternal OR (t.tgisinternal AND t.tgenabled = 'D') \n" " OR EXISTS (SELECT 1 FROM pg_catalog.pg_depend WHERE objid = t.oid \n" " AND refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass))"); |