diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-04-22 01:26:01 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-04-22 01:26:01 +0000 |
commit | 2206b498d8240447a9353ce4e994ba41a8e307ac (patch) | |
tree | eb60585d0dae556ae45aae35a7d50f83be715ab4 /src/backend/executor/execQual.c | |
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/executor/execQual.c')
-rw-r--r-- | src/backend/executor/execQual.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index fcc7d4b683c..41ea452df58 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.189 2006/03/10 01:51:23 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.190 2006/04/22 01:25:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -605,13 +605,12 @@ ExecEvalParam(ExprState *exprstate, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone) { Param *expression = (Param *) exprstate->expr; - int thisParamKind = expression->paramkind; - AttrNumber thisParamId = expression->paramid; + int thisParamId = expression->paramid; if (isDone) *isDone = ExprSingleResult; - if (thisParamKind == PARAM_EXEC) + if (expression->paramkind == PARAM_EXEC) { /* * PARAM_EXEC params (internal executor parameters) are stored in the @@ -633,18 +632,27 @@ ExecEvalParam(ExprState *exprstate, ExprContext *econtext, else { /* - * All other parameter types must be sought in ecxt_param_list_info. + * PARAM_EXTERN parameters must be sought in ecxt_param_list_info. */ - ParamListInfo paramInfo; - - paramInfo = lookupParam(econtext->ecxt_param_list_info, - thisParamKind, - expression->paramname, - thisParamId, - false); - Assert(paramInfo->ptype == expression->paramtype); - *isNull = paramInfo->isnull; - return paramInfo->value; + ParamListInfo paramInfo = econtext->ecxt_param_list_info; + + Assert(expression->paramkind == PARAM_EXTERN); + if (paramInfo && + thisParamId > 0 && thisParamId <= paramInfo->numParams) + { + ParamExternData *prm = ¶mInfo->params[thisParamId - 1]; + + if (OidIsValid(prm->ptype)) + { + Assert(prm->ptype == expression->paramtype); + *isNull = prm->isnull; + return prm->value; + } + } + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("no value found for parameter %d", thisParamId))); + return (Datum) 0; /* keep compiler quiet */ } } |