From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: proposal: support empty string as separator for string_to_array |
Date: | 2009-07-27 17:28:29 |
Message-ID: | b42b73150907271028u57108e31nf00358d3b13a6b1@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Jul 27, 2009 at 12:42 PM, Pavel Stehule<pavel(dot)stehule(at)gmail(dot)com> wrote:
> 2009/7/25 Merlin Moncure <mmoncure(at)gmail(dot)com>:
>> On Fri, Jul 24, 2009 at 11:40 PM, Pavel Stehule<pavel(dot)stehule(at)gmail(dot)com> wrote:
>>> Hello
>>>
>>> I have one idea, that should simplify string to char array
>>> transformation. The base is idea: between every char is empty string,
>>> so empty string is regular separator for string_to_array function.
>>> This behave is inversion of array_to_string function behave:
>>>
>>> postgres=# select array_to_string(array['a','b','c'],'');
>>> array_to_string
>>> -----------------
>>> abc
>>> (1 row)
>>>
>>> postgres=# select string_to_array('abc','');
>>> string_to_array
>>> -----------------
>>> {a,b,c}
>>> (1 row)
>>
>> postgres=# select regexp_split_to_array('abc', '');
>> regexp_split_to_array
>> -----------------------
>> {a,b,c}
>> (1 row)
>>
>> :-)
>>
>
> I tested implementation and it's about 30% faster than using regexp.
>
> I could to thing, 30% is significant reason for implementation.
yes, I noticed that too. I was thinking though that if anything
should be done, it should be to go the other way: simple cases of
regexp_split_to_array should use the simpler algorithm in
'string_to_array'...just not the '' case, since they produce different
results.
I don't think the chars_to_array function is the way to go. One thing
that might work though is to overload the string_to_array function (or
use default parameter) to control the empty string case with an bool,
or an option or something.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-07-27 17:51:47 | Re: proposal: support empty string as separator for string_to_array |
Previous Message | Tom Lane | 2009-07-27 17:14:17 | Re: WIP: Deferrable unique constraints |