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-15 12:02:00 |
Message-ID: | CACJufxGJavz+UTJLBw=qTMZywG7E24oKNxp5B4+4uRHmXCW8Og@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, May 16, 2024 at 3:10 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> > On Thu, Apr 4, 2024 at 9:55 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> >> changing "N" to lower-case would be misleading for regexp_replace?
> >> so I choose "count".
>
> > I don't see why that would be confusing for regexp_replace
> > specifically, but I think N => count is a reasonable change to make.
> > However, I don't think this quite works:
> > + then the <replaceable>count</replaceable>'th match of the pattern
>
> I think the origin of the problem here is not wanting to use "N"
> as the actual name of the parameter, because then users would have
> to double-quote it to write "regexp_replace(..., "N" => 42, ...)".
>
> However ... is that really so awful? It's still fewer keystrokes
> than "count". It's certainly a potential gotcha for users who've
> not internalized when they need double quotes, but I think we
> could largely address that problem just by making sure to provide
> a documentation example that shows use of "N".
done it this way. patch attached.
last example from
regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 3, 'i')
A PostgrXSQL function
change to
regexp_replace(string=>'A PostgreSQL function', pattern=>'a|e|i|o|u',
replacement=>'X',start=>1, "N"=>3, flags=>'i');
A PostgrXSQL function
but I am not 100% sure
<lineannotation>A PostgrXSQL
function</lineannotation>
is in the right position.
also address Chapman Flack point:
correct me if i am wrong, but i don't think the ISO standard mandates
function argument names.
So we can choose the best function argument name for our purpose?
Attachment | Content-Type | Size |
---|---|---|
v5-0001-add-regex-functions-argument-names-to-pg_proc.patch | text/x-patch | 11.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Ashutosh Sharma | 2024-07-15 12:05:05 | Re: Addressing SECURITY DEFINER Function Vulnerabilities in PostgreSQL Extensions |
Previous Message | Amit Kapila | 2024-07-15 11:39:10 | Re: Slow catchup of 2PC (twophase) transactions on replica in LR |