Re: proposal - plpgsql - support standard syntax for named arguments for cursors
Pavel Stehule <pavel.stehule@gmail.com>
From: Pavel Stehule <pavel.stehule@gmail.com>
To: Japin Li <japinli@hotmail.com>
Cc: Julien Rouhaud <rjuju123@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-02-08T11:28:34Z
Lists: pgsql-hackers
Attachments
- v20250208-2-0001-allow-to-use-standard-syntax-for-named-arguments-for.patch (text/x-patch) patch v20250208-0001
Hi
so 8. 2. 2025 v 11:27 odesílatel Japin Li <japinli@hotmail.com> napsal:
> 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);
>
good idea
done
Regards
Pavel
> --
> Regrads,
> Japin Li
>
Commits
-
Allow => syntax for named cursor arguments in plpgsql.
- 246dedc5d028 18.0 landed
-
Allow named parameters to be specified using => in addition to :=
- 865f14a2d31a 9.5.0 cited
-
Add support for passing cursor parameters in named notation in PL/pgSQL.
- 4adead1d2242 9.2.0 cited