Thread: Re: proposal - plpgsql - support standard syntax for named arguments for cursors
Re: proposal - plpgsql - support standard syntax for named arguments for cursors
From
Julien Rouhaud
Date:
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.
Re: proposal - plpgsql - support standard syntax for named arguments for cursors
From
Japin Li
Date:
On Sat, 08 Feb 2025 at 16:34, Julien Rouhaud <rjuju123@gmail.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