PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
execUtils.c File Reference
#include "postgres.h"
#include "access/parallel.h"
#include "access/table.h"
#include "access/tableam.h"
#include "executor/executor.h"
#include "executor/nodeModifyTable.h"
#include "jit/jit.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "parser/parse_relation.h"
#include "partitioning/partdesc.h"
#include "storage/lmgr.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/typcache.h"
Include dependency graph for execUtils.c:

Go to the source code of this file.

Functions

static bool tlist_matches_tupdesc (PlanState *ps, List *tlist, int varno, TupleDesc tupdesc)
 
static void ShutdownExprContext (ExprContext *econtext, bool isCommit)
 
static RTEPermissionInfoGetResultRTEPermissionInfo (ResultRelInfo *relinfo, EState *estate)
 
EStateCreateExecutorState (void)
 
void FreeExecutorState (EState *estate)
 
static ExprContextCreateExprContextInternal (EState *estate, Size minContextSize, Size initBlockSize, Size maxBlockSize)
 
ExprContextCreateExprContext (EState *estate)
 
ExprContextCreateWorkExprContext (EState *estate)
 
ExprContextCreateStandaloneExprContext (void)
 
void FreeExprContext (ExprContext *econtext, bool isCommit)
 
void ReScanExprContext (ExprContext *econtext)
 
ExprContextMakePerTupleExprContext (EState *estate)
 
void ExecAssignExprContext (EState *estate, PlanState *planstate)
 
TupleDesc ExecGetResultType (PlanState *planstate)
 
const TupleTableSlotOpsExecGetResultSlotOps (PlanState *planstate, bool *isfixed)
 
const TupleTableSlotOpsExecGetCommonSlotOps (PlanState **planstates, int nplans)
 
const TupleTableSlotOpsExecGetCommonChildSlotOps (PlanState *ps)
 
void ExecAssignProjectionInfo (PlanState *planstate, TupleDesc inputDesc)
 
void ExecConditionalAssignProjectionInfo (PlanState *planstate, TupleDesc inputDesc, int varno)
 
void ExecAssignScanType (ScanState *scanstate, TupleDesc tupDesc)
 
void ExecCreateScanSlotFromOuterPlan (EState *estate, ScanState *scanstate, const TupleTableSlotOps *tts_ops)
 
bool ExecRelationIsTargetRelation (EState *estate, Index scanrelid)
 
Relation ExecOpenScanRelation (EState *estate, Index scanrelid, int eflags)
 
void ExecInitRangeTable (EState *estate, List *rangeTable, List *permInfos, Bitmapset *unpruned_relids)
 
Relation ExecGetRangeTableRelation (EState *estate, Index rti, bool isResultRel)
 
void ExecInitResultRelation (EState *estate, ResultRelInfo *resultRelInfo, Index rti)
 
void UpdateChangedParamSet (PlanState *node, Bitmapset *newchg)
 
int executor_errposition (EState *estate, int location)
 
