PostgreSQL Source Code git master
nodeGather.h File Reference
#include "nodes/execnodes.h"
Include dependency graph for nodeGather.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

GatherStateExecInitGather (Gather *node, EState *estate, int eflags)
 
void ExecEndGather (GatherState *node)
 
void ExecShutdownGather (GatherState *node)
 
void ExecReScanGather (GatherState *node)
 

Function Documentation

◆ ExecEndGather()

void ExecEndGather ( GatherState node)

Definition at line 251 of file nodeGather.c.

252{
253 ExecEndNode(outerPlanState(node)); /* let children clean up first */
254 ExecShutdownGather(node);
255}
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:562
#define outerPlanState(node)
Definition: execnodes.h:1237
void ExecShutdownGather(GatherState *node)
Definition: nodeGather.c:418

References ExecEndNode(), ExecShutdownGather(), and outerPlanState.

Referenced by ExecEndNode().

◆ ExecInitGather()

GatherState * ExecInitGather ( Gather node,
EState estate,
int  eflags 
)

Definition at line 53 of file nodeGather.c.

54{
55 GatherState *gatherstate;
56 Plan *outerNode;
57 TupleDesc tupDesc;
58
59 /* Gather node doesn't have innerPlan node. */
60 Assert(innerPlan(node) == NULL);
61
62 /*
63 * create state structure
64 */
65 gatherstate = makeNode(GatherState);
66 gatherstate->ps.plan = (Plan *) node;
67 gatherstate->ps.state = estate;
68 gatherstate->ps.ExecProcNode = ExecGather;
69
70 gatherstate->initialized = false;
71 gatherstate->need_to_scan_locally =
73 gatherstate->tuples_needed = -1;
74
75 /*
76 * Miscellaneous initialization
77 *
78 * create expression context for node
79 */
80 ExecAssignExprContext(estate, &gatherstate->ps);
81
82 /*
83 * now initialize outer plan
84 */
85 outerNode = outerPlan(node);
86 outerPlanState(gatherstate) = ExecInitNode(outerNode, estate, eflags);
87 tupDesc = ExecGetResultType(outerPlanState(gatherstate));
88
89 /*
90 * Leader may access ExecProcNode result directly (if
91 * need_to_scan_locally), or from workers via tuple queue. So we can't
92 * trivially rely on the slot type being fixed for expressions evaluated
93 * within this node.
94 */
95 gatherstate->ps.outeropsset = true;
96 gatherstate->ps.outeropsfixed = false;
97
98 /*
99 * Initialize result type and projection.
100 */
101 ExecInitResultTypeTL(&gatherstate->ps);
102 ExecConditionalAssignProjectionInfo(&gatherstate->ps, tupDesc, OUTER_VAR);
103
104 /*
105 * Without projections result slot type is not trivially known, see
106 * comment above.
107 */
108 if (gatherstate->ps.ps_ProjInfo == NULL)
109 {
110 gatherstate->ps.resultopsset = true;
111 gatherstate->ps.resultopsfixed = false;
112 }
113
114 /*
115 * Initialize funnel slot to same tuple descriptor as outer plan.
116 */
117 gatherstate->funnel_slot = ExecInitExtraTupleSlot(estate, tupDesc,
119
120 /*
121 * Gather doesn't support checking a qual (it's always more efficient to
122 * do it in the child node).
123 */
124 Assert(!node->plan.qual);
125
126 return gatherstate;
127}
#define Assert(condition)
Definition: c.h:815
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:142
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1942
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:2018
const TupleTableSlotOps TTSOpsMinimalTuple
Definition: execTuples.c:86
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:495
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:485
void ExecConditionalAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc, int varno)
Definition: execUtils.c:603
static TupleTableSlot * ExecGather(PlanState *pstate)
Definition: nodeGather.c:137
#define makeNode(_type_)
Definition: nodes.h:155
bool parallel_leader_participation
Definition: planner.c:68
#define innerPlan(node)
Definition: plannodes.h:182
#define outerPlan(node)
Definition: plannodes.h:183
#define OUTER_VAR
Definition: primnodes.h:242
bool initialized
Definition: execnodes.h:2718
TupleTableSlot * funnel_slot
Definition: execnodes.h:2722
PlanState ps
Definition: execnodes.h:2717
int64 tuples_needed
Definition: execnodes.h:2720
bool need_to_scan_locally
Definition: execnodes.h:2719
bool single_copy
Definition: plannodes.h:1148
Plan plan
Definition: plannodes.h:1145
bool outeropsset
Definition: execnodes.h:1224
bool resultopsset
Definition: execnodes.h:1226
Plan * plan
Definition: execnodes.h:1141
bool outeropsfixed
Definition: execnodes.h:1220
EState * state
Definition: execnodes.h:1143
ProjectionInfo * ps_ProjInfo
Definition: execnodes.h:1181
bool resultopsfixed
Definition: execnodes.h:1222
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1147
List * qual
Definition: plannodes.h:154

