Re: proposal - plpgsql - support standard syntax for named arguments for cursors

From: Japin Li <japinli(at)hotmail(dot)com>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: proposal - plpgsql - support standard syntax for named arguments for cursors
Date: 2025-02-08 10:26:54
Message-ID: ME0P300MB0445540132FB3F50996B34A1B6F02@ME0P300MB0445.AUSP300.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 08 Feb 2025 at 16:34, Julien Rouhaud <rjuju123(at)gmail(dot)com> wrote:
> Hi,
>
> On Sat, Feb 08, 2025 at 07:47:23AM +0100, Pavel Stehule wrote:
>> Hi
>>
>> when I worked on strict expr check patch I found so syntax for named
>> arguments of cursors supports only our legacy proprietary syntax `argname
>> := value`
>>
>> https://www.postgresql.org/docs/current/plpgsql-cursors.html
>>
>> I propose to enhancing to ANSI/SQL standard syntax for named arguments
>> `argname => value`
>
> Seems sensible to me.
>
>> The patch is almost trivial
>
> Documentation and tests are updated, and the patch LGTM.

Maybe we should also update the comments?

diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y
index 867017d8ed9..43186c8e85e 100644
--- a/src/pl/plpgsql/src/pl_gram.y
+++ b/src/pl/plpgsql/src/pl_gram.y
@@ -3911,7 +3911,7 @@ read_cursor_args(PLpgSQL_var *cursor, int until, YYSTYPE *yylvalp, YYLTYPE *yyll
tok2;
int arglocation;

- /* Check if it's a named parameter: "param := value" */
+ /* Check if it's a named parameter: "param := value" or "param => value" */
plpgsql_peek2(&tok1, &tok2, &arglocation, NULL, yyscanner);
if (tok1 == IDENT && (tok2 == COLON_EQUALS || tok2 == EQUALS_GREATER))
{
@@ -3939,7 +3939,7 @@ read_cursor_args(PLpgSQL_var *cursor, int until, YYSTYPE *yylvalp, YYLTYPE *yyll
parser_errposition(*yyllocp)));

/*
- * Eat the ":=". We already peeked, so the error should never
+ * Eat the ":=" and "=>". We already peeked, so the error should never
* happen.
*/
tok2 = yylex(yylvalp, yyllocp, yyscanner);
--
Regrads,
Japin Li

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2025-02-08 10:32:58 Re: pgbench with partitioned tables
Previous Message Alexander Korotkov 2025-02-08 10:07:16 Re: Get rid of WALBufMappingLock