mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
Add a WHEN clause to CREATE TRIGGER, allowing a boolean expression to be
checked to determine whether the trigger should be fired. For BEFORE triggers this is mostly a matter of spec compliance; but for AFTER triggers it can provide a noticeable performance improvement, since queuing of a deferred trigger event and re-fetching of the row(s) at end of statement can be short-circuited if the trigger does not need to be fired. Takahiro Itagaki, reviewed by KaiGai Kohei.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.323 2009/10/14 22:14:21 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.324 2009/11/20 20:38:09 tgl Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -793,12 +793,13 @@ index_create(Oid heapRelationId,
|
||||
trigger->row = true;
|
||||
trigger->events = TRIGGER_TYPE_INSERT | TRIGGER_TYPE_UPDATE;
|
||||
trigger->columns = NIL;
|
||||
trigger->whenClause = NULL;
|
||||
trigger->isconstraint = true;
|
||||
trigger->deferrable = true;
|
||||
trigger->initdeferred = initdeferred;
|
||||
trigger->constrrel = NULL;
|
||||
|
||||
(void) CreateTrigger(trigger, conOid, indexRelationId,
|
||||
(void) CreateTrigger(trigger, NULL, conOid, indexRelationId,
|
||||
isprimary ? "PK_ConstraintTrigger" :
|
||||
"Unique_ConstraintTrigger",
|
||||
false);
|
||||
|
||||
Reference in New Issue
Block a user