pgsql: Allow polymorphic aggregates to have non-polymorphic state data

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Allow polymorphic aggregates to have non-polymorphic state data
Дата
Msg-id E1Wd6QK-0004D7-8K@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Allow polymorphic aggregates to have non-polymorphic state data types.

Before 9.4, such an aggregate couldn't be declared, because its final
function would have to have polymorphic result type but no polymorphic
argument, which CREATE FUNCTION would quite properly reject.  The
ordered-set-aggregate patch found a workaround: allow the final function
to be declared as accepting additional dummy arguments that have types
matching the aggregate's regular input arguments.  However, we failed
to notice that this problem applies just as much to regular aggregates,
despite the fact that we had a built-in regular aggregate array_agg()
that was known to be undeclarable in SQL because its final function
had an illegal signature.  So what we should have done, and what this
patch does, is to decouple the extra-dummy-arguments behavior from
ordered-set aggregates and make it generally available for all aggregate
declarations.  We have to put this into 9.4 rather than waiting till
later because it slightly alters the rules for declaring ordered-set
aggregates.

The patch turned out a bit bigger than I'd hoped because it proved
necessary to record the extra-arguments option in a new pg_aggregate
column.  I'd thought we could just look at the final function's pronargs
at runtime, but that didn't work well for variadic final functions.
It's probably just as well though, because it simplifies life for pg_dump
to record the option explicitly.

While at it, fix array_agg() to have a valid final-function signature,
and add an opr_sanity test to notice future deviations from polymorphic
consistency.  I also marked the percentile_cont() aggregates as not
needing extra arguments, since they don't.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/f0fedfe82c8adea78354652d67c027a1a8fbce88

Modified Files
--------------
doc/src/sgml/catalogs.sgml                     |   12 +
doc/src/sgml/ref/create_aggregate.sgml         |   49 +++-
doc/src/sgml/xaggr.sgml                        |   82 +++++--
src/backend/catalog/pg_aggregate.c             |   93 ++++----
src/backend/commands/aggregatecmds.c           |    8 +
src/backend/executor/nodeAgg.c                 |   48 ++--
src/backend/executor/nodeWindowAgg.c           |   33 ++-
src/backend/parser/parse_agg.c                 |   24 +-
src/bin/pg_dump/pg_dump.c                      |   40 +++-
src/include/catalog/catversion.h               |    2 +-
src/include/catalog/pg_aggregate.h             |  290 ++++++++++++------------
src/include/catalog/pg_proc.h                  |   10 +-
src/include/parser/parse_agg.h                 |    2 +-
src/test/regress/expected/create_aggregate.out |    4 +-
src/test/regress/expected/opr_sanity.out       |   60 +++--
src/test/regress/sql/create_aggregate.sql      |    4 +-
src/test/regress/sql/opr_sanity.sql            |   46 ++--
17 files changed, 509 insertions(+), 298 deletions(-)


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: doc: Fix DocBook table column count declaration
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix incorrect pg_proc.proallargtypes entries for two built-in fu