1/*-------------------------------------------------------------------------
3 * nodeNamedtuplestorescan.c
4 * routines to handle NamedTuplestoreScan nodes.
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/executor/nodeNamedtuplestorescan.c
13 *-------------------------------------------------------------------------
24/* ----------------------------------------------------------------
25 * NamedTuplestoreScanNext
27 * This is a workhorse for ExecNamedTuplestoreScan
28 * ----------------------------------------------------------------
35 /* We intentionally do not support backward scan. */
39 * Get the next tuple from tuplestore. Return NULL if no more tuples.
48 * NamedTuplestoreScanRecheck -- access method routine to recheck a tuple in
54 /* nothing to check */
58/* ----------------------------------------------------------------
59 * ExecNamedTuplestoreScan(node)
61 * Scans the CTE sequentially and returns the next qualifying tuple.
62 * We call the ExecScan() routine and pass it the appropriate
63 * access method functions.
64 * ----------------------------------------------------------------
77/* ----------------------------------------------------------------
78 * ExecInitNamedTuplestoreScan
79 * ----------------------------------------------------------------
87 /* check for unsupported flags */
91 * NamedTuplestoreScan should not have any children.
97 * create new NamedTuplestoreScanState for node
106 elog(
ERROR,
"executor could not find named tuplestore \"%s\"",
116 * The new read pointer copies its position from read pointer 0, which
117 * could be anywhere, so explicitly rewind it.
123 * XXX: Should we add a function to free that read pointer when done?
125 * This was attempted, but it did not improve performance or memory usage
126 * in any tested cases.
130 * Miscellaneous initialization
132 * create expression context for node
137 * The scan tuple type is specified for the tuplestore.
143 * Initialize result type and projection.
149 * initialize child expressions
157/* ----------------------------------------------------------------
158 * ExecReScanNamedTuplestoreScan
160 * Rescans the relation.
161 * ----------------------------------------------------------------
174 * Rewind my own pointer.
ExprState * ExecInitQual(List *qual, PlanState *parent)
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
void ExecAssignScanProjectionInfo(ScanState *node)
void ExecScanReScan(ScanState *node)
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
void ExecInitResultTypeTL(PlanState *planstate)
const TupleTableSlotOps TTSOpsMinimalTuple
void ExecAssignExprContext(EState *estate, PlanState *planstate)
#define EXEC_FLAG_BACKWARD
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
Assert(PointerIsAligned(start, uint64))
static TupleTableSlot * ExecNamedTuplestoreScan(PlanState *pstate)
static TupleTableSlot * NamedTuplestoreScanNext(NamedTuplestoreScanState *node)
static bool NamedTuplestoreScanRecheck(NamedTuplestoreScanState *node, TupleTableSlot *slot)
void ExecReScanNamedTuplestoreScan(NamedTuplestoreScanState *node)
NamedTuplestoreScanState * ExecInitNamedTuplestoreScan(NamedTuplestoreScan *node, EState *estate, int eflags)
#define castNode(_type_, nodeptr)
TupleDesc ENRMetadataGetTupDesc(EphemeralNamedRelationMetadata enrmd)
EphemeralNamedRelation get_ENR(QueryEnvironment *queryEnv, const char *name)
#define ScanDirectionIsForward(direction)
QueryEnvironment * es_queryEnv
ScanDirection es_direction
EphemeralNamedRelationMetadataData md
Tuplestorestate * relation
TupleTableSlot * ps_ResultTupleSlot
ExecProcNodeMtd ExecProcNode
TupleTableSlot * ss_ScanTupleSlot
bool tuplestore_gettupleslot(Tuplestorestate *state, bool forward, bool copy, TupleTableSlot *slot)
void tuplestore_select_read_pointer(Tuplestorestate *state, int ptr)
void tuplestore_rescan(Tuplestorestate *state)
int tuplestore_alloc_read_pointer(Tuplestorestate *state, int eflags)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)