From: | Mark Dilger <pgsql(at)markdilger(dot)com> |
---|---|
To: | Jeremy Drake <pgsql(at)jdrake(dot)com> |
Cc: | Peter Eisentraut <peter_e(at)gmx(dot)net>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>, Neil Conway <neilc(at)samurai(dot)com>, David Fetter <david(at)fetter(dot)org> |
Subject: | Re: patch adding new regexp functions |
Date: | 2007-02-17 19:27:06 |
Message-ID: | 45D7570A.2050502@markdilger.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
Jeremy Drake wrote:
> The regexp_split function code was based on some code that a friend of
> mine wrote which used PCRE rather than postgres' internal regexp support.
> I don't know exactly what his use-case was, but he probably had
> one because he wrote the function and had it returning SETOF text ;)
> Perhaps he can share a general idea of what it was (nudge nudge)?
db=# CREATE OR REPLACE FUNCTION split(p TEXT, t TEXT) RETURNS SETOF TEXT AS $$
db$# my ($p, $t) = @_;
db$# return [ split(/$p/,$t) ];
db$# $$ LANGUAGE plperl;
CREATE FUNCTION
Time: 1.254 ms
db=# select distinct word from (select * from split('\\W+','mary had a little
lamb, whose fleece was black as soot') as word) as ss;
word
--------
a
as
black
fleece
had
lamb
little
mary
soot
was
whose
(11 rows)
Time: 30.517 ms
As you can see, this can easily be done with a plperl function. Some people may
not want to install plperl, or may not want to allow arbitrary patterns to be
handed to perl in this fashion. That was not my concern. I was simply trying
to see if I could make it faster in a C-language coded function.
In the end I dropped the project because the plperl function works fast enough
for me and I don't have any objection to plperl from a security standpoint, etc.
mark
From | Date | Subject | |
---|---|---|---|
Next Message | Matthew Campbell | 2007-02-17 19:28:28 | Re: GiST Comparing IndexTuples/Datums |
Previous Message | Warren Turkal | 2007-02-17 18:41:03 | Re: RFC: Temporal Extensions for PostgreSQL |
From | Date | Subject | |
---|---|---|---|
Next Message | Jeremy Drake | 2007-02-17 19:32:58 | Re: patch adding new regexp functions |
Previous Message | Chad Wagner | 2007-02-17 18:18:49 | Re: \prompt for psql |