PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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)
extern

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}
static int fb(int x)
Tuplestorestate * tupstore
Definition execnodes.h:2022
void tuplestore_end(Tuplestorestate *state)
Definition tuplestore.c:492

References fb(), tuplestore_end(), and TableFuncScanState::tupstore.

Referenced by ExecEndNode().

◆ ExecInitTableFuncScan()

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

Definition at line 111 of file nodeTableFuncscan.c.

112{
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 */
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 */
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 =
181 scanstate->rowexpr =
183 scanstate->colexprs =
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_array(FmgrInfo, tupdesc->natts);
196 scanstate->typioparams = palloc_array(Oid, tupdesc->natts);
197
198 /*
199 * Fill in the necessary fmgr infos.
200 */
201 for (i = 0; i < tupdesc->natts; i++)
202 {
204
206 &in_funcid, &scanstate->typioparams[i]);
207 fmgr_info(in_funcid, &scanstate->in_functions[i]);
208 }
209
210 return scanstate;
211}
#define Assert(condition)
Definition c.h:873
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)
void ExecInitResultTypeTL(PlanState *planstate)
const TupleTableSlotOps TTSOpsMinimalTuple
Definition execTuples.c:86
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition execUtils.c:485
#define EXEC_FLAG_MARK
Definition executor.h:70
#define palloc_array(type, count)
Definition fe_memutils.h:76
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition fmgr.c:128
int i
Definition isn.c:77
const TableFuncRoutine JsonbTableRoutine
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Definition lsyscache.c:3024
MemoryContext CurrentMemoryContext
Definition mcxt.c:160
#define AllocSetContextCreate
Definition memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition memutils.h:160
static TupleTableSlot * ExecTableFuncScan(PlanState *pstate)
#define makeNode(_type_)
Definition nodes.h:161
#define innerPlan(node)
Definition plannodes.h:260
#define outerPlan(node)
Definition plannodes.h:261
unsigned int Oid
@ TFT_XMLTABLE
Definition primnodes.h:100
TableFunc * tablefunc
Definition plannodes.h:791
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:1034
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition tupdesc.h:160
const TableFuncRoutine XmlTableRoutine
Definition xml.c:222

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, BuildDescFromLists(), TableFunc::colexprs, CurrentMemoryContext, TableFunc::docexpr, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignScanProjectionInfo(), ExecInitExpr(), ExecInitExprList(), ExecInitQual(), ExecInitResultTypeTL(), ExecInitScanTupleSlot(), ExecTableFuncScan(), fb(), fmgr_info(), TableFunc::functype, getTypeInputInfo(), i, innerPlan, JsonbTableRoutine, makeNode, TupleDescData::natts, outerPlan, palloc_array, TableFunc::rowexpr, TableFuncScan::scan, TableFuncScan::tablefunc, TFT_XMLTABLE, TTSOpsMinimalTuple, TupleDescAttr(), and XmlTableRoutine.

Referenced by ExecInitNode().

◆ ExecReScanTableFuncScan()

void ExecReScanTableFuncScan ( TableFuncScanState node)
extern

Definition at line 237 of file nodeTableFuncscan.c.

238{
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:1199
TupleTableSlot * ps_ResultTupleSlot
Definition execnodes.h:1205
PlanState ps
Definition execnodes.h:1623
void tuplestore_rescan(Tuplestorestate *state)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition tuptable.h:457

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

Referenced by ExecReScan().