aboutsummaryrefslogtreecommitdiff
path: root/src/include/commands/trigger.h
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2022-01-05 19:00:13 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2022-01-05 19:00:13 -0300
commitf4566345cf40b068368cb5617e61318da60676ec (patch)
treee60b0eb8f9dc977e14e17aed4f3b689ebd86e587 /src/include/commands/trigger.h
parentc2e8bd27519f47ff56987b30eb34a01969b9a9e8 (diff)
downloadpostgresql-f4566345cf40b068368cb5617e61318da60676ec.tar.gz
postgresql-f4566345cf40b068368cb5617e61318da60676ec.zip
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
Diffstat (limited to 'src/include/commands/trigger.h')
-rw-r--r--src/include/commands/trigger.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h
index 9ef7f6d7685..489c93de928 100644
--- a/src/include/commands/trigger.h
+++ b/src/include/commands/trigger.h
@@ -160,6 +160,10 @@ extern ObjectAddress CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *que
Node *whenClause, bool isInternal, bool in_partition,
char trigger_fires_when);
+extern void TriggerSetParentTrigger(Relation trigRel,
+ Oid childTrigId,
+ Oid parentTrigId,
+ Oid childTableId);
extern void RemoveTriggerById(Oid trigOid);
extern Oid get_trigger_oid(Oid relid, const char *name, bool missing_ok);