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

Function ExecMaterial

src/backend/executor/nodeMaterial.c:48–213  ·  view source on GitHub ↗

---------------------------------------------------------------- * ExecMaterial * * As long as we are at the end of the data collected in the tuplestore, * we collect one new row from the subplan on each call, and stash it * aside in the tuplestore before returning it. The tuplestore is * only read if we are asked to scan backwards, rescan, or mark/restore. * * ----------------------

Source from the content-addressed store, hash-verified

46 * ----------------------------------------------------------------
47 */
48static TupleTableSlot * /* result tuple from subplan */
49ExecMaterial(PlanState *pstate)
50{
51 MaterialState *node = castNode(MaterialState, pstate);
52 EState *estate;
53 ScanDirection dir;
54 bool forward;
55 Tuplestorestate *tuplestorestate;
56 bool eof_tuplestore;
57 TupleTableSlot *slot;
58
59 CHECK_FOR_INTERRUPTS();
60
61 /*
62 * get state info from node
63 */
64 estate = node->ss.ps.state;
65 dir = estate->es_direction;
66 forward = ScanDirectionIsForward(dir);
67 tuplestorestate = node->tuplestorestate;
68
69 /*
70 * If first time through, and we need a tuplestore, initialize it.
71 */
72 if (tuplestorestate == NULL && node->eflags != 0)
73 {
74 tuplestorestate = tuplestore_begin_heap(true, false, PlanStateOperatorMemKB(&node->ss.ps));
75 tuplestore_set_eflags(tuplestorestate, node->eflags);
76 if (node->eflags & EXEC_FLAG_MARK)
77 {
78 /*
79 * Allocate a second read pointer to serve as the mark. We know it
80 * must have index 1, so needn't store that.
81 */
82 int ptrno PG_USED_FOR_ASSERTS_ONLY;
83
84 ptrno = tuplestore_alloc_read_pointer(tuplestorestate,
85 node->eflags);
86 Assert(ptrno == 1);
87 }
88 node->tuplestorestate = tuplestorestate;
89
90 /* CDB: Offer extra info for EXPLAIN ANALYZE. */
91 if (node->ss.ps.instrument && node->ss.ps.instrument->need_cdb)
92 {
93 /* Let the tuplestore share our Instrumentation object. */
94 tuplestore_set_instrument(tuplestorestate, node->ss.ps.instrument);
95
96 /* Request a callback at end of query. */
97 node->ss.ps.cdbexplainfun = ExecMaterialExplainEnd;
98 }
99
100 /*
101 * MPP: If requested, fetch all rows from subplan and put them
102 * in the tuplestore. This decouples a middle slice's receiving
103 * and sending Motion operators to neutralize a deadlock hazard.
104 * MPP TODO: Remove when a better solution is implemented.
105 *

Callers

nothing calls this directly

Calls 14

tuplestore_begin_heapFunction · 0.85
PlanStateOperatorMemKBFunction · 0.85
tuplestore_set_eflagsFunction · 0.85
ExecProcNodeFunction · 0.85
tuplestore_puttupleslotFunction · 0.85
tuplestore_rescanFunction · 0.85
tuplestore_ateofFunction · 0.85
tuplestore_advanceFunction · 0.85
tuplestore_gettupleslotFunction · 0.85
ExecEagerFreeMaterialFunction · 0.85

Tested by

no test coverage detected