From: | "David E(dot) Wheeler" <david(at)kineticode(dot)com> |
---|---|
To: | Sam Mason <sam(at)samason(dot)me(dot)uk> |
Cc: | pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [HACKERS] string_to_array with empty input |
Date: | 2009-03-31 15:56:32 |
Message-ID: | 69813E76-A2B1-452B-B5B0-F0B2BC708A64@kineticode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On Mar 31, 2009, at 8:34 AM, Sam Mason wrote:
>> What do you really expect to be returned for things like
>>
>> select count_elements(string_to_array('butter,tea,milk',','))
3 = {butter,tea,milk}
>> select count_elements(string_to_array('butter,tea',','))
2 = {butter,tea}
>> select count_elements(string_to_array('butter',','))
1 = {butter}
>> select count_elements(string_to_array('',','))
1 = ARRAY['']
> I'd expect 3,2,1 and 1.
>
> That's also a disingenuous example; what would you expect back from:
>
> select count_elements(string_to_array('butter,,milk',','))
3 = ARRAY['butter', '', 'milk']
> I think the semantics you want is what you'd get from:
>
> array_filter_blanks(string_to_array($1,$2))
>
> where I defined "array_filter_blanks" in my previous post.
Yeah, if I wanted something like that in Perl, I'd do:
my @stuff = grep { $_ } split /,/, $string;
In no case would I ever expect a NULL, however, unless I was trying to
split on NULL.
NULL = string_to_array(NULL, ',');
Best,
David
From | Date | Subject | |
---|---|---|---|
Next Message | SHARMILA JOTHIRAJAH | 2009-03-31 15:57:28 | Re: Space for pg_dump |
Previous Message | Tom Lane | 2009-03-31 15:50:46 | Re: weird problem with PG 8.1 |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2009-03-31 15:59:45 | Re: Partitioning feature ... |
Previous Message | Alvaro Herrera | 2009-03-31 15:48:39 | Re: Fwd: Abwesend: [GENERAL] string_to_array with empty input |