Re: [PATCHES] regexp_replace

From: Atsushi Ogawa <a_ogawa(at)hi-ho(dot)ne(dot)jp>
To: David Fetter <david(at)fetter(dot)org>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] regexp_replace
Date: 2005-06-08 12:32:01
Message-ID: PIEMIKOOMKNIJLLLBCBBKEBBCIAA.a_ogawa@hi-ho.ne.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


David Fetter wrote:
> On Tue, Jun 07, 2005 at 10:27:28PM +0900, Atsushi Ogawa wrote:
> > David Fetter wrote:
> > > Ogawa-san,
> > >
> > > I think that this would be a case for function overloading:
> > >
> > > function regexp_replace(
> > > string text, pattern text, replacement text
> > > ) RETURNS TEXT; /* First only */
> > >
> > > regexp_replace(
> > > string text, pattern text, replacement text, global bool
> > > ) RETURNS TEXT; /* Global if global is TRUE, first only otherwise */
> > >
> > > What do you think of this idea? One trouble is that there are some
> > > other options. For example, one could add switches for all
> > > combinations of "global," "case insensitive," "compile once," "exclude
> > > whitespace," etc. as perl does. Do we want to go this route?
> >
> > My idea is opposite. I think that the regexp_replace() should make
> > "replace all" a default. Because the replace() of pgsql replaces all
> > string, and regexp_replace() of oracle10g is also similar.
>
> I respectfully disagree. Although Oracle does things this way, no
> other regular expression search and replace does. Historically, you
> can find that "Oracle does it this way" is not a reason why we would
> do it. Text editors, programming languages, etc., etc. do "replace
> the first" by default and "replace globally" only when told to.

I agree. Let's stop the way to Oracle.

> > And I think that it is better to be able to specify the option with
text.
>
> I think that "case insensitive" is a good thing to add separately as a
> boolean :)

I don't like to specify operation with boolean. ;)
Because when a SQL is read, the meaning becomes indistinct.

How about changing the function name of each usage?

regexp_replace: replace first
regexp_replace_all: replace all
regexp_ic_replace: replace first and case insensitive
regexp_ic_replace_all: replace all and case insensitive

regards,

--
Atsushi Ogawa

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-06-08 13:39:57 Re: adding new pages bulky way
Previous Message Peter Eisentraut 2005-06-08 10:05:29 Correlated subselect in regression test

Browse pgsql-patches by date

  From Date Subject
Next Message Hannu Krosing 2005-06-08 14:30:44 Re: [PATCHES] regexp_replace
Previous Message Tom Lane 2005-06-07 23:00:48 Re: Are you actively hacking on 2PC?