Re: Should array_length() Return NULL

Поиск
Список
Период
Сортировка
От Brendan Jurd
Тема Re: Should array_length() Return NULL
Дата
Msg-id CADxJZo194K4Nk9sg_6s6CEyX0ppUjg_bfOLr35ZfEm0jAuZ2wg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Should array_length() Return NULL  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Should array_length() Return NULL  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: Improving avg performance for numeric
Следующее
От: Fujii Masao
Дата:
Сообщение: Re: Support for REINDEX CONCURRENTLY