pgsql: Support arrays as input to array_agg() and ARRAY(SELECT ...). - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Support arrays as input to array_agg() and ARRAY(SELECT ...).
Date
Msg-id E1XtJoW-0006SS-R7@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Support arrays as input to array_agg() and ARRAY(SELECT ...).

These cases formerly failed with errors about "could not find array type
for data type".  Now they yield arrays of the same element type and one
higher dimension.

The implementation involves creating functions with API similar to the
existing accumArrayResult() family.  I (tgl) also extended the base family
by adding an initArrayResult() function, which allows callers to avoid
special-casing the zero-inputs case if they just want an empty array as
result.  (Not all do, so the previous calling convention remains valid.)
This allowed simplifying some existing code in xml.c and plperl.c.

Ali Akbar, reviewed by Pavel Stehule, significantly modified by me

Branch
------
master

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

Modified Files
--------------
doc/src/sgml/func.sgml                  |   17 +-
doc/src/sgml/syntax.sgml                |   13 +-
doc/src/sgml/xaggr.sgml                 |    8 +-
src/backend/executor/nodeSubplan.c      |   38 +--
src/backend/nodes/nodeFuncs.c           |    4 +-
src/backend/optimizer/plan/subselect.c  |    2 +-
src/backend/utils/adt/array_userfuncs.c |   88 +++++-
src/backend/utils/adt/arrayfuncs.c      |  495 ++++++++++++++++++++++++++++---
src/backend/utils/adt/xml.c             |   31 +-
src/backend/utils/cache/lsyscache.c     |   21 ++
src/include/catalog/catversion.h        |    2 +-
src/include/catalog/pg_aggregate.h      |    1 +
src/include/catalog/pg_proc.h           |   18 +-
src/include/utils/array.h               |   55 ++++
src/include/utils/lsyscache.h           |    1 +
src/pl/plperl/plperl.c                  |   33 ++-
src/test/regress/expected/arrays.out    |   63 ++++
src/test/regress/sql/arrays.sql         |   22 ++
18 files changed, 797 insertions(+), 115 deletions(-)


pgsql-committers by date:

Previous
From: Stephen Frost
Date:
Subject: pgsql: Add int64 -> int8 mapping to genbki
Next
From: Tom Lane
Date:
Subject: pgsql: De-reserve most statement-introducing keywords in plpgsql.