Re: patch adding new regexp functions

From: Jeremy Drake <pgsql(at)jdrake(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, David Fetter <david(at)fetter(dot)org>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>, Neil Conway <neilc(at)samurai(dot)com>, Mark Dilger <pgsql(at)markdilger(dot)com>
Subject: Re: patch adding new regexp functions
Date: 2007-02-18 06:15:43
Message-ID: Pine.BSO.4.64.0702172207530.18849@resin.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Attached, please find a new version of the patch which follows Tom's
advice (except regexp_matches returing a 2-D array, which I am not sure if
it is required/desired). Hopefully this version makes everyone happy ;)

On Sat, 17 Feb 2007, Tom Lane wrote:

> So I'd vote against complicating the API in order to make special
> provision for these results. I claim that all we need is a function
> taking (string text, pattern text, flags text) and returning either
> array of text or setof text containing the matched substrings in
> whatever order is standard (order by left-parenthesis position,
> I think). In the degenerate case where there are no parenthesized
> subpatterns, just return the whole match as a single element.

The signature is

regexp_matches(string text, pattern text[, flags text]) returns setof
text[]

and behaves as described.

>
> As for the argument about array vs setof, I could see doing both to
> end the argument of which one is really superior for any particular
> problem.

regexp_split(string text, pattern text[, flags text]) returns setof text

regexp_split_array(string text, pattern text[. flags text[, limit int]])
returns text[]

--
When I was in school, I cheated on my metaphysics exam:
I looked into the soul of the boy sitting next to me.
-- Woody Allen

Attachment Content-Type Size
regexp-split-matches-documented_witharray.patch text/plain 45.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Warren Turkal 2007-02-18 06:46:45 Re: New feature request: FlashBack Query
Previous Message Tom Lane 2007-02-18 05:52:47 Re: Plan invalidation design

Browse pgsql-patches by date

  From Date Subject
Next Message Greg Smith 2007-02-18 07:25:40 Re: WIP patch - INSERT-able log statements
Previous Message Bruce Momjian 2007-02-18 04:07:44 Re: [BUGS] BUG #2977: dow doesn't conform to ISO-8601