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

Function ValuesNext

src/backend/executor/nodeValuesscan.c:49–177  ·  view source on GitHub ↗

---------------------------------------------------------------- * ValuesNext * * This is a workhorse for ExecValuesScan * ---------------------------------------------------------------- */

Source from the content-addressed store, hash-verified

47 * ----------------------------------------------------------------
48 */
49static TupleTableSlot *
50ValuesNext(ValuesScanState *node)
51{
52 TupleTableSlot *slot;
53 EState *estate;
54 ExprContext *econtext;
55 ScanDirection direction;
56 int curr_idx;
57
58 /*
59 * get information from the estate and scan state
60 */
61 estate = node->ss.ps.state;
62 direction = estate->es_direction;
63 slot = node->ss.ss_ScanTupleSlot;
64 econtext = node->rowcontext;
65
66 /*
67 * Get the next tuple. Return NULL if no more tuples.
68 */
69 if (ScanDirectionIsForward(direction))
70 {
71 if (node->curr_idx < node->array_len)
72 node->curr_idx++;
73 }
74 else
75 {
76 if (node->curr_idx >= 0)
77 node->curr_idx--;
78 }
79
80 /*
81 * Always clear the result slot; this is appropriate if we are at the end
82 * of the data, and if we're not, we still need it as the first step of
83 * the store-virtual-tuple protocol. It seems wise to clear the slot
84 * before we reset the context it might have pointers into.
85 */
86 ExecClearTuple(slot);
87
88 curr_idx = node->curr_idx;
89 if (curr_idx >= 0 && curr_idx < node->array_len)
90 {
91 List *exprlist = node->exprlists[curr_idx];
92 List *exprstatelist = node->exprstatelists[curr_idx];
93 MemoryContext oldContext;
94 Datum *values;
95 bool *isnull;
96 ListCell *lc;
97 int resind;
98
99 /*
100 * Get rid of any prior cycle's leftovers. We use ReScanExprContext
101 * not just ResetExprContext because we want any registered shutdown
102 * callbacks to be called.
103 */
104 ReScanExprContext(econtext);
105
106 /*

Callers

nothing calls this directly

Calls 8

ExecClearTupleFunction · 0.85
ReScanExprContextFunction · 0.85
MemoryContextSwitchToFunction · 0.85
ExecInitExprListFunction · 0.85
list_lengthFunction · 0.85
ExecEvalExprFunction · 0.85
ExecStoreVirtualTupleFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected