PostgreSQL Source Code  git master
execUtils.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * execUtils.c
4  * miscellaneous executor utility routines
5  *
6  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  * src/backend/executor/execUtils.c
12  *
13  *-------------------------------------------------------------------------
14  */
15 /*
16  * INTERFACE ROUTINES
17  * CreateExecutorState Create/delete executor working state
18  * FreeExecutorState
19  * CreateExprContext
20  * CreateStandaloneExprContext
21  * FreeExprContext
22  * ReScanExprContext
23  *
24  * ExecAssignExprContext Common code for plan node init routines.
25  * etc
26  *
27  * ExecOpenScanRelation Common code for scan node init routines.
28  *
29  * ExecInitRangeTable Set up executor's range-table-related data.
30  *
31  * ExecGetRangeTableRelation Fetch Relation for a rangetable entry.
32  *
33  * executor_errposition Report syntactic position of an error.
34  *
35  * RegisterExprContextCallback Register function shutdown callback
36  * UnregisterExprContextCallback Deregister function shutdown callback
37  *
38  * GetAttributeByName Runtime extraction of columns from tuples.
39  * GetAttributeByNum
40  *
41  * NOTES
42  * This file has traditionally been the place to stick misc.
43  * executor support stuff that doesn't really go anyplace else.
44  */
45 
46 #include "postgres.h"
47 
48 #include "access/parallel.h"
49 #include "access/relscan.h"
50 #include "access/table.h"
51 #include "access/tableam.h"
52 #include "access/transam.h"
53 #include "executor/executor.h"
54 #include "jit/jit.h"
55 #include "mb/pg_wchar.h"
56 #include "miscadmin.h"
57 #include "nodes/nodeFuncs.h"
58 #include "parser/parsetree.h"
59 #include "partitioning/partdesc.h"
60 #include "storage/lmgr.h"
61 #include "utils/builtins.h"
62 #include "utils/memutils.h"
63 #include "utils/rel.h"
64 #include "utils/typcache.h"
65 
66 
67 static bool tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc);
68 static void ShutdownExprContext(ExprContext *econtext, bool isCommit);
69 
70 
71 /* ----------------------------------------------------------------
72  * Executor state and memory management functions
73  * ----------------------------------------------------------------
74  */
75 
76 /* ----------------
77  * CreateExecutorState
78  *
79  * Create and initialize an EState node, which is the root of
80  * working storage for an entire Executor invocation.
81  *
82  * Principally, this creates the per-query memory context that will be
83  * used to hold all working data that lives till the end of the query.
84  * Note that the per-query context will become a child of the caller's
85  * CurrentMemoryContext.
86  * ----------------
87  */
88 EState *
90 {
91  EState *estate;
92  MemoryContext qcontext;
93  MemoryContext oldcontext;
94 
95  /*
96  * Create the per-query context for this Executor run.
97  */
99  "ExecutorState",
101 
102  /*
103  * Make the EState node within the per-query context. This way, we don't
104  * need a separate pfree() operation for it at shutdown.
105  */
106  oldcontext = MemoryContextSwitchTo(qcontext);
107 
108  estate = makeNode(EState);
109 
110  /*
111  * Initialize all fields of the Executor State structure
112  */
114  estate->es_snapshot = InvalidSnapshot; /* caller must initialize this */
115  estate->es_crosscheck_snapshot = InvalidSnapshot; /* no crosscheck */
116  estate->es_range_table = NIL;
117  estate->es_range_table_size = 0;
118  estate->es_relations = NULL;
119  estate->es_rowmarks = NULL;
120  estate->es_plannedstmt = NULL;
121 
122  estate->es_junkFilter = NULL;
123 
124  estate->es_output_cid = (CommandId) 0;
125 
126  estate->es_result_relations = NULL;
127  estate->es_num_result_relations = 0;
128  estate->es_result_relation_info = NULL;
129 
130  estate->es_root_result_relations = NULL;
131  estate->es_num_root_result_relations = 0;
132 
134 
135  estate->es_trig_target_relations = NIL;
136 
137  estate->es_param_list_info = NULL;
138  estate->es_param_exec_vals = NULL;
139 
140  estate->es_queryEnv = NULL;
141 
142  estate->es_query_cxt = qcontext;
143 
144  estate->es_tupleTable = NIL;
145 
146  estate->es_processed = 0;
147 
148  estate->es_top_eflags = 0;
149  estate->es_instrument = 0;
150  estate->es_finished = false;
151 
152  estate->es_exprcontexts = NIL;
153 
154  estate->es_subplanstates = NIL;
155 
156  estate->es_auxmodifytables = NIL;
157 
158  estate->es_per_tuple_exprcontext = NULL;
159 
160  estate->es_sourceText = NULL;
161 
162  estate->es_use_parallel_mode = false;
163 
164  estate->es_jit_flags = 0;
165  estate->es_jit = NULL;
166 
167  /*
168  * Return the executor state structure
169  */
170  MemoryContextSwitchTo(oldcontext);
171 
172  return estate;
173 }
174 
175 /* ----------------
176  * FreeExecutorState
177  *
178  * Release an EState along with all remaining working storage.
179  *
180  * Note: this is not responsible for releasing non-memory resources, such as
181  * open relations or buffer pins. But it will shut down any still-active
182  * ExprContexts within the EState and deallocate associated JITed expressions.
183  * That is sufficient cleanup for situations where the EState has only been
184  * used for expression evaluation, and not to run a complete Plan.
185  *
186  * This can be called in any memory context ... so long as it's not one
187  * of the ones to be freed.
188  * ----------------
189  */
190 void
192 {
193  /*
194  * Shut down and free any remaining ExprContexts. We do this explicitly
195  * to ensure that any remaining shutdown callbacks get called (since they
196  * might need to release resources that aren't simply memory within the
197  * per-query memory context).
198  */
199  while (estate->es_exprcontexts)
200  {
201  /*
202  * XXX: seems there ought to be a faster way to implement this than
203  * repeated list_delete(), no?
204  */
206  true);
207  /* FreeExprContext removed the list link for us */
208  }
209 
210  /* release JIT context, if allocated */
211  if (estate->es_jit)
212  {
213  jit_release_context(estate->es_jit);
214  estate->es_jit = NULL;
215  }
216 
217  /* release partition directory, if allocated */
218  if (estate->es_partition_directory)
219  {
221  estate->es_partition_directory = NULL;
222  }
223 
224  /*
225  * Free the per-query memory context, thereby releasing all working
226  * memory, including the EState node itself.
227  */
229 }
230 
231 /*
232  * Internal implementation for CreateExprContext() and CreateWorkExprContext()
233  * that allows control over the AllocSet parameters.
234  */
235 static ExprContext *
236 CreateExprContextInternal(EState *estate, Size minContextSize,
237  Size initBlockSize, Size maxBlockSize)
238 {
239  ExprContext *econtext;
240  MemoryContext oldcontext;
241 
242  /* Create the ExprContext node within the per-query memory context */
243  oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
244 
245  econtext = makeNode(ExprContext);
246 
247  /* Initialize fields of ExprContext */
248  econtext->ecxt_scantuple = NULL;
249  econtext->ecxt_innertuple = NULL;
250  econtext->ecxt_outertuple = NULL;
251 
252  econtext->ecxt_per_query_memory = estate->es_query_cxt;
253 
254  /*
255  * Create working memory for expression evaluation in this context.
256  */
257  econtext->ecxt_per_tuple_memory =
259  "ExprContext",
260  minContextSize,
261  initBlockSize,
262  maxBlockSize);
263 
264  econtext->ecxt_param_exec_vals = estate->es_param_exec_vals;
265  econtext->ecxt_param_list_info = estate->es_param_list_info;
266 
267  econtext->ecxt_aggvalues = NULL;
268  econtext->ecxt_aggnulls = NULL;
269 
270  econtext->caseValue_datum = (Datum) 0;
271  econtext->caseValue_isNull = true;
272 
273  econtext->domainValue_datum = (Datum) 0;
274  econtext->domainValue_isNull = true;
275 
276  econtext->ecxt_estate = estate;
277 
278  econtext->ecxt_callbacks = NULL;
279 
280  /*
281  * Link the ExprContext into the EState to ensure it is shut down when the
282  * EState is freed. Because we use lcons(), shutdowns will occur in
283  * reverse order of creation, which may not be essential but can't hurt.
284  */
285  estate->es_exprcontexts = lcons(econtext, estate->es_exprcontexts);
286 
287  MemoryContextSwitchTo(oldcontext);
288 
289  return econtext;
290 }
291 
292 /* ----------------
293  * CreateExprContext
294  *
295  * Create a context for expression evaluation within an EState.
296  *
297  * An executor run may require multiple ExprContexts (we usually make one
298  * for each Plan node, and a separate one for per-output-tuple processing
299  * such as constraint checking). Each ExprContext has its own "per-tuple"
300  * memory context.
301  *
302  * Note we make no assumption about the caller's memory context.
303  * ----------------
304  */
305 ExprContext *
307 {
309 }
310 
311 
312 /* ----------------
313  * CreateWorkExprContext
314  *
315  * Like CreateExprContext, but specifies the AllocSet sizes to be reasonable
316  * in proportion to work_mem. If the maximum block allocation size is too
317  * large, it's easy to skip right past work_mem with a single allocation.
318  * ----------------
319  */
320 ExprContext *
322 {
323  Size minContextSize = ALLOCSET_DEFAULT_MINSIZE;
324  Size initBlockSize = ALLOCSET_DEFAULT_INITSIZE;
325  Size maxBlockSize = ALLOCSET_DEFAULT_MAXSIZE;
326 
327  /* choose the maxBlockSize to be no larger than 1/16 of work_mem */
328  while (16 * maxBlockSize > work_mem * 1024L)
329  maxBlockSize >>= 1;
330 
331  if (maxBlockSize < ALLOCSET_DEFAULT_INITSIZE)
332  maxBlockSize = ALLOCSET_DEFAULT_INITSIZE;
333 
334  return CreateExprContextInternal(estate, minContextSize,
335  initBlockSize, maxBlockSize);
336 }
337 
338 /* ----------------
339  * CreateStandaloneExprContext
340  *
341  * Create a context for standalone expression evaluation.
342  *
343  * An ExprContext made this way can be used for evaluation of expressions
344  * that contain no Params, subplans, or Var references (it might work to
345  * put tuple references into the scantuple field, but it seems unwise).
346  *
347  * The ExprContext struct is allocated in the caller's current memory
348  * context, which also becomes its "per query" context.
349  *
350  * It is caller's responsibility to free the ExprContext when done,
351  * or at least ensure that any shutdown callbacks have been called
352  * (ReScanExprContext() is suitable). Otherwise, non-memory resources
353  * might be leaked.
354  * ----------------
355  */
356 ExprContext *
358 {
359  ExprContext *econtext;
360 
361  /* Create the ExprContext node within the caller's memory context */
362  econtext = makeNode(ExprContext);
363 
364  /* Initialize fields of ExprContext */
365  econtext->ecxt_scantuple = NULL;
366  econtext->ecxt_innertuple = NULL;
367  econtext->ecxt_outertuple = NULL;
368 
370 
371  /*
372  * Create working memory for expression evaluation in this context.
373  */
374  econtext->ecxt_per_tuple_memory =
376  "ExprContext",
378 
379  econtext->ecxt_param_exec_vals = NULL;
380  econtext->ecxt_param_list_info = NULL;
381 
382  econtext->ecxt_aggvalues = NULL;
383  econtext->ecxt_aggnulls = NULL;
384 
385  econtext->caseValue_datum = (Datum) 0;
386  econtext->caseValue_isNull = true;
387 
388  econtext->domainValue_datum = (Datum) 0;
389  econtext->domainValue_isNull = true;
390 
391  econtext->ecxt_estate = NULL;
392 
393  econtext->ecxt_callbacks = NULL;
394 
395  return econtext;
396 }
397 
398 /* ----------------
399  * FreeExprContext
400  *
401  * Free an expression context, including calling any remaining
402  * shutdown callbacks.
403  *
404  * Since we free the temporary context used for expression evaluation,
405  * any previously computed pass-by-reference expression result will go away!
406  *
407  * If isCommit is false, we are being called in error cleanup, and should
408  * not call callbacks but only release memory. (It might be better to call
409  * the callbacks and pass the isCommit flag to them, but that would require
410  * more invasive code changes than currently seems justified.)
411  *
412  * Note we make no assumption about the caller's memory context.
413  * ----------------
414  */
415 void
416 FreeExprContext(ExprContext *econtext, bool isCommit)
417 {
418  EState *estate;
419 
420  /* Call any registered callbacks */
421  ShutdownExprContext(econtext, isCommit);
422  /* And clean up the memory used */
424  /* Unlink self from owning EState, if any */
425  estate = econtext->ecxt_estate;
426  if (estate)
428  econtext);
429  /* And delete the ExprContext node */
430  pfree(econtext);
431 }
432 
433 /*
434  * ReScanExprContext
435  *
436  * Reset an expression context in preparation for a rescan of its
437  * plan node. This requires calling any registered shutdown callbacks,
438  * since any partially complete set-returning-functions must be canceled.
439  *
440  * Note we make no assumption about the caller's memory context.
441  */
442 void
444 {
445  /* Call any registered callbacks */
446  ShutdownExprContext(econtext, true);
447  /* And clean up the memory used */
449 }
450 
451 /*
452  * Build a per-output-tuple ExprContext for an EState.
453  *
454  * This is normally invoked via GetPerTupleExprContext() macro,
455  * not directly.
456  */
457 ExprContext *
459 {
460  if (estate->es_per_tuple_exprcontext == NULL)
462 
463  return estate->es_per_tuple_exprcontext;
464 }
465 
466 
467 /* ----------------------------------------------------------------
468  * miscellaneous node-init support functions
469  *
470  * Note: all of these are expected to be called with CurrentMemoryContext
471  * equal to the per-query memory context.
472  * ----------------------------------------------------------------
473  */
474 
475 /* ----------------
476  * ExecAssignExprContext
477  *
478  * This initializes the ps_ExprContext field. It is only necessary
479  * to do this for nodes which use ExecQual or ExecProject
480  * because those routines require an econtext. Other nodes that
481  * don't have to evaluate expressions don't need to do this.
482  * ----------------
483  */
484 void
486 {
487  planstate->ps_ExprContext = CreateExprContext(estate);
488 }
489 
490 /* ----------------
491  * ExecGetResultType
492  * ----------------
493  */
494 TupleDesc
496 {
497  return planstate->ps_ResultTupleDesc;
498 }
499 
500 /*
501  * ExecGetResultSlotOps - information about node's type of result slot
502  */
503 const TupleTableSlotOps *
504 ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
505 {
506  if (planstate->resultopsset && planstate->resultops)
507  {
508  if (isfixed)
509  *isfixed = planstate->resultopsfixed;
510  return planstate->resultops;
511  }
512 
513  if (isfixed)
514  {
515  if (planstate->resultopsset)
516  *isfixed = planstate->resultopsfixed;
517  else if (planstate->ps_ResultTupleSlot)
518  *isfixed = TTS_FIXED(planstate->ps_ResultTupleSlot);
519  else
520  *isfixed = false;
521  }
522 
523  if (!planstate->ps_ResultTupleSlot)
524  return &TTSOpsVirtual;
525 
526  return planstate->ps_ResultTupleSlot->tts_ops;
527 }
528 
529 
530 /* ----------------
531  * ExecAssignProjectionInfo
532  *
533  * forms the projection information from the node's targetlist
534  *
535  * Notes for inputDesc are same as for ExecBuildProjectionInfo: supply it
536  * for a relation-scan node, can pass NULL for upper-level nodes
537  * ----------------
538  */
539 void
541  TupleDesc inputDesc)
542 {
543  planstate->ps_ProjInfo =
545  planstate->ps_ExprContext,
546  planstate->ps_ResultTupleSlot,
547  planstate,
548  inputDesc);
549 }
550 
551 
552 /* ----------------
553  * ExecConditionalAssignProjectionInfo
554  *
555  * as ExecAssignProjectionInfo, but store NULL rather than building projection
556  * info if no projection is required
557  * ----------------
558  */
559 void
561  Index varno)
562 {
563  if (tlist_matches_tupdesc(planstate,
564  planstate->plan->targetlist,
565  varno,
566  inputDesc))
567  {
568  planstate->ps_ProjInfo = NULL;
569  planstate->resultopsset = planstate->scanopsset;
570  planstate->resultopsfixed = planstate->scanopsfixed;
571  planstate->resultops = planstate->scanops;
572  }
573  else
574  {
575  if (!planstate->ps_ResultTupleSlot)
576  {
577  ExecInitResultSlot(planstate, &TTSOpsVirtual);
578  planstate->resultops = &TTSOpsVirtual;
579  planstate->resultopsfixed = true;
580  planstate->resultopsset = true;
581  }
582  ExecAssignProjectionInfo(planstate, inputDesc);
583  }
584 }
585 
586 static bool
587 tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc)
588 {
589  int numattrs = tupdesc->natts;
590  int attrno;
591  ListCell *tlist_item = list_head(tlist);
592 
593  /* Check the tlist attributes */
594  for (attrno = 1; attrno <= numattrs; attrno++)
595  {
596  Form_pg_attribute att_tup = TupleDescAttr(tupdesc, attrno - 1);
597  Var *var;
598 
599  if (tlist_item == NULL)
600  return false; /* tlist too short */
601  var = (Var *) ((TargetEntry *) lfirst(tlist_item))->expr;
602  if (!var || !IsA(var, Var))
603  return false; /* tlist item not a Var */
604  /* if these Asserts fail, planner messed up */
605  Assert(var->varno == varno);
606  Assert(var->varlevelsup == 0);
607  if (var->varattno != attrno)
608  return false; /* out of order */
609  if (att_tup->attisdropped)
610  return false; /* table contains dropped columns */
611  if (att_tup->atthasmissing)
612  return false; /* table contains cols with missing values */
613 
614  /*
615  * Note: usually the Var's type should match the tupdesc exactly, but
616  * in situations involving unions of columns that have different
617  * typmods, the Var may have come from above the union and hence have
618  * typmod -1. This is a legitimate situation since the Var still
619  * describes the column, just not as exactly as the tupdesc does. We
620  * could change the planner to prevent it, but it'd then insert
621  * projection steps just to convert from specific typmod to typmod -1,
622  * which is pretty silly.
623  */
624  if (var->vartype != att_tup->atttypid ||
625  (var->vartypmod != att_tup->atttypmod &&
626  var->vartypmod != -1))
627  return false; /* type mismatch */
628 
629  tlist_item = lnext(tlist, tlist_item);
630  }
631 
632  if (tlist_item)
633  return false; /* tlist too long */
634 
635  return true;
636 }
637 
638 /* ----------------
639  * ExecFreeExprContext
640  *
641  * A plan node's ExprContext should be freed explicitly during executor
642  * shutdown because there may be shutdown callbacks to call. (Other resources
643  * made by the above routines, such as projection info, don't need to be freed
644  * explicitly because they're just memory in the per-query memory context.)
645  *
646  * However ... there is no particular need to do it during ExecEndNode,
647  * because FreeExecutorState will free any remaining ExprContexts within
648  * the EState. Letting FreeExecutorState do it allows the ExprContexts to
649  * be freed in reverse order of creation, rather than order of creation as
650  * will happen if we delete them here, which saves O(N^2) work in the list
651  * cleanup inside FreeExprContext.
652  * ----------------
653  */
654 void
656 {
657  /*
658  * Per above discussion, don't actually delete the ExprContext. We do
659  * unlink it from the plan node, though.
660  */
661  planstate->ps_ExprContext = NULL;
662 }
663 
664 
665 /* ----------------------------------------------------------------
666  * Scan node support
667  * ----------------------------------------------------------------
668  */
669 
670 /* ----------------
671  * ExecAssignScanType
672  * ----------------
673  */
674 void
676 {
677  TupleTableSlot *slot = scanstate->ss_ScanTupleSlot;
678 
679  ExecSetSlotDescriptor(slot, tupDesc);
680 }
681 
682 /* ----------------
683  * ExecCreateScanSlotFromOuterPlan
684  * ----------------
685  */
686 void
688  ScanState *scanstate,
689  const TupleTableSlotOps *tts_ops)
690 {
692  TupleDesc tupDesc;
693 
694  outerPlan = outerPlanState(scanstate);
695  tupDesc = ExecGetResultType(outerPlan);
696 
697  ExecInitScanTupleSlot(estate, scanstate, tupDesc, tts_ops);
698 }
699 
700 /* ----------------------------------------------------------------
701  * ExecRelationIsTargetRelation
702  *
703  * Detect whether a relation (identified by rangetable index)
704  * is one of the target relations of the query.
705  *
706  * Note: This is currently no longer used in core. We keep it around
707  * because FDWs may wish to use it to determine if their foreign table
708  * is a target relation.
709  * ----------------------------------------------------------------
710  */
711 bool
713 {
714  ResultRelInfo *resultRelInfos;
715  int i;
716 
717  resultRelInfos = estate->es_result_relations;
718  for (i = 0; i < estate->es_num_result_relations; i++)
719  {
720  if (resultRelInfos[i].ri_RangeTableIndex == scanrelid)
721  return true;
722  }
723  return false;
724 }
725 
726 /* ----------------------------------------------------------------
727  * ExecOpenScanRelation
728  *
729  * Open the heap relation to be scanned by a base-level scan plan node.
730  * This should be called during the node's ExecInit routine.
731  * ----------------------------------------------------------------
732  */
733 Relation
734 ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
735 {
736  Relation rel;
737 
738  /* Open the relation. */
739  rel = ExecGetRangeTableRelation(estate, scanrelid);
740 
741  /*
742  * Complain if we're attempting a scan of an unscannable relation, except
743  * when the query won't actually be run. This is a slightly klugy place
744  * to do this, perhaps, but there is no better place.
745  */
746  if ((eflags & (EXEC_FLAG_EXPLAIN_ONLY | EXEC_FLAG_WITH_NO_DATA)) == 0 &&
747  !RelationIsScannable(rel))
748  ereport(ERROR,
749  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
750  errmsg("materialized view \"%s\" has not been populated",
752  errhint("Use the REFRESH MATERIALIZED VIEW command.")));
753 
754  return rel;
755 }
756 
757 /*
758  * ExecInitRangeTable
759  * Set up executor's range-table-related data
760  *
761  * In addition to the range table proper, initialize arrays that are
762  * indexed by rangetable index.
763  */
764 void
765 ExecInitRangeTable(EState *estate, List *rangeTable)
766 {
767  /* Remember the range table List as-is */
768  estate->es_range_table = rangeTable;
769 
770  /* Set size of associated arrays */
771  estate->es_range_table_size = list_length(rangeTable);
772 
773  /*
774  * Allocate an array to store an open Relation corresponding to each
775  * rangetable entry, and initialize entries to NULL. Relations are opened
776  * and stored here as needed.
777  */
778  estate->es_relations = (Relation *)
779  palloc0(estate->es_range_table_size * sizeof(Relation));
780 
781  /*
782  * es_rowmarks is also parallel to the es_range_table, but it's allocated
783  * only if needed.
784  */
785  estate->es_rowmarks = NULL;
786 }
787 
788 /*
789  * ExecGetRangeTableRelation
790  * Open the Relation for a range table entry, if not already done
791  *
792  * The Relations will be closed again in ExecEndPlan().
793  */
794 Relation
796 {
797  Relation rel;
798 
799  Assert(rti > 0 && rti <= estate->es_range_table_size);
800 
801  rel = estate->es_relations[rti - 1];
802  if (rel == NULL)
803  {
804  /* First time through, so open the relation */
805  RangeTblEntry *rte = exec_rt_fetch(rti, estate);
806 
807  Assert(rte->rtekind == RTE_RELATION);
808 
809  if (!IsParallelWorker())
810  {
811  /*
812  * In a normal query, we should already have the appropriate lock,
813  * but verify that through an Assert. Since there's already an
814  * Assert inside table_open that insists on holding some lock, it
815  * seems sufficient to check this only when rellockmode is higher
816  * than the minimum.
817  */
818  rel = table_open(rte->relid, NoLock);
820  CheckRelationLockedByMe(rel, rte->rellockmode, false));
821  }
822  else
823  {
824  /*
825  * If we are a parallel worker, we need to obtain our own local
826  * lock on the relation. This ensures sane behavior in case the
827  * parent process exits before we do.
828  */
829  rel = table_open(rte->relid, rte->rellockmode);
830  }
831 
832  estate->es_relations[rti - 1] = rel;
833  }
834 
835  return rel;
836 }
837 
838 /*
839  * UpdateChangedParamSet
840  * Add changed parameters to a plan node's chgParam set
841  */
842 void
844 {
845  Bitmapset *parmset;
846 
847  /*
848  * The plan node only depends on params listed in its allParam set. Don't
849  * include anything else into its chgParam set.
850  */
851  parmset = bms_intersect(node->plan->allParam, newchg);
852 
853  /*
854  * Keep node->chgParam == NULL if there's not actually any members; this
855  * allows the simplest possible tests in executor node files.
856  */
857  if (!bms_is_empty(parmset))
858  node->chgParam = bms_join(node->chgParam, parmset);
859  else
860  bms_free(parmset);
861 }
862 
863 /*
864  * executor_errposition
865  * Report an execution-time cursor position, if possible.
866  *
867  * This is expected to be used within an ereport() call. The return value
868  * is a dummy (always 0, in fact).
869  *
870  * The locations stored in parsetrees are byte offsets into the source string.
871  * We have to convert them to 1-based character indexes for reporting to
872  * clients. (We do things this way to avoid unnecessary overhead in the
873  * normal non-error case: computing character indexes would be much more
874  * expensive than storing token offsets.)
875  */
876 int
877 executor_errposition(EState *estate, int location)
878 {
879  int pos;
880 
881  /* No-op if location was not provided */
882  if (location < 0)
883  return 0;
884  /* Can't do anything if source text is not available */
885  if (estate == NULL || estate->es_sourceText == NULL)
886  return 0;
887  /* Convert offset to character number */
888  pos = pg_mbstrlen_with_len(estate->es_sourceText, location) + 1;
889  /* And pass it to the ereport mechanism */
890  return errposition(pos);
891 }
892 
893 /*
894  * Register a shutdown callback in an ExprContext.
895  *
896  * Shutdown callbacks will be called (in reverse order of registration)
897  * when the ExprContext is deleted or rescanned. This provides a hook
898  * for functions called in the context to do any cleanup needed --- it's
899  * particularly useful for functions returning sets. Note that the
900  * callback will *not* be called in the event that execution is aborted
901  * by an error.
902  */
903 void
906  Datum arg)
907 {
908  ExprContext_CB *ecxt_callback;
909 
910  /* Save the info in appropriate memory context */
911  ecxt_callback = (ExprContext_CB *)
913  sizeof(ExprContext_CB));
914 
915  ecxt_callback->function = function;
916  ecxt_callback->arg = arg;
917 
918  /* link to front of list for appropriate execution order */
919  ecxt_callback->next = econtext->ecxt_callbacks;
920  econtext->ecxt_callbacks = ecxt_callback;
921 }
922 
923 /*
924  * Deregister a shutdown callback in an ExprContext.
925  *
926  * Any list entries matching the function and arg will be removed.
927  * This can be used if it's no longer necessary to call the callback.
928  */
929 void
932  Datum arg)
933 {
934  ExprContext_CB **prev_callback;
935  ExprContext_CB *ecxt_callback;
936 
937  prev_callback = &econtext->ecxt_callbacks;
938 
939  while ((ecxt_callback = *prev_callback) != NULL)
940  {
941  if (ecxt_callback->function == function && ecxt_callback->arg == arg)
942  {
943  *prev_callback = ecxt_callback->next;
944  pfree(ecxt_callback);
945  }
946  else
947  prev_callback = &ecxt_callback->next;
948  }
949 }
950 
951 /*
952  * Call all the shutdown callbacks registered in an ExprContext.
953  *
954  * The callback list is emptied (important in case this is only a rescan
955  * reset, and not deletion of the ExprContext).
956  *
957  * If isCommit is false, just clean the callback list but don't call 'em.
958  * (See comment for FreeExprContext.)
959  */
960 static void
961 ShutdownExprContext(ExprContext *econtext, bool isCommit)
962 {
963  ExprContext_CB *ecxt_callback;
964  MemoryContext oldcontext;
965 
966  /* Fast path in normal case where there's nothing to do. */
967  if (econtext->ecxt_callbacks == NULL)
968  return;
969 
970  /*
971  * Call the callbacks in econtext's per-tuple context. This ensures that
972  * any memory they might leak will get cleaned up.
973  */
974  oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
975 
976  /*
977  * Call each callback function in reverse registration order.
978  */
979  while ((ecxt_callback = econtext->ecxt_callbacks) != NULL)
980  {
981  econtext->ecxt_callbacks = ecxt_callback->next;
982  if (isCommit)
983  ecxt_callback->function(ecxt_callback->arg);
984  pfree(ecxt_callback);
985  }
986 
987  MemoryContextSwitchTo(oldcontext);
988 }
989 
990 /*
991  * GetAttributeByName
992  * GetAttributeByNum
993  *
994  * These functions return the value of the requested attribute
995  * out of the given tuple Datum.
996  * C functions which take a tuple as an argument are expected
997  * to use these. Ex: overpaid(EMP) might call GetAttributeByNum().
998  * Note: these are actually rather slow because they do a typcache
999  * lookup on each call.
1000  */
1001 Datum
1002 GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
1003 {
1004  AttrNumber attrno;
1005  Datum result;
1006  Oid tupType;
1007  int32 tupTypmod;
1008  TupleDesc tupDesc;
1009  HeapTupleData tmptup;
1010  int i;
1011 
1012  if (attname == NULL)
1013  elog(ERROR, "invalid attribute name");
1014 
1015  if (isNull == NULL)
1016  elog(ERROR, "a NULL isNull pointer was passed");
1017 
1018  if (tuple == NULL)
1019  {
1020  /* Kinda bogus but compatible with old behavior... */
1021  *isNull = true;
1022  return (Datum) 0;
1023  }
1024 
1025  tupType = HeapTupleHeaderGetTypeId(tuple);
1026  tupTypmod = HeapTupleHeaderGetTypMod(tuple);
1027  tupDesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
1028 
1029  attrno = InvalidAttrNumber;
1030  for (i = 0; i < tupDesc->natts; i++)
1031  {
1032  Form_pg_attribute att = TupleDescAttr(tupDesc, i);
1033 
1034  if (namestrcmp(&(att->attname), attname) == 0)
1035  {
1036  attrno = att->attnum;
1037  break;
1038  }
1039  }
1040 
1041  if (attrno == InvalidAttrNumber)
1042  elog(ERROR, "attribute \"%s\" does not exist", attname);
1043 
1044  /*
1045  * heap_getattr needs a HeapTuple not a bare HeapTupleHeader. We set all
1046  * the fields in the struct just in case user tries to inspect system
1047  * columns.
1048  */
1049  tmptup.t_len = HeapTupleHeaderGetDatumLength(tuple);
1050  ItemPointerSetInvalid(&(tmptup.t_self));
1051  tmptup.t_tableOid = InvalidOid;
1052  tmptup.t_data = tuple;
1053 
1054  result = heap_getattr(&tmptup,
1055  attrno,
1056  tupDesc,
1057  isNull);
1058 
1059  ReleaseTupleDesc(tupDesc);
1060 
1061  return result;
1062 }
1063 
1064 Datum
1066  AttrNumber attrno,
1067  bool *isNull)
1068 {
1069  Datum result;
1070  Oid tupType;
1071  int32 tupTypmod;
1072  TupleDesc tupDesc;
1073  HeapTupleData tmptup;
1074 
1075  if (!AttributeNumberIsValid(attrno))
1076  elog(ERROR, "invalid attribute number %d", attrno);
1077 
1078  if (isNull == NULL)
1079  elog(ERROR, "a NULL isNull pointer was passed");
1080 
1081  if (tuple == NULL)
1082  {
1083  /* Kinda bogus but compatible with old behavior... */
1084  *isNull = true;
1085  return (Datum) 0;
1086  }
1087 
1088  tupType = HeapTupleHeaderGetTypeId(tuple);
1089  tupTypmod = HeapTupleHeaderGetTypMod(tuple);
1090  tupDesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
1091 
1092  /*
1093  * heap_getattr needs a HeapTuple not a bare HeapTupleHeader. We set all
1094  * the fields in the struct just in case user tries to inspect system
1095  * columns.
1096  */
1097  tmptup.t_len = HeapTupleHeaderGetDatumLength(tuple);
1098  ItemPointerSetInvalid(&(tmptup.t_self));
1099  tmptup.t_tableOid = InvalidOid;
1100  tmptup.t_data = tuple;
1101 
1102  result = heap_getattr(&tmptup,
1103  attrno,
1104  tupDesc,
1105  isNull);
1106 
1107  ReleaseTupleDesc(tupDesc);
1108 
1109  return result;
1110 }
1111 
1112 /*
1113  * Number of items in a tlist (including any resjunk items!)
1114  */
1115 int
1117 {
1118  /* This used to be more complex, but fjoins are dead */
1119  return list_length(targetlist);
1120 }
1121 
1122 /*
1123  * Number of items in a tlist, not including any resjunk items
1124  */
1125 int
1127 {
1128  int len = 0;
1129  ListCell *tl;
1130 
1131  foreach(tl, targetlist)
1132  {
1133  TargetEntry *curTle = lfirst_node(TargetEntry, tl);
1134 
1135  if (!curTle->resjunk)
1136  len++;
1137  }
1138  return len;
1139 }
1140 
1141 /*
1142  * Return a relInfo's tuple slot for a trigger's OLD tuples.
1143  */
1146 {
1147  if (relInfo->ri_TrigOldSlot == NULL)
1148  {
1149  Relation rel = relInfo->ri_RelationDesc;
1150  MemoryContext oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
1151 
1152  relInfo->ri_TrigOldSlot =
1153  ExecInitExtraTupleSlot(estate,
1154  RelationGetDescr(rel),
1155  table_slot_callbacks(rel));
1156 
1157  MemoryContextSwitchTo(oldcontext);
1158  }
1159 
1160  return relInfo->ri_TrigOldSlot;
1161 }
1162 
1163 /*
1164  * Return a relInfo's tuple slot for a trigger's NEW tuples.
1165  */
1168 {
1169  if (relInfo->ri_TrigNewSlot == NULL)
1170  {
1171  Relation rel = relInfo->ri_RelationDesc;
1172  MemoryContext oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
1173 
1174  relInfo->ri_TrigNewSlot =
1175  ExecInitExtraTupleSlot(estate,
1176  RelationGetDescr(rel),
1177  table_slot_callbacks(rel));
1178 
1179  MemoryContextSwitchTo(oldcontext);
1180  }
1181 
1182  return relInfo->ri_TrigNewSlot;
1183 }
1184 
1185 /*
1186  * Return a relInfo's tuple slot for processing returning tuples.
1187  */
1190 {
1191  if (relInfo->ri_ReturningSlot == NULL)
1192  {
1193  Relation rel = relInfo->ri_RelationDesc;
1194  MemoryContext oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
1195 
1196  relInfo->ri_ReturningSlot =
1197  ExecInitExtraTupleSlot(estate,
1198  RelationGetDescr(rel),
1199  table_slot_callbacks(rel));
1200 
1201  MemoryContextSwitchTo(oldcontext);
1202  }
1203 
1204  return relInfo->ri_ReturningSlot;
1205 }
#define TTS_FIXED(slot)
Definition: tuptable.h:109
#define NIL
Definition: pg_list.h:65
uint32 CommandId
Definition: c.h:534
void ExecInitRangeTable(EState *estate, List *rangeTable)
Definition: execUtils.c:765
ExprContext * CreateStandaloneExprContext(void)
Definition: execUtils.c:357
JunkFilter * es_junkFilter
Definition: execnodes.h:519
int ExecTargetListLength(List *targetlist)
Definition: execUtils.c:1116
Relation ri_RelationDesc
Definition: execnodes.h:413
#define IsA(nodeptr, _type_)
Definition: nodes.h:580
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:211
#define AllocSetContextCreate
Definition: memutils.h:170
Datum * ecxt_aggvalues
Definition: execnodes.h:245
Index varlevelsup
Definition: primnodes.h:191
int errhint(const char *fmt,...)
Definition: elog.c:1071
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1801
TupleTableSlot * ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo)
Definition: execUtils.c:1189
CommandId es_output_cid
Definition: execnodes.h:522
ProjectionInfo * ps_ProjInfo
Definition: execnodes.h:985
const TupleTableSlotOps * ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
Definition: execUtils.c:504
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
Definition: typcache.c:1710
struct JitContext * es_jit
Definition: execnodes.h:601
static ListCell * lnext(const List *l, const ListCell *c)
Definition: pg_list.h:321
#define RelationGetDescr(relation)
Definition: rel.h:482
#define RelationIsScannable(relation)
Definition: rel.h:604
void UnregisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
Definition: execUtils.c:930
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
ExprContext * ps_ExprContext
Definition: execnodes.h:984
MemoryContext ecxt_per_tuple_memory
Definition: execnodes.h:234
static ExprContext * CreateExprContextInternal(EState *estate, Size minContextSize, Size initBlockSize, Size maxBlockSize)
Definition: execUtils.c:236
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
Definition: tableam.c:44
const TupleTableSlotOps TTSOpsVirtual
Definition: execTuples.c:83
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define AccessShareLock
Definition: lockdefs.h:36
PlannedStmt * es_plannedstmt
Definition: execnodes.h:516
Snapshot es_crosscheck_snapshot
Definition: execnodes.h:509
TupleTableSlot * ExecGetTriggerOldSlot(EState *estate, ResultRelInfo *relInfo)
Definition: execUtils.c:1145
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
int errcode(int sqlerrcode)
Definition: elog.c:610
int namestrcmp(Name name, const char *str)
Definition: name.c:287
ExprContext * es_per_tuple_exprcontext
Definition: execnodes.h:576
AttrNumber varattno
Definition: primnodes.h:186
Snapshot es_snapshot
Definition: execnodes.h:508
#define EXEC_FLAG_WITH_NO_DATA
Definition: executor.h:61
Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
Definition: execUtils.c:1002
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1335
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:136
List * list_delete_ptr(List *list, void *datum)
Definition: list.c:796
List * es_range_table
Definition: execnodes.h:510
unsigned int Oid
Definition: postgres_ext.h:31
Datum domainValue_datum
Definition: execnodes.h:257
void ExecConditionalAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc, Index varno)
Definition: execUtils.c:560
TupleTableSlot * ri_TrigNewSlot
Definition: execnodes.h:439
Definition: primnodes.h:181
TupleTableSlot * ExecGetTriggerNewSlot(EState *estate, ResultRelInfo *relInfo)
Definition: execUtils.c:1167
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:655
ScanDirection es_direction
Definition: execnodes.h:507
#define ALLOCSET_DEFAULT_MINSIZE
Definition: memutils.h:189
const TupleTableSlotOps * resultops
Definition: execnodes.h:1020
signed int int32
Definition: c.h:362
bool es_use_parallel_mode
Definition: execnodes.h:586
HeapTupleHeader t_data
Definition: htup.h:68
int pg_mbstrlen_with_len(const char *mbstr, int limit)
Definition: mbutils.c:941
struct ExecRowMark ** es_rowmarks
Definition: execnodes.h:514
#define HeapTupleHeaderGetTypMod(tup)
Definition: htup_details.h:468
void FreeExecutorState(EState *estate)
Definition: execUtils.c:191
const char * es_sourceText
Definition: execnodes.h:517
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:983
ParamExecData * es_param_exec_vals
Definition: execnodes.h:550
void pfree(void *pointer)
Definition: mcxt.c:1056
MemoryContext es_query_cxt
Definition: execnodes.h:555
ExprContextCallbackFunction function
Definition: execnodes.h:193
bool resjunk
Definition: primnodes.h:1414
#define linitial(l)
Definition: pg_list.h:195
#define ERROR
Definition: elog.h:43
NameData attname
Definition: pg_attribute.h:40
void DestroyPartitionDirectory(PartitionDirectory pdir)
Definition: partdesc.c:344
Oid vartype
Definition: primnodes.h:188
Datum caseValue_datum
Definition: execnodes.h:251
Bitmapset * bms_join(Bitmapset *a, Bitmapset *b)
Definition: bitmapset.c:949
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition: execUtils.c:734
ExprContext_CB * ecxt_callbacks
Definition: execnodes.h:265
ItemPointerData t_self
Definition: htup.h:65
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:192
#define lfirst_node(type, lc)
Definition: pg_list.h:193
#define outerPlanState(node)
Definition: execnodes.h:1039
uint32 t_len
Definition: htup.h:64
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1781
const TupleTableSlotOps * scanops
Definition: execnodes.h:1017
#define NoLock
Definition: lockdefs.h:34
int es_jit_flags
Definition: execnodes.h:600
void ExecAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc)
Definition: execUtils.c:540
ResultRelInfo * es_result_relations
Definition: execnodes.h:525
TupleTableSlot * ri_ReturningSlot
Definition: execnodes.h:437
TupleTableSlot * ecxt_innertuple
Definition: execnodes.h:228
ParamExecData * ecxt_param_exec_vals
Definition: execnodes.h:237
#define RelationGetRelationName(relation)
Definition: rel.h:490
struct EState * ecxt_estate
Definition: execnodes.h:262
static ListCell * list_head(const List *l)
Definition: pg_list.h:125
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
Definition: executor.h:543
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
Oid t_tableOid
Definition: htup.h:66
Bitmapset * allParam
Definition: plannodes.h:161
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38
int es_instrument
Definition: execnodes.h:562
#define IsParallelWorker()
Definition: parallel.h:61
bool resultopsset
Definition: execnodes.h:1028
EState * CreateExecutorState(void)
Definition: execUtils.c:89
Bitmapset * chgParam
Definition: execnodes.h:977
struct ExprContext_CB * next
Definition: execnodes.h:192
#define outerPlan(node)
Definition: plannodes.h:172
int ExecCleanTargetListLength(List *targetlist)
Definition: execUtils.c:1126
QueryEnvironment * es_queryEnv
Definition: execnodes.h:552
bool bms_is_empty(const Bitmapset *a)
Definition: bitmapset.c:701
static void ShutdownExprContext(ExprContext *econtext, bool isCommit)
Definition: execUtils.c:961
int es_num_root_result_relations
Definition: execnodes.h:536
Index varno
Definition: primnodes.h:184
#define heap_getattr(tup, attnum, tupleDesc, isnull)
Definition: htup_details.h:762
bool domainValue_isNull
Definition: execnodes.h:259
#define InvalidSnapshot
Definition: snapshot.h:123
TupleDesc ps_ResultTupleDesc
Definition: execnodes.h:982
#define AttributeNumberIsValid(attributeNumber)
Definition: attnum.h:34
bool * ecxt_aggnulls
Definition: execnodes.h:247
List * es_trig_target_relations
Definition: execnodes.h:546
List * es_tupleTable
Definition: execnodes.h:557
void * palloc0(Size size)
Definition: mcxt.c:980
List * es_auxmodifytables
Definition: execnodes.h:569
uintptr_t Datum
Definition: postgres.h:367
void ExecSetSlotDescriptor(TupleTableSlot *slot, TupleDesc tupdesc)
Definition: execTuples.c:1259
Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:259
void FreeExprContext(ExprContext *econtext, bool isCommit)
Definition: execUtils.c:416
#define HeapTupleHeaderGetTypeId(tup)
Definition: htup_details.h:458
int work_mem
Definition: globals.c:121
int es_num_result_relations
Definition: execnodes.h:526
unsigned int Index
Definition: c.h:482
Plan * plan
Definition: execnodes.h:945
#define InvalidOid
Definition: postgres_ext.h:36
List * es_tuple_routing_result_relations
Definition: execnodes.h:543
bool es_finished
Definition: execnodes.h:563
#define ereport(elevel,...)
Definition: elog.h:144
void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
Definition: execUtils.c:843
int executor_errposition(EState *estate, int location)
Definition: execUtils.c:877
bool scanopsfixed
Definition: execnodes.h:1021
Relation ExecGetRangeTableRelation(EState *estate, Index rti)
Definition: execUtils.c:795
List * lcons(void *datum, List *list)
Definition: list.c:453
void bms_free(Bitmapset *a)
Definition: bitmapset.c:208
#define makeNode(_type_)
Definition: nodes.h:577
TupleTableSlot * ecxt_outertuple
Definition: execnodes.h:230
TupleTableSlot * ri_TrigOldSlot
Definition: execnodes.h:438
#define Assert(condition)
Definition: c.h:745
#define lfirst(lc)
Definition: pg_list.h:190
void RegisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
Definition: execUtils.c:904
Relation * es_relations
Definition: execnodes.h:512
void ExecInitResultSlot(PlanState *planstate, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1749
uint64 es_processed
Definition: execnodes.h:559
void(* ExprContextCallbackFunction)(Datum arg)
Definition: execnodes.h:188
size_t Size
Definition: c.h:473
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:485
static int list_length(const List *l)
Definition: pg_list.h:169
TupleTableSlot * ecxt_scantuple
Definition: execnodes.h:226
Index es_range_table_size
Definition: execnodes.h:511
void ReScanExprContext(ExprContext *econtext)
Definition: execUtils.c:443
List * es_subplanstates
Definition: execnodes.h:567
static bool tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc)
Definition: execUtils.c:587
bool scanopsset
Definition: execnodes.h:1025
PartitionDirectory es_partition_directory
Definition: execnodes.h:537
MemoryContext ecxt_per_query_memory
Definition: execnodes.h:233
bool CheckRelationLockedByMe(Relation relation, LOCKMODE lockmode, bool orstronger)
Definition: lmgr.c:302
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:495
#define InvalidAttrNumber
Definition: attnum.h:23
List * targetlist
Definition: plannodes.h:142
RTEKind rtekind
Definition: parsenodes.h:976
bool resultopsfixed
Definition: execnodes.h:1024
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:172
bool caseValue_isNull
Definition: execnodes.h:253
void jit_release_context(JitContext *context)
Definition: jit.c:138
ProjectionInfo * ExecBuildProjectionInfo(List *targetList, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent, TupleDesc inputDesc)
Definition: execExpr.c:353
int errmsg(const char *fmt,...)
Definition: elog.c:824
int es_top_eflags
Definition: execnodes.h:561
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:796
ResultRelInfo * es_root_result_relations
Definition: execnodes.h:535
ExprContext * MakePerTupleExprContext(EState *estate)
Definition: execUtils.c:458
#define elog(elevel,...)
Definition: elog.h:214
#define ALLOCSET_DEFAULT_INITSIZE
Definition: memutils.h:190
int i
ExprContext * CreateExprContext(EState *estate)
Definition: execUtils.c:306
void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc)
Definition: execUtils.c:675
void * arg
ParamListInfo es_param_list_info
Definition: execnodes.h:549
List * es_exprcontexts
Definition: execnodes.h:565
#define ALLOCSET_DEFAULT_MAXSIZE
Definition: memutils.h:191
ExprContext * CreateWorkExprContext(EState *estate)
Definition: execUtils.c:321
void ExecCreateScanSlotFromOuterPlan(EState *estate, ScanState *scanstate, const TupleTableSlotOps *tts_ops)
Definition: execUtils.c:687
Datum GetAttributeByNum(HeapTupleHeader tuple, AttrNumber attrno, bool *isNull)
Definition: execUtils.c:1065
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:122
ParamListInfo ecxt_param_list_info
Definition: execnodes.h:238
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39
Definition: pg_list.h:50
#define EXEC_FLAG_EXPLAIN_ONLY
Definition: executor.h:56
int16 AttrNumber
Definition: attnum.h:21
bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid)
Definition: execUtils.c:712
int errposition(int cursorpos)
Definition: elog.c:1199
#define HeapTupleHeaderGetDatumLength(tup)
Definition: htup_details.h:452
int32 vartypmod
Definition: primnodes.h:189
ResultRelInfo * es_result_relation_info
Definition: execnodes.h:527