mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +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/commands/copy.c,v 1.317 2009/09/21 20:10:21 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.318 2009/11/20 20:38:10 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1799,8 +1799,12 @@ CopyFrom(CopyState cstate)
|
||||
resultRelInfo->ri_RelationDesc = cstate->rel;
|
||||
resultRelInfo->ri_TrigDesc = CopyTriggerDesc(cstate->rel->trigdesc);
|
||||
if (resultRelInfo->ri_TrigDesc)
|
||||
{
|
||||
resultRelInfo->ri_TrigFunctions = (FmgrInfo *)
|
||||
palloc0(resultRelInfo->ri_TrigDesc->numtriggers * sizeof(FmgrInfo));
|
||||
resultRelInfo->ri_TrigWhenExprs = (List **)
|
||||
palloc0(resultRelInfo->ri_TrigDesc->numtriggers * sizeof(List *));
|
||||
}
|
||||
resultRelInfo->ri_TrigInstrument = NULL;
|
||||
|
||||
ExecOpenIndices(resultRelInfo);
|
||||
@ -1810,7 +1814,8 @@ CopyFrom(CopyState cstate)
|
||||
estate->es_result_relation_info = resultRelInfo;
|
||||
|
||||
/* Set up a tuple slot too */
|
||||
slot = MakeSingleTupleTableSlot(tupDesc);
|
||||
slot = ExecInitExtraTupleSlot(estate);
|
||||
ExecSetSlotDescriptor(slot, tupDesc);
|
||||
|
||||
econtext = GetPerTupleExprContext(estate);
|
||||
|
||||
@ -2198,7 +2203,7 @@ CopyFrom(CopyState cstate)
|
||||
pfree(defmap);
|
||||
pfree(defexprs);
|
||||
|
||||
ExecDropSingleTupleTableSlot(slot);
|
||||
ExecResetTupleTable(estate->es_tupleTable, false);
|
||||
|
||||
ExecCloseIndices(resultRelInfo);
|
||||
|
||||
|
Reference in New Issue
Block a user