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

Function setop_retrieve_direct

src/backend/executor/nodeSetOp.c:226–333  ·  view source on GitHub ↗

* ExecSetOp for non-hashed case */

Source from the content-addressed store, hash-verified

224 * ExecSetOp for non-hashed case
225 */
226static TupleTableSlot *
227setop_retrieve_direct(SetOpState *setopstate)
228{
229 PlanState *outerPlan;
230 SetOpStatePerGroup pergroup;
231 TupleTableSlot *outerslot;
232 TupleTableSlot *resultTupleSlot;
233 ExprContext *econtext = setopstate->ps.ps_ExprContext;
234
235 /*
236 * get state info from node
237 */
238 outerPlan = outerPlanState(setopstate);
239 pergroup = (SetOpStatePerGroup) setopstate->pergroup;
240 resultTupleSlot = setopstate->ps.ps_ResultTupleSlot;
241
242 /*
243 * We loop retrieving groups until we find one we should return
244 */
245 while (!setopstate->setop_done)
246 {
247 /*
248 * If we don't already have the first tuple of the new group, fetch it
249 * from the outer plan.
250 */
251 if (setopstate->grp_firstTuple == NULL)
252 {
253 outerslot = ExecProcNode(outerPlan);
254 if (!TupIsNull(outerslot))
255 {
256 /* Make a copy of the first input tuple */
257 setopstate->grp_firstTuple = ExecCopySlotHeapTuple(outerslot);
258 }
259 else
260 {
261 /* outer plan produced no tuples at all */
262 setopstate->setop_done = true;
263 return NULL;
264 }
265 }
266
267 /*
268 * Store the copied first input tuple in the tuple table slot reserved
269 * for it. The tuple will be deleted when it is cleared from the
270 * slot.
271 */
272 ExecStoreHeapTuple(setopstate->grp_firstTuple,
273 resultTupleSlot,
274 true);
275 setopstate->grp_firstTuple = NULL; /* don't keep two pointers */
276
277 /* Initialize working state for a new input tuple group */
278 initialize_counts(pergroup);
279
280 /* Count the first input tuple */
281 advance_counts(pergroup,
282 fetch_tuple_flag(setopstate, resultTupleSlot));
283

Callers 1

ExecSetOpFunction · 0.85

Calls 9

ExecProcNodeFunction · 0.85
ExecCopySlotHeapTupleFunction · 0.85
ExecStoreHeapTupleFunction · 0.85
initialize_countsFunction · 0.85
advance_countsFunction · 0.85
fetch_tuple_flagFunction · 0.85
ExecQualAndResetFunction · 0.85
set_output_countFunction · 0.85
ExecClearTupleFunction · 0.85

Tested by

no test coverage detected