From: | Jeremy Drake <pgsql(at)jdrake(dot)com> |
---|---|
To: | David Fetter <david(at)fetter(dot)org> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: [HACKERS] writing new regexp functions |
Date: | 2007-02-03 03:01:33 |
Message-ID: | Pine.BSO.4.64.0702021845540.28908@resin.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
On Fri, 2 Feb 2007, David Fetter wrote:
> On Fri, Feb 02, 2007 at 08:56:31PM -0500, Tom Lane wrote:
> >
> > All of SQL's pattern match operators have the pattern on the right,
> > so my advice is to stick with that and try not to think about Perl
> > ;-)
>
> Perl provides inspiration, but here, consistency would help more than
> orderly imitation of how it does what it does. And besides, when
> people really need Perl, they can pull it in as a PL :)
Alright, here is my code to date. I have put the pattern after the string
in the split function, as discussed above. The .tar.gz file expects to be
untarred in contrib/. I have made some regression tests that can be run
using 'make installcheck' as normal for contrib. I think they exercise
the corner cases in the code, but I may very well have missed some. It
requires the (previously submitted) attached patch to core to compile, as
it takes advantage of new exported functions from
src/backend/utils/adt/regexp.c.
Let me know if you see any bugs or issues with this code, and I am open to
suggestions for further regression tests ;)
Things that I still want to look into:
* regexp flags (a la regexp_replace).
* maybe make regexp_matches return setof whatever, if given a 'g' flag
return all matches in string.
* maybe a join function that works as an aggregate
SELECT join(',', col) FROM tbl
currently can be written as
SELECT array_to_string(ARRAY(SELECT col FROM tbl), ',')
--
It was a virgin forest, a place where the Hand of Man had never set
foot.
Attachment | Content-Type | Size |
---|---|---|
regexp-export.patch | text/plain | 9.3 KB |
regexp_ext.tar.gz | application/octet-stream | 3.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Kate F | 2007-02-03 03:40:18 | snprintf() |
Previous Message | Bruce Momjian | 2007-02-03 02:46:04 | Re: unixware and --with-ldap |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2007-02-03 09:18:05 | \copy (query) delimiter syntax error |
Previous Message | Bruce Momjian | 2007-02-03 02:44:27 | Re: [HACKERS] unixware and --with-ldap |