Re: [HACKERS] string_to_array with empty input

Поиск
Список
Период
Сортировка
От Sam Mason
Тема Re: [HACKERS] string_to_array with empty input
Дата
Msg-id 20090402173540.GP12225@frubble.xen.chris-lamb.co.uk
обсуждение исходный текст
Ответ на Re: [HACKERS] string_to_array with empty input  (Steve Crawford <scrawford@pinpointresearch.com>)
Список pgsql-general
On Thu, Apr 02, 2009 at 09:29:04AM -0700, Steve Crawford wrote:
> Leif B. Kristensen wrote:
> >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

This is just a matter of definitions; divide by zero is fine in lots of
languages and no exception will be raised.  The fact that you're saying
it's "simply illegal" means that you've internalised the definition to
such an extent that any alternative appears "simply illegal".

It seems reasonable to assume that if, to pick an arbitrary choice,
string_to_array returned a zero element set people would say it was
"simply illegal" for it to do anything else.  There are choices for
either and a choice needs to be made or the situation should somehow be
made impossible.

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

I'd agree, throwing an exception here doesn't seem useful.

--
  Sam  http://samason.me.uk/

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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: How to find the query completeion time?
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] string_to_array with empty input