Re: string_to_array with an empty input string

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com>, "David E(dot) Wheeler" <david(at)kineticode(dot)com>, Thom Brown <thom(at)linux(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: string_to_array with an empty input string
Date: 2010-08-11 14:32:53
Message-ID: 5012.1281537173@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Greg Stark <gsstark(at)mit(dot)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.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2010-08-11 14:35:18 Re: RecordTransactionCommit() and SharedInvalidationMessages
Previous Message Kevin Grittner 2010-08-11 14:27:27 Re: assertions and constraint triggers