diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/executor/executor.h | 4 | ||||
-rw-r--r-- | src/include/executor/nodeProjectSet.h | 24 | ||||
-rw-r--r-- | src/include/nodes/execnodes.h | 20 | ||||
-rw-r--r-- | src/include/nodes/nodes.h | 3 | ||||
-rw-r--r-- | src/include/nodes/plannodes.h | 11 | ||||
-rw-r--r-- | src/include/nodes/relation.h | 11 | ||||
-rw-r--r-- | src/include/optimizer/clauses.h | 1 | ||||
-rw-r--r-- | src/include/optimizer/pathnode.h | 4 | ||||
-rw-r--r-- | src/include/optimizer/tlist.h | 3 |
9 files changed, 79 insertions, 2 deletions
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index b9c7f72903..d424031676 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -253,6 +253,10 @@ extern Tuplestorestate *ExecMakeTableFunctionResult(ExprState *funcexpr, MemoryContext argContext, TupleDesc expectedDesc, bool randomAccess); +extern Datum ExecMakeFunctionResultSet(FuncExprState *fcache, + ExprContext *econtext, + bool *isNull, + ExprDoneCond *isDone); extern Datum ExecEvalExprSwitchContext(ExprState *expression, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone); extern ExprState *ExecInitExpr(Expr *node, PlanState *parent); diff --git a/src/include/executor/nodeProjectSet.h b/src/include/executor/nodeProjectSet.h new file mode 100644 index 0000000000..30b2b7cec9 --- /dev/null +++ b/src/include/executor/nodeProjectSet.h @@ -0,0 +1,24 @@ +/*------------------------------------------------------------------------- + * + * nodeProjectSet.h + * + * + * + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/executor/nodeProjectSet.h + * + *------------------------------------------------------------------------- + */ +#ifndef NODEPROJECTSET_H +#define NODEPROJECTSET_H + +#include "nodes/execnodes.h" + +extern ProjectSetState *ExecInitProjectSet(ProjectSet *node, EState *estate, int eflags); +extern TupleTableSlot *ExecProjectSet(ProjectSetState *node); +extern void ExecEndProjectSet(ProjectSetState *node); +extern void ExecReScanProjectSet(ProjectSetState *node); + +#endif /* NODEPROJECTSET_H */ diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index ce13bf7635..1da1e1f804 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -696,7 +696,7 @@ typedef struct FuncExprState /* * Function manager's lookup info for the target function. If func.fn_oid * is InvalidOid, we haven't initialized it yet (nor any of the following - * fields). + * fields, except funcReturnsSet). */ FmgrInfo func; @@ -717,6 +717,12 @@ typedef struct FuncExprState * NULL */ /* + * Remember whether the function is declared to return a set. This is set + * by ExecInitExpr, and is valid even before the FmgrInfo is set up. + */ + bool funcReturnsSet; + + /* * setArgsValid is true when we are evaluating a set-returning function * that uses value-per-call mode and we are in the middle of a call * series; we want to pass the same argument values to the function again @@ -1130,6 +1136,18 @@ typedef struct ResultState } ResultState; /* ---------------- + * ProjectSetState information + * ---------------- + */ +typedef struct ProjectSetState +{ + PlanState ps; /* its first field is NodeTag */ + ExprDoneCond *elemdone; /* array of per-SRF is-done states */ + int nelems; /* length of elemdone[] array */ + bool pending_srf_tuples; /* still evaluating srfs in tlist? */ +} ProjectSetState; + +/* ---------------- * ModifyTableState information * ---------------- */ diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 4c4319bcab..d65958153d 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -43,6 +43,7 @@ typedef enum NodeTag */ T_Plan, T_Result, + T_ProjectSet, T_ModifyTable, T_Append, T_MergeAppend, @@ -91,6 +92,7 @@ typedef enum NodeTag */ T_PlanState, T_ResultState, + T_ProjectSetState, T_ModifyTableState, T_AppendState, T_MergeAppendState, @@ -245,6 +247,7 @@ typedef enum NodeTag T_UniquePath, T_GatherPath, T_ProjectionPath, + T_ProjectSetPath, T_SortPath, T_GroupPath, T_UpperUniquePath, diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index 6810f8c099..f72f7a8978 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -177,6 +177,17 @@ typedef struct Result } Result; /* ---------------- + * ProjectSet node - + * Apply a projection that includes set-returning functions to the + * output tuples of the outer plan. + * ---------------- + */ +typedef struct ProjectSet +{ + Plan plan; +} ProjectSet; + +/* ---------------- * ModifyTable node - * Apply rows produced by subplan(s) to result table(s), * by inserting, updating, or deleting. diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 1e950c4afd..643be54d40 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -1305,6 +1305,17 @@ typedef struct ProjectionPath } ProjectionPath; /* + * ProjectSetPath represents evaluation of a targetlist that includes + * set-returning function(s), which will need to be implemented by a + * ProjectSet plan node. + */ +typedef struct ProjectSetPath +{ + Path path; + Path *subpath; /* path representing input source */ +} ProjectSetPath; + +/* * SortPath represents an explicit sort step * * The sort keys are, by definition, the same as path.pathkeys. diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h index 6173ef8d75..cc0d7b0a26 100644 --- a/src/include/optimizer/clauses.h +++ b/src/include/optimizer/clauses.h @@ -54,7 +54,6 @@ extern bool contain_window_function(Node *clause); extern WindowFuncLists *find_window_functions(Node *clause, Index maxWinRef); extern double expression_returns_set_rows(Node *clause); -extern double tlist_returns_set_rows(List *tlist); extern bool contain_subplans(Node *clause); diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index d16f879fc1..7b41317621 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -144,6 +144,10 @@ extern Path *apply_projection_to_path(PlannerInfo *root, RelOptInfo *rel, Path *path, PathTarget *target); +extern ProjectSetPath *create_set_projection_path(PlannerInfo *root, + RelOptInfo *rel, + Path *subpath, + PathTarget *target); extern SortPath *create_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, diff --git a/src/include/optimizer/tlist.h b/src/include/optimizer/tlist.h index f80b31a673..976024a164 100644 --- a/src/include/optimizer/tlist.h +++ b/src/include/optimizer/tlist.h @@ -61,6 +61,9 @@ extern void add_column_to_pathtarget(PathTarget *target, extern void add_new_column_to_pathtarget(PathTarget *target, Expr *expr); extern void add_new_columns_to_pathtarget(PathTarget *target, List *exprs); extern void apply_pathtarget_labeling_to_tlist(List *tlist, PathTarget *target); +extern void split_pathtarget_at_srfs(PlannerInfo *root, + PathTarget *target, PathTarget *input_target, + List **targets, List **targets_contain_srfs); /* Convenience macro to get a PathTarget with valid cost/width fields */ #define create_pathtarget(root, tlist) \ |