void RegisterExprContextCallback (ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
 
void UnregisterExprContextCallback (ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
 
Datum GetAttributeByName (HeapTupleHeader tuple, const char *attname, bool *isNull)
 
Datum GetAttributeByNum (HeapTupleHeader tuple, AttrNumber attrno, bool *isNull)
 
int ExecTargetListLength (List *targetlist)
 
int ExecCleanTargetListLength (List *targetlist)
 
TupleTableSlotExecGetTriggerOldSlot (EState *estate, ResultRelInfo *relInfo)
 
TupleTableSlotExecGetTriggerNewSlot (EState *estate, ResultRelInfo *relInfo)
 
TupleTableSlotExecGetReturningSlot (EState *estate, ResultRelInfo *relInfo)
 
TupleTableSlotExecGetAllNullSlot (EState *estate, ResultRelInfo *relInfo)
 
TupleConversionMapExecGetChildToRootMap (ResultRelInfo *resultRelInfo)
 
TupleConversionMapExecGetRootToChildMap (ResultRelInfo *resultRelInfo, EState *estate)
 
BitmapsetExecGetInsertedCols (ResultRelInfo *relinfo, EState *estate)
 
BitmapsetExecGetUpdatedCols (ResultRelInfo *relinfo, EState *estate)
 
BitmapsetExecGetExtraUpdatedCols (ResultRelInfo *relinfo, EState *estate)
 
BitmapsetExecGetAllUpdatedCols (ResultRelInfo *relinfo, EState *estate)
 
Oid ExecGetResultRelCheckAsUser (ResultRelInfo *relInfo, EState *estate)
 

Function Documentation

◆ CreateExecutorState()

EState * CreateExecutorState ( void  )

Definition at line 88 of file execUtils.c.

89{
90 EState *estate;
91 MemoryContext qcontext;
92 MemoryContext oldcontext;
93
94 /*
95 * Create the per-query context for this Executor run.
96 */
98 "ExecutorState",
100
101 /*
102 * Make the EState node within the per-query context. This way, we don't
103 * need a separate pfree() operation for it at shutdown.
104 */
105 oldcontext = MemoryContextSwitchTo(qcontext);
106
107 estate = makeNode(EState);
108
109 /*
110 * Initialize all fields of the Executor State structure
111 */
113 estate->es_snapshot = InvalidSnapshot; /* caller must initialize this */
114 estate->es_crosscheck_snapshot = InvalidSnapshot; /* no crosscheck */
115 estate->es_range_table = NIL;
116 estate->es_range_table_size = 0;
117 estate->es_relations = NULL;
118 estate->es_rowmarks = NULL;
119 estate->es_rteperminfos = NIL;
120 estate->es_plannedstmt = NULL;
121 estate->es_part_prune_infos = NIL;
122
123 estate->es_junkFilter = NULL;
124
125 estate->es_output_cid = (CommandId) 0;
126
127 estate->es_result_relations = NULL;
131
134
135 estate->es_param_list_info = NULL;
136 estate->es_param_exec_vals = NULL;
137
138 estate->es_queryEnv = NULL;
139
140 estate->es_query_cxt = qcontext;
141
142 estate->es_tupleTable = NIL;
143
144 estate->es_processed = 0;
145 estate->es_total_processed = 0;
146
147 estate->es_top_eflags = 0;
148 estate->es_instrument = 0;
149 estate->es_finished = false;
150 estate->es_aborted = 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;
165
166 estate->es_jit_flags = 0;
167 estate->es_jit = NULL;
168
169 /*
170 * Return the executor state structure
171 */
172 MemoryContextSwitchTo(oldcontext);
173
174 return estate;
175}
uint32 CommandId
Definition: c.h:637
MemoryContext CurrentMemoryContext
Definition: mcxt.c:143
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:160
#define makeNode(_type_)
Definition: nodes.h:161
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:124
#define NIL
Definition: pg_list.h:68
@ ForwardScanDirection
Definition: sdir.h:28
#define InvalidSnapshot
Definition: snapshot.h:119
uint64 es_processed
Definition: execnodes.h:712
bool es_aborted
Definition: execnodes.h:720
List * es_part_prune_infos
Definition: execnodes.h:668
struct ExecRowMark ** es_rowmarks
Definition: execnodes.h:663
int es_parallel_workers_to_launch
Definition: execnodes.h:745
List * es_tuple_routing_result_relations
Definition: execnodes.h:696
int es_top_eflags
Definition: execnodes.h:717
struct JitContext * es_jit
Definition: execnodes.h:763
int es_instrument
Definition: execnodes.h:718
PlannedStmt * es_plannedstmt
Definition: execnodes.h:666
QueryEnvironment * es_queryEnv
Definition: execnodes.h:705
ResultRelInfo ** es_result_relations
Definition: execnodes.h:683
ParamExecData * es_param_exec_vals
Definition: execnodes.h:703
uint64 es_total_processed
Definition: execnodes.h:714
List * es_range_table
Definition: execnodes.h:659
List * es_rteperminfos
Definition: execnodes.h:665
List * es_exprcontexts
Definition: execnodes.h:722
ParamListInfo es_param_list_info
Definition: execnodes.h:702
bool es_finished
Definition: execnodes.h:719
List * es_insert_pending_result_relations
Definition: execnodes.h:770
MemoryContext es_query_cxt
Definition: execnodes.h:708
List * es_tupleTable
Definition: execnodes.h:710
ScanDirection es_direction
Definition: execnodes.h:656
List * es_trig_target_relations
Definition: execnodes.h:699
int es_jit_flags
Definition: execnodes.h:762
List * es_opened_result_relations
Definition: execnodes.h:686
bool es_use_parallel_mode
Definition: execnodes.h:743
Relation * es_relations
Definition: execnodes.h:661
List * es_subplanstates
Definition: execnodes.h:724
ExprContext * es_per_tuple_exprcontext
Definition: execnodes.h:733
int es_parallel_workers_launched
Definition: execnodes.h:747
CommandId es_output_cid
Definition: execnodes.h:680
Index es_range_table_size
Definition: execnodes.h:660
List * es_insert_pending_modifytables
Definition: execnodes.h:771
const char * es_sourceText
Definition: execnodes.h:675
Snapshot es_snapshot
Definition: execnodes.h:657
List * es_auxmodifytables
Definition: execnodes.h:726
JunkFilter * es_junkFilter
Definition: execnodes.h:677
Snapshot es_crosscheck_snapshot
Definition: execnodes.h:658

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, CurrentMemoryContext, EState::es_aborted, EState::es_auxmodifytables, EState::es_crosscheck_snapshot, EState::es_direction, EState::es_exprcontexts, EState::es_finished, EState::es_insert_pending_modifytables, EState::es_insert_pending_result_relations, EState::es_instrument, EState::es_jit, EState::es_jit_flags, EState::es_junkFilter, EState::es_opened_result_relations, EState::es_output_cid, EState::es_parallel_workers_launched, EState::es_parallel_workers_to_launch, EState::es_param_exec_vals, EState::es_param_list_info, EState::es_part_prune_infos, EState::es_per_tuple_exprcontext, EState::es_plannedstmt, EState::es_processed, EState::es_query_cxt, EState::es_queryEnv, EState::es_range_table, EState::es_range_table_size, EState::es_relations, EState::es_result_relations, EState::es_rowmarks, EState::es_rteperminfos, EState::es_snapshot, EState::es_sourceText, EState::es_subplanstates, EState::es_top_eflags, EState::es_total_processed, EState::es_trig_target_relations, EState::es_tuple_routing_result_relations, EState::es_tupleTable, EState::es_use_parallel_mode, ForwardScanDirection, InvalidSnapshot, makeNode, MemoryContextSwitchTo(), and NIL.

Referenced by afterTriggerInvokeEvents(), ATExecAddColumn(), ATRewriteTable(), check_default_partition_contents(), compute_expr_stats(), compute_index_stats(), CopyFrom(), create_edata_for_relation(), create_estate_for_relation(), EvalPlanQualStart(), evaluate_expr(), ExecuteCallStmt(), ExecuteQuery(), ExecuteTruncateGuts(), ExplainExecuteQuery(), fileIterateForeignScan(), get_qual_for_range(), heapam_index_build_range_scan(), heapam_index_validate_scan(), IndexCheckExclusion(), make_build_data(), operator_predicate_proof(), plpgsql_create_econtext(), plpgsql_inline_handler(), standard_ExecutorStart(), tuplesort_begin_cluster(), and validateDomainCheckConstraint().

◆ CreateExprContext()

ExprContext * CreateExprContext ( EState estate)

Definition at line 308 of file execUtils.c.

309{
311}
static ExprContext * CreateExprContextInternal(EState *estate, Size minContextSize, Size initBlockSize, Size maxBlockSize)
Definition: execUtils.c:238

References ALLOCSET_DEFAULT_SIZES, and CreateExprContextInternal().

Referenced by CreatePartitionPruneState(), ExecAssignExprContext(), ExecInitMergeJoin(), ExecInitSubPlan(), ExecuteCallStmt(), MakePerTupleExprContext(), and plpgsql_create_econtext().

◆ CreateExprContextInternal()

static ExprContext * CreateExprContextInternal ( EState estate,
Size  minContextSize,
Size  initBlockSize,
Size  maxBlockSize 
)
static

Definition at line 238 of file execUtils.c.

240{
241 ExprContext *econtext;
242 MemoryContext oldcontext;
243
244 /* Create the ExprContext node within the per-query memory context */
245 oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
246
247 econtext = makeNode(ExprContext);
248
249 /* Initialize fields of ExprContext */
250 econtext->ecxt_scantuple = NULL;
251 econtext->ecxt_innertuple = NULL;
252 econtext->ecxt_outertuple = NULL;
253
254 econtext->ecxt_per_query_memory = estate->es_query_cxt;
255
256 /*
257 * Create working memory for expression evaluation in this context.
258 */
259 econtext->ecxt_per_tuple_memory =
261 "ExprContext",
262 minContextSize,
263 initBlockSize,
264 maxBlockSize);
265
266 econtext->ecxt_param_exec_vals = estate->es_param_exec_vals;
267 econtext->ecxt_param_list_info = estate->es_param_list_info;
268
269 econtext->ecxt_aggvalues = NULL;
270 econtext->ecxt_aggnulls = NULL;
271
272 econtext->caseValue_datum = (Datum) 0;
273 econtext->caseValue_isNull = true;
274
275 econtext->domainValue_datum = (Datum) 0;
276 econtext->domainValue_isNull = true;
277
278 econtext->ecxt_estate = estate;
279
280 econtext->ecxt_callbacks = NULL;
281
282 /*
283 * Link the ExprContext into the EState to ensure it is shut down when the
284 * EState is freed. Because we use lcons(), shutdowns will occur in
285 * reverse order of creation, which may not be essential but can't hurt.
286 */
287 estate->es_exprcontexts = lcons(econtext, estate->es_exprcontexts);
288
289 MemoryContextSwitchTo(oldcontext);
290
291 return econtext;
292}
List * lcons(void *datum, List *list)
Definition: list.c:495
uintptr_t Datum
Definition: postgres.h:69
Datum domainValue_datum
Definition: execnodes.h:299
ParamListInfo ecxt_param_list_info
Definition: execnodes.h:280
MemoryContext ecxt_per_tuple_memory
Definition: execnodes.h:276
TupleTableSlot * ecxt_innertuple
Definition: execnodes.h:270
ParamExecData * ecxt_param_exec_vals
Definition: execnodes.h:279
Datum * ecxt_aggvalues
Definition: execnodes.h:287
bool caseValue_isNull
Definition: execnodes.h:295
TupleTableSlot * ecxt_scantuple
Definition: execnodes.h:268
Datum caseValue_datum
Definition: execnodes.h:293
bool * ecxt_aggnulls
Definition: execnodes.h:289
MemoryContext ecxt_per_query_memory
Definition: execnodes.h:275
ExprContext_CB * ecxt_callbacks
Definition: execnodes.h:313
bool domainValue_isNull
Definition: execnodes.h:301
struct EState * ecxt_estate
Definition: execnodes.h:310
TupleTableSlot * ecxt_outertuple
Definition: execnodes.h:272

References AllocSetContextCreate, ExprContext::caseValue_datum, ExprContext::caseValue_isNull, ExprContext::domainValue_datum, ExprContext::domainValue_isNull, ExprContext::ecxt_aggnulls, ExprContext::ecxt_aggvalues, ExprContext::ecxt_callbacks, ExprContext::ecxt_estate, ExprContext::ecxt_innertuple, ExprContext::ecxt_outertuple, ExprContext::ecxt_param_exec_vals, ExprContext::ecxt_param_list_info, ExprContext::ecxt_per_query_memory, ExprContext::ecxt_per_tuple_memory, ExprContext::ecxt_scantuple, EState::es_exprcontexts, EState::es_param_exec_vals, EState::es_param_list_info, EState::es_query_cxt, lcons(), makeNode, and MemoryContextSwitchTo().

Referenced by CreateExprContext(), and CreateWorkExprContext().

◆ CreateStandaloneExprContext()

ExprContext * CreateStandaloneExprContext ( void  )

Definition at line 358 of file execUtils.c.

359{
360 ExprContext *econtext;
361
362 /* Create the ExprContext node within the caller's memory context */
363 econtext = makeNode(ExprContext);
364
365 /* Initialize fields of ExprContext */
366 econtext->ecxt_scantuple = NULL;
367 econtext->ecxt_innertuple = NULL;
368 econtext->ecxt_outertuple = NULL;
369
371
372 /*
373 * Create working memory for expression evaluation in this context.
374 */
375 econtext->ecxt_per_tuple_memory =
377 "ExprContext",
379
380 econtext->ecxt_param_exec_vals = NULL;
381 econtext->ecxt_param_list_info = NULL;
382
383 econtext->ecxt_aggvalues = NULL;
384 econtext->ecxt_aggnulls = NULL;
385
386 econtext->caseValue_datum = (Datum) 0;
387 econtext->caseValue_isNull = true;
388
389 econtext->domainValue_datum = (Datum) 0;
390 econtext->domainValue_isNull = true;
391
392 econtext->ecxt_estate = NULL;
393
394 econtext->ecxt_callbacks = NULL;
395
396 return econtext;
397}

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, ExprContext::caseValue_datum, ExprContext::caseValue_isNull, CurrentMemoryContext, ExprContext::domainValue_datum, ExprContext::domainValue_isNull, ExprContext::ecxt_aggnulls, ExprContext::ecxt_aggvalues, ExprContext::ecxt_callbacks, ExprContext::ecxt_estate, ExprContext::ecxt_innertuple, ExprContext::ecxt_outertuple, ExprContext::ecxt_param_exec_vals, ExprContext::ecxt_param_list_info, ExprContext::ecxt_per_query_memory, ExprContext::ecxt_per_tuple_memory, ExprContext::ecxt_scantuple, and makeNode.

Referenced by BuildTupleHashTable(), domain_check_input(), and hypothetical_dense_rank_final().

◆ CreateWorkExprContext()

ExprContext * CreateWorkExprContext ( EState estate)

Definition at line 323 of file execUtils.c.

324{
325 Size maxBlockSize = ALLOCSET_DEFAULT_MAXSIZE;
326
327 maxBlockSize = pg_prevpower2_size_t(work_mem * (Size) 1024 / 16);
328
329 /* But no bigger than ALLOCSET_DEFAULT_MAXSIZE */
330 maxBlockSize = Min(maxBlockSize, ALLOCSET_DEFAULT_MAXSIZE);
331
332 /* and no smaller than ALLOCSET_DEFAULT_INITSIZE */
333 maxBlockSize = Max(maxBlockSize, ALLOCSET_DEFAULT_INITSIZE);
334
336 ALLOCSET_DEFAULT_INITSIZE, maxBlockSize);
337}
#define Min(x, y)
Definition: c.h:975
#define Max(x, y)
Definition: c.h:969
size_t Size
Definition: c.h:576
int work_mem
Definition: globals.c:131
#define ALLOCSET_DEFAULT_MAXSIZE
Definition: memutils.h:159
#define ALLOCSET_DEFAULT_MINSIZE
Definition: memutils.h:157
#define ALLOCSET_DEFAULT_INITSIZE
Definition: memutils.h:158
#define pg_prevpower2_size_t
Definition: pg_bitutils.h:442

References ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE, ALLOCSET_DEFAULT_MINSIZE, CreateExprContextInternal(), Max, Min, pg_prevpower2_size_t, and work_mem.

Referenced by hash_create_memory().

◆ ExecAssignExprContext()

◆ ExecAssignProjectionInfo()

void ExecAssignProjectionInfo ( PlanState planstate,
TupleDesc  inputDesc 
)

Definition at line 584 of file execUtils.c.

586{
587 planstate->ps_ProjInfo =
589 planstate->ps_ExprContext,
590 planstate->ps_ResultTupleSlot,
591 planstate,
592 inputDesc);
593}
ProjectionInfo * ExecBuildProjectionInfo(List *targetList, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent, TupleDesc inputDesc)
Definition: execExpr.c:370
Plan * plan
Definition: execnodes.h:1159
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:1197
ProjectionInfo * ps_ProjInfo
Definition: execnodes.h:1199
List * targetlist
Definition: plannodes.h:209

References ExecBuildProjectionInfo(), PlanState::plan, PlanState::ps_ExprContext, PlanState::ps_ProjInfo, PlanState::ps_ResultTupleSlot, and Plan::targetlist.

Referenced by ExecConditionalAssignProjectionInfo(), ExecInitAgg(), ExecInitGroup(), ExecInitHashJoin(), ExecInitMergeJoin(), ExecInitNestLoop(), ExecInitResult(), and ExecInitWindowAgg().

◆ ExecAssignScanType()

void ExecAssignScanType ( ScanState scanstate,
TupleDesc  tupDesc 
)

Definition at line 693 of file execUtils.c.

694{
695 TupleTableSlot *slot = scanstate->ss_ScanTupleSlot;
696
697 ExecSetSlotDescriptor(slot, tupDesc);
698}
void ExecSetSlotDescriptor(TupleTableSlot *slot, TupleDesc tupdesc)
Definition: execTuples.c:1478
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1618

References ExecSetSlotDescriptor(), and ScanState::ss_ScanTupleSlot.

Referenced by ExecWorkTableScan().

◆ ExecCleanTargetListLength()

int ExecCleanTargetListLength ( List targetlist)

Definition at line 1186 of file execUtils.c.

1187{
1188 int len = 0;
1189 ListCell *tl;
1190
1191 foreach(tl, targetlist)
1192 {
1193 TargetEntry *curTle = lfirst_node(TargetEntry, tl);
1194
1195 if (!curTle->resjunk)
1196 len++;
1197 }
1198 return len;
1199}
const void size_t len
#define lfirst_node(type, lc)
Definition: pg_list.h:176

References len, and lfirst_node.

Referenced by ApplyRetrieveRule(), check_sql_stmt_retval(), and ExecTypeFromTLInternal().

◆ ExecConditionalAssignProjectionInfo()

void ExecConditionalAssignProjectionInfo ( PlanState planstate,
TupleDesc  inputDesc,
int  varno 
)

Definition at line 604 of file execUtils.c.

606{
607 if (tlist_matches_tupdesc(planstate,
608 planstate->plan->targetlist,
609 varno,
610 inputDesc))
611 {
612 planstate->ps_ProjInfo = NULL;
613 planstate->resultopsset = planstate->scanopsset;
614 planstate->resultopsfixed = planstate->scanopsfixed;
615 planstate->resultops = planstate->scanops;
616 }
617 else
618 {
619 if (!planstate->ps_ResultTupleSlot)
620 {
622 planstate->resultops = &TTSOpsVirtual;
623 planstate->resultopsfixed = true;
624 planstate->resultopsset = true;
625 }
626 ExecAssignProjectionInfo(planstate, inputDesc);
627 }
628}
const TupleTableSlotOps TTSOpsVirtual
Definition: execTuples.c:84
void ExecInitResultSlot(PlanState *planstate, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1968
static bool tlist_matches_tupdesc(PlanState *ps, List *tlist, int varno, TupleDesc tupdesc)
Definition: execUtils.c:631
void ExecAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc)
Definition: execUtils.c:584
const TupleTableSlotOps * resultops
Definition: execnodes.h:1236
bool resultopsset
Definition: execnodes.h:1244
const TupleTableSlotOps * scanops
Definition: execnodes.h:1233
bool scanopsset
Definition: execnodes.h:1241
bool scanopsfixed
Definition: execnodes.h:1237
bool resultopsfixed
Definition: execnodes.h:1240

References ExecAssignProjectionInfo(), ExecInitResultSlot(), PlanState::plan, PlanState::ps_ProjInfo, PlanState::ps_ResultTupleSlot, PlanState::resultops, PlanState::resultopsfixed, PlanState::resultopsset, PlanState::scanops, PlanState::scanopsfixed, PlanState::scanopsset, Plan::targetlist, tlist_matches_tupdesc(), and TTSOpsVirtual.

Referenced by ExecAssignScanProjectionInfo(), ExecAssignScanProjectionInfoWithVarno(), ExecInitGather(), and ExecInitGatherMerge().

◆ ExecCreateScanSlotFromOuterPlan()

void ExecCreateScanSlotFromOuterPlan ( EState estate,
ScanState scanstate,
const TupleTableSlotOps tts_ops 
)

Definition at line 705 of file execUtils.c.

708{
710 TupleDesc tupDesc;
711
712 outerPlan = outerPlanState(scanstate);
713 tupDesc = ExecGetResultType(outerPlan);
714
715 ExecInitScanTupleSlot(estate, scanstate, tupDesc, tts_ops);
716}
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:2000
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:496
#define outerPlanState(node)
Definition: execnodes.h:1255
#define outerPlan(node)
Definition: plannodes.h:241

References ExecGetResultType(), ExecInitScanTupleSlot(), outerPlan, and outerPlanState.

Referenced by ExecInitAgg(), ExecInitGroup(), ExecInitIncrementalSort(), ExecInitMaterial(), ExecInitMemoize(), ExecInitSort(), and ExecInitWindowAgg().

◆ ExecGetAllNullSlot()

TupleTableSlot * ExecGetAllNullSlot ( EState estate,
ResultRelInfo relInfo 
)

Definition at line 1274 of file execUtils.c.

