Re: [HACKERS] string_to_array with empty input

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, justin <justin(at)emproshunts(dot)com>, Greg Stark <stark(at)enterprisedb(dot)com>, Sam Mason <sam(at)samason(dot)me(dot)uk>, pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] string_to_array with empty input
Date: 2009-04-02 00:31:30
Message-ID: 49D40762.6090908@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Tom Lane wrote:
>
> I'm starting to vacillate again. It's clear that for the purposes
> of string_to_array, an empty input string is fundamentally ambiguous:
> it could mean a list of no things, or a list of one empty thing.
>
Agreed. Of the two, a list of one empty thing makes string_to_array
closer to an inverse of array_to_string.

> Or we could stick to the current behavior and say "use COALESCE() to
> resolve the ambiguity, if you need to".
>
>
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.

If the decision is to leave the behavior unchanged, it at least cries
out for a documentation patch.

Cheers,
Steve

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Leif B. Kristensen 2009-04-02 00:53:26 Re: [HACKERS] string_to_array with empty input
Previous Message Robert Haas 2009-04-01 21:33:29 Re: [HACKERS] string_to_array with empty input

Browse pgsql-hackers by date

  From Date Subject
Next Message Leif B. Kristensen 2009-04-02 00:53:26 Re: [HACKERS] string_to_array with empty input
Previous Message Tom Lane 2009-04-01 23:57:17 Re: protect dll lib initialisation against any exception, for 8.5