PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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)
extern

Definition at line 252 of file nodeGather.c.

253{
254 ExecEndNode(outerPlanState(node)); /* let children clean up first */
255 ExecShutdownGather(node);
256}
void ExecEndNode(PlanState *node)
#define outerPlanState(node)
Definition execnodes.h:1264
void ExecShutdownGather(GatherState *node)
Definition nodeGather.c:419

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

Referenced by ExecEndNode().

◆ ExecInitGather()

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

Definition at line 54 of file nodeGather.c.

55{
58 TupleDesc tupDesc;
59
60 /* Gather node doesn't have innerPlan node. */
61 Assert(innerPlan(node) == NULL);
62
63 /*
64 * create state structure
65 */
67 gatherstate->ps.plan = (Plan *) node;
68 gatherstate->ps.state = estate;
69 gatherstate->ps.ExecProcNode = ExecGather;
70
71 gatherstate->initialized = false;
72 gatherstate->need_to_scan_locally =
74 gatherstate->tuples_needed = -1;
75
76 /*
77 * Miscellaneous initialization
78 *
79 * create expression context for node
80 */
82
83 /*
84 * now initialize outer plan
85 */
86 outerNode = outerPlan(node);
89
90 /*
91 * Leader may access ExecProcNode result directly (if
92 * need_to_scan_locally), or from workers via tuple queue. So we can't
93 * trivially rely on the slot type being fixed for expressions evaluated
94 * within this node.
95 */
96 gatherstate->ps.outeropsset = true;
97 gatherstate->ps.outeropsfixed = false;
98
99 /*
100 * Initialize result type and projection.
101 */
104
105 /*
106 * Without projections result slot type is not trivially known, see
107 * comment above.
108 */
109 if (gatherstate->ps.ps_ProjInfo == NULL)
110 {
111 gatherstate->ps.resultopsset = true;
112 gatherstate->ps.resultopsfixed = false;
113 }
114
115 /*
116 * Initialize funnel slot to same tuple descriptor as outer plan.
117 */
118 gatherstate->funnel_slot = ExecInitExtraTupleSlot(estate, tupDesc,
120
121 /*
122 * Gather doesn't support checking a qual (it's always more efficient to
123 * do it in the child node).
124 */
125 Assert(!node->plan.qual);
126
127 return gatherstate;
128}
#define Assert(condition)
Definition c.h:885
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
void ExecInitResultTypeTL(PlanState *planstate)
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
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:138
#define makeNode(_type_)
Definition nodes.h:161
bool parallel_leader_participation
Definition planner.c:70
#define innerPlan(node)
Definition plannodes.h:266
#define outerPlan(node)
Definition plannodes.h:267
static int fb(int x)
#define OUTER_VAR
Definition primnodes.h:244
bool single_copy
Definition plannodes.h:1362
Plan plan
Definition plannodes.h:1356
List * qual
Definition plannodes.h:237

References Assert, ExecAssignExprContext(), ExecConditionalAssignProjectionInfo(), ExecGather(), ExecGetResultType(), ExecInitExtraTupleSlot(), ExecInitNode(), ExecInitResultTypeTL(), fb(), innerPlan, makeNode, OUTER_VAR, outerPlan, outerPlanState, parallel_leader_participation, Gather::plan, Plan::qual, Gather::single_copy, and TTSOpsMinimalTuple.

Referenced by ExecInitNode().

◆ ExecReScanGather()

void ExecReScanGather ( GatherState node)
extern

Definition at line 443 of file nodeGather.c.

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

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

Referenced by ExecReScan().

◆ ExecShutdownGather()

void ExecShutdownGather ( GatherState node)
extern

Definition at line 419 of file nodeGather.c.

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

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

Referenced by ExecEndGather(), and ExecShutdownNode_walker().