Re: [HACKERS] string_to_array with empty input

Поиск
Список
Период
Сортировка
От Steve Crawford
Тема Re: [HACKERS] string_to_array with empty input
Дата
Msg-id 49D4E7D0.2090704@pinpointresearch.com
обсуждение исходный текст
Ответ на Re: [HACKERS] string_to_array with empty input  ("Leif B. Kristensen" <leif@solumslekt.org>)
Ответы Re: [HACKERS] string_to_array with empty input  (Sam Mason <sam@samason.me.uk>)
Список pgsql-general
Leif B. Kristensen wrote:
> On Thursday 2. April 2009, Steve Crawford wrote:
>
>> Currently string_to_array(null, ',') yields a null result -
>> indistinguishable from string_to_array('',','). Wrapping in coalesce
>> does not help distinguish true null input from empty-string input. I'm
>> not sure at the moment what other cases exist where non-null input
>> generates null output.
>>
>
> Somehow this reminds me of the old "division by zero" problem.
>
> IMO, the proper way to handle this kind of anomaly would be to test if
> the length of the string is non-zero before submitting it to the
> string_to_array() function.
>
Quite the opposite. Where division by zero is simply illegal as is, say,
string_to_array(1234, ','), string_to_array('', ',') is legal.
Unfortunately it is legal, and legal and legal.... with numerous
reasonable interpretations of which legal is most appropriate/consistent.

I would argue against a change to have string_to_array('',',') throw an
error.

Cheers,
Steve


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

Предыдущее
От: Sam Mason
Дата:
Сообщение: Re: reducing IO and memory usage: sending the content of a table to multiple files
Следующее
От: Steve Clark
Дата:
Сообщение: Re: cast needed - but where and why?