mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Do parse analysis of an EXPLAIN's contained statement during the normal
parse analysis phase, rather than at execution time. This makes parameter handling work the same as it does in ordinary plannable queries, and in particular fixes the incompatibility that Pavel pointed out with plpgsql's new handling of variable references. plancache.c gets a little bit grottier, but the alternatives seem worse.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/params.c,v 1.13 2010/01/02 16:57:46 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/params.c,v 1.14 2010/01/15 22:36:31 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -75,47 +75,3 @@ copyParamList(ParamListInfo from)
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the parser to treat the given list of run-time parameters
|
||||
* as available external parameters during parsing of a new query.
|
||||
*
|
||||
* Note that the parser doesn't actually care about the *values* of the given
|
||||
* parameters, only about their *types*. Also, the code that originally
|
||||
* provided the ParamListInfo may have provided a setupHook, which should
|
||||
* override applying parse_fixed_parameters().
|
||||
*/
|
||||
void
|
||||
setupParserWithParamList(struct ParseState *pstate,
|
||||
ParamListInfo params)
|
||||
{
|
||||
if (params == NULL) /* no params, nothing to do */
|
||||
return;
|
||||
|
||||
/* If there is a parserSetup hook, it gets to do this */
|
||||
if (params->parserSetup != NULL)
|
||||
{
|
||||
(*params->parserSetup) (pstate, params->parserSetupArg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Else, treat any available parameters as being of fixed type */
|
||||
if (params->numParams > 0)
|
||||
{
|
||||
Oid *ptypes;
|
||||
int i;
|
||||
|
||||
ptypes = (Oid *) palloc(params->numParams * sizeof(Oid));
|
||||
for (i = 0; i < params->numParams; i++)
|
||||
{
|
||||
ParamExternData *prm = ¶ms->params[i];
|
||||
|
||||
/* give hook a chance in case parameter is dynamic */
|
||||
if (!OidIsValid(prm->ptype) && params->paramFetch != NULL)
|
||||
(*params->paramFetch) (params, i+1);
|
||||
|
||||
ptypes[i] = prm->ptype;
|
||||
}
|
||||
parse_fixed_parameters(pstate, ptypes, params->numParams);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user