aboutsummaryrefslogtreecommitdiff
path: root/src/include/commands/trigger.h
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2005-05-30 07:20:59 +0000
committerNeil Conway <neilc@samurai.com>2005-05-30 07:20:59 +0000
commitadfeef55cbcc5dc72a772777f88c1be05a70dfee (patch)
treeb7d0a756c03241faa60c0ea416d68040741be4d0 /src/include/commands/trigger.h
parentf99b75b0a0ee642a87a10726ba8f6831c1c95cc7 (diff)
downloadpostgresql-adfeef55cbcc5dc72a772777f88c1be05a70dfee.tar.gz
postgresql-adfeef55cbcc5dc72a772777f88c1be05a70dfee.zip
When enqueueing after-row triggers for updates of a table with a foreign
key, compare the new and old row versions. If the foreign key column has not changed, we needn't enqueue the trigger, since the update cannot violate the foreign key. This optimization was previously applied in the RI trigger function, but it is more efficient to avoid firing the trigger altogether. Per recent discussion on pgsql-hackers. Also add a regression test for some unintuitive foreign key behavior, and refactor some code that deals with the OIDs of the various RI trigger functions.
Diffstat (limited to 'src/include/commands/trigger.h')
-rw-r--r--src/include/commands/trigger.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h
index 81a665e2476..f6c1f88480b 100644
--- a/src/include/commands/trigger.h
+++ b/src/include/commands/trigger.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/trigger.h,v 1.53 2005/04/11 19:51:15 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/commands/trigger.h,v 1.54 2005/05/30 07:20:58 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -168,9 +168,18 @@ extern void AfterTriggerSetState(ConstraintsSetStmt *stmt);
/*
* in utils/adt/ri_triggers.c
*/
-extern bool RI_FKey_keyequal_upd(TriggerData *trigdata);
+extern bool RI_FKey_keyequal_upd_pk(Trigger *trigger, Relation pk_rel,
+ HeapTuple old_row, HeapTuple new_row);
+extern bool RI_FKey_keyequal_upd_fk(Trigger *trigger, Relation fk_rel,
+ HeapTuple old_row, HeapTuple new_row);
extern bool RI_Initial_Check(FkConstraint *fkconstraint,
Relation rel,
Relation pkrel);
+#define RI_TRIGGER_PK 1 /* is a trigger on the PK relation */
+#define RI_TRIGGER_FK 2 /* is a trigger on the FK relation */
+#define RI_TRIGGER_NONE 0 /* is not an RI trigger function */
+
+extern int RI_FKey_trigger_type(Oid tgfoid);
+
#endif /* TRIGGER_H */