References Assert, ExecAssignExprContext(), ExecConditionalAssignProjectionInfo(), ExecGather(), ExecGetResultType(), ExecInitExtraTupleSlot(), ExecInitNode(), ExecInitResultTypeTL(), PlanState::ExecProcNode, GatherState::funnel_slot, GatherState::initialized, innerPlan, makeNode, GatherState::need_to_scan_locally, OUTER_VAR, PlanState::outeropsfixed, PlanState::outeropsset, outerPlan, outerPlanState, parallel_leader_participation, PlanState::plan, Gather::plan, GatherState::ps, PlanState::ps_ProjInfo, Plan::qual, PlanState::resultopsfixed, PlanState::resultopsset, Gather::single_copy, PlanState::state, TTSOpsMinimalTuple, and GatherState::tuples_needed.

Referenced by ExecInitNode().

◆ ExecReScanGather()

void ExecReScanGather ( GatherState node)

Definition at line 442 of file nodeGather.c.

443{
444 Gather *gather = (Gather *) node->ps.plan;
446
447 /* Make sure any existing workers are gracefully shut down */
449
450 /* Mark node so that shared state will be rebuilt at next call */
451 node->initialized = false;
452
453 /*
454 * Set child node's chgParam to tell it that the next scan might deliver a
455 * different set of rows within the leader process. (The overall rowset
456 * shouldn't change, but the leader process's subset might; hence nodes
457 * between here and the parallel table scan node mustn't optimize on the
458 * assumption of an unchanging rowset.)
459 */
460 if (gather->rescan_param >= 0)
461 outerPlan->chgParam = bms_add_member(outerPlan->chgParam,
462 gather->rescan_param);
463
464 /*
465 * If chgParam of subnode is not null then plan will be re-scanned by
466 * first ExecProcNode. Note: because this does nothing if we have a
467 * rescan_param, it's currently guaranteed that parallel-aware child nodes
468 * will not see a ReScan call until after they get a ReInitializeDSM call.
469 * That ordering might not be something to rely on, though. A good rule
470 * of thumb is that ReInitializeDSM should reset only shared state, ReScan
471 * should reset only local state, and anything that depends on both of
472 * those steps being finished must wait until the first ExecProcNode call.
473 */
474 if (outerPlan->chgParam == NULL)
476}
Bitmapset * bms_add_member(Bitmapset *a, int x)
Definition: bitmapset.c:815
void ExecReScan(PlanState *node)
Definition: execAmi.c:76
static void ExecShutdownGatherWorkers(GatherState *node)
Definition: nodeGather.c:400
int rescan_param
Definition: plannodes.h:1147

References bms_add_member(), ExecReScan(), ExecShutdownGatherWorkers(), GatherState::initialized, outerPlan, outerPlanState, PlanState::plan, GatherState::ps, and Gather::rescan_param.

Referenced by ExecReScan().

◆ ExecShutdownGather()

void ExecShutdownGather ( GatherState node)

Definition at line 418 of file nodeGather.c.

419{
421
422 /* Now destroy the parallel context. */
423 if (node->pei != NULL)
424 {
426 node->pei = NULL;
427 }
428}
void ExecParallelCleanup(ParallelExecutorInfo *pei)
struct ParallelExecutorInfo * pei
Definition: execnodes.h:2723

References ExecParallelCleanup(), ExecShutdownGatherWorkers(), and GatherState::pei.

Referenced by ExecEndGather(), and ExecShutdownNode_walker().