Re: [PATCHES] regexp_replace - Mailing list pgsql-hackers

From Atsushi Ogawa
Subject Re: [PATCHES] regexp_replace
Date
Msg-id PIEMIKOOMKNIJLLLBCBBKEBBCIAA.a_ogawa@hi-ho.ne.jp
Whole thread Raw
In response to Re: [PATCHES] regexp_replace  (David Fetter <david@fetter.org>)
Responses Re: [PATCHES] regexp_replace
Re: [PATCHES] regexp_replace
List pgsql-hackers
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 firstregexp_replace_all:    replace allregexp_ic_replace:     replace first and case
insensitiveregexp_ic_replace_all:replace all and case insensitive
 

regards,

--
Atsushi Ogawa



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Correlated subselect in regression test
Next
From: Euler Taveira de Oliveira
Date:
Subject: Re: The Contrib Roundup (long)