pgsql: Support multi-argument UNNEST(), and TABLE() syntax for multiple

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Support multi-argument UNNEST(), and TABLE() syntax for multiple
Дата
Msg-id E1Vjel1-0007x9-TR@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Support multi-argument UNNEST(), and TABLE() syntax for multiple functions.

This patch adds the ability to write TABLE( function1(), function2(), ...)
as a single FROM-clause entry.  The result is the concatenation of the
first row from each function, followed by the second row from each
function, etc; with NULLs inserted if any function produces fewer rows than
others.  This is believed to be a much more useful behavior than what
Postgres currently does with multiple SRFs in a SELECT list.

This syntax also provides a reasonable way to combine use of column
definition lists with WITH ORDINALITY: put the column definition list
inside TABLE(), where it's clear that it doesn't control the ordinality
column as well.

Also implement SQL-compliant multiple-argument UNNEST(), by turning
UNNEST(a,b,c) into TABLE(unnest(a), unnest(b), unnest(c)).

The SQL standard specifies TABLE() with only a single function, not
multiple functions, and it seems to require an implicit UNNEST() which is
not what this patch does.  There may be something wrong with that reading
of the spec, though, because if it's right then the spec's TABLE() is just
a pointless alternative spelling of UNNEST().  After further review of
that, we might choose to adopt a different syntax for what this patch does,
but in any case this functionality seems clearly worthwhile.

Andrew Gierth, reviewed by Zoltán Böszörményi and Heikki Linnakangas, and
significantly revised by me

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/784e762e886e6f72f548da86a27cd2ead87dbd1c

Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c |    9 +-
doc/src/sgml/func.sgml                          |   30 +-
doc/src/sgml/queries.sgml                       |   77 ++-
doc/src/sgml/ref/select.sgml                    |   83 ++-
src/backend/access/common/tupdesc.c             |   75 +-
src/backend/catalog/dependency.c                |   48 +-
src/backend/commands/createas.c                 |    1 +
src/backend/commands/explain.c                  |   45 +-
src/backend/commands/sequence.c                 |    1 +
src/backend/commands/tablecmds.c                |    2 +
src/backend/commands/view.c                     |    1 +
src/backend/executor/nodeFunctionscan.c         |  595 ++++++++++------
src/backend/nodes/copyfuncs.c                   |   36 +-
src/backend/nodes/equalfuncs.c                  |   28 +-
src/backend/nodes/makefuncs.c                   |   46 +-
src/backend/nodes/nodeFuncs.c                   |   24 +-
src/backend/nodes/outfuncs.c                    |   34 +-
src/backend/nodes/readfuncs.c                   |   26 +-
src/backend/optimizer/path/allpaths.c           |   51 +-
src/backend/optimizer/path/costsize.c           |   22 +-
src/backend/optimizer/path/pathkeys.c           |   51 ++
src/backend/optimizer/plan/createplan.c         |   35 +-
src/backend/optimizer/plan/initsplan.c          |    2 +-
src/backend/optimizer/plan/planner.c            |    4 +-
src/backend/optimizer/plan/setrefs.c            |    9 +-
src/backend/optimizer/plan/subselect.c          |   34 +-
src/backend/optimizer/prep/prepjointree.c       |    9 +-
src/backend/optimizer/util/clauses.c            |   16 +-
src/backend/optimizer/util/pathnode.c           |    4 +-
src/backend/parser/gram.y                       |   98 ++-
src/backend/parser/parse_clause.c               |  192 +++++-
src/backend/parser/parse_relation.c             |  836 +++++++++++++----------
src/backend/parser/parse_type.c                 |    2 +-
src/backend/parser/parse_utilcmd.c              |    2 +
src/backend/rewrite/rewriteHandler.c            |    2 +-
src/backend/utils/adt/ruleutils.c               |  134 +++-
src/include/access/tupdesc.h                    |    4 +-
src/include/catalog/catversion.h                |    2 +-
src/include/catalog/pg_operator.h               |    1 +
src/include/nodes/execnodes.h                   |   26 +-
src/include/nodes/nodes.h                       |    1 +
src/include/nodes/parsenodes.h                  |   83 ++-
src/include/nodes/plannodes.h                   |    8 +-
src/include/optimizer/pathnode.h                |    2 +-
src/include/optimizer/paths.h                   |    3 +
src/include/parser/parse_relation.h             |    5 +-
src/test/regress/expected/rangefuncs.out        |  772 +++++++++++++++------
src/test/regress/sql/rangefuncs.sql             |  271 +++++---
48 files changed, 2639 insertions(+), 1203 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Fujii Masao
Дата:
Сообщение: pgsql: Fix pg_isready to handle -d option properly.
Следующее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Tweak streamutil.c further to avoid scan-build warning