]> granicus.if.org Git - postgresql/blob - src/include/executor/executor.h
Introduce notion of different types of slots (without implementing them).
[postgresql] / src / include / executor / executor.h
1 /*-------------------------------------------------------------------------
2  *
3  * executor.h
4  *        support for the POSTGRES executor module
5  *
6  *
7  * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/executor/executor.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef EXECUTOR_H
15 #define EXECUTOR_H
16
17 #include "executor/execdesc.h"
18 #include "nodes/parsenodes.h"
19 #include "utils/memutils.h"
20
21
22 /*
23  * The "eflags" argument to ExecutorStart and the various ExecInitNode
24  * routines is a bitwise OR of the following flag bits, which tell the
25  * called plan node what to expect.  Note that the flags will get modified
26  * as they are passed down the plan tree, since an upper node may require
27  * functionality in its subnode not demanded of the plan as a whole
28  * (example: MergeJoin requires mark/restore capability in its inner input),
29  * or an upper node may shield its input from some functionality requirement
30  * (example: Materialize shields its input from needing to do backward scan).
31  *
32  * EXPLAIN_ONLY indicates that the plan tree is being initialized just so
33  * EXPLAIN can print it out; it will not be run.  Hence, no side-effects
34  * of startup should occur.  However, error checks (such as permission checks)
35  * should be performed.
36  *
37  * REWIND indicates that the plan node should try to efficiently support
38  * rescans without parameter changes.  (Nodes must support ExecReScan calls
39  * in any case, but if this flag was not given, they are at liberty to do it
40  * through complete recalculation.  Note that a parameter change forces a
41  * full recalculation in any case.)
42  *
43  * BACKWARD indicates that the plan node must respect the es_direction flag.
44  * When this is not passed, the plan node will only be run forwards.
45  *
46  * MARK indicates that the plan node must support Mark/Restore calls.
47  * When this is not passed, no Mark/Restore will occur.
48  *
49  * SKIP_TRIGGERS tells ExecutorStart/ExecutorFinish to skip calling
50  * AfterTriggerBeginQuery/AfterTriggerEndQuery.  This does not necessarily
51  * mean that the plan can't queue any AFTER triggers; just that the caller
52  * is responsible for there being a trigger context for them to be queued in.
53  *
54  * WITH/WITHOUT_OIDS tell the executor to emit tuples with or without space
55  * for OIDs, respectively.  These are currently used only for CREATE TABLE AS.
56  * If neither is set, the plan may or may not produce tuples including OIDs.
57  */
58 #define EXEC_FLAG_EXPLAIN_ONLY  0x0001  /* EXPLAIN, no ANALYZE */
59 #define EXEC_FLAG_REWIND                0x0002  /* need efficient rescan */
60 #define EXEC_FLAG_BACKWARD              0x0004  /* need backward scan */
61 #define EXEC_FLAG_MARK                  0x0008  /* need mark/restore */
62 #define EXEC_FLAG_SKIP_TRIGGERS 0x0010  /* skip AfterTrigger calls */
63 #define EXEC_FLAG_WITH_OIDS             0x0020  /* force OIDs in returned tuples */
64 #define EXEC_FLAG_WITHOUT_OIDS  0x0040  /* force no OIDs in returned tuples */
65 #define EXEC_FLAG_WITH_NO_DATA  0x0080  /* rel scannability doesn't matter */
66
67
68 /* Hook for plugins to get control in ExecutorStart() */
69 typedef void (*ExecutorStart_hook_type) (QueryDesc *queryDesc, int eflags);
70 extern PGDLLIMPORT ExecutorStart_hook_type ExecutorStart_hook;
71
72 /* Hook for plugins to get control in ExecutorRun() */
73 typedef void (*ExecutorRun_hook_type) (QueryDesc *queryDesc,
74                                                                            ScanDirection direction,
75                                                                            uint64 count,
76                                                                            bool execute_once);
77 extern PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook;
78
79 /* Hook for plugins to get control in ExecutorFinish() */
80 typedef void (*ExecutorFinish_hook_type) (QueryDesc *queryDesc);
81 extern PGDLLIMPORT ExecutorFinish_hook_type ExecutorFinish_hook;
82
83 /* Hook for plugins to get control in ExecutorEnd() */
84 typedef void (*ExecutorEnd_hook_type) (QueryDesc *queryDesc);
85 extern PGDLLIMPORT ExecutorEnd_hook_type ExecutorEnd_hook;
86
87 /* Hook for plugins to get control in ExecCheckRTPerms() */
88 typedef bool (*ExecutorCheckPerms_hook_type) (List *, bool);
89 extern PGDLLIMPORT ExecutorCheckPerms_hook_type ExecutorCheckPerms_hook;
90
91
92 /*
93  * prototypes from functions in execAmi.c
94  */
95 struct Path;                                    /* avoid including relation.h here */
96
97 extern void ExecReScan(PlanState *node);
98 extern void ExecMarkPos(PlanState *node);
99 extern void ExecRestrPos(PlanState *node);
100 extern bool ExecSupportsMarkRestore(struct Path *pathnode);
101 extern bool ExecSupportsBackwardScan(Plan *node);
102 extern bool ExecMaterializesOutput(NodeTag plantype);
103
104 /*
105  * prototypes from functions in execCurrent.c
106  */
107 extern bool execCurrentOf(CurrentOfExpr *cexpr,
108                           ExprContext *econtext,
109                           Oid table_oid,
110                           ItemPointer current_tid);
111
112 /*
113  * prototypes from functions in execGrouping.c
114  */
115 extern ExprState *execTuplesMatchPrepare(TupleDesc desc,
116                                            int numCols,
117                                            AttrNumber *keyColIdx,
118                                            Oid *eqOperators,
119                                            PlanState *parent);
120 extern void execTuplesHashPrepare(int numCols,
121                                           Oid *eqOperators,
122                                           Oid **eqFuncOids,
123                                           FmgrInfo **hashFunctions);
124 extern TupleHashTable BuildTupleHashTable(PlanState *parent,
125                                         TupleDesc inputDesc,
126                                         int numCols, AttrNumber *keyColIdx,
127                                         Oid *eqfuncoids,
128                                         FmgrInfo *hashfunctions,
129                                         long nbuckets, Size additionalsize,
130                                         MemoryContext tablecxt,
131                                         MemoryContext tempcxt, bool use_variable_hash_iv);
132 extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable,
133                                          TupleTableSlot *slot,
134                                          bool *isnew);
135 extern TupleHashEntry FindTupleHashEntry(TupleHashTable hashtable,
136                                    TupleTableSlot *slot,
137                                    ExprState *eqcomp,
138                                    FmgrInfo *hashfunctions);
139
140 /*
141  * prototypes from functions in execJunk.c
142  */
143 extern JunkFilter *ExecInitJunkFilter(List *targetList, bool hasoid,
144                                    TupleTableSlot *slot);
145 extern JunkFilter *ExecInitJunkFilterConversion(List *targetList,
146                                                          TupleDesc cleanTupType,
147                                                          TupleTableSlot *slot);
148 extern AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter,
149                                           const char *attrName);
150 extern AttrNumber ExecFindJunkAttributeInTlist(List *targetlist,
151                                                          const char *attrName);
152 extern Datum ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno,
153                                          bool *isNull);
154 extern TupleTableSlot *ExecFilterJunk(JunkFilter *junkfilter,
155                            TupleTableSlot *slot);
156
157
158 /*
159  * prototypes from functions in execMain.c
160  */
161 extern void ExecutorStart(QueryDesc *queryDesc, int eflags);
162 extern void standard_ExecutorStart(QueryDesc *queryDesc, int eflags);
163 extern void ExecutorRun(QueryDesc *queryDesc,
164                         ScanDirection direction, uint64 count, bool execute_once);
165 extern void standard_ExecutorRun(QueryDesc *queryDesc,
166                                          ScanDirection direction, uint64 count, bool execute_once);
167 extern void ExecutorFinish(QueryDesc *queryDesc);
168 extern void standard_ExecutorFinish(QueryDesc *queryDesc);
169 extern void ExecutorEnd(QueryDesc *queryDesc);
170 extern void standard_ExecutorEnd(QueryDesc *queryDesc);
171 extern void ExecutorRewind(QueryDesc *queryDesc);
172 extern bool ExecCheckRTPerms(List *rangeTable, bool ereport_on_violation);
173 extern void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation);
174 extern void InitResultRelInfo(ResultRelInfo *resultRelInfo,
175                                   Relation resultRelationDesc,
176                                   Index resultRelationIndex,
177                                   Relation partition_root,
178                                   int instrument_options);
179 extern ResultRelInfo *ExecGetTriggerResultRel(EState *estate, Oid relid);
180 extern void ExecCleanUpTriggerState(EState *estate);
181 extern bool ExecContextForcesOids(PlanState *planstate, bool *hasoids);
182 extern void ExecConstraints(ResultRelInfo *resultRelInfo,
183                                 TupleTableSlot *slot, EState *estate);
184 extern bool ExecPartitionCheck(ResultRelInfo *resultRelInfo,
185                                    TupleTableSlot *slot, EState *estate, bool emitError);
186 extern void ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo,
187                                                         TupleTableSlot *slot, EState *estate);
188 extern void ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo,
189                                          TupleTableSlot *slot, EState *estate);
190 extern LockTupleMode ExecUpdateLockMode(EState *estate, ResultRelInfo *relinfo);
191 extern ExecRowMark *ExecFindRowMark(EState *estate, Index rti, bool missing_ok);
192 extern ExecAuxRowMark *ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist);
193 extern TupleTableSlot *EvalPlanQual(EState *estate, EPQState *epqstate,
194                          Relation relation, Index rti, int lockmode,
195                          ItemPointer tid, TransactionId priorXmax);
196 extern HeapTuple EvalPlanQualFetch(EState *estate, Relation relation,
197                                   int lockmode, LockWaitPolicy wait_policy, ItemPointer tid,
198                                   TransactionId priorXmax);
199 extern void EvalPlanQualInit(EPQState *epqstate, EState *estate,
200                                  Plan *subplan, List *auxrowmarks, int epqParam);
201 extern void EvalPlanQualSetPlan(EPQState *epqstate,
202                                         Plan *subplan, List *auxrowmarks);
203 extern void EvalPlanQualSetTuple(EPQState *epqstate, Index rti,
204                                          HeapTuple tuple);
205 extern HeapTuple EvalPlanQualGetTuple(EPQState *epqstate, Index rti);
206
207 #define EvalPlanQualSetSlot(epqstate, slot)  ((epqstate)->origslot = (slot))
208 extern void EvalPlanQualFetchRowMarks(EPQState *epqstate);
209 extern TupleTableSlot *EvalPlanQualNext(EPQState *epqstate);
210 extern void EvalPlanQualBegin(EPQState *epqstate, EState *parentestate);
211 extern void EvalPlanQualEnd(EPQState *epqstate);
212
213 /*
214  * functions in execProcnode.c
215  */
216 extern PlanState *ExecInitNode(Plan *node, EState *estate, int eflags);
217 extern void ExecSetExecProcNode(PlanState *node, ExecProcNodeMtd function);
218 extern Node *MultiExecProcNode(PlanState *node);
219 extern void ExecEndNode(PlanState *node);
220 extern bool ExecShutdownNode(PlanState *node);
221 extern void ExecSetTupleBound(int64 tuples_needed, PlanState *child_node);
222
223
224 /* ----------------------------------------------------------------
225  *              ExecProcNode
226  *
227  *              Execute the given node to return a(nother) tuple.
228  * ----------------------------------------------------------------
229  */
230 #ifndef FRONTEND
231 static inline TupleTableSlot *
232 ExecProcNode(PlanState *node)
233 {
234         if (node->chgParam != NULL) /* something changed? */
235                 ExecReScan(node);               /* let ReScan handle this */
236
237         return node->ExecProcNode(node);
238 }
239 #endif
240
241 /*
242  * prototypes from functions in execExpr.c
243  */
244 extern ExprState *ExecInitExpr(Expr *node, PlanState *parent);
245 extern ExprState *ExecInitExprWithParams(Expr *node, ParamListInfo ext_params);
246 extern ExprState *ExecInitQual(List *qual, PlanState *parent);
247 extern ExprState *ExecInitCheck(List *qual, PlanState *parent);
248 extern List *ExecInitExprList(List *nodes, PlanState *parent);
249 extern ExprState *ExecBuildAggTrans(AggState *aggstate, struct AggStatePerPhaseData *phase,
250                                   bool doSort, bool doHash);
251 extern ExprState *ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
252                                            const TupleTableSlotOps *lops, const TupleTableSlotOps *rops,
253                                            int numCols,
254                                            AttrNumber *keyColIdx,
255                                            Oid *eqfunctions,
256                                            PlanState *parent);
257 extern ProjectionInfo *ExecBuildProjectionInfo(List *targetList,
258                                                 ExprContext *econtext,
259                                                 TupleTableSlot *slot,
260                                                 PlanState *parent,
261                                                 TupleDesc inputDesc);
262 extern ExprState *ExecPrepareExpr(Expr *node, EState *estate);
263 extern ExprState *ExecPrepareQual(List *qual, EState *estate);
264 extern ExprState *ExecPrepareCheck(List *qual, EState *estate);
265 extern List *ExecPrepareExprList(List *nodes, EState *estate);
266
267 /*
268  * ExecEvalExpr
269  *
270  * Evaluate expression identified by "state" in the execution context
271  * given by "econtext".  *isNull is set to the is-null flag for the result,
272  * and the Datum value is the function result.
273  *
274  * The caller should already have switched into the temporary memory
275  * context econtext->ecxt_per_tuple_memory.  The convenience entry point
276  * ExecEvalExprSwitchContext() is provided for callers who don't prefer to
277  * do the switch in an outer loop.
278  */
279 #ifndef FRONTEND
280 static inline Datum
281 ExecEvalExpr(ExprState *state,
282                          ExprContext *econtext,
283                          bool *isNull)
284 {
285         return state->evalfunc(state, econtext, isNull);
286 }
287 #endif
288
289 /*
290  * ExecEvalExprSwitchContext
291  *
292  * Same as ExecEvalExpr, but get into the right allocation context explicitly.
293  */
294 #ifndef FRONTEND
295 static inline Datum
296 ExecEvalExprSwitchContext(ExprState *state,
297                                                   ExprContext *econtext,
298                                                   bool *isNull)
299 {
300         Datum           retDatum;
301         MemoryContext oldContext;
302
303         oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
304         retDatum = state->evalfunc(state, econtext, isNull);
305         MemoryContextSwitchTo(oldContext);
306         return retDatum;
307 }
308 #endif
309
310 /*
311  * ExecProject
312  *
313  * Projects a tuple based on projection info and stores it in the slot passed
314  * to ExecBuildProjectInfo().
315  *
316  * Note: the result is always a virtual tuple; therefore it may reference
317  * the contents of the exprContext's scan tuples and/or temporary results
318  * constructed in the exprContext.  If the caller wishes the result to be
319  * valid longer than that data will be valid, he must call ExecMaterializeSlot
320  * on the result slot.
321  */
322 #ifndef FRONTEND
323 static inline TupleTableSlot *
324 ExecProject(ProjectionInfo *projInfo)
325 {
326         ExprContext *econtext = projInfo->pi_exprContext;
327         ExprState  *state = &projInfo->pi_state;
328         TupleTableSlot *slot = state->resultslot;
329         bool            isnull;
330
331         /*
332          * Clear any former contents of the result slot.  This makes it safe for
333          * us to use the slot's Datum/isnull arrays as workspace.
334          */
335         ExecClearTuple(slot);
336
337         /* Run the expression, discarding scalar result from the last column. */
338         (void) ExecEvalExprSwitchContext(state, econtext, &isnull);
339
340         /*
341          * Successfully formed a result row.  Mark the result slot as containing a
342          * valid virtual tuple (inlined version of ExecStoreVirtualTuple()).
343          */
344         slot->tts_flags &= ~TTS_FLAG_EMPTY;
345         slot->tts_nvalid = slot->tts_tupleDescriptor->natts;
346
347         return slot;
348 }
349 #endif
350
351 /*
352  * ExecQual - evaluate a qual prepared with ExecInitQual (possibly via
353  * ExecPrepareQual).  Returns true if qual is satisfied, else false.
354  *
355  * Note: ExecQual used to have a third argument "resultForNull".  The
356  * behavior of this function now corresponds to resultForNull == false.
357  * If you want the resultForNull == true behavior, see ExecCheck.
358  */
359 #ifndef FRONTEND
360 static inline bool
361 ExecQual(ExprState *state, ExprContext *econtext)
362 {
363         Datum           ret;
364         bool            isnull;
365
366         /* short-circuit (here and in ExecInitQual) for empty restriction list */
367         if (state == NULL)
368                 return true;
369
370         /* verify that expression was compiled using ExecInitQual */
371         Assert(state->flags & EEO_FLAG_IS_QUAL);
372
373         ret = ExecEvalExprSwitchContext(state, econtext, &isnull);
374
375         /* EEOP_QUAL should never return NULL */
376         Assert(!isnull);
377
378         return DatumGetBool(ret);
379 }
380 #endif
381
382 /*
383  * ExecQualAndReset() - evaluate qual with ExecQual() and reset expression
384  * context.
385  */
386 #ifndef FRONTEND
387 static inline bool
388 ExecQualAndReset(ExprState *state, ExprContext *econtext)
389 {
390         bool            ret = ExecQual(state, econtext);
391
392         /* inline ResetExprContext, to avoid ordering issue in this file */
393         MemoryContextReset(econtext->ecxt_per_tuple_memory);
394         return ret;
395 }
396 #endif
397
398 extern bool ExecCheck(ExprState *state, ExprContext *context);
399
400 /*
401  * prototypes from functions in execSRF.c
402  */
403 extern SetExprState *ExecInitTableFunctionResult(Expr *expr,
404                                                         ExprContext *econtext, PlanState *parent);
405 extern Tuplestorestate *ExecMakeTableFunctionResult(SetExprState *setexpr,
406                                                         ExprContext *econtext,
407                                                         MemoryContext argContext,
408                                                         TupleDesc expectedDesc,
409                                                         bool randomAccess);
410 extern SetExprState *ExecInitFunctionResultSet(Expr *expr,
411                                                   ExprContext *econtext, PlanState *parent);
412 extern Datum ExecMakeFunctionResultSet(SetExprState *fcache,
413                                                   ExprContext *econtext,
414                                                   MemoryContext argContext,
415                                                   bool *isNull,
416                                                   ExprDoneCond *isDone);
417
418 /*
419  * prototypes from functions in execScan.c
420  */
421 typedef TupleTableSlot *(*ExecScanAccessMtd) (ScanState *node);
422 typedef bool (*ExecScanRecheckMtd) (ScanState *node, TupleTableSlot *slot);
423
424 extern TupleTableSlot *ExecScan(ScanState *node, ExecScanAccessMtd accessMtd,
425                  ExecScanRecheckMtd recheckMtd);
426 extern void ExecAssignScanProjectionInfo(ScanState *node);
427 extern void ExecAssignScanProjectionInfoWithVarno(ScanState *node, Index varno);
428 extern void ExecScanReScan(ScanState *node);
429
430 /*
431  * prototypes from functions in execTuples.c
432  */
433 extern void ExecInitResultTypeTL(PlanState *planstate);
434 extern void ExecInitResultSlot(PlanState *planstate,
435                                                            const TupleTableSlotOps *tts_ops);
436 extern void ExecInitResultTupleSlotTL(PlanState *planstate,
437                                                                           const TupleTableSlotOps *tts_ops);
438 extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate,
439                                                                   TupleDesc tupleDesc,
440                                                                   const TupleTableSlotOps *tts_ops);
441 extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate,
442                                            TupleDesc tupledesc,
443                                            const TupleTableSlotOps *tts_ops);
444 extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate, TupleDesc tupType,
445                                           const TupleTableSlotOps *tts_ops);
446 extern TupleDesc ExecTypeFromTL(List *targetList, bool hasoid);
447 extern TupleDesc ExecCleanTypeFromTL(List *targetList, bool hasoid);
448 extern TupleDesc ExecTypeFromExprList(List *exprList);
449 extern void ExecTypeSetColNames(TupleDesc typeInfo, List *namesList);
450 extern void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg);
451
452 typedef struct TupOutputState
453 {
454         TupleTableSlot *slot;
455         DestReceiver *dest;
456 } TupOutputState;
457
458 extern TupOutputState *begin_tup_output_tupdesc(DestReceiver *dest,
459                                                  TupleDesc tupdesc,
460                                                  const TupleTableSlotOps *tts_ops);
461 extern void do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull);
462 extern void do_text_output_multiline(TupOutputState *tstate, const char *txt);
463 extern void end_tup_output(TupOutputState *tstate);
464
465 /*
466  * Write a single line of text given as a C string.
467  *
468  * Should only be used with a single-TEXT-attribute tupdesc.
469  */
470 #define do_text_output_oneline(tstate, str_to_emit) \
471         do { \
472                 Datum   values_[1]; \
473                 bool    isnull_[1]; \
474                 values_[0] = PointerGetDatum(cstring_to_text(str_to_emit)); \
475                 isnull_[0] = false; \
476                 do_tup_output(tstate, values_, isnull_); \
477                 pfree(DatumGetPointer(values_[0])); \
478         } while (0)
479
480
481 /*
482  * prototypes from functions in execUtils.c
483  */
484 extern EState *CreateExecutorState(void);
485 extern void FreeExecutorState(EState *estate);
486 extern ExprContext *CreateExprContext(EState *estate);
487 extern ExprContext *CreateStandaloneExprContext(void);
488 extern void FreeExprContext(ExprContext *econtext, bool isCommit);
489 extern void ReScanExprContext(ExprContext *econtext);
490
491 #define ResetExprContext(econtext) \
492         MemoryContextReset((econtext)->ecxt_per_tuple_memory)
493
494 extern ExprContext *MakePerTupleExprContext(EState *estate);
495
496 /* Get an EState's per-output-tuple exprcontext, making it if first use */
497 #define GetPerTupleExprContext(estate) \
498         ((estate)->es_per_tuple_exprcontext ? \
499          (estate)->es_per_tuple_exprcontext : \
500          MakePerTupleExprContext(estate))
501
502 #define GetPerTupleMemoryContext(estate) \
503         (GetPerTupleExprContext(estate)->ecxt_per_tuple_memory)
504
505 /* Reset an EState's per-output-tuple exprcontext, if one's been created */
506 #define ResetPerTupleExprContext(estate) \
507         do { \
508                 if ((estate)->es_per_tuple_exprcontext) \
509                         ResetExprContext((estate)->es_per_tuple_exprcontext); \
510         } while (0)
511
512 extern void ExecAssignExprContext(EState *estate, PlanState *planstate);
513 extern TupleDesc ExecGetResultType(PlanState *planstate);
514 extern TupleTableSlot ExecGetResultSlot(PlanState *planstate);
515 extern const TupleTableSlotOps *ExecGetResultSlotOps(PlanState *planstate,
516                                                                                                          bool *isfixed);
517 extern void ExecAssignProjectionInfo(PlanState *planstate,
518                                                  TupleDesc inputDesc);
519 extern void ExecConditionalAssignProjectionInfo(PlanState *planstate,
520                                                                         TupleDesc inputDesc, Index varno);
521 extern void ExecFreeExprContext(PlanState *planstate);
522 extern void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc);
523 extern void ExecCreateScanSlotFromOuterPlan(EState *estate,
524                                                                 ScanState *scanstate,
525                                                                 const TupleTableSlotOps *tts_ops);
526
527 extern bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid);
528
529 extern Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags);
530
531 extern void ExecInitRangeTable(EState *estate, List *rangeTable);
532
533 static inline RangeTblEntry *
534 exec_rt_fetch(Index rti, EState *estate)
535 {
536         Assert(rti > 0 && rti <= estate->es_range_table_size);
537         return estate->es_range_table_array[rti - 1];
538 }
539
540 extern Relation ExecGetRangeTableRelation(EState *estate, Index rti);
541
542 extern int      executor_errposition(EState *estate, int location);
543
544 extern void RegisterExprContextCallback(ExprContext *econtext,
545                                                         ExprContextCallbackFunction function,
546                                                         Datum arg);
547 extern void UnregisterExprContextCallback(ExprContext *econtext,
548                                                           ExprContextCallbackFunction function,
549                                                           Datum arg);
550
551 extern Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname,
552                                    bool *isNull);
553 extern Datum GetAttributeByNum(HeapTupleHeader tuple, AttrNumber attrno,
554                                   bool *isNull);
555
556 extern int      ExecTargetListLength(List *targetlist);
557 extern int      ExecCleanTargetListLength(List *targetlist);
558
559 /*
560  * prototypes from functions in execIndexing.c
561  */
562 extern void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative);
563 extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);
564 extern List *ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid,
565                                           EState *estate, bool noDupErr, bool *specConflict,
566                                           List *arbiterIndexes);
567 extern bool ExecCheckIndexConstraints(TupleTableSlot *slot, EState *estate,
568                                                   ItemPointer conflictTid, List *arbiterIndexes);
569 extern void check_exclusion_constraint(Relation heap, Relation index,
570                                                    IndexInfo *indexInfo,
571                                                    ItemPointer tupleid,
572                                                    Datum *values, bool *isnull,
573                                                    EState *estate, bool newIndex);
574
575 /*
576  * prototypes from functions in execReplication.c
577  */
578 extern bool RelationFindReplTupleByIndex(Relation rel, Oid idxoid,
579                                                          LockTupleMode lockmode,
580                                                          TupleTableSlot *searchslot,
581                                                          TupleTableSlot *outslot);
582 extern bool RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode,
583                                                  TupleTableSlot *searchslot, TupleTableSlot *outslot);
584
585 extern void ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot);
586 extern void ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate,
587                                                  TupleTableSlot *searchslot, TupleTableSlot *slot);
588 extern void ExecSimpleRelationDelete(EState *estate, EPQState *epqstate,
589                                                  TupleTableSlot *searchslot);
590 extern void CheckCmdReplicaIdentity(Relation rel, CmdType cmd);
591
592 extern void CheckSubscriptionRelkind(char relkind, const char *nspname,
593                                                  const char *relname);
594
595 #endif                                                  /* EXECUTOR_H  */