1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Back out use of palloc0 in place if palloc/MemSet. Seems constant len

to MemSet is a performance boost.
This commit is contained in:
Bruce Momjian
2002-11-11 03:02:20 +00:00
parent 5d283d89cb
commit 75fee4535d
38 changed files with 212 additions and 110 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.137 2002/11/10 07:25:13 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.138 2002/11/11 03:02:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -94,7 +94,7 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
constrrelid = RangeVarGetRelid(stmt->constrrel, false);
else if (stmt->isconstraint)
{
/*
/*
* If this trigger is a constraint (and a foreign key one)
* then we really need a constrrelid. Since we don't have one,
* we'll try to generate one from the argument information.
@ -779,7 +779,8 @@ RelationBuildTriggers(Relation relation)
RelationGetRelationName(relation));
/* Build trigdesc */
trigdesc = (TriggerDesc *) palloc0(sizeof(TriggerDesc));
trigdesc = (TriggerDesc *) palloc(sizeof(TriggerDesc));
MemSet(trigdesc, 0, sizeof(TriggerDesc));
trigdesc->triggers = triggers;
trigdesc->numtriggers = ntrigs;
for (found = 0; found < ntrigs; found++)
@ -1145,8 +1146,12 @@ ExecBRInsertTriggers(EState *estate, ResultRelInfo *relinfo,
/* Allocate cache space for fmgr lookup info, if not done yet */
if (relinfo->ri_TrigFunctions == NULL)
{
relinfo->ri_TrigFunctions = (FmgrInfo *)
palloc0(trigdesc->numtriggers * sizeof(FmgrInfo));
palloc(trigdesc->numtriggers * sizeof(FmgrInfo));
MemSet(relinfo->ri_TrigFunctions, 0,
trigdesc->numtriggers * sizeof(FmgrInfo));
}
LocTriggerData.type = T_TriggerData;
LocTriggerData.tg_event = TRIGGER_EVENT_INSERT | TRIGGER_EVENT_ROW | TRIGGER_EVENT_BEFORE;
@ -1201,8 +1206,12 @@ ExecBRDeleteTriggers(EState *estate, ResultRelInfo *relinfo,
/* Allocate cache space for fmgr lookup info, if not done yet */
if (relinfo->ri_TrigFunctions == NULL)
{
relinfo->ri_TrigFunctions = (FmgrInfo *)
palloc0(trigdesc->numtriggers * sizeof(FmgrInfo));
palloc(trigdesc->numtriggers * sizeof(FmgrInfo));
MemSet(relinfo->ri_TrigFunctions, 0,
trigdesc->numtriggers * sizeof(FmgrInfo));
}
LocTriggerData.type = T_TriggerData;
LocTriggerData.tg_event = TRIGGER_EVENT_DELETE | TRIGGER_EVENT_ROW | TRIGGER_EVENT_BEFORE;
@ -1273,8 +1282,12 @@ ExecBRUpdateTriggers(EState *estate, ResultRelInfo *relinfo,
/* Allocate cache space for fmgr lookup info, if not done yet */
if (relinfo->ri_TrigFunctions == NULL)
{
relinfo->ri_TrigFunctions = (FmgrInfo *)
palloc0(trigdesc->numtriggers * sizeof(FmgrInfo));
palloc(trigdesc->numtriggers * sizeof(FmgrInfo));
MemSet(relinfo->ri_TrigFunctions, 0,
trigdesc->numtriggers * sizeof(FmgrInfo));
}
LocTriggerData.type = T_TriggerData;
LocTriggerData.tg_event = TRIGGER_EVENT_UPDATE | TRIGGER_EVENT_ROW | TRIGGER_EVENT_BEFORE;
@ -1756,7 +1769,9 @@ deferredTriggerInvokeEvents(bool immediate_only)
* Allocate space to cache fmgr lookup info for triggers.
*/
finfo = (FmgrInfo *)
palloc0(trigdesc->numtriggers * sizeof(FmgrInfo));
palloc(trigdesc->numtriggers * sizeof(FmgrInfo));
MemSet(finfo, 0,
trigdesc->numtriggers * sizeof(FmgrInfo));
}
DeferredTriggerExecute(event, i, rel, trigdesc, finfo,