1275{
1276 if (relInfo->ri_AllNullSlot == NULL)
1277 {
1278 Relation rel = relInfo->ri_RelationDesc;
1279 MemoryContext oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
1280 TupleTableSlot *slot;
1281
1282 slot = ExecInitExtraTupleSlot(estate,
1283 RelationGetDescr(rel),
1286
1287 relInfo->ri_AllNullSlot = slot;
1288
1289 MemoryContextSwitchTo(oldcontext);
1290 }
1291
1292 return relInfo->ri_AllNullSlot;
1293}
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:2020
TupleTableSlot * ExecStoreAllNullTuple(TupleTableSlot *slot)
Definition: execTuples.c:1765
#define RelationGetDescr(relation)
Definition: rel.h:542
Relation ri_RelationDesc
Definition: execnodes.h:475
TupleTableSlot * ri_AllNullSlot
Definition: execnodes.h:525
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
Definition: tableam.c:59

References EState::es_query_cxt, ExecInitExtraTupleSlot(), ExecStoreAllNullTuple(), MemoryContextSwitchTo(), RelationGetDescr, ResultRelInfo::ri_AllNullSlot, ResultRelInfo::ri_RelationDesc, and table_slot_callbacks().

Referenced by ExecProcessReturning().

◆ ExecGetAllUpdatedCols()

Bitmapset * ExecGetAllUpdatedCols ( ResultRelInfo relinfo,
EState estate 
)

Definition at line 1419 of file execUtils.c.

1420{
1421 Bitmapset *ret;
1422 MemoryContext oldcxt;
1423
1425
1426 ret = bms_union(ExecGetUpdatedCols(relinfo, estate),
1427 ExecGetExtraUpdatedCols(relinfo, estate));
1428
1429 MemoryContextSwitchTo(oldcxt);
1430
1431 return ret;
1432}
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:251
Bitmapset * ExecGetExtraUpdatedCols(ResultRelInfo *relinfo, EState *estate)
Definition: execUtils.c:1404
Bitmapset * ExecGetUpdatedCols(ResultRelInfo *relinfo, EState *estate)
Definition: execUtils.c:1383
#define GetPerTupleMemoryContext(estate)
Definition: executor.h:683

References bms_union(), ExecGetExtraUpdatedCols(), ExecGetUpdatedCols(), GetPerTupleMemoryContext, and MemoryContextSwitchTo().

Referenced by ExecARUpdateTriggers(), ExecASUpdateTriggers(), ExecBRUpdateTriggers(), ExecBSUpdateTriggers(), and ExecUpdateLockMode().

◆ ExecGetChildToRootMap()

TupleConversionMap * ExecGetChildToRootMap ( ResultRelInfo resultRelInfo)

Definition at line 1301 of file execUtils.c.

1302{
1303 /* If we didn't already do so, compute the map for this child. */
1304 if (!resultRelInfo->ri_ChildToRootMapValid)
1305 {
1306 ResultRelInfo *rootRelInfo = resultRelInfo->ri_RootResultRelInfo;
1307
1308 if (rootRelInfo)
1309 resultRelInfo->ri_ChildToRootMap =
1311 RelationGetDescr(rootRelInfo->ri_RelationDesc));
1312 else /* this isn't a child result rel */
1313 resultRelInfo->ri_ChildToRootMap = NULL;
1314
1315 resultRelInfo->ri_ChildToRootMapValid = true;
1316 }
1317
1318 return resultRelInfo->ri_ChildToRootMap;
1319}
struct ResultRelInfo * ri_RootResultRelInfo
Definition: execnodes.h:615
TupleConversionMap * ri_ChildToRootMap
Definition: execnodes.h:595
bool ri_ChildToRootMapValid
Definition: execnodes.h:596
TupleConversionMap * convert_tuples_by_name(TupleDesc indesc, TupleDesc outdesc)
Definition: tupconvert.c:102

References convert_tuples_by_name(), RelationGetDescr, ResultRelInfo::ri_ChildToRootMap, ResultRelInfo::ri_ChildToRootMapValid, ResultRelInfo::ri_RelationDesc, and ResultRelInfo::ri_RootResultRelInfo.

Referenced by adjust_partition_colnos(), AfterTriggerExecute(), AfterTriggerSaveEvent(), ExecCrossPartitionUpdate(), ExecDelete(), and TransitionTableAddTuple().

◆ ExecGetCommonChildSlotOps()

const TupleTableSlotOps * ExecGetCommonChildSlotOps ( PlanState ps)

Definition at line 564 of file execUtils.c.

565{
566 PlanState *planstates[2];
567
568 planstates[0] = outerPlanState(ps);
569 planstates[1] = innerPlanState(ps);
570 return ExecGetCommonSlotOps(planstates, 2);
571}
const TupleTableSlotOps * ExecGetCommonSlotOps(PlanState **planstates, int nplans)
Definition: execUtils.c:537
#define innerPlanState(node)
Definition: execnodes.h:1254
struct parser_state ps

References ExecGetCommonSlotOps(), innerPlanState, outerPlanState, and ps.

Referenced by build_hash_table().

◆ ExecGetCommonSlotOps()

const TupleTableSlotOps * ExecGetCommonSlotOps ( PlanState **  planstates,
int  nplans 
)

Definition at line 537 of file execUtils.c.

538{
539 const TupleTableSlotOps *result;
540 bool isfixed;
541
542 if (nplans <= 0)
543 return NULL;
544 result = ExecGetResultSlotOps(planstates[0], &isfixed);
545 if (!isfixed)
546 return NULL;
547 for (int i = 1; i < nplans; i++)
548 {
549 const TupleTableSlotOps *thisops;
550
551 thisops = ExecGetResultSlotOps(planstates[i], &isfixed);
552 if (!isfixed)
553 return NULL;
554 if (result != thisops)
555 return NULL;
556 }
557 return result;
558}
const TupleTableSlotOps * ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
Definition: execUtils.c:505
int i
Definition: isn.c:77

References ExecGetResultSlotOps(), and i.

Referenced by ExecGetCommonChildSlotOps(), ExecInitAppend(), and ExecInitMergeAppend().

◆ ExecGetExtraUpdatedCols()

Bitmapset * ExecGetExtraUpdatedCols ( ResultRelInfo relinfo,
EState estate 
)

Definition at line 1404 of file execUtils.c.

1405{
1406 /* Compute the info if we didn't already */
1407 if (!relinfo->ri_extraUpdatedCols_valid)
1408 ExecInitGenerated(relinfo, estate, CMD_UPDATE);
1409 return relinfo->ri_extraUpdatedCols;
1410}
void ExecInitGenerated(ResultRelInfo *resultRelInfo, EState *estate, CmdType cmdtype)
@ CMD_UPDATE
Definition: nodes.h:272
bool ri_extraUpdatedCols_valid
Definition: execnodes.h:495
Bitmapset * ri_extraUpdatedCols
Definition: execnodes.h:493

References CMD_UPDATE, ExecInitGenerated(), ResultRelInfo::ri_extraUpdatedCols, and ResultRelInfo::ri_extraUpdatedCols_valid.

Referenced by ExecGetAllUpdatedCols(), and index_unchanged_by_update().

◆ ExecGetInsertedCols()

Bitmapset * ExecGetInsertedCols ( ResultRelInfo relinfo,
EState estate 
)

Definition at line 1362 of file execUtils.c.

1363{
1364 RTEPermissionInfo *perminfo = GetResultRTEPermissionInfo(relinfo, estate);
1365
1366 if (perminfo == NULL)
1367 return NULL;
1368
1369 /* Map the columns to child's attribute numbers if needed. */
1370 if (relinfo->ri_RootResultRelInfo)
1371 {
1372 TupleConversionMap *map = ExecGetRootToChildMap(relinfo, estate);
1373
1374 if (map)
1375 return execute_attr_map_cols(map->attrMap, perminfo->insertedCols);
1376 }
1377
1378 return perminfo->insertedCols;
1379}
TupleConversionMap * ExecGetRootToChildMap(ResultRelInfo *resultRelInfo, EState *estate)
Definition: execUtils.c:1327
static RTEPermissionInfo * GetResultRTEPermissionInfo(ResultRelInfo *relinfo, EState *estate)
Definition: execUtils.c:1439
Bitmapset * insertedCols
Definition: parsenodes.h:1308
AttrMap * attrMap
Definition: tupconvert.h:28
Bitmapset * execute_attr_map_cols(AttrMap *attrMap, Bitmapset *in_cols)
Definition: tupconvert.c:252

References TupleConversionMap::attrMap, ExecGetRootToChildMap(), execute_attr_map_cols(), GetResultRTEPermissionInfo(), RTEPermissionInfo::insertedCols, and ResultRelInfo::ri_RootResultRelInfo.

Referenced by build_tuple_value_details(), ExecConstraints(), ExecPartitionCheckEmitError(), ExecWithCheckOptions(), and ReportNotNullViolationError().

◆ ExecGetRangeTableRelation()

Relation ExecGetRangeTableRelation ( EState estate,
Index  rti,
bool  isResultRel 
)

Definition at line 826 of file execUtils.c.

827{
828 Relation rel;
829
830 Assert(rti > 0 && rti <= estate->es_range_table_size);
831
832 if (!isResultRel && !bms_is_member(rti, estate->es_unpruned_relids))
833 elog(ERROR, "trying to open a pruned relation");
834
835 rel = estate->es_relations[rti - 1];
836 if (rel == NULL)
837 {
838 /* First time through, so open the relation */
839 RangeTblEntry *rte = exec_rt_fetch(rti, estate);
840
841 Assert(rte->rtekind == RTE_RELATION);
842
843 if (!IsParallelWorker())
844 {
845 /*
846 * In a normal query, we should already have the appropriate lock,
847 * but verify that through an Assert. Since there's already an
848 * Assert inside table_open that insists on holding some lock, it
849 * seems sufficient to check this only when rellockmode is higher
850 * than the minimum.
851 */
852 rel = table_open(rte->relid, NoLock);
853 Assert(rte->rellockmode == AccessShareLock ||
854 CheckRelationLockedByMe(rel, rte->rellockmode, false));
855 }
856 else
857 {
858 /*
859 * If we are a parallel worker, we need to obtain our own local
860 * lock on the relation. This ensures sane behavior in case the
861 * parent process exits before we do.
862 */
863 rel = table_open(rte->relid, rte->rellockmode);
864 }
865
866 estate->es_relations[rti - 1] = rel;
867 }
868
869 return rel;
870}
bool bms_is_member(int x, const Bitmapset *a)
Definition: bitmapset.c:510
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
Definition: executor.h:719
Assert(PointerIsAligned(start, uint64))
#define IsParallelWorker()
Definition: parallel.h:60
bool CheckRelationLockedByMe(Relation relation, LOCKMODE lockmode, bool orstronger)
Definition: lmgr.c:334
#define NoLock
Definition: lockdefs.h:34
#define AccessShareLock
Definition: lockdefs.h:36
@ RTE_RELATION
Definition: parsenodes.h:1026
Bitmapset * es_unpruned_relids
Definition: execnodes.h:671
RTEKind rtekind
Definition: parsenodes.h:1061
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:40

