1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-31 17:02:12 +03:00

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
This commit is contained in:
Tom Lane
2014-11-25 12:21:22 -05:00
parent 25976710df
commit bac27394a1
18 changed files with 797 additions and 115 deletions

View File

@@ -12035,7 +12035,7 @@ NULL baz</literallayout>(3 rows)</entry>
<function>array_agg(<replaceable class="parameter">expression</replaceable>)</function>
</entry>
<entry>
any
any non-array type
</entry>
<entry>
array of the argument type
@@ -12043,6 +12043,21 @@ NULL baz</literallayout>(3 rows)</entry>
<entry>input values, including nulls, concatenated into an array</entry>
</row>
<row>
<entry>
<function>array_agg(<replaceable class="parameter">expression</replaceable>)</function>
</entry>
<entry>
any array type
</entry>
<entry>
same as argument data type
</entry>
<entry>input arrays concatenated into array of one higher dimension
(inputs must all have same dimensionality,
and cannot be empty or NULL)</entry>
</row>
<row>
<entry>
<indexterm>