Re: ARRAY_LENGTH() function behavior with empty array

Поиск
Список
Период
Сортировка
От otar shavadze
Тема Re: ARRAY_LENGTH() function behavior with empty array
Дата
Msg-id CAG-jOyCN6LRL9UTfDwcwWG5Gfq8uX_OgD9K589FM8jG3fHqKjw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: ARRAY_LENGTH() function behavior with empty array  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Understood, and  backwards compatibility also of course. Thank you

On Fri, Dec 2, 2016 at 7:20 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
otar shavadze <oshavadze@gmail.com> writes:
> SELECT ARRAY_LENGTH('{}'::INT[], 1)
> This returns NULL, not so "dangerous" either way,  not would be more
> logically, if  array length function will return 0 from empty array,
> instead of NULL ?

Well, the issue is that you're asking about dimension 1 of a
zero-dimensional array, so the answer is indeed undefined, not 0.

A lot of people are not terribly happy with PG's array handling,
but there's enough interconnectedness to the behaviors that it's
hard to change just one thing ... and there's also backwards
compatibility to worry about.

                        regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Full text search randomly not working for short prefixes?
Следующее
От: cen
Дата:
Сообщение: Re: Full text search randomly not working for short prefixes?