mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
Simplify ParamListInfo data structure to support only numbered parameters,
not named ones, and replace linear searches of the list with array indexing. The named-parameter support has been dead code for many years anyway, and recent profiling suggests that the searching was costing a noticeable amount of performance for complex queries.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
* Copyright (c) 2002-2006, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.49 2006/03/05 15:58:24 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.50 2006/04/22 01:25:58 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -247,30 +247,30 @@ EvaluateParams(EState *estate, List *params, List *argtypes)
|
||||
if (list_length(params) != nargs)
|
||||
elog(ERROR, "wrong number of arguments");
|
||||
|
||||
if (nargs == 0)
|
||||
return NULL;
|
||||
|
||||
exprstates = (List *) ExecPrepareExpr((Expr *) params, estate);
|
||||
|
||||
paramLI = (ParamListInfo)
|
||||
palloc0((nargs + 1) * sizeof(ParamListInfoData));
|
||||
/* sizeof(ParamListInfoData) includes the first array element */
|
||||
paramLI = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
|
||||
(nargs - 1) * sizeof(ParamExternData));
|
||||
paramLI->numParams = nargs;
|
||||
|
||||
forboth(le, exprstates, la, argtypes)
|
||||
{
|
||||
ExprState *n = lfirst(le);
|
||||
bool isNull;
|
||||
ParamExternData *prm = ¶mLI->params[i];
|
||||
|
||||
paramLI[i].value = ExecEvalExprSwitchContext(n,
|
||||
GetPerTupleExprContext(estate),
|
||||
&isNull,
|
||||
NULL);
|
||||
paramLI[i].kind = PARAM_NUM;
|
||||
paramLI[i].id = i + 1;
|
||||
paramLI[i].ptype = lfirst_oid(la);
|
||||
paramLI[i].isnull = isNull;
|
||||
prm->ptype = lfirst_oid(la);
|
||||
prm->value = ExecEvalExprSwitchContext(n,
|
||||
GetPerTupleExprContext(estate),
|
||||
&prm->isnull,
|
||||
NULL);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
paramLI[i].kind = PARAM_INVALID;
|
||||
|
||||
return paramLI;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user