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

Function ExecReScanCteScan

src/backend/executor/nodeCtescan.c:319–352  ·  view source on GitHub ↗

---------------------------------------------------------------- * ExecReScanCteScan * * Rescans the relation. * ---------------------------------------------------------------- */

Source from the content-addressed store, hash-verified

317 * ----------------------------------------------------------------
318 */
319void
320ExecReScanCteScan(CteScanState *node)
321{
322 Tuplestorestate *tuplestorestate = node->leader->cte_table;
323
324 if (node->ss.ps.ps_ResultTupleSlot)
325 ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
326
327 ExecScanReScan(&node->ss);
328
329 /*
330 * Clear the tuplestore if a new scan of the underlying CTE is required.
331 * This implicitly resets all the tuplestore's read pointers. Note that
332 * multiple CTE nodes might redundantly clear the tuplestore; that's OK,
333 * and not unduly expensive. We'll stop taking this path as soon as
334 * somebody has attempted to read something from the underlying CTE
335 * (thereby causing its chgParam to be cleared).
336 */
337 if (node->leader->cteplanstate->chgParam != NULL)
338 {
339 tuplestore_clear(tuplestorestate);
340 node->leader->eof_cte = false;
341 }
342 else
343 {
344 /*
345 * Else, just rewind my own pointer. Either the underlying CTE
346 * doesn't need a rescan (and we can re-read what's in the tuplestore
347 * now), or somebody else already took care of it.
348 */
349 tuplestore_select_read_pointer(tuplestorestate, node->readptr);
350 tuplestore_rescan(tuplestorestate);
351 }
352}

Callers 1

ExecReScanFunction · 0.85

Calls 5

ExecClearTupleFunction · 0.85
ExecScanReScanFunction · 0.85
tuplestore_clearFunction · 0.85
tuplestore_rescanFunction · 0.85

Tested by

no test coverage detected