* nodeFunctionscan.c
* Support routines for scanning RangeFunctions (functions in rangetable).
*
- * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
*/
typedef struct FunctionScanPerFuncState
{
- ExprState *funcexpr; /* state of the expression being evaluated */
+ SetExprState *setexpr; /* state of the expression being evaluated */
TupleDesc tupdesc; /* desc of the function result type */
int colcount; /* expected number of result columns */
Tuplestorestate *tstore; /* holds the function result set */
if (tstore == NULL)
{
node->funcstates[0].tstore = tstore =
- ExecMakeTableFunctionResult(node->funcstates[0].funcexpr,
+ ExecMakeTableFunctionResult(node->funcstates[0].setexpr,
node->ss.ps.ps_ExprContext,
node->argcontext,
node->funcstates[0].tupdesc,
- node->eflags & EXEC_FLAG_BACKWARD);
+ node->eflags & EXEC_FLAG_BACKWARD);
/*
* paranoia - cope if the function, which may have constructed the
if (fs->tstore == NULL)
{
fs->tstore =
- ExecMakeTableFunctionResult(fs->funcexpr,
+ ExecMakeTableFunctionResult(fs->setexpr,
node->ss.ps.ps_ExprContext,
node->argcontext,
fs->tupdesc,
- node->eflags & EXEC_FLAG_BACKWARD);
+ node->eflags & EXEC_FLAG_BACKWARD);
/*
* paranoia - cope if the function, which may have constructed the
* access method functions.
* ----------------------------------------------------------------
*/
-TupleTableSlot *
-ExecFunctionScan(FunctionScanState *node)
+static TupleTableSlot *
+ExecFunctionScan(PlanState *pstate)
{
+ FunctionScanState *node = castNode(FunctionScanState, pstate);
+
return ExecScan(&node->ss,
(ExecScanAccessMtd) FunctionNext,
(ExecScanRecheckMtd) FunctionRecheck);
scanstate = makeNode(FunctionScanState);
scanstate->ss.ps.plan = (Plan *) node;
scanstate->ss.ps.state = estate;
+ scanstate->ss.ps.ExecProcNode = ExecFunctionScan;
scanstate->eflags = eflags;
/*
*/
ExecAssignExprContext(estate, &scanstate->ss.ps);
- scanstate->ss.ps.ps_TupFromTlist = false;
-
/*
* tuple table initialization
*/
/*
* initialize child expressions
*/
- scanstate->ss.ps.targetlist = (List *)
- ExecInitExpr((Expr *) node->scan.plan.targetlist,
- (PlanState *) scanstate);
- scanstate->ss.ps.qual = (List *)
- ExecInitExpr((Expr *) node->scan.plan.qual,
- (PlanState *) scanstate);
+ scanstate->ss.ps.qual =
+ ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
scanstate->funcstates = palloc(nfuncs * sizeof(FunctionScanPerFuncState));
Oid funcrettype;
TupleDesc tupdesc;
- fs->funcexpr = ExecInitExpr((Expr *) funcexpr, (PlanState *) scanstate);
+ fs->setexpr =
+ ExecInitTableFunctionResult((Expr *) funcexpr,
+ scanstate->ss.ps.ps_ExprContext,
+ &scanstate->ss.ps);
/*
* Don't allocate the tuplestores; the actual calls to the functions
&funcrettype,
&tupdesc);
- if (functypclass == TYPEFUNC_COMPOSITE)
+ if (functypclass == TYPEFUNC_COMPOSITE ||
+ functypclass == TYPEFUNC_COMPOSITE_DOMAIN)
{
/* Composite data type, e.g. a table's row type */
Assert(tupdesc);
*/
scanstate->argcontext = AllocSetContextCreate(CurrentMemoryContext,
"Table function arguments",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
+ ALLOCSET_DEFAULT_SIZES);
return scanstate;
}