Waiting for 9.5 – Support arrays as input to array_agg() and ARRAY(SELECT …).

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

I have waited for this for so long. To be honest, I think our (PostgreSQL) array support is somewhat limited. But maybe I'm spoiled by Perl or Ruby.

In any way – up to now, there was no simple way to aggregate arrays – of course you could write your own aggregates, but this gets tedious fast.

Work with different length is not simple due possible performance (memory) issues. Next, there is not clean how to merge arrays of different size – PostgreSQL arrays have to be regular. If you need a array of arrays, then use a trick ARRAY(ROW(ARRAY))