Re: string_to_array with empty input

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: string_to_array with empty input
Дата
Msg-id 4136ffa0903310908g43a8a733n2abbc12d02d8ba3e@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [GENERAL] string_to_array with empty input  (Sam Mason <sam@samason.me.uk>)
Ответы Re: [GENERAL] string_to_array with empty input  (Sam Mason <sam@samason.me.uk>)
Список pgsql-hackers
On Tue, Mar 31, 2009 at 4:34 PM, Sam Mason <sam@samason.me.uk> wrote:
>
> That's also a disingenuous example; what would you expect back from:
>
>  select count_elements(string_to_array('butter,,milk',','))
>
> I think the semantics you want is what you'd get from:
>
>  array_filter_blanks(string_to_array($1,$2))
>
> where I defined "array_filter_blanks" in my previous post.

I think you're still thinking from a programmers point of view
thinking about string processing.

From a functional point of view, if I give you a comma separated list
of items which is an empty string and ask you how many items are in it
nobody would normally say there's one empty thing in the list.

Both interpretations are clearly consistent but it depends on whether
you think it's a bunch of text strings concatenated together or if
it's a list of objects.

The example of string_to_array('',',')::int[] is relevant to this
point. The whole "there's one empty element" only makes sense if
you're thinking in terms of string processing. If it's a list of any
other kind of object it probably doesn't make sense; you can't say
there's one empty integer or one empty composite object or one empty
anything else.

--
greg

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

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: Partitioning feature ...
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Solaris getopt_long and PostgreSQL