Re: add function argument names to regex* functions.
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>,
Peter Eisentraut <peter@eisentraut.org>, Dian Fay <di@nmfay.com>, Jim Nasby <jim.nasby@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Chapman Flack <jcflack@acm.org>
Date: 2024-07-19T05:51:39Z
Lists: pgsql-hackers
Attachments
- v6-0001-add-regex-functions-argument-names.patch (text/x-patch) patch v6-0001
On Fri, Jul 19, 2024 at 5:48 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > > jian he <jian.universality@gmail.com> writes: > > [ v5-0001-add-regex-functions-argument-names-to-pg_proc.patch ] > > I'm not sure whether we've bikeshedded this to death yet, but > personally I'm content with the naming choices here (which basically > are those already shown in table 9.10). However, while looking > at the patch I noticed a couple of issues, one small, the other > a bit bigger. > > The small issue is that table 9.10 offers this syntax diagram > for regexp_replace: > > regexp_replace ( string text, pattern text, replacement text [, start integer ] [, flags text ] ) → text > > This implies that it's valid to write > > regexp_replace (string, pattern, replacement, start, flags) > > but it is not: we have no function matching that signature. I'm not > in a hurry to add one, either, for fear of ambiguity against the other > regexp_replace signature. I think this needs to be broken into two > syntax diagrams: > > regexp_replace ( string text, pattern text, replacement text [, start integer ] ) → text > regexp_replace ( string text, pattern text, replacement text [, flags text ] ) → text We can list them separately. regexp_replace(string, pattern, replacement [, start]) regexp_replace(string, pattern, replacement [, flags]) regexp_replace(string, pattern, replacement , start , N [, flags ]). if both optional is not there then they are the same, list 2 potential identical functions separately seems wrong? so i choose 2 bracket with a vertical bar: regexp_replace(string, pattern, replacement [[, start] | [, flags]]). maybe less readable. > The larger issue is that contrib/citext offers versions of some of > these functions that are meant to be drop-in replacements using > citext input. Hence, we need to add the same parameter names to > those functions, or they'll fail to replace some calls. > I first wanted to use alterfunction solve this, then found out it cannot, later I found out CREATE OR REPLACE FUNCTION saved us. citext module, these functions: regexp_match() regexp_matches() regexp_replace() regexp_split_to_array() regexp_split_to_table() were created in contrib/citext/citext--1.4.sql, we can add the CREATE OR REPLACE FUNCTION to 1.4.sql. but to avoid unintended consequences I just add these to the newly created file citext--1.6--1.7.sql, to make a version bump.
Commits
-
Doc: fix text's description of regexp_replace's arguments.
- da4017a694de 18.0 landed
-
Add argument names to the regexp_XXX functions.
- 580f8727ca93 18.0 landed
-
Add assorted new regexp_xxx SQL functions.
- 642433707358 15.0 cited