diff options
| author | Tom Lane | 2006-04-22 01:26:01 +0000 |
|---|---|---|
| committer | Tom Lane | 2006-04-22 01:26:01 +0000 |
| commit | 2206b498d8240447a9353ce4e994ba41a8e307ac (patch) | |
| tree | eb60585d0dae556ae45aae35a7d50f83be715ab4 /src/backend/commands | |
| parent | 0606860a20511c41d5c9074831e6328547722537 (diff) | |
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.
Diffstat (limited to 'src/backend/commands')
| -rw-r--r-- | src/backend/commands/prepare.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index c0fbbabdba..0892ab9fbb 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -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; } |
