Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] writing new regexp functions

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: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-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

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

Attachment: regexp-export.patch
Description: text/plain (9.3 KB)
Attachment: regexp_ext.tar.gz
Description: application/octet-stream (3.7 KB)

In response to


pgsql-hackers by date

Next:From: Kate FDate: 2007-02-03 03:40:18
Subject: snprintf()
Previous:From: Bruce MomjianDate: 2007-02-03 02:46:04
Subject: Re: unixware and --with-ldap

pgsql-patches by date

Next:From: Michael FuhrDate: 2007-02-03 09:18:05
Subject: \copy (query) delimiter syntax error
Previous:From: Bruce MomjianDate: 2007-02-03 02:44:27
Subject: Re: [HACKERS] unixware and --with-ldap

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group