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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Support arrays as input to array_agg() and ARRAY(SELECT ...).
Date: 2014-11-25 17:22:08
Message-ID: E1XtJoW-0006SS-R7@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2014-11-25 20:02:17 pgsql: De-reserve most statement-introducing keywords in plpgsql.
Previous Message Stephen Frost 2014-11-25 17:12:18 pgsql: Add int64 -> int8 mapping to genbki