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

Function ExecAppend

src/backend/executor/nodeAppend.c:300–388  ·  view source on GitHub ↗

---------------------------------------------------------------- * ExecAppend * * Handles iteration over multiple subplans. * ---------------------------------------------------------------- */

Source from the content-addressed store, hash-verified

298 * ----------------------------------------------------------------
299 */
300static TupleTableSlot *
301ExecAppend(PlanState *pstate)
302{
303 AppendState *node = castNode(AppendState, pstate);
304 TupleTableSlot *result;
305
306 /*
307 * If this is the first call after Init or ReScan, we need to do the
308 * initialization work.
309 */
310 if (!node->as_begun)
311 {
312 Assert(node->as_whichplan == INVALID_SUBPLAN_INDEX);
313 Assert(!node->as_syncdone);
314
315 /* Nothing to do if there are no subplans */
316 if (node->as_nplans == 0)
317 return ExecClearTuple(node->ps.ps_ResultTupleSlot);
318
319 /* If there are any async subplans, begin executing them. */
320 if (node->as_nasyncplans > 0)
321 ExecAppendAsyncBegin(node);
322
323 /*
324 * If no sync subplan has been chosen, we must choose one before
325 * proceeding.
326 */
327 if (!node->choose_next_subplan(node) && node->as_nasyncremain == 0)
328 return ExecClearTuple(node->ps.ps_ResultTupleSlot);
329
330 Assert(node->as_syncdone ||
331 (node->as_whichplan >= 0 &&
332 node->as_whichplan < node->as_nplans));
333
334 /* And we're initialized. */
335 node->as_begun = true;
336 }
337
338 for (;;)
339 {
340 PlanState *subnode;
341
342 CHECK_FOR_INTERRUPTS();
343
344 /*
345 * try to get a tuple from an async subplan if any
346 */
347 if (node->as_syncdone || !bms_is_empty(node->as_needrequest))
348 {
349 if (ExecAppendAsyncGetNext(node, &result))
350 return result;
351 Assert(!node->as_syncdone);
352 Assert(bms_is_empty(node->as_needrequest));
353 }
354
355 /*
356 * figure out which sync subplan we are currently processing
357 */

Callers

nothing calls this directly

Calls 6

ExecClearTupleFunction · 0.85
ExecAppendAsyncBeginFunction · 0.85
bms_is_emptyFunction · 0.85
ExecAppendAsyncGetNextFunction · 0.85
ExecProcNodeFunction · 0.85
ExecAppendAsyncEventWaitFunction · 0.85

Tested by

no test coverage detected