On 16 March 2013 09:07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "David E. Wheeler" <david@justatheory.com> writes:
>> This surprised me:
>
>> david=# select array_length('{}'::text[], 1);
>> array_length
>> --------------
>> [null]
>
>> I had expecte dit to retur 0. I might expect NULL for a NULL param, but not one that's defined but has no elements.
>
> The thing is that that syntax creates an array of zero dimensions,
> not one that has 1 dimension and zero elements. So "0" would be
> incorrect.
>
I'm going to ask the question that immediately comes to mind: Is there
anything good at all about being able to define a zero-dimensional
array?
I would have thought that anything deserving the name "array" has
one-or-more dimensions, and that a "zero-dimensional array" is a weird
way of talking about a scalar value. In which case '{}'::text[] would
not be a legitimate way to declare one anyway. Am I missing
something?
Cheers,
BJ