From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Dian Fay <di(at)nmfay(dot)com>, Jim Nasby <jim(dot)nasby(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Chapman Flack <jcflack(at)acm(dot)org> |
Subject: | Re: add function argument names to regex* functions. |
Date: | 2024-07-19 05:51:39 |
Message-ID: | CACJufxE5p4KhGyBUwCZCxhxdU+zJBXy2deX4u85SL+kew4F7Cw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Jul 19, 2024 at 5:48 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> jian he <jian(dot)universality(at)gmail(dot)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.
Attachment | Content-Type | Size |
---|---|---|
v6-0001-add-regex-functions-argument-names.patch | text/x-patch | 23.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Shlok Kyal | 2024-07-19 06:01:01 | Re: Pgoutput not capturing the generated columns |
Previous Message | Michael Paquier | 2024-07-19 05:42:35 | Re: Patch bug: Fix jsonpath .* on Arrays |