References AccessShareLock, Assert(), bms_is_member(), CheckRelationLockedByMe(), elog, ERROR, EState::es_relations, EState::es_unpruned_relids, exec_rt_fetch(), IsParallelWorker, NoLock, RTE_RELATION, RangeTblEntry::rtekind, and table_open().

Referenced by CreatePartitionPruneState(), ExecInitResultRelation(), ExecOpenScanRelation(), and InitPlan().

◆ ExecGetResultRelCheckAsUser()

Oid ExecGetResultRelCheckAsUser ( ResultRelInfo relInfo,
EState estate 
)

Definition at line 1490 of file execUtils.c.

1491{
1492 RTEPermissionInfo *perminfo = GetResultRTEPermissionInfo(relInfo, estate);
1493
1494 /* XXX - maybe ok to return GetUserId() in this case? */
1495 if (perminfo == NULL)
1496 elog(ERROR, "no RTEPermissionInfo found for result relation with OID %u",
1498
1499 return perminfo->checkAsUser ? perminfo->checkAsUser : GetUserId();
1500}
Oid GetUserId(void)
Definition: miscinit.c:520
#define RelationGetRelid(relation)
Definition: rel.h:516

References RTEPermissionInfo::checkAsUser, elog, ERROR, GetResultRTEPermissionInfo(), GetUserId(), RelationGetRelid, and ResultRelInfo::ri_RelationDesc.

Referenced by create_foreign_modify().

◆ ExecGetResultSlotOps()

const TupleTableSlotOps * ExecGetResultSlotOps ( PlanState planstate,
bool *  isfixed 
)

Definition at line 505 of file execUtils.c.

506{
507 if (planstate->resultopsset && planstate->resultops)
508 {
509 if (isfixed)
510 *isfixed = planstate->resultopsfixed;
511 return planstate->resultops;
512 }
513
514 if (isfixed)
515 {
516 if (planstate->resultopsset)
517 *isfixed = planstate->resultopsfixed;
518 else if (planstate->ps_ResultTupleSlot)
519 *isfixed = TTS_FIXED(planstate->ps_ResultTupleSlot);
520 else
521 *isfixed = false;
522 }
523
524 if (!planstate->ps_ResultTupleSlot)
525 return &TTSOpsVirtual;
526
527 return planstate->ps_ResultTupleSlot->tts_ops;
528}
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:121
#define TTS_FIXED(slot)
Definition: tuptable.h:108

References PlanState::ps_ResultTupleSlot, PlanState::resultops, PlanState::resultopsfixed, PlanState::resultopsset, TTS_FIXED, TupleTableSlot::tts_ops, and TTSOpsVirtual.

Referenced by ExecComputeSlotInfo(), ExecGetCommonSlotOps(), ExecInitAgg(), ExecInitGroup(), ExecInitHashJoin(), ExecInitLimit(), ExecInitLockRows(), ExecInitMergeJoin(), and ExecInitSubqueryScan().

◆ ExecGetResultType()

◆ ExecGetReturningSlot()

TupleTableSlot * ExecGetReturningSlot ( EState estate,
ResultRelInfo relInfo 
)

Definition at line 1249 of file execUtils.c.

1250{
1251 if (relInfo->ri_ReturningSlot == NULL)
1252 {
1253 Relation rel = relInfo->ri_RelationDesc;
1254 MemoryContext oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
1255
1256 relInfo->ri_ReturningSlot =
1258 RelationGetDescr(rel),
1260
1261 MemoryContextSwitchTo(oldcontext);
1262 }
1263
1264 return relInfo->ri_ReturningSlot;
1265}
TupleTableSlot * ri_ReturningSlot
Definition: execnodes.h:522

References EState::es_query_cxt, ExecInitExtraTupleSlot(), MemoryContextSwitchTo(), RelationGetDescr, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_ReturningSlot, and table_slot_callbacks().

Referenced by apply_returning_filter(), ExecDelete(), and ExecInsert().

◆ ExecGetRootToChildMap()

TupleConversionMap * ExecGetRootToChildMap ( ResultRelInfo resultRelInfo,
EState estate 
)

Definition at line 1327 of file execUtils.c.

1328{
1329 /* Mustn't get called for a non-child result relation. */
1330 Assert(resultRelInfo->ri_RootResultRelInfo);
1331
1332 /* If we didn't already do so, compute the map for this child. */
1333 if (!resultRelInfo->ri_RootToChildMapValid)
1334 {
1335 ResultRelInfo *rootRelInfo = resultRelInfo->ri_RootResultRelInfo;
1336 TupleDesc indesc = RelationGetDescr(rootRelInfo->ri_RelationDesc);
1337 TupleDesc outdesc = RelationGetDescr(resultRelInfo->ri_RelationDesc);
1338 Relation childrel = resultRelInfo->ri_RelationDesc;
1339 AttrMap *attrMap;
1340 MemoryContext oldcontext;
1341
1342 /*
1343 * When this child table is not a partition (!relispartition), it may
1344 * have columns that are not present in the root table, which we ask
1345 * to ignore by passing true for missing_ok.
1346 */
1347 oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
1348 attrMap = build_attrmap_by_name_if_req(indesc, outdesc,
1349 !childrel->rd_rel->relispartition);
1350 if (attrMap)
1351 resultRelInfo->ri_RootToChildMap =
1352 convert_tuples_by_name_attrmap(indesc, outdesc, attrMap);
1353 MemoryContextSwitchTo(oldcontext);
1354 resultRelInfo->ri_RootToChildMapValid = true;
1355 }
1356
1357 return resultRelInfo->ri_RootToChildMap;
1358}
AttrMap * build_attrmap_by_name_if_req(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
Definition: attmap.c:261
Definition: attmap.h:35
Form_pg_class rd_rel
Definition: rel.h:111
TupleConversionMap * ri_RootToChildMap
Definition: execnodes.h:601
bool ri_RootToChildMapValid
Definition: execnodes.h:602
TupleConversionMap * convert_tuples_by_name_attrmap(TupleDesc indesc, TupleDesc outdesc, AttrMap *attrMap)
Definition: tupconvert.c:124

References Assert(), build_attrmap_by_name_if_req(), convert_tuples_by_name_attrmap(), EState::es_query_cxt, MemoryContextSwitchTo(), RelationData::rd_rel, RelationGetDescr, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_RootResultRelInfo, ResultRelInfo::ri_RootToChildMap, and ResultRelInfo::ri_RootToChildMapValid.

Referenced by apply_handle_tuple_routing(), CopyFrom(), ExecFindPartition(), ExecGetInsertedCols(), ExecGetUpdatedCols(), ExecInitPartitionInfo(), ExecInitRoutingInfo(), ExecInsert(), and ExecPrepareTupleRouting().

◆ ExecGetTriggerNewSlot()

TupleTableSlot * ExecGetTriggerNewSlot ( EState estate,
ResultRelInfo relInfo 
)

Definition at line 1227 of file execUtils.c.

1228{
1229 if (relInfo->ri_TrigNewSlot == NULL)
1230 {
1231 Relation rel = relInfo->ri_RelationDesc;
1232 MemoryContext oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
1233
1234 relInfo->ri_TrigNewSlot =
1236 RelationGetDescr(rel),
1238
1239 MemoryContextSwitchTo(oldcontext);
1240 }
1241
1242 return relInfo->ri_TrigNewSlot;
1243}
TupleTableSlot * ri_TrigNewSlot
Definition: execnodes.h:524

References EState::es_query_cxt, ExecInitExtraTupleSlot(), MemoryContextSwitchTo(), RelationGetDescr, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_TrigNewSlot, and table_slot_callbacks().

Referenced by AfterTriggerExecute(), and AfterTriggerSaveEvent().

◆ ExecGetTriggerOldSlot()

TupleTableSlot * ExecGetTriggerOldSlot ( EState estate,
ResultRelInfo relInfo 
)

◆ ExecGetUpdatedCols()

Bitmapset * ExecGetUpdatedCols ( ResultRelInfo relinfo,
EState estate 
)

Definition at line 1383 of file execUtils.c.

1384{
1385 RTEPermissionInfo *perminfo = GetResultRTEPermissionInfo(relinfo, estate);
1386
1387 if (perminfo == NULL)
1388 return NULL;
1389
1390 /* Map the columns to child's attribute numbers if needed. */
1391 if (relinfo->ri_RootResultRelInfo)
1392 {
1393 TupleConversionMap *map = ExecGetRootToChildMap(relinfo, estate);
1394
1395 if (map)
1396 return execute_attr_map_cols(map->attrMap, perminfo->updatedCols);
1397 }
1398
1399 return perminfo->updatedCols;
1400}
Bitmapset * updatedCols
Definition: parsenodes.h:1309

References TupleConversionMap::attrMap, ExecGetRootToChildMap(), execute_attr_map_cols(), GetResultRTEPermissionInfo(), ResultRelInfo::ri_RootResultRelInfo, and RTEPermissionInfo::updatedCols.

Referenced by build_tuple_value_details(), ExecConstraints(), ExecGetAllUpdatedCols(), ExecInitGenerated(), ExecPartitionCheckEmitError(), ExecWithCheckOptions(), index_unchanged_by_update(), and ReportNotNullViolationError().

◆ ExecInitRangeTable()

void ExecInitRangeTable ( EState estate,
List rangeTable,
List permInfos,
Bitmapset unpruned_relids 
)

Definition at line 774 of file execUtils.c.

776{
777 /* Remember the range table List as-is */
778 estate->es_range_table = rangeTable;
779
780 /* ... and the RTEPermissionInfo List too */
781 estate->es_rteperminfos = permInfos;
782
783 /* Set size of associated arrays */
784 estate->es_range_table_size = list_length(rangeTable);
785
786 /*
787 * Initialize the bitmapset of RT indexes (es_unpruned_relids)
788 * representing relations that will be scanned during execution. This set
789 * is initially populated by the caller and may be extended later by
790 * ExecDoInitialPruning() to include RT indexes of unpruned leaf
791 * partitions.
792 */
793 estate->es_unpruned_relids = unpruned_relids;
794
795 /*
796 * Allocate an array to store an open Relation corresponding to each
797 * rangetable entry, and initialize entries to NULL. Relations are opened
798 * and stored here as needed.
799 */
800 estate->es_relations = (Relation *)
801 palloc0(estate->es_range_table_size * sizeof(Relation));
802
803 /*
804 * es_result_relations and es_rowmarks are also parallel to
805 * es_range_table, but are allocated only if needed.
806 */
807 estate->es_result_relations = NULL;
808 estate->es_rowmarks = NULL;
809}
void * palloc0(Size size)
Definition: mcxt.c:1347
static int list_length(const List *l)
Definition: pg_list.h:152

References EState::es_range_table, EState::es_range_table_size, EState::es_relations, EState::es_result_relations, EState::es_rowmarks, EState::es_rteperminfos, EState::es_unpruned_relids, list_length(), and palloc0().

Referenced by CopyFrom(), create_edata_for_relation(), create_estate_for_relation(), and InitPlan().

◆ ExecInitResultRelation()

void ExecInitResultRelation ( EState estate,
ResultRelInfo resultRelInfo,
Index  rti 
)

Definition at line 881 of file execUtils.c.

883{
884 Relation resultRelationDesc;
885
886 resultRelationDesc = ExecGetRangeTableRelation(estate, rti, true);
887 InitResultRelInfo(resultRelInfo,
888 resultRelationDesc,
889 rti,
890 NULL,
891 estate->es_instrument);
892
893 if (estate->es_result_relations == NULL)
895 palloc0(estate->es_range_table_size * sizeof(ResultRelInfo *));
896 estate->es_result_relations[rti - 1] = resultRelInfo;
897
898 /*
899 * Saving in the list allows to avoid needlessly traversing the whole
900 * array when only a few of its entries are possibly non-NULL.
901 */
903 lappend(estate->es_opened_result_relations, resultRelInfo);
904}
void InitResultRelInfo(ResultRelInfo *resultRelInfo, Relation resultRelationDesc, Index resultRelationIndex, ResultRelInfo *partition_root_rri, int instrument_options)
Definition: execMain.c:1329
Relation ExecGetRangeTableRelation(EState *estate, Index rti, bool isResultRel)
Definition: execUtils.c:826
List * lappend(List *list, void *datum)
Definition: list.c:339

References EState::es_instrument, EState::es_opened_result_relations, EState::es_range_table_size, EState::es_result_relations, ExecGetRangeTableRelation(), InitResultRelInfo(), lappend(), and palloc0().

Referenced by CopyFrom(), and ExecInitModifyTable().

◆ ExecOpenScanRelation()

Relation ExecOpenScanRelation ( EState estate,
Index  scanrelid,
int  eflags 
)

Definition at line 743 of file execUtils.c.

744{
745 Relation rel;
746
747 /* Open the relation. */
748 rel = ExecGetRangeTableRelation(estate, scanrelid, false);
749
750 /*
751 * Complain if we're attempting a scan of an unscannable relation, except
752 * when the query won't actually be run. This is a slightly klugy place
753 * to do this, perhaps, but there is no better place.
754 */
755 if ((eflags & (EXEC_FLAG_EXPLAIN_ONLY | EXEC_FLAG_WITH_NO_DATA)) == 0 &&
758 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
759 errmsg("materialized view \"%s\" has not been populated",
761 errhint("Use the REFRESH MATERIALIZED VIEW command.")));
762
763 return rel;
764}
int errhint(const char *fmt,...)
Definition: elog.c:1318
int errcode(int sqlerrcode)
Definition: elog.c:854
int errmsg(const char *fmt,...)
Definition: elog.c:1071
#define ereport(elevel,...)
Definition: elog.h:149
#define EXEC_FLAG_WITH_NO_DATA
Definition: executor.h:72
#define EXEC_FLAG_EXPLAIN_ONLY
Definition: executor.h:66
#define RelationIsScannable(relation)
Definition: rel.h:680
#define RelationGetRelationName(relation)
Definition: rel.h:550

References ereport, errcode(), errhint(), errmsg(), ERROR, EXEC_FLAG_EXPLAIN_ONLY, EXEC_FLAG_WITH_NO_DATA, ExecGetRangeTableRelation(), RelationGetRelationName, and RelationIsScannable.

Referenced by ExecInitBitmapHeapScan(), ExecInitCustomScan(), ExecInitForeignScan(), ExecInitIndexOnlyScan(), ExecInitIndexScan(), ExecInitSampleScan(), ExecInitSeqScan(), ExecInitTidRangeScan(), ExecInitTidScan(), and postgresBeginDirectModify().

◆ ExecRelationIsTargetRelation()

bool ExecRelationIsTargetRelation ( EState estate,
Index  scanrelid 
)

Definition at line 730 of file execUtils.c.

731{
732 return list_member_int(estate->es_plannedstmt->resultRelations, scanrelid);
733}
bool list_member_int(const List *list, int datum)
Definition: list.c:702
List * resultRelations
Definition: plannodes.h:106

References EState::es_plannedstmt, list_member_int(), and PlannedStmt::resultRelations.

◆ ExecTargetListLength()

int ExecTargetListLength ( List targetlist)

Definition at line 1176 of file execUtils.c.

1177{
1178 /* This used to be more complex, but fjoins are dead */
1179 return list_length(targetlist);
1180}

References list_length().

Referenced by ExecTypeFromTLInternal().

◆ executor_errposition()

int executor_errposition ( EState estate,
int  location 
)

Definition at line 937 of file execUtils.c.

938{
939 int pos;
940
941 /* No-op if location was not provided */
942 if (location < 0)
943 return 0;
944 /* Can't do anything if source text is not available */
945 if (estate == NULL || estate->es_sourceText == NULL)
946 return 0;
947 /* Convert offset to character number */
948 pos = pg_mbstrlen_with_len(estate->es_sourceText, location) + 1;
949 /* And pass it to the ereport mechanism */
950 return errposition(pos);
951}
int errposition(int cursorpos)
Definition: elog.c:1468
int pg_mbstrlen_with_len(const char *mbstr, int limit)
Definition: mbutils.c:1057

References errposition(), EState::es_sourceText, and pg_mbstrlen_with_len().

Referenced by ExecInitFunc(), ExecInitSubscriptingRef(), and init_sexpr().

◆ FreeExecutorState()

void FreeExecutorState ( EState estate)

Definition at line 193 of file execUtils.c.

194{
195 /*
196 * Shut down and free any remaining ExprContexts. We do this explicitly
197 * to ensure that any remaining shutdown callbacks get called (since they
198 * might need to release resources that aren't simply memory within the
199 * per-query memory context).
200 */
201 while (estate->es_exprcontexts)
202 {
203 /*
204 * XXX: seems there ought to be a faster way to implement this than
205 * repeated list_delete(), no?
206 */
208 true);
209 /* FreeExprContext removed the list link for us */
210 }
211
212 /* release JIT context, if allocated */
213 if (estate->es_jit)
214 {
216 estate->es_jit = NULL;
217 }
218
219 /* release partition directory, if allocated */
220 if (estate->es_partition_directory)
221 {
223 estate->es_partition_directory = NULL;
224 }
225
226 /*
227 * Free the per-query memory context, thereby releasing all working
228 * memory, including the EState node itself.
229 */
231}
void FreeExprContext(ExprContext *econtext, bool isCommit)
Definition: execUtils.c:417
void jit_release_context(JitContext *context)
Definition: jit.c:137
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:454
void DestroyPartitionDirectory(PartitionDirectory pdir)
Definition: partdesc.c:484
#define linitial(l)
Definition: pg_list.h:178
PartitionDirectory es_partition_directory
Definition: execnodes.h:690

References DestroyPartitionDirectory(), EState::es_exprcontexts, EState::es_jit, EState::es_partition_directory, EState::es_query_cxt, FreeExprContext(), jit_release_context(), linitial, and MemoryContextDelete().

Referenced by afterTriggerInvokeEvents(), ATExecAddColumn(), ATRewriteTable(), check_default_partition_contents(), compute_expr_stats(), compute_index_stats(), CopyFrom(), EvalPlanQualEnd(), evaluate_expr(), ExecuteCallStmt(), ExecuteQuery(), ExecuteTruncateGuts(), ExplainExecuteQuery(), finish_edata(), freestate_cluster(), get_qual_for_range(), heapam_index_build_range_scan(), heapam_index_validate_scan(), IndexCheckExclusion(), make_build_data(), operator_predicate_proof(), plpgsql_inline_handler(), plpgsql_xact_cb(), standard_ExecutorEnd(), and validateDomainCheckConstraint().

◆ FreeExprContext()

void FreeExprContext ( ExprContext econtext,
bool  isCommit 
)

Definition at line 417 of file execUtils.c.

418{
419 EState *estate;
420
421 /* Call any registered callbacks */
422 ShutdownExprContext(econtext, isCommit);
423 /* And clean up the memory used */
425 /* Unlink self from owning EState, if any */
426 estate = econtext->ecxt_estate;
427 if (estate)
429 econtext);
430 /* And delete the ExprContext node */
431 pfree(econtext);
432}
static void ShutdownExprContext(ExprContext *econtext, bool isCommit)
Definition: execUtils.c:1021
List * list_delete_ptr(List *list, void *datum)
Definition: list.c:872
void pfree(void *pointer)
Definition: mcxt.c:1524

References ExprContext::ecxt_estate, ExprContext::ecxt_per_tuple_memory, EState::es_exprcontexts, list_delete_ptr(), MemoryContextDelete(), pfree(), and ShutdownExprContext().

Referenced by FreeExecutorState(), plpgsql_destroy_econtext(), and plpgsql_subxact_cb().

◆ GetAttributeByName()

Datum GetAttributeByName ( HeapTupleHeader  tuple,
const char *  attname,
bool *  isNull 
)

Definition at line 1062 of file execUtils.c.

1063{
1064 AttrNumber attrno;
1065 Datum result;
1066 Oid tupType;
1067 int32 tupTypmod;
1068 TupleDesc tupDesc;
1069 HeapTupleData tmptup;
1070 int i;
1071
1072 if (attname == NULL)
1073 elog(ERROR, "invalid attribute name");
1074
1075 if (isNull == NULL)
1076 elog(ERROR, "a NULL isNull pointer was passed");
1077
1078 if (tuple == NULL)
1079 {
1080 /* Kinda bogus but compatible with old behavior... */
1081 *isNull = true;
1082 return (Datum) 0;
1083 }
1084
1085 tupType = HeapTupleHeaderGetTypeId(tuple);
1086 tupTypmod = HeapTupleHeaderGetTypMod(tuple);
1087 tupDesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
1088
1089 attrno = InvalidAttrNumber;
1090 for (i = 0; i < tupDesc->natts; i++)
1091 {
1092 Form_pg_attribute att = TupleDescAttr(tupDesc, i);
1093
1094 if (namestrcmp(&(att->attname), attname) == 0)
1095 {
1096 attrno = att->attnum;
1097 break;
1098 }
1099 }
1100
1101 if (attrno == InvalidAttrNumber)
1102 elog(ERROR, "attribute \"%s\" does not exist", attname);
1103
1104 /*
1105 * heap_getattr needs a HeapTuple not a bare HeapTupleHeader. We set all
1106 * the fields in the struct just in case user tries to inspect system
1107 * columns.
1108 */
1109 tmptup.t_len = HeapTupleHeaderGetDatumLength(tuple);
1110 ItemPointerSetInvalid(&(tmptup.t_self));
1111 tmptup.t_tableOid = InvalidOid;
1112 tmptup.t_data = tuple;
1113
1114 result = heap_getattr(&tmptup,
1115 attrno,
1116 tupDesc,
1117 isNull);
1118
1119 ReleaseTupleDesc(tupDesc);
1120
1121 return result;
1122}
int16 AttrNumber
Definition: attnum.h:21
#define InvalidAttrNumber
Definition: attnum.h:23
int32_t int32
Definition: c.h:498
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
Definition: htup_details.h:904
static int32 HeapTupleHeaderGetTypMod(const HeapTupleHeaderData *tup)
Definition: htup_details.h:516
static uint32 HeapTupleHeaderGetDatumLength(const HeapTupleHeaderData *tup)
Definition: htup_details.h:492
static Oid HeapTupleHeaderGetTypeId(const HeapTupleHeaderData *tup)
Definition: htup_details.h:504
static void ItemPointerSetInvalid(ItemPointerData *pointer)
Definition: itemptr.h:184
int namestrcmp(Name name, const char *str)
Definition: name.c:247
NameData attname
Definition: pg_attribute.h:41
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:202
#define InvalidOid
Definition: postgres_ext.h:35
unsigned int Oid
Definition: postgres_ext.h:30
ItemPointerData t_self
Definition: htup.h:65
uint32 t_len
Definition: htup.h:64
HeapTupleHeader t_data
Definition: htup.h:68
Oid t_tableOid
Definition: htup.h:66
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:219
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition: tupdesc.h:160
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
Definition: typcache.c:1922

