Fix handling of empty arrays in array_fill().
authorTom Lane <[email protected]>
Thu, 5 Jan 2017 16:33:51 +0000 (11:33 -0500)
committerTom Lane <[email protected]>
Thu, 5 Jan 2017 16:33:51 +0000 (11:33 -0500)
commitee9cb284a6d6c79080033b825391b8b78b5eccfb
tree43179809987ff115609890b712a76214a4929156
parent5f89a9885e118ab22689f9641237f7941d9ba8fd
Fix handling of empty arrays in array_fill().

array_fill(..., array[0]) produced an empty array, which is probably
what users expect, but it was a one-dimensional zero-length array
which is not our standard representation of empty arrays.  Also, for
no very good reason, it rejected empty input arrays; that case should
be allowed and produce an empty output array.

In passing, remove the restriction that the input array(s) have lower
bound 1.  That seems rather pointless, and it would have needed extra
complexity to make the check deal with empty input arrays.

Per bug #14487 from Andrew Gierth.  It's been broken all along, so
back-patch to all supported branches.

Discussion: https://postgr.es/m/20170105152156[email protected]
src/backend/utils/adt/arrayfuncs.c
src/test/regress/expected/arrays.out
src/test/regress/sql/arrays.sql