1
/*-------------------------------------------------------------------------
4
* support for the POSTGRES executor module
7
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
8
* Portions Copyright (c) 1994, Regents of the University of California
10
* $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.115 2004-12-31 22:03:29 pgsql Exp $
12
*-------------------------------------------------------------------------
17
#include "executor/execdesc.h"
23
* This is used mainly to detect when there are no more
26
/* return: true if tuple in slot is NULL, slot is slot to test */
27
#define TupIsNull(slot) \
28
((slot) == NULL || (slot)->val == NULL)
32
* ExecEvalExpr was formerly a function containing a switch statement;
33
* now it's just a macro invoking the function pointed to by an ExprState
34
* node. Beware of double evaluation of the ExprState argument!
36
#define ExecEvalExpr(expr, econtext, isNull, isDone) \
37
((*(expr)->evalfunc) (expr, econtext, isNull, isDone))
41
* prototypes from functions in execAmi.c
43
extern void ExecReScan(PlanState *node, ExprContext *exprCtxt);
44
extern void ExecMarkPos(PlanState *node);
45
extern void ExecRestrPos(PlanState *node);
46
extern bool ExecSupportsMarkRestore(NodeTag plantype);
47
extern bool ExecSupportsBackwardScan(Plan *node);
48
extern bool ExecMayReturnRawTuples(PlanState *node);
51
* prototypes from functions in execGrouping.c
53
extern bool execTuplesMatch(HeapTuple tuple1,
57
AttrNumber *matchColIdx,
58
FmgrInfo *eqfunctions,
59
MemoryContext evalContext);
60
extern bool execTuplesUnequal(HeapTuple tuple1,
64
AttrNumber *matchColIdx,
65
FmgrInfo *eqfunctions,
66
MemoryContext evalContext);
67
extern FmgrInfo *execTuplesMatchPrepare(TupleDesc tupdesc,
69
AttrNumber *matchColIdx);
70
extern void execTuplesHashPrepare(TupleDesc tupdesc,
72
AttrNumber *matchColIdx,
73
FmgrInfo **eqfunctions,
74
FmgrInfo **hashfunctions);
75
extern TupleHashTable BuildTupleHashTable(int numCols, AttrNumber *keyColIdx,
76
FmgrInfo *eqfunctions,
77
FmgrInfo *hashfunctions,
78
int nbuckets, Size entrysize,
79
MemoryContext tablecxt,
80
MemoryContext tempcxt);
81
extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable,
86
* prototypes from functions in execJunk.c
88
extern JunkFilter *ExecInitJunkFilter(List *targetList, bool hasoid,
89
TupleTableSlot *slot);
90
extern JunkFilter *ExecInitJunkFilterConversion(List *targetList,
91
TupleDesc cleanTupType,
92
TupleTableSlot *slot);
93
extern bool ExecGetJunkAttribute(JunkFilter *junkfilter, TupleTableSlot *slot,
94
char *attrName, Datum *value, bool *isNull);
95
extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot);
99
* prototypes from functions in execMain.c
101
extern void ExecutorStart(QueryDesc *queryDesc, bool explainOnly);
102
extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc,
103
ScanDirection direction, long count);
104
extern void ExecutorEnd(QueryDesc *queryDesc);
105
extern void ExecutorRewind(QueryDesc *queryDesc);
106
extern void ExecCheckRTPerms(List *rangeTable);
107
extern void ExecEndPlan(PlanState *planstate, EState *estate);
108
extern bool ExecContextForcesOids(PlanState *planstate, bool *hasoids);
109
extern void ExecConstraints(ResultRelInfo *resultRelInfo,
110
TupleTableSlot *slot, EState *estate);
111
extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti,
115
* prototypes from functions in execProcnode.c
117
extern PlanState *ExecInitNode(Plan *node, EState *estate);
118
extern TupleTableSlot *ExecProcNode(PlanState *node);
119
extern int ExecCountSlotsNode(Plan *node);
120
extern void ExecEndNode(PlanState *node);
123
* prototypes from functions in execQual.c
125
extern Datum GetAttributeByNum(HeapTupleHeader tuple, AttrNumber attrno,
127
extern Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname,
129
extern void init_fcache(Oid foid, FuncExprState *fcache,
130
MemoryContext fcacheCxt);
131
extern Datum ExecMakeFunctionResult(FuncExprState *fcache,
132
ExprContext *econtext,
134
ExprDoneCond *isDone);
135
extern Tuplestorestate *ExecMakeTableFunctionResult(ExprState *funcexpr,
136
ExprContext *econtext,
137
TupleDesc expectedDesc,
138
TupleDesc *returnDesc);
139
extern Datum ExecEvalExprSwitchContext(ExprState *expression, ExprContext *econtext,
140
bool *isNull, ExprDoneCond *isDone);
141
extern ExprState *ExecInitExpr(Expr *node, PlanState *parent);
142
extern SubPlanState *ExecInitExprInitPlan(SubPlan *node, PlanState *parent);
143
extern ExprState *ExecPrepareExpr(Expr *node, EState *estate);
144
extern bool ExecQual(List *qual, ExprContext *econtext, bool resultForNull);
145
extern int ExecTargetListLength(List *targetlist);
146
extern int ExecCleanTargetListLength(List *targetlist);
147
extern TupleTableSlot *ExecProject(ProjectionInfo *projInfo,
148
ExprDoneCond *isDone);
151
* prototypes from functions in execScan.c
153
typedef TupleTableSlot *(*ExecScanAccessMtd) (ScanState *node);
155
extern TupleTableSlot *ExecScan(ScanState *node, ExecScanAccessMtd accessMtd);
156
extern void ExecAssignScanProjectionInfo(ScanState *node);
159
* prototypes from functions in execTuples.c
161
extern TupleTable ExecCreateTupleTable(int initialSize);
162
extern void ExecDropTupleTable(TupleTable table, bool shouldFree);
163
extern TupleTableSlot *ExecAllocTableSlot(TupleTable table);
164
extern TupleTableSlot *MakeTupleTableSlot(void);
165
extern TupleTableSlot *ExecStoreTuple(HeapTuple tuple,
166
TupleTableSlot *slot,
169
extern TupleTableSlot *ExecClearTuple(TupleTableSlot *slot);
170
extern void ExecSetSlotDescriptor(TupleTableSlot *slot,
171
TupleDesc tupdesc, bool shouldFree);
172
extern void ExecSetSlotDescriptorIsNew(TupleTableSlot *slot, bool isNew);
173
extern void ExecInitResultTupleSlot(EState *estate, PlanState *planstate);
174
extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate);
175
extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate);
176
extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate,
178
extern TupleDesc ExecTypeFromTL(List *targetList, bool hasoid);
179
extern TupleDesc ExecCleanTypeFromTL(List *targetList, bool hasoid);
180
extern TupleDesc ExecTypeFromExprList(List *exprList);
181
extern void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg);
183
typedef struct TupOutputState
185
/* use "struct" here to allow forward reference */
186
struct AttInMetadata *metadata;
190
extern TupOutputState *begin_tup_output_tupdesc(DestReceiver *dest,
192
extern void do_tup_output(TupOutputState *tstate, char **values);
193
extern void do_text_output_multiline(TupOutputState *tstate, char *text);
194
extern void end_tup_output(TupOutputState *tstate);
197
* Write a single line of text given as a C string.
199
* Should only be used with a single-TEXT-attribute tupdesc.
201
#define do_text_output_oneline(tstate, text_to_emit) \
204
values_[0] = (text_to_emit); \
205
do_tup_output(tstate, values_); \
210
* prototypes from functions in execUtils.c
212
extern EState *CreateExecutorState(void);
213
extern void FreeExecutorState(EState *estate);
214
extern ExprContext *CreateExprContext(EState *estate);
215
extern void FreeExprContext(ExprContext *econtext);
216
extern void ReScanExprContext(ExprContext *econtext);
218
#define ResetExprContext(econtext) \
219
MemoryContextReset((econtext)->ecxt_per_tuple_memory)
221
extern ExprContext *MakePerTupleExprContext(EState *estate);
223
/* Get an EState's per-output-tuple exprcontext, making it if first use */
224
#define GetPerTupleExprContext(estate) \
225
((estate)->es_per_tuple_exprcontext ? \
226
(estate)->es_per_tuple_exprcontext : \
227
MakePerTupleExprContext(estate))
229
#define GetPerTupleMemoryContext(estate) \
230
(GetPerTupleExprContext(estate)->ecxt_per_tuple_memory)
232
/* Reset an EState's per-output-tuple exprcontext, if one's been created */
233
#define ResetPerTupleExprContext(estate) \
235
if ((estate)->es_per_tuple_exprcontext) \
236
ResetExprContext((estate)->es_per_tuple_exprcontext); \
239
extern void ExecAssignExprContext(EState *estate, PlanState *planstate);
240
extern void ExecAssignResultType(PlanState *planstate,
241
TupleDesc tupDesc, bool shouldFree);
242
extern void ExecAssignResultTypeFromOuterPlan(PlanState *planstate);
243
extern void ExecAssignResultTypeFromTL(PlanState *planstate);
244
extern TupleDesc ExecGetResultType(PlanState *planstate);
245
extern ProjectionInfo *ExecBuildProjectionInfo(List *targetList,
246
ExprContext *econtext,
247
TupleTableSlot *slot);
248
extern void ExecAssignProjectionInfo(PlanState *planstate);
249
extern void ExecFreeExprContext(PlanState *planstate);
250
extern TupleDesc ExecGetScanType(ScanState *scanstate);
251
extern void ExecAssignScanType(ScanState *scanstate,
252
TupleDesc tupDesc, bool shouldFree);
253
extern void ExecAssignScanTypeFromOuterPlan(ScanState *scanstate);
255
extern void ExecOpenIndices(ResultRelInfo *resultRelInfo);
256
extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);
257
extern void ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid,
258
EState *estate, bool is_vacuum);
260
extern void RegisterExprContextCallback(ExprContext *econtext,
261
ExprContextCallbackFunction function,
263
extern void UnregisterExprContextCallback(ExprContext *econtext,
264
ExprContextCallbackFunction function,
267
#endif /* EXECUTOR_H */