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

Re: 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-hackers(at)postgresql(dot)org>
Subject: Re: writing new regexp functions
Date: 2007-02-03 00:59:54
Message-ID: Pine.BSO.4.64.0702021653360.28908@resin.csoft.net (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
On Fri, 2 Feb 2007, Jeremy Drake wrote:

> I just coded up for this:
>
> CREATE FUNCTION regexp_matches(IN str text, IN pattern text) RETURNS
> text[]
>     AS 'MODULE_PATHNAME', 'regexp_matches'
>     LANGUAGE C IMMUTABLE STRICT;
>
> CREATE FUNCTION regexp_matches(
>         IN str text, IN pattern text, IN return_pre_and_post bool,
>         OUT prematch text, OUT fullmatch text, OUT matches text[], OUT
> postmatch text) RETURNS record
>     AS 'MODULE_PATHNAME', 'regexp_matches'
>     LANGUAGE C IMMUTABLE STRICT;
>

I wanted to put out there the question of what order the parameters to
these regex functions should go.  ISTM most people expect them to go
(pattern, string), but I made these functions consistant with
substring(text,text) which takes (string, pattern).  Now I have been
working on a regexp_split function, which takes (pattern, string), which
is what someone familiar with the function from perl would expect, but is
not consistant with substring or now with my regexp_matches function.

I want to ask, should I break with following substring's precedent, and
put the pattern first (as most people probably would expect), or should I
break with perl's precedent and put the pattern second (to behave like
substring)?


-- 
We cannot put the face of a person on a stamp unless said person is
deceased.  My suggestion, therefore, is that you drop dead.
		-- James E. Day, Postmaster General

In response to

Responses

pgsql-hackers by date

Next:From: Florian G. PflugDate: 2007-02-03 01:37:09
Subject: Re: Referential Integrity and SHARE locks
Previous:From: Joshua D. DrakeDate: 2007-02-02 23:14:36
Subject: Re: Re: [pgsql-patches] [GENERAL] Corrupt database? 8.1/FreeBSD6.0

pgsql-patches by date

Next:From: Tom LaneDate: 2007-02-03 01:56:31
Subject: Re: writing new regexp functions
Previous:From: Joshua D. DrakeDate: 2007-02-02 23:14:36
Subject: Re: Re: [pgsql-patches] [GENERAL] Corrupt database? 8.1/FreeBSD6.0

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