diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml
index 78e4983139b5..2acdf43b4a1d 100644
--- a/doc/src/sgml/plpgsql.sgml
+++ b/doc/src/sgml/plpgsql.sgml
@@ -3317,7 +3317,7 @@ OPEN curs1 FOR EXECUTE format('SELECT * FROM %I WHERE col1 = $1',tabname) USING
Opening a Bound Cursor
-OPEN bound_cursorvar ( argument_name := argument_value , ... ) ;
+OPEN bound_cursorvar ( argument_name { => | := } argument_value , ... ) ;
@@ -3340,7 +3340,7 @@ OPEN bound_cursorvar ( positional
or named notation. In positional
notation, all arguments are specified in order. In named notation,
- each argument's name is specified using := to
+ each argument's name is specified using => to
separate it from the argument expression. Similar to calling
functions, described in , it
is also allowed to mix positional and named notation.
@@ -3351,6 +3351,14 @@ OPEN bound_cursorvar (
OPEN curs2;
OPEN curs3(42);
+OPEN curs3(Key => 42);
+
+
+
+
+ An older syntax based on := is supported for backward
+ compatibility:
+
OPEN curs3(key := 42);
diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y
index 8048e040f810..dc0ae1131842 100644
--- a/src/pl/plpgsql/src/pl_gram.y
+++ b/src/pl/plpgsql/src/pl_gram.y
@@ -3955,9 +3955,12 @@ 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)
+ if (tok1 == IDENT && (tok2 == COLON_EQUALS || tok2 == EQUALS_GREATER))
{
char *argname;
IdentifierLookup save_IdentifierLookup;
@@ -3983,11 +3986,11 @@ 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
- * happen.
+ * Eat the ":=" and the "=>". We already peeked, so the error should
+ * never happen.
*/
tok2 = yylex(yylvalp, yyllocp, yyscanner);
- if (tok2 != COLON_EQUALS)
+ if (tok2 != COLON_EQUALS && tok2 != EQUALS_GREATER)
yyerror(yyllocp, NULL, yyscanner, "syntax error");
any_named = true;
diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out
index 0a6945581bd8..31aa806e491b 100644
--- a/src/test/regress/expected/plpgsql.out
+++ b/src/test/regress/expected/plpgsql.out
@@ -2419,7 +2419,8 @@ declare
p2 int4 := 1006;
n int4;
begin
- open c1 (p1 := p1, p2 := p2, debug := 2);
+ -- use both supported syntaxes for named arguments
+ open c1 (p1 := p1, p2 => p2, debug => 2);
fetch c1 into n;
return n;
end $$ language plpgsql;
diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql
index 18c91572ae14..aaae1e44c6fa 100644
--- a/src/test/regress/sql/plpgsql.sql
+++ b/src/test/regress/sql/plpgsql.sql
@@ -2072,7 +2072,8 @@ declare
p2 int4 := 1006;
n int4;
begin
- open c1 (p1 := p1, p2 := p2, debug := 2);
+ -- use both supported syntaxes for named arguments
+ open c1 (p1 := p1, p2 => p2, debug => 2);
fetch c1 into n;
return n;
end $$ language plpgsql;