Re: string_to_array with an empty input string

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: string_to_array with an empty input string
Дата
Msg-id AANLkTimY0Z4U9S-=dNON82fVhm9xFC38JrfMZYeef3Zo@mail.gmail.com
обсуждение исходный текст
Ответ на Re: string_to_array with an empty input string  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: string_to_array with an empty input string  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: string_to_array with an empty input string  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
On 11 August 2010 18:53, Robert Haas <robertmhaas@gmail.com> wrote:
>> I think that there's a need for additional built-in array functions,
>> including one to succinctly test if an array has no elements.
>
> What do you propose?  I think the easiest ways to do it right now are:
>
> array_length(arr, 1) is null
>
> or just using an equality test, like this:
>
> arr = '{}'::int[]

What's wrong with something like array_is_empty(anyarray) returns
boolean? I don't know why we're so apparently averse to creating
built-in convenience functions. It's quite easy to forget the intent
of either of those two statements.

>> Iterating through an array with plpgsql, for example, is more clunky
>> than it should be.
>
> Really?
>
> FOR var IN SELECT UNNEST(arr) LOOP ... END LOOP
>
> I mean, doing everything is sort of clunky in PL/pgsql, but this
> doesn't seem particularly bad as PL/pgsql idioms go.

Right. I agree that many of the idioms are on the clunky side, but I
think that the fact that my original remarks about iterating over
arrays generated discussion is a bit telling. unnest() was only
introduced in PG 8.4.

Iterating over an array is a simple thing. We should make simple things easy.

--
Regards,
Peter Geoghegan


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Regression tests versus the buildfarm environment
Следующее
От: Tom Lane
Дата:
Сообщение: Re: review: xml_is_well_formed