mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +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:
@ -27,7 +27,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.182 2002/11/10 07:25:13 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.183 2002/11/11 03:02:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -106,8 +106,12 @@ ExecutorStart(QueryDesc *queryDesc, EState *estate)
|
||||
Assert(queryDesc != NULL);
|
||||
|
||||
if (queryDesc->plantree->nParamExec > 0)
|
||||
{
|
||||
estate->es_param_exec_vals = (ParamExecData *)
|
||||
palloc0(queryDesc->plantree->nParamExec * sizeof(ParamExecData));
|
||||
palloc(queryDesc->plantree->nParamExec * sizeof(ParamExecData));
|
||||
MemSet(estate->es_param_exec_vals, 0,
|
||||
queryDesc->plantree->nParamExec * sizeof(ParamExecData));
|
||||
}
|
||||
|
||||
/*
|
||||
* Make our own private copy of the current query snapshot data.
|
||||
@ -1788,12 +1792,17 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
|
||||
*/
|
||||
epqstate->es_evTupleNull = (bool *) palloc(rtsize * sizeof(bool));
|
||||
if (epq == NULL)
|
||||
{
|
||||
/* first PQ stack entry */
|
||||
epqstate->es_evTuple = (HeapTuple *)
|
||||
palloc0(rtsize * sizeof(HeapTuple));
|
||||
palloc(rtsize * sizeof(HeapTuple));
|
||||
memset(epqstate->es_evTuple, 0, rtsize * sizeof(HeapTuple));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* later stack entries share the same storage */
|
||||
epqstate->es_evTuple = epq->estate.es_evTuple;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.58 2002/11/10 07:25:13 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.59 2002/11/11 03:02:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -121,7 +121,9 @@ init_execution_state(char *src, Oid *argOidVect, int nargs)
|
||||
int i;
|
||||
ParamListInfo paramLI;
|
||||
|
||||
paramLI = (ParamListInfo) palloc0((nargs + 1) * sizeof(ParamListInfoData));
|
||||
paramLI = (ParamListInfo) palloc((nargs + 1) * sizeof(ParamListInfoData));
|
||||
|
||||
MemSet(paramLI, 0, (nargs + 1) * sizeof(ParamListInfoData));
|
||||
|
||||
estate->es_param_list_info = paramLI;
|
||||
|
||||
@ -183,7 +185,8 @@ init_sql_fcache(FmgrInfo *finfo)
|
||||
|
||||
typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
|
||||
|
||||
fcache = (SQLFunctionCachePtr) palloc0(sizeof(SQLFunctionCache));
|
||||
fcache = (SQLFunctionCachePtr) palloc(sizeof(SQLFunctionCache));
|
||||
MemSet(fcache, 0, sizeof(SQLFunctionCache));
|
||||
|
||||
/*
|
||||
* get the type length and by-value flag from the type tuple
|
||||
|
@ -45,7 +45,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.93 2002/11/10 07:25:13 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.94 2002/11/11 03:02:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -651,7 +651,8 @@ lookup_hash_entry(Agg *node, TupleTableSlot *slot)
|
||||
MemoryContextSwitchTo(aggstate->aggcontext);
|
||||
entrysize = sizeof(AggHashEntryData) +
|
||||
(aggstate->numaggs - 1) * sizeof(AggStatePerGroupData);
|
||||
entry = (AggHashEntry) palloc0(entrysize);
|
||||
entry = (AggHashEntry) palloc(entrysize);
|
||||
MemSet(entry, 0, entrysize);
|
||||
|
||||
entry->hashkey = hashkey;
|
||||
entry->firstTuple = heap_copytuple(tuple);
|
||||
@ -887,8 +888,9 @@ agg_retrieve_direct(Agg *node)
|
||||
Datum *dvalues;
|
||||
char *dnulls;
|
||||
|
||||
dvalues = (Datum *) palloc0(sizeof(Datum) * tupType->natts);
|
||||
dvalues = (Datum *) palloc(sizeof(Datum) * tupType->natts);
|
||||
dnulls = (char *) palloc(sizeof(char) * tupType->natts);
|
||||
MemSet(dvalues, 0, sizeof(Datum) * tupType->natts);
|
||||
MemSet(dnulls, 'n', sizeof(char) * tupType->natts);
|
||||
nullsTuple = heap_formtuple(tupType, dvalues, dnulls);
|
||||
ExecStoreTuple(nullsTuple,
|
||||
@ -1168,10 +1170,13 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
|
||||
* allocate my private per-agg working storage
|
||||
*/
|
||||
econtext = aggstate->csstate.cstate.cs_ExprContext;
|
||||
econtext->ecxt_aggvalues = (Datum *) palloc0(sizeof(Datum) * numaggs);
|
||||
econtext->ecxt_aggnulls = (bool *) palloc0(sizeof(bool) * numaggs);
|
||||
econtext->ecxt_aggvalues = (Datum *) palloc(sizeof(Datum) * numaggs);
|
||||
MemSet(econtext->ecxt_aggvalues, 0, sizeof(Datum) * numaggs);
|
||||
econtext->ecxt_aggnulls = (bool *) palloc(sizeof(bool) * numaggs);
|
||||
MemSet(econtext->ecxt_aggnulls, 0, sizeof(bool) * numaggs);
|
||||
|
||||
peragg = (AggStatePerAgg) palloc0(sizeof(AggStatePerAggData) * numaggs);
|
||||
peragg = (AggStatePerAgg) palloc(sizeof(AggStatePerAggData) * numaggs);
|
||||
MemSet(peragg, 0, sizeof(AggStatePerAggData) * numaggs);
|
||||
aggstate->peragg = peragg;
|
||||
|
||||
if (node->aggstrategy == AGG_HASHED)
|
||||
@ -1183,7 +1188,8 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
|
||||
{
|
||||
AggStatePerGroup pergroup;
|
||||
|
||||
pergroup = (AggStatePerGroup) palloc0(sizeof(AggStatePerGroupData) * numaggs);
|
||||
pergroup = (AggStatePerGroup) palloc(sizeof(AggStatePerGroupData) * numaggs);
|
||||
MemSet(pergroup, 0, sizeof(AggStatePerGroupData) * numaggs);
|
||||
aggstate->pergroup = pergroup;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.48 2002/11/10 07:25:13 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.49 2002/11/11 03:02:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -166,7 +166,8 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
appendplans = node->appendplans;
|
||||
nplans = length(appendplans);
|
||||
|
||||
initialized = (bool *) palloc0(nplans * sizeof(bool));
|
||||
initialized = (bool *) palloc(nplans * sizeof(bool));
|
||||
MemSet(initialized, 0, nplans * sizeof(bool));
|
||||
|
||||
/*
|
||||
* create new AppendState for our append node
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.38 2002/11/10 07:25:13 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.39 2002/11/11 03:02:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -50,9 +50,11 @@ ExtractSortKeys(Sort *sortnode,
|
||||
*/
|
||||
if (keycount <= 0)
|
||||
elog(ERROR, "ExtractSortKeys: keycount <= 0");
|
||||
sortOps = (Oid *) palloc0(keycount * sizeof(Oid));
|
||||
sortOps = (Oid *) palloc(keycount * sizeof(Oid));
|
||||
MemSet(sortOps, 0, keycount * sizeof(Oid));
|
||||
*sortOperators = sortOps;
|
||||
attNos = (AttrNumber *) palloc0(keycount * sizeof(AttrNumber));
|
||||
attNos = (AttrNumber *) palloc(keycount * sizeof(AttrNumber));
|
||||
MemSet(attNos, 0, keycount * sizeof(AttrNumber));
|
||||
*attNums = attNos;
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.76 2002/11/10 07:25:13 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.77 2002/11/11 03:02:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -783,8 +783,9 @@ SPI_cursor_open(char *name, void *plan, Datum *Values, char *Nulls)
|
||||
{
|
||||
ParamListInfo paramLI;
|
||||
|
||||
paramLI = (ParamListInfo) palloc0((spiplan->nargs + 1) *
|
||||
paramLI = (ParamListInfo) palloc((spiplan->nargs + 1) *
|
||||
sizeof(ParamListInfoData));
|
||||
MemSet(paramLI, 0, (spiplan->nargs + 1) * sizeof(ParamListInfoData));
|
||||
|
||||
eState->es_param_list_info = paramLI;
|
||||
for (k = 0; k < spiplan->nargs; paramLI++, k++)
|
||||
@ -1192,7 +1193,9 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, char *Nulls, int tcount)
|
||||
int k;
|
||||
|
||||
paramLI = (ParamListInfo)
|
||||
palloc0((nargs + 1) * sizeof(ParamListInfoData));
|
||||
palloc((nargs + 1) * sizeof(ParamListInfoData));
|
||||
MemSet(paramLI, 0,
|
||||
(nargs + 1) * sizeof(ParamListInfoData));
|
||||
|
||||
state->es_param_list_info = paramLI;
|
||||
for (k = 0; k < plan->nargs; paramLI++, k++)
|
||||
|
Reference in New Issue
Block a user