mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +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:
@ -26,7 +26,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.334 2009/10/26 02:26:29 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.335 2009/11/20 20:38:10 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -752,6 +752,7 @@ InitPlan(QueryDesc *queryDesc, int eflags)
|
||||
*/
|
||||
estate->es_tupleTable = NIL;
|
||||
estate->es_trig_tuple_slot = NULL;
|
||||
estate->es_trig_oldtup_slot = NULL;
|
||||
|
||||
/* mark EvalPlanQual not active */
|
||||
estate->es_epqTuple = NULL;
|
||||
@ -911,6 +912,8 @@ InitResultRelInfo(ResultRelInfo *resultRelInfo,
|
||||
|
||||
resultRelInfo->ri_TrigFunctions = (FmgrInfo *)
|
||||
palloc0(n * sizeof(FmgrInfo));
|
||||
resultRelInfo->ri_TrigWhenExprs = (List **)
|
||||
palloc0(n * sizeof(List *));
|
||||
if (doInstrument)
|
||||
resultRelInfo->ri_TrigInstrument = InstrAlloc(n);
|
||||
else
|
||||
@ -919,6 +922,7 @@ InitResultRelInfo(ResultRelInfo *resultRelInfo,
|
||||
else
|
||||
{
|
||||
resultRelInfo->ri_TrigFunctions = NULL;
|
||||
resultRelInfo->ri_TrigWhenExprs = NULL;
|
||||
resultRelInfo->ri_TrigInstrument = NULL;
|
||||
}
|
||||
resultRelInfo->ri_ConstraintExprs = NULL;
|
||||
|
Reference in New Issue
Block a user