From 53685d79813a46c7e3a46ae4b1210f608d41d6ab Mon Sep 17 00:00:00 2001 From: Noah Misch Date: Tue, 10 Dec 2013 09:34:37 -0500 Subject: Rename TABLE() to ROWS FROM(). SQL-standard TABLE() is a subset of UNNEST(); they deal with arrays and other collection types. This feature, however, deals with set-returning functions. Use a different syntax for this feature to keep open the possibility of implementing the standard TABLE(). --- doc/src/sgml/queries.sgml | 16 ++++++++-------- doc/src/sgml/ref/select.sgml | 19 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/queries.sgml b/doc/src/sgml/queries.sgml index b33de682005..daba74bd631 100644 --- a/doc/src/sgml/queries.sgml +++ b/doc/src/sgml/queries.sgml @@ -647,7 +647,7 @@ FROM (VALUES ('anne', 'smith'), ('bob', 'jones'), ('joe', 'blow')) - Table functions may also be combined using the TABLE + Table functions may also be combined using the ROWS FROM syntax, with the results returned in parallel columns; the number of result rows in this case is that of the largest function result, with smaller results padded with NULLs to match. @@ -655,7 +655,7 @@ FROM (VALUES ('anne', 'smith'), ('bob', 'jones'), ('joe', 'blow')) function_call WITH ORDINALITY AS table_alias (column_alias , ... ) -TABLE( function_call , ... ) WITH ORDINALITY AS table_alias (column_alias , ... ) +ROWS FROM( function_call , ... ) WITH ORDINALITY AS table_alias (column_alias , ... ) @@ -674,7 +674,7 @@ TABLE( function_call , ... ) UNNEST () had been called on each parameter - separately and combined using the TABLE construct. + separately and combined using the ROWS FROM construct. @@ -683,7 +683,7 @@ UNNEST( array_expression , ... If no table_alias is specified, the function - name is used as the table name; in the case of a TABLE() + name is used as the table name; in the case of a ROWS FROM() construct, the first function's name is used. @@ -731,20 +731,20 @@ SELECT * FROM vw_getfoo; function_call AS alias (column_definition , ... ) function_call AS alias (column_definition , ... ) -TABLE( ... function_call AS (column_definition , ... ) , ... ) +ROWS FROM( ... function_call AS (column_definition , ... ) , ... ) - When not using the TABLE() syntax, + When not using the ROWS FROM() syntax, the column_definition list replaces the column alias list that could otherwise be attached to the FROM item; the names in the column definitions serve as column aliases. - When using the TABLE() syntax, + When using the ROWS FROM() syntax, a column_definition list can be attached to each member function separately; or if there is only one member function and no WITH ORDINALITY clause, a column_definition list can be written in - place of a column alias list following TABLE(). + place of a column alias list following ROWS FROM(). diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml index 88ebd73d49c..d6a17cc7a44 100644 --- a/doc/src/sgml/ref/select.sgml +++ b/doc/src/sgml/ref/select.sgml @@ -56,7 +56,7 @@ SELECT [ ALL | DISTINCT [ ON ( expressionalias [ ( column_alias [, ...] ) ] ] [ LATERAL ] function_name ( [ argument [, ...] ] ) [ AS ] alias ( column_definition [, ...] ) [ LATERAL ] function_name ( [ argument [, ...] ] ) AS ( column_definition [, ...] ) - [ LATERAL ] TABLE( function_name ( [ argument [, ...] ] ) [ AS ( column_definition [, ...] ) ] [, ...] ) + [ LATERAL ] ROWS FROM( function_name ( [ argument [, ...] ] ) [ AS ( column_definition [, ...] ) ] [, ...] ) [ WITH ORDINALITY ] [ [ AS ] alias [ ( column_alias [, ...] ) ] ] from_item [ NATURAL ] join_type from_item [ ON join_condition | USING ( join_column [, ...] ) ] @@ -390,7 +390,7 @@ TABLE [ ONLY ] table_name [ * ] Multiple function calls can be combined into a single FROM-clause item by surrounding them - with TABLE( ... ). The output of such an item is the + with ROWS FROM( ... ). The output of such an item is the concatenation of the first row from each function, then the second row from each function, etc. If some of the functions produce fewer rows than others, NULLs are substituted for the missing data, so @@ -410,18 +410,18 @@ TABLE [ ONLY ] table_name [ * ] - When using the TABLE( ... ) syntax, if one of the + When using the ROWS FROM( ... ) syntax, if one of the functions requires a column definition list, it's preferred to put the column definition list after the function call inside - TABLE( ... ). A column definition list can be placed - after the TABLE( ... ) construct only if there's just a - single function and no WITH ORDINALITY clause. + ROWS FROM( ... ). A column definition list can be placed + after the ROWS FROM( ... ) construct only if there's just + a single function and no WITH ORDINALITY clause. To use ORDINALITY together with a column definition - list, you must use the TABLE( ... ) syntax and put the - column definition list inside TABLE( ... ). + list, you must use the ROWS FROM( ... ) syntax and put the + column definition list inside ROWS FROM( ... ). @@ -1811,8 +1811,7 @@ SELECT distributors.* WHERE distributors.name = 'Westward'; - Placing multiple function calls inside TABLE( ... ) syntax is - also an extension of the SQL standard. + ROWS FROM( ... ) is an extension of the SQL standard. -- cgit v1.2.3