| From: | Sam Mason <sam(at)samason(dot)me(dot)uk> | 
|---|---|
| To: | pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org | 
| Subject: | Re: [HACKERS] string_to_array with empty input | 
| Date: | 2009-04-01 18:27:09 | 
| Message-ID: | 20090401182709.GF12225@frubble.xen.chris-lamb.co.uk | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general pgsql-hackers | 
On Wed, Apr 01, 2009 at 10:23:18AM -0700, David E. Wheeler wrote:
> On Apr 1, 2009, at 10:05 AM, justin wrote:
> >string_to_array('',',')::INT[]  works as proposed
> >
> >But
> >string_to_array(',,,', ',' )::INT[]   Fails
> >or
> >string_to_array('1,2,,4', ',' )::INT[] Fails .
> >
> >
> >I'm trying to understand the difference between a empty string to a  
> >string with  many blank entries between  the delimiter.
> >Consider   ',,,,,,'  = ''  once the delimiter is removed .  Yet  
> >Seven zero length entries were passed.  How is that going to be  
> >handled????
> 
> Right, it's making a special case of '', which does seem rather  
> inconsistent to me.
Yes it is; but it's a useful special case because it allows:
string_to_array(array_to_string(col,','),',')
to do the right thing whether it's got zero or more elements in.  With
the current implementation you get a NULL back in the case of zero
elements and the expected array back the rest of the time.
To me, it doesn't really matter whether:
string_to_array(',', ',' )::INT[]
fails or not; because array_to_string will never generate a string that
looks like this.
-- 
  Sam  http://samason.me.uk/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Greg Stark | 2009-04-01 18:40:16 | Re: [HACKERS] string_to_array with empty input | 
| Previous Message | Aleksey Tsalolikhin | 2009-04-01 17:58:28 | Re: SELinux problem rsync'ing WAL logs | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Greg Stark | 2009-04-01 18:40:16 | Re: [HACKERS] string_to_array with empty input | 
| Previous Message | Vincze, Tamas | 2009-04-01 18:18:13 | Re: Patch to speed up pg_dump |