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

Function ExecInitMaterial

src/backend/executor/nodeMaterial.c:219–333  ·  view source on GitHub ↗

---------------------------------------------------------------- * ExecInitMaterial * ---------------------------------------------------------------- */

Source from the content-addressed store, hash-verified

217 * ----------------------------------------------------------------
218 */
219MaterialState *
220ExecInitMaterial(Material *node, EState *estate, int eflags)
221{
222 MaterialState *matstate;
223 Plan *outerPlan;
224
225 /*
226 * create state structure
227 */
228 matstate = makeNode(MaterialState);
229 matstate->ss.ps.plan = (Plan *) node;
230 matstate->ss.ps.state = estate;
231 matstate->ss.ps.ExecProcNode = ExecMaterial;
232
233 if (node->cdb_strict)
234 eflags |= EXEC_FLAG_REWIND;
235
236 /*
237 * If the Material node was inserted to protect the child node from rescanning, don't
238 * eager free.
239 *
240 * XXX: The planner doesn't always set the flag for Material nodes that are put
241 * directly on top of Motion nodes, so check for that, too. (Or is this for ORCA?)
242 */
243 if (node->cdb_shield_child_from_rescans ||
244 IsA(outerPlan((Plan *) node), Motion))
245 {
246 eflags |= EXEC_FLAG_REWIND;
247 }
248
249 /*
250 * We must have a tuplestore buffering the subplan output to do backward
251 * scan or mark/restore. We also prefer to materialize the subplan output
252 * if we might be called on to rewind and replay it many times. However,
253 * if none of these cases apply, we can skip storing the data.
254 */
255 matstate->eflags = (eflags & (EXEC_FLAG_REWIND |
256 EXEC_FLAG_BACKWARD |
257 EXEC_FLAG_MARK));
258
259 /*
260 * Tuplestore's interpretation of the flag bits is subtly different from
261 * the general executor meaning: it doesn't think BACKWARD necessarily
262 * means "backwards all the way to start". If told to support BACKWARD we
263 * must include REWIND in the tuplestore eflags, else tuplestore_trim
264 * might throw away too much.
265 */
266 if (eflags & EXEC_FLAG_BACKWARD)
267 matstate->eflags |= EXEC_FLAG_REWIND;
268
269 matstate->eof_underlying = false;
270 matstate->tuplestorestate = NULL;
271 matstate->ts_destroyed = false;
272
273 /*
274 * Miscellaneous initialization
275 *
276 * Materialization nodes don't need ExprContexts because they never call

Callers 1

ExecInitNodeFunction · 0.85

Calls 4

list_lengthFunction · 0.85
ExecInitNodeFunction · 0.85

Tested by

no test coverage detected