Re: Adding regexp_match() function

From: Jim Nasby <jim(at)nasby(dot)net>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Adding regexp_match() function
Date: 2010-06-30 08:25:27
Message-ID: AE534CD4-4C5B-4FCC-919E-6E5FB5EB7E84@nasby.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This seems like it'd be useful. Anyone else have thoughts on it?

On May 31, 2010, at 4:09 AM, Daniele Varrazzo wrote:

> Hello,
>
> I'd like to contribute a "regexp_match()" function as discussed in bug
> #5469 [1] The aim is to overcome the limitation outlined in the thread
> above <http://archives.postgresql.org/pgsql-bugs/2010-05/msg00227.php>.
>
> PostgreSQL currently offers the function regexp_matches(), a SRF
> (which, unless invoked with the 'g' flag, returns at most one result).
> An user interested in the "nonglob" behaviour, i.e. expecting at most
> 1 match group, has to adopt special care to avoid records to be
> dropped from the target list in case no match is found. Being this a
> rather common use case, I'd like to provide a function with a less
> astonishing behaviour, i.e. returning a text[] instead of a set of
> text[] and returning NULL in case no match is found (the 'g' flag
> wouldn't be supported).
>
> The proposed name is regexp_match(), to underline the semantics very
> similar to regexp_matches() but returning a single value as result.
> While the symmetry between the names is a pro, an excessive similarity
> may result confusing, so I wouldn't be surprised if a better name is
> found. The implementation of the function is very simple, given the
> infrastructure already available for the other regexp-related
> functions. I've actually already implemented it (mostly to check how
> easy or hard it would have been: I had never written a C procedure for
> PG before): a preliminary patch is attached.
>
> If the idea is accepted I will submit a complete patch including
> documentation and tests.
>
> Best regards,
>
>
> -- Daniele
> <regexp_match.patch>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers

--
Jim C. Nasby, Database Architect jim(at)nasby(dot)net
512.569.9461 (cell) http://jim.nasby.net

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2010-06-30 09:36:48 Re: Proposal for 9.1: WAL streaming from WAL buffers
Previous Message Pavel Golub 2010-06-30 07:57:37 Re: Keepalives win32