Support arrays as input to array_agg() and ARRAY(SELECT ...).

Enterprise / PostgreSQL - Tom Lane [sss.pgh.pa.us] - 25 November 2014 11:21 UTC

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

bac2739 Support arrays as input to array_agg() and ARRAY(SELECT ...).
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(-)

Upstream: git.postgresql.org


  • Share