From: Gilles Darold <gilles@darold.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Gilles Darold <gillesdarold@gmail.com>
Cc: Chapman Flack <chap@anastigmatix.net>
Cc: er@xs4all.nl
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: [PATCH] proposal for regexp_count, regexp_instr, regexp_substr and regexp_replace
Date: Tue, 27 Jul 2021 11:38:36 +0200
Message-ID: <2204c4a4-8ee8-abdd-d5ca-d0b6893f96ab@darold.net> (raw)
In-Reply-To: <212635.1627329361@sss.pgh.pa.us>
References: <fc160ee0-c843-b024-29bb-97b5da61971f@darold.net>
<2292303d-766d-2172-2942-b076a3bb6505@darold.net>
<2122577845.234888.1616324857283@webmailclassic.xs4all.nl>
<9f91e4e7-19c8-d8e0-6955-fefaebd4c8fe@darold.net>
<60575B5A.4080807@anastigmatix.net>
<345476.1616338397@sss.pgh.pa.us>
<45fe2893-1efc-1666-3ea5-b5fb1918c7fa@gmail.com>
<212635.1627329361@sss.pgh.pa.us>
Le 26/07/2021 à 21:56, Tom Lane a écrit :
> Gilles Darold <gillesdarold@gmail.com> writes:
>> [ v4-0001-regexp-foo-functions.patch ]
> I started to work through this and was distressed to realize that
> it's trying to redefine regexp_replace() in an incompatible way.
> We already have
>
> regression=# \df regexp_replace
> List of functions
> Schema | Name | Result data type | Argument data types | Type
> ------------+----------------+------------------+------------------------+------
> pg_catalog | regexp_replace | text | text, text, text | func
> pg_catalog | regexp_replace | text | text, text, text, text | func
> (2 rows)
>
> The patch proposes to add (among other alternatives)
>
> +{ oid => '9608', descr => 'replace text using regexp',
> + proname => 'regexp_replace', prorettype => 'text',
> + proargtypes => 'text text text int4', prosrc => 'textregexreplace_extended_no_occurrence' },
>
> which is going to be impossibly confusing for both humans and machines.
> I don't think we should go there. Even if you managed to construct
> examples that didn't result in "ambiguous function" failures, that
> doesn't mean that ordinary mortals won't get bit that way.
>
> I'm inclined to just drop the regexp_replace additions. I don't think
> that the extra parameters Oracle provides here are especially useful.
> They're definitely not useful enough to justify creating compatibility
> hazards for.
I would not say that being able to replace the Nth occurrence of a
pattern matching is not useful but i agree that this is not a common
case with replacement. Both Oracle [1] and IBM DB2 [2] propose this form
and I have though that we can not have compatibility issues because of
the different data type at the 4th parameter. Anyway, maybe we can just
rename the function even if I would prefer that regexp_replace() be
extended. For example:
regexp_replace(source, pattern, replacement [, flags ]);
regexp_substitute(source, pattern, replacement [, position ] [,
occurrence ] [, flags ]);
of course with only 3 parameters the two functions are the same.
What do you think about the renaming proposal instead of simply drop the
extended form of the function?
Best regards,
[1] https://docs.oracle.com/database/121/SQLRF/functions163.htm#SQLRF06302
[2] https://www.ibm.com/docs/en/db2oc?topic=functions-regexp-replace
--
Gilles Darold
http://www.darold.net/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: gilles@darold.net, tgl@sss.pgh.pa.us, gillesdarold@gmail.com, chap@anastigmatix.net, er@xs4all.nl
Subject: Re: [PATCH] proposal for regexp_count, regexp_instr, regexp_substr and regexp_replace
In-Reply-To: <2204c4a4-8ee8-abdd-d5ca-d0b6893f96ab@darold.net>
References: <fc160ee0-c843-b024-29bb-97b5da61971f@darold.net> <2292303d-766d-2172-2942-b076a3bb6505@darold.net> <2122577845.234888.1616324857283@webmailclassic.xs4all.nl> <9f91e4e7-19c8-d8e0-6955-fefaebd4c8fe@darold.net> <60575B5A.4080807@anastigmatix.net> <345476.1616338397@sss.pgh.pa.us> <45fe2893-1efc-1666-3ea5-b5fb1918c7fa@gmail.com> <212635.1627329361@sss.pgh.pa.us> <2204c4a4-8ee8-abdd-d5ca-d0b6893f96ab@darold.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox