pgsql: Allow aggregate functions to be VARIADIC.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Allow aggregate functions to be VARIADIC.
Дата
Msg-id E1VGxqX-000483-Iy@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Allow aggregate functions to be VARIADIC.

There's no inherent reason why an aggregate function can't be variadic
(even VARIADIC ANY) if its transition function can handle the case.
Indeed, this patch to add the feature touches none of the planner or
executor, and little of the parser; the main missing stuff was DDL and
pg_dump support.

It is true that variadic aggregates can create the same sort of ambiguity
about parameters versus ORDER BY keys that was complained of when we
(briefly) had both one- and two-argument forms of string_agg().  However,
the policy formed in response to that discussion only said that we'd not
create any built-in aggregates with varying numbers of arguments, not that
we shouldn't allow users to do it.  So the logical extension of that is
we can allow users to make variadic aggregates as long as we're wary about
shipping any such in core.

In passing, this patch allows aggregate function arguments to be named, to
the extent of remembering the names in pg_proc and dumping them in pg_dump.
You can't yet call an aggregate using named-parameter notation.  That seems
like a likely future extension, but it'll take some work, and it's not what
this patch is really about.  Likewise, there's still some work needed to
make window functions handle VARIADIC fully, but I left that for another
day.

initdb forced because of new aggvariadic field in Aggref parse nodes.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/0d3f4406dfa00d848711fdb4af53be663ffc7d0f

Modified Files
--------------
doc/src/sgml/ref/alter_aggregate.sgml          |   37 +++++++++++--
doc/src/sgml/ref/alter_extension.sgml          |    4 +-
doc/src/sgml/ref/comment.sgml                  |    8 +--
doc/src/sgml/ref/create_aggregate.sgml         |   36 ++++++++++---
doc/src/sgml/ref/drop_aggregate.sgml           |   32 ++++++++++--
doc/src/sgml/ref/security_label.sgml           |   10 ++--
doc/src/sgml/syntax.sgml                       |    7 +++
doc/src/sgml/xaggr.sgml                        |   36 +++++++++++++
src/backend/catalog/pg_aggregate.c             |   18 ++++---
src/backend/commands/aggregatecmds.c           |   55 ++++++++++++++------
src/backend/commands/functioncmds.c            |   66 ++++++++++++++++--------
src/backend/executor/nodeAgg.c                 |    1 +
src/backend/executor/nodeWindowAgg.c           |    1 +
src/backend/nodes/copyfuncs.c                  |    1 +
src/backend/nodes/equalfuncs.c                 |    1 +
src/backend/nodes/outfuncs.c                   |    1 +
src/backend/nodes/readfuncs.c                  |    1 +
src/backend/parser/gram.y                      |   47 ++++++++++++-----
src/backend/parser/parse_agg.c                 |   16 +++---
src/backend/parser/parse_func.c                |   16 +++---
src/backend/tcop/utility.c                     |    3 +-
src/backend/utils/adt/ruleutils.c              |   20 +++++--
src/bin/pg_dump/pg_dump.c                      |   60 +++++++++++++++++----
src/bin/psql/describe.c                        |    9 +++-
src/include/catalog/catversion.h               |    2 +-
src/include/catalog/pg_aggregate.h             |    6 ++-
src/include/commands/defrem.h                  |   13 ++++-
src/include/nodes/primnodes.h                  |    1 +
src/include/parser/parse_agg.h                 |    1 +
src/test/regress/expected/aggregates.out       |   13 +++++
src/test/regress/expected/create_aggregate.out |    7 +++
src/test/regress/expected/opr_sanity.out       |   12 ++++-
src/test/regress/sql/aggregates.sql            |    4 ++
src/test/regress/sql/create_aggregate.sql      |    9 ++++
src/test/regress/sql/opr_sanity.sql            |   10 +++-
35 files changed, 448 insertions(+), 116 deletions(-)


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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: pgsql: Update obsolete comment
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Don't fail for bad GUCs in CREATE FUNCTION with check_function_b