The following bug has been logged on the website:
Bug reference: 14487
Logged by: Andrew Gierth
Email address: andrew(at)tao11(dot)riddles(dot)org(dot)uk
PostgreSQL version: 9.6.1
Operating system: any
Description:
array_fill returns a malformed empty array when given a size of zero:
select a, a = '{}' from (select array_fill(null::integer, array[0]) as a)
s;
a | ?column?
----+----------
{} | f
The result actually has ndims=1 and a length of 0, which can be checked with
array_length(a,1).
Obvious fix is to move the fast-track empty result to after computing
nitems?