diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 2 | ||||
-rw-r--r-- | src/backend/nodes/equalfuncs.c | 2 | ||||
-rw-r--r-- | src/backend/nodes/outfuncs.c | 2 | ||||
-rw-r--r-- | src/backend/parser/gram.y | 29 | ||||
-rw-r--r-- | src/backend/parser/parse_clause.c | 14 | ||||
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 14 |
6 files changed, 32 insertions, 31 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index e3edcf6f74f..cd8a11b8d5d 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -2310,7 +2310,7 @@ _copyRangeFunction(const RangeFunction *from) COPY_SCALAR_FIELD(lateral); COPY_SCALAR_FIELD(ordinality); - COPY_SCALAR_FIELD(is_table); + COPY_SCALAR_FIELD(is_rowsfrom); COPY_NODE_FIELD(functions); COPY_NODE_FIELD(alias); COPY_NODE_FIELD(coldeflist); diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 1f9b5d70f55..6188114060f 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -2142,7 +2142,7 @@ _equalRangeFunction(const RangeFunction *a, const RangeFunction *b) { COMPARE_SCALAR_FIELD(lateral); COMPARE_SCALAR_FIELD(ordinality); - COMPARE_SCALAR_FIELD(is_table); + COMPARE_SCALAR_FIELD(is_rowsfrom); COMPARE_NODE_FIELD(functions); COMPARE_NODE_FIELD(alias); COMPARE_NODE_FIELD(coldeflist); diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 4c7505e3341..22c7d40156b 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -2629,7 +2629,7 @@ _outRangeFunction(StringInfo str, const RangeFunction *node) WRITE_BOOL_FIELD(lateral); WRITE_BOOL_FIELD(ordinality); - WRITE_BOOL_FIELD(is_table); + WRITE_BOOL_FIELD(is_rowsfrom); WRITE_NODE_FIELD(functions); WRITE_NODE_FIELD(alias); WRITE_NODE_FIELD(coldeflist); diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 19220971da6..8fced4427b1 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -406,7 +406,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); a_expr b_expr c_expr AexprConst indirection_el columnref in_expr having_clause func_table array_expr ExclusionWhereClause -%type <list> func_table_item func_table_list opt_col_def_list +%type <list> rowsfrom_item rowsfrom_list opt_col_def_list %type <boolean> opt_ordinality %type <list> ExclusionConstraintList ExclusionConstraintElem %type <list> func_arg_list @@ -9980,13 +9980,13 @@ relation_expr_opt_alias: relation_expr %prec UMINUS /* * func_table represents a function invocation in a FROM list. It can be - * a plain function call, like "foo(...)", or a TABLE expression with - * one or more function calls, "TABLE (foo(...), bar(...))", + * a plain function call, like "foo(...)", or a ROWS FROM expression with + * one or more function calls, "ROWS FROM (foo(...), bar(...))", * optionally with WITH ORDINALITY attached. - * In the TABLE syntax, a column definition list can be given for each + * In the ROWS FROM syntax, a column definition list can be given for each * function, for example: - * TABLE (foo() AS (foo_res_a text, foo_res_b text), - * bar() AS (bar_res_a text, bar_res_b text)) + * ROWS FROM (foo() AS (foo_res_a text, foo_res_b text), + * bar() AS (bar_res_a text, bar_res_b text)) * It's also possible to attach a column definition list to the RangeFunction * as a whole, but that's handled by the table_ref production. */ @@ -9995,29 +9995,30 @@ func_table: func_expr_windowless opt_ordinality RangeFunction *n = makeNode(RangeFunction); n->lateral = false; n->ordinality = $2; - n->is_table = false; + n->is_rowsfrom = false; n->functions = list_make1(list_make2($1, NIL)); /* alias and coldeflist are set by table_ref production */ $$ = (Node *) n; } - | TABLE '(' func_table_list ')' opt_ordinality + | ROWS FROM '(' rowsfrom_list ')' opt_ordinality { RangeFunction *n = makeNode(RangeFunction); n->lateral = false; - n->ordinality = $5; - n->is_table = true; - n->functions = $3; + n->ordinality = $6; + n->is_rowsfrom = true; + n->functions = $4; /* alias and coldeflist are set by table_ref production */ $$ = (Node *) n; } ; -func_table_item: func_expr_windowless opt_col_def_list +rowsfrom_item: func_expr_windowless opt_col_def_list { $$ = list_make2($1, $2); } ; -func_table_list: func_table_item { $$ = list_make1($1); } - | func_table_list ',' func_table_item { $$ = lappend($1, $3); } +rowsfrom_list: + rowsfrom_item { $$ = list_make1($1); } + | rowsfrom_list ',' rowsfrom_item { $$ = lappend($1, $3); } ; opt_col_def_list: AS '(' TableFuncElementList ')' { $$ = $3; } diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 8b4c0ae0d3b..939fa834e0a 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -655,25 +655,25 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) * expansion) and no WITH ORDINALITY. The reason for the latter * restriction is that it's not real clear whether the ordinality column * should be in the coldeflist, and users are too likely to make mistakes - * in one direction or the other. Putting the coldeflist inside TABLE() - * is much clearer in this case. + * in one direction or the other. Putting the coldeflist inside ROWS + * FROM() is much clearer in this case. */ if (r->coldeflist) { if (list_length(funcexprs) != 1) { - if (r->is_table) + if (r->is_rowsfrom) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("TABLE() with multiple functions cannot have a column definition list"), - errhint("Put a separate column definition list for each function inside TABLE()."), + errmsg("ROWS FROM() with multiple functions cannot have a column definition list"), + errhint("Put a separate column definition list for each function inside ROWS FROM()."), parser_errposition(pstate, exprLocation((Node *) r->coldeflist)))); else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("UNNEST() with multiple arguments cannot have a column definition list"), - errhint("Use separate UNNEST() calls inside TABLE(), and attach a column definition list to each one."), + errhint("Use separate UNNEST() calls inside ROWS FROM(), and attach a column definition list to each one."), parser_errposition(pstate, exprLocation((Node *) r->coldeflist)))); } @@ -681,7 +681,7 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("WITH ORDINALITY cannot be used with a column definition list"), - errhint("Put the column definition list inside TABLE()."), + errhint("Put the column definition list inside ROWS FROM()."), parser_errposition(pstate, exprLocation((Node *) r->coldeflist)))); diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 348f620f2a4..86c0a582539 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -8125,10 +8125,10 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) rtfunc1 = (RangeTblFunction *) linitial(rte->functions); /* - * Omit TABLE() syntax if there's just one function, unless it + * Omit ROWS FROM() syntax for just one function, unless it * has both a coldeflist and WITH ORDINALITY. If it has both, - * we must use TABLE() syntax to avoid ambiguity about whether - * the coldeflist includes the ordinality column. + * we must use ROWS FROM() syntax to avoid ambiguity about + * whether the coldeflist includes the ordinality column. */ if (list_length(rte->functions) == 1 && (rtfunc1->funccolnames == NIL || !rte->funcordinality)) @@ -8151,8 +8151,8 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) * XXX This is pretty ugly, since it makes not-terribly- * future-proof assumptions about what the parser would do * with the output; but the alternative is to emit our - * nonstandard extended TABLE() notation for what might - * have been a perfectly spec-compliant multi-argument + * nonstandard ROWS FROM() notation for what might have + * been a perfectly spec-compliant multi-argument * UNNEST(). */ all_unnest = true; @@ -8189,7 +8189,7 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) { int funcno = 0; - appendStringInfoString(buf, "TABLE("); + appendStringInfoString(buf, "ROWS FROM("); foreach(lc, rte->functions) { RangeTblFunction *rtfunc = (RangeTblFunction *) lfirst(lc); @@ -8422,7 +8422,7 @@ get_column_alias_list(deparse_columns *colinfo, deparse_context *context) * * When printing a top-level coldeflist (which is syntactically also the * relation's column alias list), use column names from colinfo. But when - * printing a coldeflist embedded inside TABLE(), we prefer to use the + * printing a coldeflist embedded inside ROWS FROM(), we prefer to use the * original coldeflist's names, which are available in rtfunc->funccolnames. * Pass NULL for colinfo to select the latter behavior. * |