PostgreSQL Source Code git master
nodeTableFuncscan.h File Reference
#include "nodes/execnodes.h"
Include dependency graph for nodeTableFuncscan.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

TableFuncScanStateExecInitTableFuncScan (TableFuncScan *node, EState *estate, int eflags)
 
void ExecEndTableFuncScan (TableFuncScanState *node)
 
void ExecReScanTableFuncScan (TableFuncScanState *node)
 

Function Documentation

◆ ExecEndTableFuncScan()

void ExecEndTableFuncScan ( TableFuncScanState node)

Definition at line 220 of file nodeTableFuncscan.c.

221{
222 /*
223 * Release tuplestore resources
224 */
225 if (node->tupstore != NULL)
227 node->tupstore = NULL;
228}
Tuplestorestate * tupstore
Definition: execnodes.h:2039
void tuplestore_end(Tuplestorestate *state)
Definition: tuplestore.c:492

References tuplestore_end(), and TableFuncScanState::tupstore.

Referenced by ExecEndNode().

◆ ExecInitTableFuncScan()

TableFuncScanState * ExecInitTableFuncScan ( TableFuncScan node,
EState estate,
int  eflags 
)

Definition at line 111 of file nodeTableFuncscan.c.

112{
113 TableFuncScanState *scanstate;
114 TableFunc *tf = node->tablefunc;
115 TupleDesc tupdesc;
116 int i;
117
118 /* check for unsupported flags */
119 Assert(!(eflags & EXEC_FLAG_MARK));
120
121 /*
122 * TableFuncscan should not have any children.
123 */
124 Assert(outerPlan(node) == NULL);
125 Assert(innerPlan(node) == NULL);
126
127 /*
128 * create new ScanState for node
129 */
130 scanstate = makeNode(TableFuncScanState);
131 scanstate->ss.ps.plan = (Plan *) node;
132 scanstate->ss.ps.state = estate;
133 scanstate->ss.ps.ExecProcNode = ExecTableFuncScan;
134
135 /*
136 * Miscellaneous initialization
137 *
138 * create expression context for node
139 */
140 ExecAssignExprContext(estate, &scanstate->ss.ps);
141
142 /*
143 * initialize source tuple type
144 */
145 tupdesc = BuildDescFromLists(tf->colnames,
146 tf->coltypes,
147 tf->coltypmods,
148 tf->colcollations);
149 /* and the corresponding scan slot */
150 ExecInitScanTupleSlot(estate, &scanstate->ss, tupdesc,
152
153 /*
154 * Initialize result type and projection.
155 */
156 ExecInitResultTypeTL(&scanstate->ss.ps);
157 ExecAssignScanProjectionInfo(&scanstate->ss);
158
159 /*
160 * initialize child expressions
161 */
162 scanstate->ss.ps.qual =
163 ExecInitQual(node->scan.plan.qual, &scanstate->ss.ps);
164
165 /* Only XMLTABLE and JSON_TABLE are supported currently */
166 scanstate->routine =
168
169 scanstate->perTableCxt =
171 "TableFunc per value context",
173 scanstate->opaque = NULL; /* initialized at runtime */
174
175 scanstate->ns_names = tf->ns_names;
176
177 scanstate->ns_uris =
178 ExecInitExprList(tf->ns_uris, (PlanState *) scanstate);
179 scanstate->docexpr =
180 ExecInitExpr((Expr *) tf->docexpr, (PlanState *) scanstate);
181 scanstate->rowexpr =
182 ExecInitExpr((Expr *) tf->rowexpr, (PlanState *) scanstate);
183 scanstate->colexprs =
184 ExecInitExprList(tf->colexprs, (PlanState *) scanstate);
185 scanstate->coldefexprs =
186 ExecInitExprList(tf->coldefexprs, (PlanState *) scanstate);
187 scanstate->colvalexprs =
188 ExecInitExprList(tf->colvalexprs, (PlanState *) scanstate);
189 scanstate->passingvalexprs =
190 ExecInitExprList(tf->passingvalexprs, (PlanState *) scanstate);
191
192 scanstate->notnulls = tf->notnulls;
193
194 /* these are allocated now and initialized later */
195 scanstate->in_functions = palloc(sizeof(FmgrInfo) * tupdesc->natts);
196 scanstate->typioparams = palloc(sizeof(Oid) * tupdesc->natts);
197
198 /*
199 * Fill in the necessary fmgr infos.
200 */
201 for (i = 0; i < tupdesc->natts; i++)
202 {
203 Oid in_funcid;
204
205 getTypeInputInfo(TupleDescAttr(tupdesc, i)->atttypid,
206 &in_funcid, &scanstate->typioparams[i]);
207 fmgr_info(in_funcid, &scanstate->in_functions[i]);
208 }
209
210 return scanstate;
211}
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:143
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:229
List * ExecInitExprList(List *nodes, PlanState *parent)
Definition: execExpr.c:335
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:81
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:2000
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1944
const TupleTableSlotOps TTSOpsMinimalTuple
Definition: execTuples.c:86
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:486
#define EXEC_FLAG_MARK
Definition: executor.h:70
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:127
Assert(PointerIsAligned(start, uint64))
int i
Definition: isn.c:77
const TableFuncRoutine JsonbTableRoutine
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Definition: lsyscache.c:3014
void * palloc(Size size)
Definition: mcxt.c:1939
MemoryContext CurrentMemoryContext
Definition: mcxt.c:159
#define AllocSetContextCreate
Definition: memutils.h:149
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:180
static TupleTableSlot * ExecTableFuncScan(PlanState *pstate)
#define makeNode(_type_)
Definition: nodes.h:161
#define innerPlan(node)
Definition: plannodes.h:240
#define outerPlan(node)
Definition: plannodes.h:241
unsigned int Oid
Definition: postgres_ext.h:30
@ TFT_XMLTABLE
Definition: primnodes.h:100
Definition: fmgr.h:57
ExprState * qual
Definition: execnodes.h:1180
Plan * plan
Definition: execnodes.h:1159
EState * state
Definition: execnodes.h:1161
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1165
PlanState ps
Definition: execnodes.h:1615
MemoryContext perTableCxt
Definition: execnodes.h:2038
Bitmapset * notnulls
Definition: execnodes.h:2032
const struct TableFuncRoutine * routine
Definition: execnodes.h:2034
ExprState * rowexpr
Definition: execnodes.h:2025
FmgrInfo * in_functions
Definition: execnodes.h:2035
List * passingvalexprs
Definition: execnodes.h:2029
ExprState * docexpr
Definition: execnodes.h:2024
TableFunc * tablefunc
Definition: plannodes.h:751
Node * docexpr
Definition: primnodes.h:120
Node * rowexpr
Definition: primnodes.h:122
List * colexprs
Definition: primnodes.h:132
TableFuncType functype
Definition: primnodes.h:114
TupleDesc BuildDescFromLists(const List *names, const List *types, const List *typmods, const List *collations)
Definition: tupdesc.c:1044
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition: tupdesc.h:160
const TableFuncRoutine XmlTableRoutine
Definition: xml.c:223

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), BuildDescFromLists(), TableFuncScanState::coldefexprs, TableFuncScanState::colexprs, TableFunc::colexprs, TableFuncScanState::colvalexprs, CurrentMemoryContext, TableFuncScanState::docexpr, TableFunc::docexpr, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignScanProjectionInfo(), ExecInitExpr(), ExecInitExprList(), ExecInitQual(), ExecInitResultTypeTL(), ExecInitScanTupleSlot(), PlanState::ExecProcNode, ExecTableFuncScan(), fmgr_info(), TableFunc::functype, getTypeInputInfo(), i, TableFuncScanState::in_functions, innerPlan, JsonbTableRoutine, makeNode, TupleDescData::natts, TableFuncScanState::notnulls, TableFuncScanState::ns_names, TableFuncScanState::ns_uris, TableFuncScanState::opaque, outerPlan, palloc(), TableFuncScanState::passingvalexprs, TableFuncScanState::perTableCxt, PlanState::plan, ScanState::ps, PlanState::qual, TableFuncScanState::routine, TableFuncScanState::rowexpr, TableFunc::rowexpr, TableFuncScan::scan, TableFuncScanState::ss, PlanState::state, TableFuncScan::tablefunc, TFT_XMLTABLE, TTSOpsMinimalTuple, TupleDescAttr(), TableFuncScanState::typioparams, and XmlTableRoutine.

Referenced by ExecInitNode().

◆ ExecReScanTableFuncScan()

void ExecReScanTableFuncScan ( TableFuncScanState node)

Definition at line 237 of file nodeTableFuncscan.c.

238{
239 Bitmapset *chgparam = node->ss.ps.chgParam;
240
241 if (node->ss.ps.ps_ResultTupleSlot)
243 ExecScanReScan(&node->ss);
244
245 /*
246 * Recompute when parameters are changed.
247 */
248 if (chgparam)
249 {
250 if (node->tupstore != NULL)
251 {
253 node->tupstore = NULL;
254 }
255 }
256
257 if (node->tupstore != NULL)
259}
void ExecScanReScan(ScanState *node)
Definition: execScan.c:108
Bitmapset * chgParam
Definition: execnodes.h:1191
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:1197
void tuplestore_rescan(Tuplestorestate *state)
Definition: tuplestore.c:1285
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:458

References PlanState::chgParam, ExecClearTuple(), ExecScanReScan(), ScanState::ps, PlanState::ps_ResultTupleSlot, TableFuncScanState::ss, tuplestore_end(), tuplestore_rescan(), and TableFuncScanState::tupstore.

Referenced by ExecReScan().