]> granicus.if.org Git - postgresql/blob - src/include/nodes/params.h
Add an "argisrow" field to NullTest nodes, following a plan made way back in
[postgresql] / src / include / nodes / params.h
1 /*-------------------------------------------------------------------------
2  *
3  * params.h
4  *        Support for finding the values associated with Param nodes.
5  *
6  *
7  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $PostgreSQL: pgsql/src/include/nodes/params.h,v 1.39 2009/11/04 22:26:06 tgl Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef PARAMS_H
15 #define PARAMS_H
16
17 /* To avoid including a pile of parser headers, reference ParseState thus: */
18 struct ParseState;
19
20
21 /* ----------------
22  *        ParamListInfo
23  *
24  *        ParamListInfo arrays are used to pass parameters into the executor
25  *        for parameterized plans.      Each entry in the array defines the value
26  *        to be substituted for a PARAM_EXTERN parameter.  The "paramid"
27  *        of a PARAM_EXTERN Param can range from 1 to numParams.
28  *
29  *        Although parameter numbers are normally consecutive, we allow
30  *        ptype == InvalidOid to signal an unused array entry.
31  *
32  *        pflags is a flags field.  Currently the only used bit is:
33  *        PARAM_FLAG_CONST signals the planner that it may treat this parameter
34  *        as a constant (i.e., generate a plan that works only for this value
35  *        of the parameter).
36  *
37  *        There are two hook functions that can be associated with a ParamListInfo
38  *        array to support dynamic parameter handling.  First, if paramFetch
39  *        isn't null and the executor requires a value for an invalid parameter
40  *        (one with ptype == InvalidOid), the paramFetch hook is called to give
41  *        it a chance to fill in the parameter value.  Second, a parserSetup
42  *        hook can be supplied to re-instantiate the original parsing hooks if
43  *        a query needs to be re-parsed/planned (as a substitute for supposing
44  *        that the current ptype values represent a fixed set of parameter types).
45
46  *        Although the data structure is really an array, not a list, we keep
47  *        the old typedef name to avoid unnecessary code changes.
48  * ----------------
49  */
50
51 #define PARAM_FLAG_CONST        0x0001          /* parameter is constant */
52
53 typedef struct ParamExternData
54 {
55         Datum           value;                  /* parameter value */
56         bool            isnull;                 /* is it NULL? */
57         uint16          pflags;                 /* flag bits, see above */
58         Oid                     ptype;                  /* parameter's datatype, or 0 */
59 } ParamExternData;
60
61 typedef struct ParamListInfoData *ParamListInfo;
62
63 typedef void (*ParamFetchHook) (ParamListInfo params, int paramid);
64
65 typedef void (*ParserSetupHook) (struct ParseState *pstate, void *arg);
66
67 typedef struct ParamListInfoData
68 {
69         ParamFetchHook paramFetch;      /* parameter fetch hook */
70         void       *paramFetchArg;
71         ParserSetupHook parserSetup; /* parser setup hook */
72         void       *parserSetupArg;
73         int                     numParams;              /* number of ParamExternDatas following */
74         ParamExternData params[1];      /* VARIABLE LENGTH ARRAY */
75 } ParamListInfoData;
76
77
78 /* ----------------
79  *        ParamExecData
80  *
81  *        ParamExecData entries are used for executor internal parameters
82  *        (that is, values being passed into or out of a sub-query).  The
83  *        paramid of a PARAM_EXEC Param is a (zero-based) index into an
84  *        array of ParamExecData records, which is referenced through
85  *        es_param_exec_vals or ecxt_param_exec_vals.
86  *
87  *        If execPlan is not NULL, it points to a SubPlanState node that needs
88  *        to be executed to produce the value.  (This is done so that we can have
89  *        lazy evaluation of InitPlans: they aren't executed until/unless a
90  *        result value is needed.)      Otherwise the value is assumed to be valid
91  *        when needed.
92  * ----------------
93  */
94
95 typedef struct ParamExecData
96 {
97         void       *execPlan;           /* should be "SubPlanState *" */
98         Datum           value;
99         bool            isnull;
100 } ParamExecData;
101
102
103 /* Functions found in src/backend/nodes/params.c */
104 extern ParamListInfo copyParamList(ParamListInfo from);
105
106 extern void setupParserWithParamList(struct ParseState *pstate,
107                                                                          ParamListInfo params);
108
109 #endif   /* PARAMS_H */