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 214 of file nodeTableFuncscan.c.

References ExecClearTuple(), ExecFreeExprContext(), ScanState::ps, PlanState::ps_ResultTupleSlot, TableFuncScanState::ss, ScanState::ss_ScanTupleSlot, tuplestore_end(), and TableFuncScanState::tupstore.

Referenced by ExecEndNode().

215 {
216  /*
217  * Free the exprcontext
218  */
219  ExecFreeExprContext(&node->ss.ps);
220 
221  /*
222  * clean out the tuple table
223  */
224  if (node->ss.ps.ps_ResultTupleSlot)
227 
228  /*
229  * Release tuplestore resources
230  */
231  if (node->tupstore != NULL)
232  tuplestore_end(node->tupstore);
233  node->tupstore = NULL;
234 }
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1333
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:614
PlanState ps
Definition: execnodes.h:1330
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:977
void tuplestore_end(Tuplestorestate *state)
Definition: tuplestore.c:453
Tuplestorestate * tupstore
Definition: execnodes.h:1718

◆ ExecInitTableFuncScan()

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

Definition at line 110 of file nodeTableFuncscan.c.

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

Referenced by ExecInitNode().

111 {
112  TableFuncScanState *scanstate;
113  TableFunc *tf = node->tablefunc;
114  TupleDesc tupdesc;
115  int i;
116 
117  /* check for unsupported flags */
118  Assert(!(eflags & EXEC_FLAG_MARK));
119 
120  /*
121  * TableFuncscan should not have any children.
122  */
123  Assert(outerPlan(node) == NULL);
124  Assert(innerPlan(node) == NULL);
125 
126  /*
127  * create new ScanState for node
128  */
129  scanstate = makeNode(TableFuncScanState);
130  scanstate->ss.ps.plan = (Plan *) node;
131  scanstate->ss.ps.state = estate;
132  scanstate->ss.ps.ExecProcNode = ExecTableFuncScan;
133 
134  /*
135  * Miscellaneous initialization
136  *
137  * create expression context for node
138  */
139  ExecAssignExprContext(estate, &scanstate->ss.ps);
140 
141  /*
142  * initialize source tuple type
143  */
144  tupdesc = BuildDescFromLists(tf->colnames,
145  tf->coltypes,
146  tf->coltypmods,
147  tf->colcollations);
148  /* and the corresponding scan slot */
149  ExecInitScanTupleSlot(estate, &scanstate->ss, tupdesc,
151 
152  /*
153  * Initialize result type and projection.
154  */
155  ExecInitResultTypeTL(&scanstate->ss.ps);
156  ExecAssignScanProjectionInfo(&scanstate->ss);
157 
158  /*
159  * initialize child expressions
160  */
161  scanstate->ss.ps.qual =
162  ExecInitQual(node->scan.plan.qual, &scanstate->ss.ps);
163 
164  /* Only XMLTABLE is supported currently */
165  scanstate->routine = &XmlTableRoutine;
166 
167  scanstate->perTableCxt =
169  "TableFunc per value context",
171  scanstate->opaque = NULL; /* initialized at runtime */
172 
173  scanstate->ns_names = tf->ns_names;
174 
175  scanstate->ns_uris =
176  ExecInitExprList(tf->ns_uris, (PlanState *) scanstate);
177  scanstate->docexpr =
178  ExecInitExpr((Expr *) tf->docexpr, (PlanState *) scanstate);
179  scanstate->rowexpr =
180  ExecInitExpr((Expr *) tf->rowexpr, (PlanState *) scanstate);
181  scanstate->colexprs =
182  ExecInitExprList(tf->colexprs, (PlanState *) scanstate);
183  scanstate->coldefexprs =
184  ExecInitExprList(tf->coldefexprs, (PlanState *) scanstate);
185 
186  scanstate->notnulls = tf->notnulls;
187 
188  /* these are allocated now and initialized later */
189  scanstate->in_functions = palloc(sizeof(FmgrInfo) * tupdesc->natts);
190  scanstate->typioparams = palloc(sizeof(Oid) * tupdesc->natts);
191 
192  /*
193  * Fill in the necessary fmgr infos.
194  */
195  for (i = 0; i < tupdesc->natts; i++)
196  {
197  Oid in_funcid;
198 
200  &in_funcid, &scanstate->typioparams[i]);
201  fmgr_info(in_funcid, &scanstate->in_functions[i]);
202  }
203 
204  return scanstate;
205 }
Definition: fmgr.h:56
List * qual
Definition: plannodes.h:141
Plan plan
Definition: plannodes.h:340
#define AllocSetContextCreate
Definition: memutils.h:170
Node * docexpr
Definition: primnodes.h:87
TupleDesc BuildDescFromLists(List *names, List *types, List *typmods, List *collations)
Definition: tupdesc.c:894
List * colnames
Definition: primnodes.h:89
List * coltypmods
Definition: primnodes.h:91
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
TableFunc * tablefunc
Definition: plannodes.h:542
EState * state
Definition: execnodes.h:941
unsigned int Oid
Definition: postgres_ext.h:31
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:207
List * colcollations
Definition: primnodes.h:92
PlanState ps
Definition: execnodes.h:1330
const TableFuncRoutine XmlTableRoutine
Definition: xml.c:207
Bitmapset * notnulls
Definition: execnodes.h:1711
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:272
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124
List * coldefexprs
Definition: primnodes.h:94
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:192
List * ns_names
Definition: primnodes.h:86
#define innerPlan(node)
Definition: plannodes.h:169
Node * rowexpr
Definition: primnodes.h:88
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1781
const struct TableFuncRoutine * routine
Definition: execnodes.h:1713
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1725
ExprState * docexpr
Definition: execnodes.h:1705
Bitmapset * notnulls
Definition: primnodes.h:95
List * ExecInitExprList(List *nodes, PlanState *parent)
Definition: execExpr.c:316
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38
Oid atttypid
Definition: pg_attribute.h:49
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Definition: lsyscache.c:2641
#define outerPlan(node)
Definition: plannodes.h:170
MemoryContext perTableCxt
Definition: execnodes.h:1717
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:945
List * coltypes
Definition: primnodes.h:90
Plan * plan
Definition: execnodes.h:939
List * colexprs
Definition: primnodes.h:93
#define makeNode(_type_)
Definition: nodes.h:573
#define Assert(condition)
Definition: c.h:739
#define EXEC_FLAG_MARK
Definition: executor.h:59
List * ns_uris
Definition: primnodes.h:85
FmgrInfo * in_functions
Definition: execnodes.h:1714
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:444
ExprState * qual
Definition: execnodes.h:960
static TupleTableSlot * ExecTableFuncScan(PlanState *pstate)
void * palloc(Size size)
Definition: mcxt.c:949
int i
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:121
ExprState * rowexpr
Definition: execnodes.h:1706
const TupleTableSlotOps TTSOpsMinimalTuple
Definition: execTuples.c:85

◆ ExecReScanTableFuncScan()

void ExecReScanTableFuncScan ( TableFuncScanState node)

Definition at line 243 of file nodeTableFuncscan.c.

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

Referenced by ExecReScan().

244 {
245  Bitmapset *chgparam = node->ss.ps.chgParam;
246 
247  if (node->ss.ps.ps_ResultTupleSlot)
249  ExecScanReScan(&node->ss);
250 
251  /*
252  * Recompute when parameters are changed.
253  */
254  if (chgparam)
255  {
256  if (node->tupstore != NULL)
257  {
258  tuplestore_end(node->tupstore);
259  node->tupstore = NULL;
260  }
261  }
262 
263  if (node->tupstore != NULL)
265 }
void tuplestore_rescan(Tuplestorestate *state)
Definition: tuplestore.c:1233
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
PlanState ps
Definition: execnodes.h:1330
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:977
Bitmapset * chgParam
Definition: execnodes.h:971
void tuplestore_end(Tuplestorestate *state)
Definition: tuplestore.c:453
void ExecScanReScan(ScanState *node)
Definition: execScan.c:299
Tuplestorestate * tupstore
Definition: execnodes.h:1718