MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecInitAppend

Function ExecInitAppend

src/backend/executor/nodeAppend.c:109–292  ·  view source on GitHub ↗

---------------------------------------------------------------- * ExecInitAppend * * Begin all of the subscans of the append node. * * (This is potentially wasteful, since the entire result of the * append node may not be scanned, but this way all of the * structures get allocated in the executor's top level memory * block instead of that of the call to ExecAppend.) * -----------

Source from the content-addressed store, hash-verified

107 * ----------------------------------------------------------------
108 */
109AppendState *
110ExecInitAppend(Append *node, EState *estate, int eflags)
111{
112 AppendState *appendstate = makeNode(AppendState);
113 PlanState **appendplanstates;
114 Bitmapset *validsubplans;
115 Bitmapset *asyncplans;
116 int nplans;
117 int nasyncplans;
118 int firstvalid;
119 int i,
120 j;
121
122 /* check for unsupported flags */
123 Assert(!(eflags & EXEC_FLAG_MARK));
124
125 /*
126 * create new AppendState for our append node
127 */
128 appendstate->ps.plan = (Plan *) node;
129 appendstate->ps.state = estate;
130 appendstate->ps.ExecProcNode = ExecAppend;
131
132 /* Let choose_next_subplan_* function handle setting the first subplan */
133 appendstate->as_whichplan = INVALID_SUBPLAN_INDEX;
134 appendstate->as_syncdone = false;
135 appendstate->as_begun = false;
136
137 /* If run-time partition pruning is enabled, then set that up now */
138 if (node->part_prune_info != NULL)
139 {
140 PartitionPruneState *prunestate;
141
142 /* We may need an expression context to evaluate partition exprs */
143 ExecAssignExprContext(estate, &appendstate->ps);
144
145 /* Create the working data structure for pruning. */
146 prunestate = ExecCreatePartitionPruneState(&appendstate->ps,
147 node->part_prune_info);
148 appendstate->as_prune_state = prunestate;
149
150 /* Perform an initial partition prune, if required. */
151 if (prunestate->do_initial_prune)
152 {
153 /* Determine which subplans survive initial pruning */
154 validsubplans = ExecFindInitialMatchingSubPlans(prunestate,
155 list_length(node->appendplans));
156
157 nplans = bms_num_members(validsubplans);
158 }
159 else
160 {
161 /* We'll need to initialize all subplans */
162 nplans = list_length(node->appendplans);
163 Assert(nplans > 0);
164 validsubplans = bms_add_range(NULL, 0, nplans - 1);
165 }
166

Callers 1

ExecInitNodeFunction · 0.85

Calls 14

ExecAssignExprContextFunction · 0.85
list_lengthFunction · 0.85
bms_num_membersFunction · 0.85
bms_add_rangeFunction · 0.85
bms_next_memberFunction · 0.85
list_nthFunction · 0.85
bms_add_memberFunction · 0.85
ExecInitNodeFunction · 0.85

Tested by

no test coverage detected