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

Function ExecProjectSet

src/backend/executor/nodeProjectSet.c:42–117  ·  view source on GitHub ↗

---------------------------------------------------------------- * ExecProjectSet(node) * * Return tuples after evaluating the targetlist (which contains set * returning functions). * ---------------------------------------------------------------- */

Source from the content-addressed store, hash-verified

40 * ----------------------------------------------------------------
41 */
42static TupleTableSlot *
43ExecProjectSet(PlanState *pstate)
44{
45 ProjectSetState *node = castNode(ProjectSetState, pstate);
46 TupleTableSlot *outerTupleSlot;
47 TupleTableSlot *resultSlot;
48 PlanState *outerPlan;
49 ExprContext *econtext;
50
51 CHECK_FOR_INTERRUPTS();
52
53 econtext = node->ps.ps_ExprContext;
54
55 /*
56 * Reset per-tuple context to free expression-evaluation storage allocated
57 * for a potentially previously returned tuple. Note that the SRF argument
58 * context has a different lifetime and is reset below.
59 */
60 ResetExprContext(econtext);
61
62 /*
63 * Check to see if we're still projecting out tuples from a previous scan
64 * tuple (because there is a function-returning-set in the projection
65 * expressions). If so, try to project another one.
66 */
67 if (node->pending_srf_tuples)
68 {
69 resultSlot = ExecProjectSRF(node, true);
70
71 if (resultSlot != NULL)
72 return resultSlot;
73 }
74
75 /*
76 * Reset argument context to free any expression evaluation storage
77 * allocated in the previous tuple cycle. Note this can't happen until
78 * we're done projecting out tuples from a scan tuple, as ValuePerCall
79 * functions are allowed to reference the arguments for each returned
80 * tuple.
81 */
82 MemoryContextReset(node->argcontext);
83
84 /*
85 * Get another input tuple and project SRFs from it.
86 */
87 for (;;)
88 {
89 /*
90 * Retrieve tuples from the outer plan until there are no more.
91 */
92 outerPlan = outerPlanState(node);
93 outerTupleSlot = ExecProcNode(outerPlan);
94
95 if (TupIsNull(outerTupleSlot))
96 return NULL;
97
98 /*
99 * Prepare to compute projection expressions, which will expect to

Callers

nothing calls this directly

Calls 3

ExecProjectSRFFunction · 0.85
MemoryContextResetFunction · 0.85
ExecProcNodeFunction · 0.85

Tested by

no test coverage detected