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-2019, 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);
144  TupleTableSlot *slot,
145  ExprState *eqcomp,
146  FmgrInfo *hashfunctions);
147 extern void ResetTupleHashTable(TupleHashTable hashtable);
148 
149 /*
150  * prototypes from functions in execJunk.c
151  */
152 extern JunkFilter *ExecInitJunkFilter(List *targetList,
153  TupleTableSlot *slot);
154 extern JunkFilter *ExecInitJunkFilterConversion(List *targetList,
155  TupleDesc cleanTupType,
156  TupleTableSlot *slot);
157 extern AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter,
158  const char *attrName);
159 extern AttrNumber ExecFindJunkAttributeInTlist(List *targetlist,
160  const char *attrName);
162  bool *isNull);
163 extern TupleTableSlot *ExecFilterJunk(JunkFilter *junkfilter,
164  TupleTableSlot *slot);
165 
166 
167 /*
168  * prototypes from functions in execMain.c
169  */
170 extern void ExecutorStart(QueryDesc *queryDesc, int eflags);
171 extern void standard_ExecutorStart(QueryDesc *queryDesc, int eflags);
172 extern void ExecutorRun(QueryDesc *queryDesc,
173  ScanDirection direction, uint64 count, bool execute_once);
174 extern void standard_ExecutorRun(QueryDesc *queryDesc,
175  ScanDirection direction, uint64 count, bool execute_once);
176 extern void ExecutorFinish(QueryDesc *queryDesc);
177 extern void standard_ExecutorFinish(QueryDesc *queryDesc);
178 extern void ExecutorEnd(QueryDesc *queryDesc);
179 extern void standard_ExecutorEnd(QueryDesc *queryDesc);
180 extern void ExecutorRewind(QueryDesc *queryDesc);
181 extern bool ExecCheckRTPerms(List *rangeTable, bool ereport_on_violation);
182 extern void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation);
183 extern void InitResultRelInfo(ResultRelInfo *resultRelInfo,
184  Relation resultRelationDesc,
185  Index resultRelationIndex,
186  Relation partition_root,
187  int instrument_options);
188 extern ResultRelInfo *ExecGetTriggerResultRel(EState *estate, Oid relid);
189 extern void ExecCleanUpTriggerState(EState *estate);
190 extern void ExecConstraints(ResultRelInfo *resultRelInfo,
191  TupleTableSlot *slot, EState *estate);
192 extern bool ExecPartitionCheck(ResultRelInfo *resultRelInfo,
193  TupleTableSlot *slot, EState *estate, bool emitError);
194 extern void ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo,
195  TupleTableSlot *slot, EState *estate);
196 extern void ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo,
197  TupleTableSlot *slot, EState *estate);
198 extern LockTupleMode ExecUpdateLockMode(EState *estate, ResultRelInfo *relinfo);
199 extern ExecRowMark *ExecFindRowMark(EState *estate, Index rti, bool missing_ok);
200 extern ExecAuxRowMark *ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist);
201 extern TupleTableSlot *EvalPlanQual(EPQState *epqstate, Relation relation,
202  Index rti, TupleTableSlot *testslot);
203 extern void EvalPlanQualInit(EPQState *epqstate, EState *parentestate,
204  Plan *subplan, List *auxrowmarks, int epqParam);
205 extern void EvalPlanQualSetPlan(EPQState *epqstate,
206  Plan *subplan, List *auxrowmarks);
207 extern TupleTableSlot *EvalPlanQualSlot(EPQState *epqstate,
208  Relation relation, Index rti);
209 
210 #define EvalPlanQualSetSlot(epqstate, slot) ((epqstate)->origslot = (slot))
211 extern bool EvalPlanQualFetchRowMark(EPQState *epqstate, Index rti, TupleTableSlot *slot);
212 extern TupleTableSlot *EvalPlanQualNext(EPQState *epqstate);
213 extern void EvalPlanQualBegin(EPQState *epqstate);
214 extern void EvalPlanQualEnd(EPQState *epqstate);
215 
216 /*
217  * functions in execProcnode.c
218  */
219 extern PlanState *ExecInitNode(Plan *node, EState *estate, int eflags);
220 extern void ExecSetExecProcNode(PlanState *node, ExecProcNodeMtd function);
221 extern Node *MultiExecProcNode(PlanState *node);
222 extern void ExecEndNode(PlanState *node);
223 extern bool ExecShutdownNode(PlanState *node);
224 extern void ExecSetTupleBound(int64 tuples_needed, PlanState *child_node);
225 
226 
227 /* ----------------------------------------------------------------
228  * ExecProcNode
229  *
230  * Execute the given node to return a(nother) tuple.
231  * ----------------------------------------------------------------
232  */
233 #ifndef FRONTEND
234 static inline TupleTableSlot *
236 {
237  if (node->chgParam != NULL) /* something changed? */
238  ExecReScan(node); /* let ReScan handle this */
239 
240  return node->ExecProcNode(node);
241 }
242 #endif
243 
244 /*
245  * prototypes from functions in execExpr.c
246  */
247 extern ExprState *ExecInitExpr(Expr *node, PlanState *parent);
248 extern ExprState *ExecInitExprWithParams(Expr *node, ParamListInfo ext_params);
249 extern ExprState *ExecInitQual(List *qual, PlanState *parent);
250 extern ExprState *ExecInitCheck(List *qual, PlanState *parent);
251 extern List *ExecInitExprList(List *nodes, PlanState *parent);
252 extern ExprState *ExecBuildAggTrans(AggState *aggstate, struct AggStatePerPhaseData *phase,
253  bool doSort, bool doHash);
255  const TupleTableSlotOps *lops, const TupleTableSlotOps *rops,
256  int numCols,
257  const AttrNumber *keyColIdx,
258  const Oid *eqfunctions,
259  const Oid *collations,
260  PlanState *parent);
261 extern ProjectionInfo *ExecBuildProjectionInfo(List *targetList,
262  ExprContext *econtext,
263  TupleTableSlot *slot,
264  PlanState *parent,
265  TupleDesc inputDesc);
266 extern ExprState *ExecPrepareExpr(Expr *node, EState *estate);
267 extern ExprState *ExecPrepareQual(List *qual, EState *estate);
268 extern ExprState *ExecPrepareCheck(List *qual, EState *estate);
269 extern List *ExecPrepareExprList(List *nodes, EState *estate);
270 
271 /*
272  * ExecEvalExpr
273  *
274  * Evaluate expression identified by "state" in the execution context
275  * given by "econtext". *isNull is set to the is-null flag for the result,
276  * and the Datum value is the function result.
277  *
278  * The caller should already have switched into the temporary memory
279  * context econtext->ecxt_per_tuple_memory. The convenience entry point
280  * ExecEvalExprSwitchContext() is provided for callers who don't prefer to
281  * do the switch in an outer loop.
282  */
283 #ifndef FRONTEND
284 static inline Datum
286  ExprContext *econtext,
287  bool *isNull)
288 {
289  return state->evalfunc(state, econtext, isNull);
290 }
291 #endif
292 
293 /*
294  * ExecEvalExprSwitchContext
295  *
296  * Same as ExecEvalExpr, but get into the right allocation context explicitly.
297  */
298 #ifndef FRONTEND
299 static inline Datum
301  ExprContext *econtext,
302  bool *isNull)
303 {
304  Datum retDatum;
305  MemoryContext oldContext;
306 
307  oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
308  retDatum = state->evalfunc(state, econtext, isNull);
309  MemoryContextSwitchTo(oldContext);
310  return retDatum;
311 }
312 #endif
313 
314 /*
315  * ExecProject
316  *
317  * Projects a tuple based on projection info and stores it in the slot passed
318  * to ExecBuildProjectionInfo().
319  *
320  * Note: the result is always a virtual tuple; therefore it may reference
321  * the contents of the exprContext's scan tuples and/or temporary results
322  * constructed in the exprContext. If the caller wishes the result to be
323  * valid longer than that data will be valid, he must call ExecMaterializeSlot
324  * on the result slot.
325  */
326 #ifndef FRONTEND
327 static inline TupleTableSlot *
329 {
330  ExprContext *econtext = projInfo->pi_exprContext;
331  ExprState *state = &projInfo->pi_state;
332  TupleTableSlot *slot = state->resultslot;
333  bool isnull;
334 
335  /*
336  * Clear any former contents of the result slot. This makes it safe for
337  * us to use the slot's Datum/isnull arrays as workspace.
338  */
339  ExecClearTuple(slot);
340 
341  /* Run the expression, discarding scalar result from the last column. */
342  (void) ExecEvalExprSwitchContext(state, econtext, &isnull);
343 
344  /*
345  * Successfully formed a result row. Mark the result slot as containing a
346  * valid virtual tuple (inlined version of ExecStoreVirtualTuple()).
347  */
348  slot->tts_flags &= ~TTS_FLAG_EMPTY;
349  slot->tts_nvalid = slot->tts_tupleDescriptor->natts;
350 
351  return slot;
352 }
353 #endif
354 
355 /*
356  * ExecQual - evaluate a qual prepared with ExecInitQual (possibly via
357  * ExecPrepareQual). Returns true if qual is satisfied, else false.
358  *
359  * Note: ExecQual used to have a third argument "resultForNull". The
360  * behavior of this function now corresponds to resultForNull == false.
361  * If you want the resultForNull == true behavior, see ExecCheck.
362  */
363 #ifndef FRONTEND
364 static inline bool
366 {
367  Datum ret;
368  bool isnull;
369 
370  /* short-circuit (here and in ExecInitQual) for empty restriction list */
371  if (state == NULL)
372  return true;
373 
374  /* verify that expression was compiled using ExecInitQual */
375  Assert(state->flags & EEO_FLAG_IS_QUAL);
376 
377  ret = ExecEvalExprSwitchContext(state, econtext, &isnull);
378 
379  /* EEOP_QUAL should never return NULL */
380  Assert(!isnull);
381 
382  return DatumGetBool(ret);
383 }
384 #endif
385 
386 /*
387  * ExecQualAndReset() - evaluate qual with ExecQual() and reset expression
388  * context.
389  */
390 #ifndef FRONTEND
391 static inline bool
393 {
394  bool ret = ExecQual(state, econtext);
395 
396  /* inline ResetExprContext, to avoid ordering issue in this file */
398  return ret;
399 }
400 #endif
401 
402 extern bool ExecCheck(ExprState *state, ExprContext *context);
403 
404 /*
405  * prototypes from functions in execSRF.c
406  */
408  ExprContext *econtext, PlanState *parent);
410  ExprContext *econtext,
411  MemoryContext argContext,
412  TupleDesc expectedDesc,
413  bool randomAccess);
415  ExprContext *econtext, PlanState *parent);
417  ExprContext *econtext,
418  MemoryContext argContext,
419  bool *isNull,
420  ExprDoneCond *isDone);
421 
422 /*
423  * prototypes from functions in execScan.c
424  */
425 typedef TupleTableSlot *(*ExecScanAccessMtd) (ScanState *node);
427 
428 extern TupleTableSlot *ExecScan(ScanState *node, ExecScanAccessMtd accessMtd,
429  ExecScanRecheckMtd recheckMtd);
430 extern void ExecAssignScanProjectionInfo(ScanState *node);
431 extern void ExecAssignScanProjectionInfoWithVarno(ScanState *node, Index varno);
432 extern void ExecScanReScan(ScanState *node);
433 
434 /*
435  * prototypes from functions in execTuples.c
436  */
437 extern void ExecInitResultTypeTL(PlanState *planstate);
438 extern void ExecInitResultSlot(PlanState *planstate,
439  const TupleTableSlotOps *tts_ops);
440 extern void ExecInitResultTupleSlotTL(PlanState *planstate,
441  const TupleTableSlotOps *tts_ops);
442 extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate,
443  TupleDesc tupleDesc,
444  const TupleTableSlotOps *tts_ops);
446  TupleDesc tupledesc,
447  const TupleTableSlotOps *tts_ops);
448 extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate, TupleDesc tupType,
449  const TupleTableSlotOps *tts_ops);
450 extern TupleDesc ExecTypeFromTL(List *targetList);
451 extern TupleDesc ExecCleanTypeFromTL(List *targetList);
452 extern TupleDesc ExecTypeFromExprList(List *exprList);
453 extern void ExecTypeSetColNames(TupleDesc typeInfo, List *namesList);
454 extern void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg);
455 
456 typedef struct TupOutputState
457 {
461 
463  TupleDesc tupdesc,
464  const TupleTableSlotOps *tts_ops);
465 extern void do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull);
466 extern void do_text_output_multiline(TupOutputState *tstate, const char *txt);
467 extern void end_tup_output(TupOutputState *tstate);
468 
469 /*
470  * Write a single line of text given as a C string.
471  *
472  * Should only be used with a single-TEXT-attribute tupdesc.
473  */
474 #define do_text_output_oneline(tstate, str_to_emit) \
475  do { \
476  Datum values_[1]; \
477  bool isnull_[1]; \
478  values_[0] = PointerGetDatum(cstring_to_text(str_to_emit)); \
479  isnull_[0] = false; \
480  do_tup_output(tstate, values_, isnull_); \
481  pfree(DatumGetPointer(values_[0])); \
482  } while (0)
483 
484 
485 /*
486  * prototypes from functions in execUtils.c
487  */
488 extern EState *CreateExecutorState(void);
489 extern void FreeExecutorState(EState *estate);
490 extern ExprContext *CreateExprContext(EState *estate);
492 extern void FreeExprContext(ExprContext *econtext, bool isCommit);
493 extern void ReScanExprContext(ExprContext *econtext);
494 
495 #define ResetExprContext(econtext) \
496  MemoryContextReset((econtext)->ecxt_per_tuple_memory)
497 
499 
500 /* Get an EState's per-output-tuple exprcontext, making it if first use */
501 #define GetPerTupleExprContext(estate) \
502  ((estate)->es_per_tuple_exprcontext ? \
503  (estate)->es_per_tuple_exprcontext : \
504  MakePerTupleExprContext(estate))
505 
506 #define GetPerTupleMemoryContext(estate) \
507  (GetPerTupleExprContext(estate)->ecxt_per_tuple_memory)
508 
509 /* Reset an EState's per-output-tuple exprcontext, if one's been created */
510 #define ResetPerTupleExprContext(estate) \
511  do { \
512  if ((estate)->es_per_tuple_exprcontext) \
513  ResetExprContext((estate)->es_per_tuple_exprcontext); \
514  } while (0)
515 
516 extern void ExecAssignExprContext(EState *estate, PlanState *planstate);
517 extern TupleDesc ExecGetResultType(PlanState *planstate);
518 extern const TupleTableSlotOps *ExecGetResultSlotOps(PlanState *planstate,
519  bool *isfixed);
520 extern void ExecAssignProjectionInfo(PlanState *planstate,
521  TupleDesc inputDesc);
522 extern void ExecConditionalAssignProjectionInfo(PlanState *planstate,
523  TupleDesc inputDesc, Index varno);
524 extern void ExecFreeExprContext(PlanState *planstate);
525 extern void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc);
526 extern void ExecCreateScanSlotFromOuterPlan(EState *estate,
527  ScanState *scanstate,
528  const TupleTableSlotOps *tts_ops);
529 
530 extern bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid);
531 
532 extern Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags);
533 
534 extern void ExecInitRangeTable(EState *estate, List *rangeTable);
535 
536 static inline RangeTblEntry *
538 {
539  return (RangeTblEntry *) list_nth(estate->es_range_table, rti - 1);
540 }
541 
542 extern Relation ExecGetRangeTableRelation(EState *estate, Index rti);
543 
544 extern int executor_errposition(EState *estate, int location);
545 
546 extern void RegisterExprContextCallback(ExprContext *econtext,
548  Datum arg);
549 extern void UnregisterExprContextCallback(ExprContext *econtext,
551  Datum arg);
552 
553 extern Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname,
554  bool *isNull);
556  bool *isNull);
557 
558 extern int ExecTargetListLength(List *targetlist);
559 extern int ExecCleanTargetListLength(List *targetlist);
560 
561 extern TupleTableSlot *ExecGetTriggerOldSlot(EState *estate, ResultRelInfo *relInfo);
562 extern TupleTableSlot *ExecGetTriggerNewSlot(EState *estate, ResultRelInfo *relInfo);
563 extern TupleTableSlot *ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo);
564 
565 /*
566  * prototypes from functions in execIndexing.c
567  */
568 extern void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative);
569 extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);
570 extern List *ExecInsertIndexTuples(TupleTableSlot *slot, EState *estate, bool noDupErr,
571  bool *specConflict, List *arbiterIndexes);
572 extern bool ExecCheckIndexConstraints(TupleTableSlot *slot, EState *estate,
573  ItemPointer conflictTid, List *arbiterIndexes);
575  IndexInfo *indexInfo,
576  ItemPointer tupleid,
577  Datum *values, bool *isnull,
578  EState *estate, bool newIndex);
579 
580 /*
581  * prototypes from functions in execReplication.c
582  */
583 extern bool RelationFindReplTupleByIndex(Relation rel, Oid idxoid,
584  LockTupleMode lockmode,
585  TupleTableSlot *searchslot,
586  TupleTableSlot *outslot);
587 extern bool RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode,
588  TupleTableSlot *searchslot, TupleTableSlot *outslot);
589 
590 extern void ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot);
591 extern void ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate,
592  TupleTableSlot *searchslot, TupleTableSlot *slot);
593 extern void ExecSimpleRelationDelete(EState *estate, EPQState *epqstate,
594  TupleTableSlot *searchslot);
595 extern void CheckCmdReplicaIdentity(Relation rel, CmdType cmd);
596 
597 extern void CheckSubscriptionRelkind(char relkind, const char *nspname,
598  const char *relname);
599 
600 #endif /* EXECUTOR_H */
bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid)
Definition: execUtils.c:671
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition: execUtils.c:693
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:241
TupleTableSlot * ExecInitNullTupleSlot(EState *estate, TupleDesc tupType, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1812
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:454
LockTupleMode ExecUpdateLockMode(EState *estate, ResultRelInfo *relinfo)
Definition: execMain.c:2320
void(* ExecutorRun_hook_type)(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once)
Definition: executor.h:69
Definition: fmgr.h:56
bool ExecCheckIndexConstraints(TupleTableSlot *slot, EState *estate, ItemPointer conflictTid, List *arbiterIndexes)
Definition: execIndexing.c:482
void ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
Definition: execMain.c:2035
ProjectionInfo * ExecBuildProjectionInfo(List *targetList, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent, TupleDesc inputDesc)
Definition: execExpr.c:351
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
bool ExecSupportsBackwardScan(Plan *node)
Definition: execAmi.c:496
LockTupleMode
Definition: lockoptions.h:49
ResultRelInfo * ExecGetTriggerResultRel(EState *estate, Oid relid)
Definition: execMain.c:1371
JunkFilter * ExecInitJunkFilter(List *targetList, TupleTableSlot *slot)
Definition: execJunk.c:60
ExprContext * CreateExprContext(EState *estate)
Definition: execUtils.c:244
static Datum ExecEvalExprSwitchContext(ExprState *state, ExprContext *econtext, bool *isNull)
Definition: executor.h:300
TupleTableSlot * ExecGetTriggerNewSlot(EState *estate, ResultRelInfo *relInfo)
Definition: execUtils.c:1126
ExecRowMark * ExecFindRowMark(EState *estate, Index rti, bool missing_ok)
Definition: execMain.c:2346
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:207
void CheckSubscriptionRelkind(char relkind, const char *nspname, const char *relname)
ExecAuxRowMark * ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist)
Definition: execMain.c:2369
TupleTableSlot * EvalPlanQualSlot(EPQState *epqstate, Relation relation, Index rti)
Definition: execMain.c:2548
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:426
ExprState * ExecInitExprWithParams(Expr *node, ParamListInfo ext_params)
Definition: execExpr.c:158
void ExecScanReScan(ScanState *node)
Definition: execScan.c:299
void ExecConditionalAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc, Index varno)
Definition: execUtils.c:519
AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter, const char *attrName)
Definition: execJunk.c:208
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:1024
MemoryContext ecxt_per_tuple_memory
Definition: execnodes.h:232
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1720
void UnregisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
Definition: execUtils.c:889
void standard_ExecutorFinish(QueryDesc *queryDesc)
Definition: execMain.c:411
void ExecCloseIndices(ResultRelInfo *resultRelInfo)
Definition: execIndexing.c:226
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
TupleHashEntry FindTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot, ExprState *eqcomp, FmgrInfo *hashfunctions)
Definition: execGrouping.c:347
Node * MultiExecProcNode(PlanState *node)
Definition: execProcnode.c:483
Definition: nodes.h:525
int ExecCleanTargetListLength(List *targetlist)
Definition: execUtils.c:1085
void ExecRestrPos(PlanState *node)
Definition: execAmi.c:364
int executor_errposition(EState *estate, int location)
Definition: execUtils.c:836
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:136
void ExecSimpleRelationDelete(EState *estate, EPQState *epqstate, TupleTableSlot *searchslot)
TupleTableSlot * EvalPlanQual(EPQState *epqstate, Relation relation, Index rti, TupleTableSlot *testslot)
Definition: execMain.c:2439
bool(* ExecutorCheckPerms_hook_type)(List *, bool)
Definition: executor.h:84
TupleTableSlot * slot
Definition: executor.h:458
bool RelationFindReplTupleByIndex(Relation rel, Oid idxoid, LockTupleMode lockmode, TupleTableSlot *searchslot, TupleTableSlot *outslot)
void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative)
Definition: execIndexing.c:151
TupleTableSlot * resultslot
Definition: execnodes.h:81
List * es_range_table
Definition: execnodes.h:505
bool ExecCheck(ExprState *state, ExprContext *context)
Definition: execExpr.c:597
NameData relname
Definition: pg_class.h:35
unsigned int Oid
Definition: postgres_ext.h:31
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:614
static bool ExecQual(ExprState *state, ExprContext *econtext)
Definition: executor.h:365
NodeTag
Definition: nodes.h:26
JunkFilter * ExecInitJunkFilterConversion(List *targetList, TupleDesc cleanTupType, TupleTableSlot *slot)
Definition: execJunk.c:135
struct TupOutputState TupOutputState
void standard_ExecutorEnd(QueryDesc *queryDesc)
Definition: execMain.c:471
TupleTableSlot *(* ExecProcNodeMtd)(struct PlanState *pstate)
Definition: execnodes.h:927
char relkind
Definition: pg_class.h:81
#define PGDLLIMPORT
Definition: c.h:1243
Datum ExecMakeFunctionResultSet(SetExprState *fcache, ExprContext *econtext, MemoryContext argContext, bool *isNull, ExprDoneCond *isDone)
Definition: execSRF.c:479
void ExecTypeSetColNames(TupleDesc typeInfo, List *namesList)
Definition: execTuples.c:2002
bool ExecShutdownNode(PlanState *node)
Definition: execProcnode.c:742
Definition: type.h:89
void ExecCleanUpTriggerState(EState *estate)
Definition: execMain.c:1454
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:406
TupleDesc ExecTypeFromExprList(List *exprList)
Definition: execTuples.c:1963
uint16 tts_flags
Definition: tuptable.h:119
TupleTableSlot * ExecGetTriggerOldSlot(EState *estate, ResultRelInfo *relInfo)
Definition: execUtils.c:1104
void EvalPlanQualSetPlan(EPQState *epqstate, Plan *subplan, List *auxrowmarks)
Definition: execMain.c:2531
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:277
bool ExecMaterializesOutput(NodeTag plantype)
Definition: execAmi.c:611
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
Definition: execScan.c:158
TupleTableSlot * ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo)
Definition: execUtils.c:1148
TupleDesc ExecCleanTypeFromTL(List *targetList)
Definition: execTuples.c:1916
void ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
Definition: execMain.c:1905
RelOptInfo * parent
Definition: pathnodes.h:1114
void ExecInitRangeTable(EState *estate, List *rangeTable)
Definition: execUtils.c:724
void EvalPlanQualInit(EPQState *epqstate, EState *parentestate, Plan *subplan, List *auxrowmarks, int epqParam)
Definition: execMain.c:2493
void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc)
Definition: execUtils.c:634
ExprStateEvalFunc evalfunc
Definition: execnodes.h:92
PGDLLIMPORT ExecutorStart_hook_type ExecutorStart_hook
Definition: execMain.c:70
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
Definition: executor.h:285
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:60
void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
Definition: execUtils.c:802
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
List * ExecInsertIndexTuples(TupleTableSlot *slot, EState *estate, bool noDupErr, bool *specConflict, List *arbiterIndexes)
Definition: execIndexing.c:273
void ExecAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc)
Definition: execUtils.c:499
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1796
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
Definition: executor.h:537
TupleTableSlot * EvalPlanQualNext(EPQState *epqstate)
Definition: execMain.c:2685
void EvalPlanQualBegin(EPQState *epqstate)
Definition: execMain.c:2701
void end_tup_output(TupOutputState *tstate)
Definition: execTuples.c:2310
ExprState * ExecPrepareCheck(List *qual, EState *estate)
Definition: execExpr.c:541
ExprState * ExecInitCheck(List *qual, PlanState *parent)
Definition: execExpr.c:296
WCOKind
Definition: parsenodes.h:1155
TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew)
Definition: execGrouping.c:289
List * ExecPrepareExprList(List *nodes, EState *estate)
Definition: execExpr.c:564
TupOutputState * begin_tup_output_tupdesc(DestReceiver *dest, TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:2232
void ResetTupleHashTable(TupleHashTable hashtable)
Definition: execGrouping.c:271
Bitmapset * chgParam
Definition: execnodes.h:972
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:444
void ExecutorFinish(QueryDesc *queryDesc)
Definition: execMain.c:402
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
Definition: executor.h:426
void ExecInitResultTupleSlotTL(PlanState *planstate, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1764
ExprContext * CreateStandaloneExprContext(void)
Definition: execUtils.c:316
ExprDoneCond
Definition: execnodes.h:270
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
void ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot)
void ExecReScan(PlanState *node)
Definition: execAmi.c:77
bool EvalPlanQualFetchRowMark(EPQState *epqstate, Index rti, TupleTableSlot *slot)
Definition: execMain.c:2576
static bool ExecQualAndReset(ExprState *state, ExprContext *econtext)
Definition: executor.h:392
AttrNumber ExecFindJunkAttributeInTlist(List *targetlist, const char *attrName)
Definition: execJunk.c:220
PGDLLIMPORT ExecutorFinish_hook_type ExecutorFinish_hook
Definition: execMain.c:72
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:946
PGDLLIMPORT ExecutorCheckPerms_hook_type ExecutorCheckPerms_hook
Definition: execMain.c:76
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:121
uintptr_t Datum
Definition: postgres.h:367
void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation)
Definition: execMain.c:1076
void FreeExprContext(ExprContext *econtext, bool isCommit)
Definition: execUtils.c:375
TupleTableSlot * ExecFilterJunk(JunkFilter *junkfilter, TupleTableSlot *slot)
Definition: execJunk.c:261
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:538
static TupleTableSlot * ExecProcNode(PlanState *node)
Definition: executor.h:235
unsigned int Index
Definition: c.h:475
void InitResultRelInfo(ResultRelInfo *resultRelInfo, Relation resultRelationDesc, Index resultRelationIndex, Relation partition_root, int instrument_options)
Definition: execMain.c:1277
const TupleTableSlotOps * ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
Definition: execUtils.c:463
ExprState * ExecPrepareExpr(Expr *node, EState *estate)
Definition: execExpr.c:490
Relation ExecGetRangeTableRelation(EState *estate, Index rti)
Definition: execUtils.c:754
EState * CreateExecutorState(void)
Definition: execUtils.c:88
void ExecSetExecProcNode(PlanState *node, ExecProcNodeMtd function)
Definition: execProcnode.c:406
void ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
Definition: execMain.c:1837
SetExprState * ExecInitTableFunctionResult(Expr *expr, ExprContext *econtext, PlanState *parent)
Definition: execSRF.c:56
void ReScanExprContext(ExprContext *econtext)
Definition: execUtils.c:402
TupleDesc ExecTypeFromTL(List *targetList)
Definition: execTuples.c:1904
int ExecTargetListLength(List *targetlist)
Definition: execUtils.c:1075
Datum ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno, bool *isNull)
Definition: execJunk.c:247
void(* ExecutorEnd_hook_type)(QueryDesc *queryDesc)
Definition: executor.h:80
void ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once)
Definition: execMain.c:301
#define Assert(condition)
Definition: c.h:732
void RegisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
Definition: execUtils.c:863
Definition: regguts.h:298
ExprState * ExecPrepareQual(List *qual, EState *estate)
Definition: execExpr.c:518
void(* ExprContextCallbackFunction)(Datum arg)
Definition: execnodes.h:186
size_t Size
Definition: c.h:466
void ExecCreateScanSlotFromOuterPlan(EState *estate, ScanState *scanstate, const TupleTableSlotOps *tts_ops)
Definition: execUtils.c:646
void CheckCmdReplicaIdentity(Relation rel, CmdType cmd)
bool ExecPartitionCheck(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, bool emitError)
Definition: execMain.c:1792
void ExecAssignScanProjectionInfoWithVarno(ScanState *node, Index varno)
Definition: execScan.c:285
List * ExecInitExprList(List *nodes, PlanState *parent)
Definition: execExpr.c:316
void ExecMarkPos(PlanState *node)
Definition: execAmi.c:315
void do_text_output_multiline(TupOutputState *tstate, const char *txt)
Definition: execTuples.c:2280
SetExprState * ExecInitFunctionResultSet(Expr *expr, ExprContext *econtext, PlanState *parent)
Definition: execSRF.c:426
static Datum values[MAXATTR]
Definition: bootstrap.c:167
void EvalPlanQualEnd(EPQState *epqstate)
Definition: execMain.c:2953
bool RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode, TupleTableSlot *searchslot, TupleTableSlot *outslot)
void do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull)
Definition: execTuples.c:2252
ExprContext * MakePerTupleExprContext(EState *estate)
Definition: execUtils.c:417
ExprState * ExecBuildAggTrans(AggState *aggstate, struct AggStatePerPhaseData *phase, bool doSort, bool doHash)
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:961
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:3316
void ExecutorEnd(QueryDesc *queryDesc)
Definition: execMain.c:462
uint8 flags
Definition: execnodes.h:66
void check_exclusion_constraint(Relation heap, Relation index, IndexInfo *indexInfo, ItemPointer tupleid, Datum *values, bool *isnull, EState *estate, bool newIndex)
Definition: execIndexing.c:866
ExprState pi_state
Definition: execnodes.h:331
void * arg
void ExecInitResultSlot(PlanState *planstate, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1744
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:459
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupleDesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1776
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
Definition: executor.h:425
Tuplestorestate * ExecMakeTableFunctionResult(SetExprState *setexpr, ExprContext *econtext, MemoryContext argContext, TupleDesc expectedDesc, bool randomAccess)
Definition: execSRF.c:101
ExprContext * pi_exprContext
Definition: execnodes.h:333
Definition: pg_list.h:50
void ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate, TupleTableSlot *searchslot, TupleTableSlot *slot)
int16 AttrNumber
Definition: attnum.h:21
CmdType
Definition: nodes.h:668
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:328
void FreeExecutorState(EState *estate)
Definition: execUtils.c:190
unsigned char bool
Definition: c.h:308
void ExecSetTupleBound(int64 tuples_needed, PlanState *child_node)
Definition: execProcnode.c:812