Markus Bertheau ☭ <twanger@bluetwanger.de> writes:
> By analogy, array_upper('{}'::TEXT[], 1) should return 0 instead of
> NULL.
No, that doesn't follow ... we've traditionally considered '{}' to
denote a zero-dimensional array. A 1-D array of no elements is
'[1:0]={}', just as Joe shows ... or at least it would be except
for an overenthusiastic error check:
regression=# select '[1:0]={}' :: int[];
ERROR: upper bound cannot be less than lower bound
I think this should be a legal boundary case. In general, it should be
possible to form zero-size arrays of any number of dimensions.
regards, tom lane