aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/tupdesc.h1
-rw-r--r--src/include/nodes/execnodes.h10
-rw-r--r--src/include/nodes/parsenodes.h22
-rw-r--r--src/include/nodes/plannodes.h1
-rw-r--r--src/include/parser/kwlist.h1
5 files changed, 28 insertions, 7 deletions
diff --git a/src/include/access/tupdesc.h b/src/include/access/tupdesc.h
index 51c5575f070..49226b70e6b 100644
--- a/src/include/access/tupdesc.h
+++ b/src/include/access/tupdesc.h
@@ -87,6 +87,7 @@ extern TupleDesc CreateTupleDesc(int natts, bool hasoid,
Form_pg_attribute *attrs);
extern TupleDesc CreateTupleDescCopy(TupleDesc tupdesc);
+extern TupleDesc CreateTupleDescCopyExtend(TupleDesc tupdesc, int moreatts);
extern TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc);
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 298af26e962..3b430e0f24a 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1395,7 +1395,10 @@ typedef struct SubqueryScanState
* function appearing in FROM (typically a function returning set).
*
* eflags node's capability flags
- * tupdesc expected return tuple description
+ * ordinal column value for WITH ORDINALITY
+ * scan_tupdesc scan tuple descriptor
+ * func_tupdesc function tuple descriptor
+ * func_slot function result slot, or null
* tuplestorestate private state of tuplestore.c
* funcexpr state for function expression being evaluated
* ----------------
@@ -1404,7 +1407,10 @@ typedef struct FunctionScanState
{
ScanState ss; /* its first field is NodeTag */
int eflags;
- TupleDesc tupdesc;
+ int64 ordinal;
+ TupleDesc scan_tupdesc;
+ TupleDesc func_tupdesc;
+ TupleTableSlot *func_slot;
Tuplestorestate *tuplestorestate;
ExprState *funcexpr;
} FunctionScanState;
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index b4013e893dc..51fef68ca3c 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -471,6 +471,7 @@ typedef struct RangeFunction
{
NodeTag type;
bool lateral; /* does it have LATERAL prefix? */
+ bool ordinality; /* does it have WITH ORDINALITY suffix? */
Node *funccallnode; /* untransformed function call tree */
Alias *alias; /* table alias & optional column aliases */
List *coldeflist; /* list of ColumnDef nodes to describe result
@@ -651,8 +652,13 @@ typedef struct XmlSerialize
* dropped columns. Note however that a stored rule may have nonempty
* colnames for columns dropped since the rule was created (and for that
* matter the colnames might be out of date due to column renamings).
+ *
* The same comments apply to FUNCTION RTEs when the function's return type
- * is a named composite type.
+ * is a named composite type. In addition, for all return types, FUNCTION
+ * RTEs with ORDINALITY must always have the last colname entry being the
+ * one for the ordinal column; this is enforced when constructing the RTE.
+ * Thus when ORDINALITY is used, there will be exactly one more colname
+ * than would have been present otherwise.
*
* In JOIN RTEs, the colnames in both alias and eref are one-to-one with
* joinaliasvars entries. A JOIN RTE will omit columns of its inputs when
@@ -751,15 +757,21 @@ typedef struct RangeTblEntry
/*
* Fields valid for a function RTE (else NULL):
*
- * If the function returns RECORD, funccoltypes lists the column types
- * declared in the RTE's column type specification, funccoltypmods lists
- * their declared typmods, funccolcollations their collations. Otherwise,
- * those fields are NIL.
+ * If the function returns an otherwise-unspecified RECORD, funccoltypes
+ * lists the column types declared in the RTE's column type specification,
+ * funccoltypmods lists their declared typmods, funccolcollations their
+ * collations. Note that in this case, ORDINALITY is not permitted, so
+ * there is no extra ordinal column to be allowed for.
+ *
+ * Otherwise, those fields are NIL, and the result column types must be
+ * derived from the funcexpr while treating the ordinal column, if
+ * present, as a special case. (see get_rte_attribute_*)
*/
Node *funcexpr; /* expression tree for func call */
List *funccoltypes; /* OID list of column type OIDs */
List *funccoltypmods; /* integer list of column typmods */
List *funccolcollations; /* OID list of column collation OIDs */
+ bool funcordinality; /* is this called WITH ORDINALITY? */
/*
* Fields valid for a values RTE (else NIL):
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index aa4f12cec55..44ea0b77529 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -425,6 +425,7 @@ typedef struct FunctionScan
{
Scan scan;
Node *funcexpr; /* expression tree for func call */
+ bool funcordinality; /* WITH ORDINALITY */
List *funccolnames; /* output column names (string Value nodes) */
List *funccoltypes; /* OID list of column type OIDs */
List *funccoltypmods; /* integer list of column typmods */
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index 287f78e72a6..8bd34d6e8f0 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -269,6 +269,7 @@ PG_KEYWORD("option", OPTION, UNRESERVED_KEYWORD)
PG_KEYWORD("options", OPTIONS, UNRESERVED_KEYWORD)
PG_KEYWORD("or", OR, RESERVED_KEYWORD)
PG_KEYWORD("order", ORDER, RESERVED_KEYWORD)
+PG_KEYWORD("ordinality", ORDINALITY, UNRESERVED_KEYWORD)
PG_KEYWORD("out", OUT_P, COL_NAME_KEYWORD)
PG_KEYWORD("outer", OUTER_P, TYPE_FUNC_NAME_KEYWORD)
PG_KEYWORD("over", OVER, UNRESERVED_KEYWORD)