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