References attname, elog, ERROR, heap_getattr(), HeapTupleHeaderGetDatumLength(), HeapTupleHeaderGetTypeId(), HeapTupleHeaderGetTypMod(), i, InvalidAttrNumber, InvalidOid, ItemPointerSetInvalid(), lookup_rowtype_tupdesc(), namestrcmp(), TupleDescData::natts, ReleaseTupleDesc, HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, HeapTupleData::t_tableOid, and TupleDescAttr().

Referenced by c_overpaid(), and overpaid().

◆ GetAttributeByNum()

Datum GetAttributeByNum ( HeapTupleHeader  tuple,
AttrNumber  attrno,
bool *  isNull 
)

Definition at line 1125 of file execUtils.c.

1128{
1129 Datum result;
1130 Oid tupType;
1131 int32 tupTypmod;
1132 TupleDesc tupDesc;
1133 HeapTupleData tmptup;
1134
1135 if (!AttributeNumberIsValid(attrno))
1136 elog(ERROR, "invalid attribute number %d", attrno);
1137
1138 if (isNull == NULL)
1139 elog(ERROR, "a NULL isNull pointer was passed");
1140
1141 if (tuple == NULL)
1142 {
1143 /* Kinda bogus but compatible with old behavior... */
1144 *isNull = true;
1145 return (Datum) 0;
1146 }
1147
1148 tupType = HeapTupleHeaderGetTypeId(tuple);
1149 tupTypmod = HeapTupleHeaderGetTypMod(tuple);
1150 tupDesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
1151
1152 /*
1153 * heap_getattr needs a HeapTuple not a bare HeapTupleHeader. We set all
1154 * the fields in the struct just in case user tries to inspect system
1155 * columns.
1156 */
1157 tmptup.t_len = HeapTupleHeaderGetDatumLength(tuple);
1158 ItemPointerSetInvalid(&(tmptup.t_self));
1159 tmptup.t_tableOid = InvalidOid;
1160 tmptup.t_data = tuple;
1161
1162 result = heap_getattr(&tmptup,
1163 attrno,
1164 tupDesc,
1165 isNull);
1166
1167 ReleaseTupleDesc(tupDesc);
1168
1169 return result;
1170}
#define AttributeNumberIsValid(attributeNumber)
Definition: attnum.h:34

References AttributeNumberIsValid, elog, ERROR, heap_getattr(), HeapTupleHeaderGetDatumLength(), HeapTupleHeaderGetTypeId(), HeapTupleHeaderGetTypMod(), InvalidOid, ItemPointerSetInvalid(), lookup_rowtype_tupdesc(), ReleaseTupleDesc, HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, and HeapTupleData::t_tableOid.

◆ GetResultRTEPermissionInfo()

static RTEPermissionInfo * GetResultRTEPermissionInfo ( ResultRelInfo relinfo,
EState estate 
)
static

Definition at line 1439 of file execUtils.c.

1440{
1441 Index rti;
1442 RangeTblEntry *rte;
1443 RTEPermissionInfo *perminfo = NULL;
1444
1445 if (relinfo->ri_RootResultRelInfo)
1446 {
1447 /*
1448 * For inheritance child result relations (a partition routing target
1449 * of an INSERT or a child UPDATE target), this returns the root
1450 * parent's RTE to fetch the RTEPermissionInfo because that's the only
1451 * one that has one assigned.
1452 */
1454 }
1455 else if (relinfo->ri_RangeTableIndex != 0)
1456 {
1457 /*
1458 * Non-child result relation should have their own RTEPermissionInfo.
1459 */
1460 rti = relinfo->ri_RangeTableIndex;
1461 }
1462 else
1463 {
1464 /*
1465 * The relation isn't in the range table and it isn't a partition
1466 * routing target. This ResultRelInfo must've been created only for
1467 * firing triggers and the relation is not being inserted into. (See
1468 * ExecGetTriggerResultRel.)
1469 */
1470 rti = 0;
1471 }
1472
1473 if (rti > 0)
1474 {
1475 rte = exec_rt_fetch(rti, estate);
1476 perminfo = getRTEPermissionInfo(estate->es_rteperminfos, rte);
1477 }
1478
1479 return perminfo;
1480}
unsigned int Index
Definition: c.h:585
RTEPermissionInfo * getRTEPermissionInfo(List *rteperminfos, RangeTblEntry *rte)
Index ri_RangeTableIndex
Definition: execnodes.h:472

