diff options
Diffstat (limited to 'src/include/nodes/params.h')
-rw-r--r-- | src/include/nodes/params.h | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/include/nodes/params.h b/src/include/nodes/params.h index adc58710553..96cbf5267a4 100644 --- a/src/include/nodes/params.h +++ b/src/include/nodes/params.h @@ -7,13 +7,16 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/params.h,v 1.38 2009/01/01 17:24:00 momjian Exp $ + * $PostgreSQL: pgsql/src/include/nodes/params.h,v 1.39 2009/11/04 22:26:06 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef PARAMS_H #define PARAMS_H +/* To avoid including a pile of parser headers, reference ParseState thus: */ +struct ParseState; + /* ---------------- * ParamListInfo @@ -26,10 +29,20 @@ * Although parameter numbers are normally consecutive, we allow * ptype == InvalidOid to signal an unused array entry. * + * pflags is a flags field. Currently the only used bit is: * PARAM_FLAG_CONST signals the planner that it may treat this parameter * as a constant (i.e., generate a plan that works only for this value * of the parameter). * + * There are two hook functions that can be associated with a ParamListInfo + * array to support dynamic parameter handling. First, if paramFetch + * isn't null and the executor requires a value for an invalid parameter + * (one with ptype == InvalidOid), the paramFetch hook is called to give + * it a chance to fill in the parameter value. Second, a parserSetup + * hook can be supplied to re-instantiate the original parsing hooks if + * a query needs to be re-parsed/planned (as a substitute for supposing + * that the current ptype values represent a fixed set of parameter types). + * Although the data structure is really an array, not a list, we keep * the old typedef name to avoid unnecessary code changes. * ---------------- @@ -45,14 +58,22 @@ typedef struct ParamExternData Oid ptype; /* parameter's datatype, or 0 */ } ParamExternData; +typedef struct ParamListInfoData *ParamListInfo; + +typedef void (*ParamFetchHook) (ParamListInfo params, int paramid); + +typedef void (*ParserSetupHook) (struct ParseState *pstate, void *arg); + typedef struct ParamListInfoData { + ParamFetchHook paramFetch; /* parameter fetch hook */ + void *paramFetchArg; + ParserSetupHook parserSetup; /* parser setup hook */ + void *parserSetupArg; int numParams; /* number of ParamExternDatas following */ ParamExternData params[1]; /* VARIABLE LENGTH ARRAY */ } ParamListInfoData; -typedef ParamListInfoData *ParamListInfo; - /* ---------------- * ParamExecData @@ -82,7 +103,7 @@ typedef struct ParamExecData /* Functions found in src/backend/nodes/params.c */ extern ParamListInfo copyParamList(ParamListInfo from); -extern void getParamListTypes(ParamListInfo params, - Oid **param_types, int *num_params); +extern void setupParserWithParamList(struct ParseState *pstate, + ParamListInfo params); #endif /* PARAMS_H */ |