Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8JY1-0002G4-M8 for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Jul 2021 09:38:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m8JY0-00051h-Ld for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Jul 2021 09:38:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8JY0-00051Z-E8 for pgsql-hackers@lists.postgresql.org; Tue, 27 Jul 2021 09:38:48 +0000 Received: from 2.mo179.mail-out.ovh.net ([178.33.250.45]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8JXx-0003V9-GM for pgsql-hackers@lists.postgresql.org; Tue, 27 Jul 2021 09:38:48 +0000 Received: from player760.ha.ovh.net (unknown [10.109.138.83]) by mo179.mail-out.ovh.net (Postfix) with ESMTP id 0D43E1A522F for ; Tue, 27 Jul 2021 11:38:43 +0200 (CEST) Received: from darold.net (lfbn-lyo-1-1368-22.w86-207.abo.wanadoo.fr [86.207.177.22]) (Authenticated sender: gilles@darold.net) by player760.ha.ovh.net (Postfix) with ESMTPSA id 1D2D1209EB900; Tue, 27 Jul 2021 09:38:37 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-105G006b37c1a18-dfc6-42f7-9278-891c4d9a89b7, CDF6A41D01F4D6E62C5C137E9A5F9CCF88821D2D) smtp.auth=gilles@darold.net X-OVh-ClientIp: 86.207.177.22 To: Tom Lane , Gilles Darold Cc: Chapman Flack , er@xs4all.nl, pgsql-hackers@lists.postgresql.org References: <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> From: Gilles Darold Subject: Re: [PATCH] proposal for regexp_count, regexp_instr, regexp_substr and regexp_replace Message-ID: <2204c4a4-8ee8-abdd-d5ca-d0b6893f96ab@darold.net> Date: Tue, 27 Jul 2021 11:38:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <212635.1627329361@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Ovh-Tracer-Id: 15286061563489984111 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvtddrgeejgddufecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefvfhfhuffkffgfgggjtgfgsehtqhertddtfeejnecuhfhrohhmpefiihhllhgvshcuffgrrhholhguuceoghhilhhlvghssegurghrohhlugdrnhgvtheqnecuggftrfgrthhtvghrnhepfeevtdejteeiveehjefgjeeguefgheehteekleduleffteeuiefgjefggefgtdegnecuffhomhgrihhnpehorhgrtghlvgdrtghomhdpihgsmhdrtghomhdpuggrrhholhgurdhnvghtnecukfhppedtrddtrddtrddtpdekiedrvddtjedrudejjedrvddvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpqdhouhhtpdhhvghlohepphhlrgihvghrjeeitddrhhgrrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpehgihhllhgvshesuggrrhholhgurdhnvghtpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Le 26/07/2021 =C3=A0 21:56, Tom Lane a =C3=A9crit=C2=A0: > Gilles Darold 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=3D# \df regexp_replace > List of functions > Schema | Name | Result data type | Argument data types = | Type=20 > ------------+----------------+------------------+----------------------= --+------ > pg_catalog | regexp_replace | text | text, text, text = | func > pg_catalog | regexp_replace | text | text, text, text, tex= t | func > (2 rows) > > The patch proposes to add (among other alternatives) > > +{ oid =3D> '9608', descr =3D> 'replace text using regexp', > + proname =3D> 'regexp_replace', prorettype =3D> 'text', > + proargtypes =3D> 'text text text int4', prosrc =3D> 'textregexreplac= e_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: =C2=A0=C2=A0=C2=A0 regexp_replace(source, pattern, replacement [, flags ]= ); =C2=A0=C2=A0=C2=A0 regexp_substitute(source, pattern, replacement [, posi= tion ] [, 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#SQLRF0630= 2 [2] https://www.ibm.com/docs/en/db2oc?topic=3Dfunctions-regexp-replace --=20 Gilles Darold http://www.darold.net/