On Wed, Aug 11, 2010 at 10:32 AM, Tom Lane <t...@sss.pgh.pa.us> wrote: > Greg Stark <gsst...@mit.edu> writes: >> Ideally you really want string_to_array(array_to_string(x, ':'),':') >> to return x. There's no safe return value to pick for the cases where >> x=[''] and x=[] that will make this work. > > It's easy to see that string_to_array/array_to_string are *not* usable > as general-purpose serialize/deserialize operations, so sweating over > corner cases like this one seems a bit pointless. The design center > for 'em seems to be array elements that are numbers, so there's no > issue with empty strings and no great difficulty in picking delimiters > and null representations that can't appear in the data. I think they're > essentially worthless for arrays of text.
array_to_string() is quite useful for arrays of text; I use it to generate human-readable output, by setting the delimiter to ', '. Whether string_to_array() is useful is another matter. It probably is in some cases, but putting parsing logic into the database layer tends to be a bit klunky, unless you know from context that you needn't worry about the error cases. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers