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

From justin
Subject Re: [HACKERS] string_to_array with empty input
Date
Msg-id 49D39EC0.3080608@emproshunts.com
Whole thread Raw
In response to Re: [HACKERS] string_to_array with empty input  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [HACKERS] string_to_array with empty input  ("David E. Wheeler" <david@kineticode.com>)
Re: [HACKERS] string_to_array with empty input  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-general
Tom Lane wrote: <blockquote cite="mid:6569.1238601738@sss.pgh.pa.us" type="cite"><pre wrap="">Robert Haas <a
class="moz-txt-link-rfc2396E"href="mailto:robertmhaas@gmail.com"><robertmhaas@gmail.com></a> writes:
</pre><blockquotetype="cite"><pre wrap="">On Tue, Mar 31, 2009 at 10:44 AM, Greg Stark <a class="moz-txt-link-rfc2396E"
href="mailto:stark@enterprisedb.com"><stark@enterprisedb.com></a>wrote:   </pre><blockquote type="cite"><pre
wrap="">OnTue, Mar 31, 2009 at 3:42 PM, Sam Mason <a class="moz-txt-link-rfc2396E"
href="mailto:sam@samason.me.uk"><sam@samason.me.uk></a>wrote:     </pre><blockquote type="cite"><pre
wrap="">string_to_array('',',')::INT[] => invalid input syntax for integer: ""       </pre></blockquote><pre
wrap="">Oof.That's a good point.     </pre></blockquote></blockquote><pre wrap=""> </pre><blockquote type="cite"><pre
wrap="">+1. I find this argument much more compelling than anything else
 
that's been offered up so far.   </pre></blockquote><pre wrap="">
Yeah.  It seems to me that if you consider only the case where the array
elements are text, there's a weak preference for considering '' to be a
single empty string; but as soon as you think about any other datatype,
there's a strong preference to consider it a zero-element list.  So I
too have come around to favor the latter interpretation.  Do we have
any remaining holdouts?
        regards, tom lane </pre></blockquote><br /> I'm still a hold out,  We are taking a string putting it into a
arraybased on a delimiter.  That is very simple and straight forward.  Yet many argue if we want to cast this into
anotherdata type the function should deal with in limited cases.  <br /><br /> string_to_array('',',')::INT[]  works as
proposed<br /><br /> But <br /> string_to_array(',,,', ',' )::INT[]   Fails <br /> or<br /> string_to_array('1,2,,4',
',')::INT[] Fails .<br /><br /><br /> I'm trying to understand the difference between a empty string to a string with 
manyblank entries between  the delimiter.    <br /> Consider   ',,,,,,'  = ''  once the delimiter is removed .  Yet
Sevenzero length entries were passed.  How is that going to be handled????  <br /><br /> In one case it works and yet
othercases it fails.  This is inconsistent behavior.  Unless all zero length strings are removed or are treated as
NULLs I can't see how casting to another type is going to work.<br /><br /> If zero length strings are treated as NULLs
thiscreates idea that zero length strings are = to NULLs. <br /><br /> The input is a string and the output is text[], 
castingto another data type is error prone and should be handled by the programmer.  <br /> 

pgsql-general by date:

Previous
From: Patrick Desjardins
Date:
Subject: Re: [GENERAL] ERROR: XX001: could not read block 2354 of relation…
Next
From: Scott Marlowe
Date:
Subject: Re: [GENERAL] Re: [GENERAL] ERROR: XX001: could not read block 2354 of relation…