From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | justin <justin(at)emproshunts(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <stark(at)enterprisedb(dot)com>, Sam Mason <sam(at)samason(dot)me(dot)uk>, 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 19:28:59 |
Message-ID: | 603c8f070904011228p524ff06ci266f3080c0d25048@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On Wed, Apr 1, 2009 at 1:05 PM, justin <justin(at)emproshunts(dot)com> wrote:
> I'm still a hold out, We are taking a string putting it into a array based
> on a delimiter. That is very simple and straight forward. Yet many argue
> if we want to cast this into another data type the function should deal with
> in limited cases.
>
> string_to_array('',',')::INT[] works as proposed
>
> But
> string_to_array(',,,', ',' )::INT[] Fails
> or
> string_to_array('1,2,,4', ',' )::INT[] Fails .
But... but... those aren't comma-separated lists of integers. If they
were, it would work.
string_to_array('cow,dog,horse')::INT[] will also fail.
If you take 0 items of any type whatsoever and join them together with
commas, you will get the empty string. It is also true that if you
join 1 item together with commas, you will get that item back, and if
that item is the empty string, you will now have the empty string. I
think it's better to worry more about the first case because it
applies to any type at all, whereas the latter case ONLY applies in
situations where the empty string is a potentially legal value.
...Robert
From | Date | Subject | |
---|---|---|---|
Next Message | Jennifer Trey | 2009-04-01 19:38:06 | Re: Installed PG with pgAdmin, some days later, now my password don't work! |
Previous Message | Duco Fijma | 2009-04-01 19:26:33 | %r in restore_command? |
From | Date | Subject | |
---|---|---|---|
Next Message | Sam Mason | 2009-04-01 19:49:20 | Re: [GENERAL] string_to_array with empty input |
Previous Message | Robert Haas | 2009-04-01 19:19:23 | Re: [HACKERS] string_to_array with empty input |