Re: [HACKERS] string_to_array with empty input - Mailing list pgsql-general

From Robert Haas
Subject Re: [HACKERS] string_to_array with empty input
Date
Msg-id 603c8f070904021041g3655aa4fi4bf9065e46e45c65@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] string_to_array with empty input  ("David E. Wheeler" <david@kineticode.com>)
List pgsql-general
On Thu, Apr 2, 2009 at 12:17 PM, David E. Wheeler <david@kineticode.com> wrote:
> On Apr 1, 2009, at 2:22 PM, Tom Lane wrote:
>
>> Another way to state the point is that we can offer people a choice of
>> two limitations: string_to_array doesn't work for zero-length lists,
>> or string_to_array doesn't work for empty strings (except most of the
>> time, it does).  The former is sounding less likely to bite people
>> unexpectedly.
>
> Right, very well put.
>
>> Or we could stick to the current behavior and say "use COALESCE() to
>> resolve the ambiguity, if you need to".
>
> Steve has a point that leaving it as-is leaves it as impossible to tell the
> difference between string_to_array(NULL, ',') and string_to_array('', ',').
> The former properly handles an unknown value, while the latter, where '' is
> a known value, seems weird to be returning NULL.

*shrug* CASE WHEN blah IS NOT NULL THEN string_to_array(blah, ',') END

More and more I'm leaning toward leaving this alone.  No matter how
you define it, the behavior can be changed to whichever alternative
you prefer with a 1-line case statement.

...Robert

pgsql-general by date:

Previous
From: Sam Mason
Date:
Subject: Re: [HACKERS] string_to_array with empty input
Next
From: Robert Haas
Date:
Subject: Re: [HACKERS] string_to_array with empty input