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 215 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().

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

◆ ExecInitTableFuncScan()

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

Definition at line 111 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().

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 is supported currently */
166  scanstate->routine = &XmlTableRoutine;
167 
168  scanstate->perTableCxt =
170  "TableFunc per value context",
172  scanstate->opaque = NULL; /* initialized at runtime */
173 
174  scanstate->ns_names = tf->ns_names;
175 
176  scanstate->ns_uris =
177  ExecInitExprList(tf->ns_uris, (PlanState *) scanstate);
178  scanstate->docexpr =
179  ExecInitExpr((Expr *) tf->docexpr, (PlanState *) scanstate);
180  scanstate->rowexpr =
181  ExecInitExpr((Expr *) tf->rowexpr, (PlanState *) scanstate);
182  scanstate->colexprs =
183  ExecInitExprList(tf->colexprs, (PlanState *) scanstate);
184  scanstate->coldefexprs =
185  ExecInitExprList(tf->coldefexprs, (PlanState *) scanstate);
186 
187  scanstate->notnulls = tf->notnulls;
188 
189  /* these are allocated now and initialized later */
190  scanstate->in_functions = palloc(sizeof(FmgrInfo) * tupdesc->natts);
191  scanstate->typioparams = palloc(sizeof(Oid) * tupdesc->natts);
192 
193  /*
194  * Fill in the necessary fmgr infos.
195  */
196  for (i = 0; i < tupdesc->natts; i++)
197  {
198  Oid in_funcid;
199 
201  &in_funcid, &scanstate->typioparams[i]);
202  fmgr_info(in_funcid, &scanstate->in_functions[i]);
203  }
204 
205  return scanstate;
206 }
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:942
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:1331
const TableFuncRoutine XmlTableRoutine
Definition: xml.c:207
Bitmapset * notnulls
Definition: execnodes.h:1712
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:1776
const struct TableFuncRoutine * routine
Definition: execnodes.h:1714
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1720
ExprState * docexpr
Definition: execnodes.h:1706
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:1718
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:946
List * coltypes
Definition: primnodes.h:90
Plan * plan
Definition: execnodes.h:940
List * colexprs
Definition: primnodes.h:93
#define makeNode(_type_)
Definition: nodes.h:573
#define Assert(condition)
Definition: c.h:732
#define EXEC_FLAG_MARK
Definition: executor.h:59
List * ns_uris
Definition: primnodes.h:85
FmgrInfo * in_functions
Definition: execnodes.h:1715
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:444
ExprState * qual
Definition: execnodes.h:961
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:1707
const TupleTableSlotOps TTSOpsMinimalTuple
Definition: execTuples.c:86

◆ ExecReScanTableFuncScan()

void ExecReScanTableFuncScan ( TableFuncScanState node)

Definition at line 244 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().

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