References EState::es_rteperminfos, exec_rt_fetch(), getRTEPermissionInfo(), ResultRelInfo::ri_RangeTableIndex, and ResultRelInfo::ri_RootResultRelInfo.

Referenced by ExecGetInsertedCols(), ExecGetResultRelCheckAsUser(), and ExecGetUpdatedCols().

◆ MakePerTupleExprContext()

ExprContext * MakePerTupleExprContext ( EState estate)

Definition at line 459 of file execUtils.c.

460{
461 if (estate->es_per_tuple_exprcontext == NULL)
463
464 return estate->es_per_tuple_exprcontext;
465}

References CreateExprContext(), and EState::es_per_tuple_exprcontext.

◆ RegisterExprContextCallback()

void RegisterExprContextCallback ( ExprContext econtext,
ExprContextCallbackFunction  function,
Datum  arg 
)

Definition at line 964 of file execUtils.c.

967{
968 ExprContext_CB *ecxt_callback;
969
970 /* Save the info in appropriate memory context */
971 ecxt_callback = (ExprContext_CB *)
973 sizeof(ExprContext_CB));
974
975 ecxt_callback->function = function;
976 ecxt_callback->arg = arg;
977
978 /* link to front of list for appropriate execution order */
979 ecxt_callback->next = econtext->ecxt_callbacks;
980 econtext->ecxt_callbacks = ecxt_callback;
981}
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:1181
on_exit_nicely_callback function
void * arg
struct ExprContext_CB * next
Definition: execnodes.h:234
ExprContextCallbackFunction function
Definition: execnodes.h:235

References arg, ExprContext_CB::arg, ExprContext::ecxt_callbacks, ExprContext::ecxt_per_query_memory, function, ExprContext_CB::function, MemoryContextAlloc(), and ExprContext_CB::next.

Referenced by AggRegisterCallback(), ExecMakeFunctionResultSet(), ExecPrepareTuplestoreResult(), fmgr_sql(), and init_MultiFuncCall().

◆ ReScanExprContext()

void ReScanExprContext ( ExprContext econtext)

Definition at line 444 of file execUtils.c.

445{
446 /* Call any registered callbacks */
447 ShutdownExprContext(econtext, true);
448 /* And clean up the memory used */
450}
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:383

References ExprContext::ecxt_per_tuple_memory, MemoryContextReset(), and ShutdownExprContext().

Referenced by agg_refill_hash_table(), agg_retrieve_direct(), domain_check_input(), ExecEndAgg(), ExecReScan(), ExecReScanAgg(), and ValuesNext().

◆ ShutdownExprContext()

static void ShutdownExprContext ( ExprContext econtext,
bool  isCommit 
)
static

Definition at line 1021 of file execUtils.c.

1022{
1023 ExprContext_CB *ecxt_callback;
1024 MemoryContext oldcontext;
1025
1026 /* Fast path in normal case where there's nothing to do. */
1027 if (econtext->ecxt_callbacks == NULL)
1028 return;
1029
1030 /*
1031 * Call the callbacks in econtext's per-tuple context. This ensures that
1032 * any memory they might leak will get cleaned up.
1033 */
1034 oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
1035
1036 /*
1037 * Call each callback function in reverse registration order.
1038 */
1039 while ((ecxt_callback = econtext->ecxt_callbacks) != NULL)
1040 {
1041 econtext->ecxt_callbacks = ecxt_callback->next;
1042 if (isCommit)
1043 ecxt_callback->function(ecxt_callback->arg);
1044 pfree(ecxt_callback);
1045 }
1046
1047 MemoryContextSwitchTo(oldcontext);
1048}

References ExprContext_CB::arg, ExprContext::ecxt_callbacks, ExprContext::ecxt_per_tuple_memory, ExprContext_CB::function, MemoryContextSwitchTo(), ExprContext_CB::next, and pfree().

Referenced by FreeExprContext(), and ReScanExprContext().

◆ tlist_matches_tupdesc()

static bool tlist_matches_tupdesc ( PlanState ps,
List tlist,
int  varno,
TupleDesc  tupdesc 
)
static

Definition at line 631 of file execUtils.c.

632{
633 int numattrs = tupdesc->natts;
634 int attrno;
635 ListCell *tlist_item = list_head(tlist);
636
637 /* Check the tlist attributes */
638 for (attrno = 1; attrno <= numattrs; attrno++)
639 {
640 Form_pg_attribute att_tup = TupleDescAttr(tupdesc, attrno - 1);
641 Var *var;
642
643 if (tlist_item == NULL)
644 return false; /* tlist too short */
645 var = (Var *) ((TargetEntry *) lfirst(tlist_item))->expr;
646 if (!var || !IsA(var, Var))
647 return false; /* tlist item not a Var */
648 /* if these Asserts fail, planner messed up */
649 Assert(var->varno == varno);
650 Assert(var->varlevelsup == 0);
651 if (var->varattno != attrno)
652 return false; /* out of order */
653 if (att_tup->attisdropped)
654 return false; /* table contains dropped columns */
655 if (att_tup->atthasmissing)
656 return false; /* table contains cols with missing values */
657
658 /*
659 * Note: usually the Var's type should match the tupdesc exactly, but
660 * in situations involving unions of columns that have different
661 * typmods, the Var may have come from above the union and hence have
662 * typmod -1. This is a legitimate situation since the Var still
663 * describes the column, just not as exactly as the tupdesc does. We
664 * could change the planner to prevent it, but it'd then insert
665 * projection steps just to convert from specific typmod to typmod -1,
666 * which is pretty silly.
667 */
668 if (var->vartype != att_tup->atttypid ||
669 (var->vartypmod != att_tup->atttypmod &&
670 var->vartypmod != -1))
671 return false; /* type mismatch */
672
673 tlist_item = lnext(tlist, tlist_item);
674 }
675
676 if (tlist_item)
677 return false; /* tlist too long */
678
679 return true;
680}
#define IsA(nodeptr, _type_)
Definition: nodes.h:164
#define lfirst(lc)
Definition: pg_list.h:172
static ListCell * list_head(const List *l)
Definition: pg_list.h:128
static ListCell * lnext(const List *l, const ListCell *c)
Definition: pg_list.h:343
Definition: primnodes.h:262
AttrNumber varattno
Definition: primnodes.h:274
int varno
Definition: primnodes.h:269
Index varlevelsup
Definition: primnodes.h:294

References Assert(), IsA, lfirst, list_head(), lnext(), TupleDescData::natts, TupleDescAttr(), Var::varattno, Var::varlevelsup, and Var::varno.

Referenced by ExecConditionalAssignProjectionInfo().

◆ UnregisterExprContextCallback()

void UnregisterExprContextCallback ( ExprContext econtext,
ExprContextCallbackFunction  function,
Datum  arg 
)

Definition at line 990 of file execUtils.c.

993{
994 ExprContext_CB **prev_callback;
995 ExprContext_CB *ecxt_callback;
996
997 prev_callback = &econtext->ecxt_callbacks;
998
999 while ((ecxt_callback = *prev_callback) != NULL)
1000 {
1001 if (ecxt_callback->function == function && ecxt_callback->arg == arg)
1002 {
1003 *prev_callback = ecxt_callback->next;
1004 pfree(ecxt_callback);
1005 }
1006 else
1007 prev_callback = &ecxt_callback->next;
1008 }
1009}

References arg, ExprContext_CB::arg, ExprContext::ecxt_callbacks, function, ExprContext_CB::function, ExprContext_CB::next, and pfree().

Referenced by end_MultiFuncCall(), and fmgr_sql().

◆ UpdateChangedParamSet()

void UpdateChangedParamSet ( PlanState node,
Bitmapset newchg 
)

Definition at line 911 of file execUtils.c.

912{
913 Bitmapset *parmset;
914
915 /*
916 * The plan node only depends on params listed in its allParam set. Don't
917 * include anything else into its chgParam set.
918 */
919 parmset = bms_intersect(node->plan->allParam, newchg);
920 node->chgParam = bms_join(node->chgParam, parmset);
921}
Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:292
Bitmapset * bms_join(Bitmapset *a, Bitmapset *b)
Definition: bitmapset.c:1230
Bitmapset * chgParam
Definition: execnodes.h:1191
Bitmapset * allParam
Definition: plannodes.h:230

References Plan::allParam, bms_intersect(), bms_join(), PlanState::chgParam, and PlanState::plan.

Referenced by ExecReScan(), ExecReScanAppend(), ExecReScanBitmapAnd(), ExecReScanBitmapOr(), ExecReScanMergeAppend(), and ExecReScanSubqueryScan().