1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-11 10:01:57 +03:00

Allow named parameters to be specified using => in addition to :=

SQL has standardized on => as the use of to specify named parameters,
and we've wanted for many years to support the same syntax ourselves,
but this has been complicated by the possible use of => as an operator
name.  In PostgreSQL 9.0, we began emitting a warning when an operator
named => was defined, and in PostgreSQL 9.2, we stopped shipping a
=>(text, text) operator as part of hstore.  By the time the next major
version of PostgreSQL is released, => will have been deprecated for a
full five years, so hopefully there won't be too many people still
relying on it.  We continue to support := for compatibility with
previous PostgreSQL releases.

Pavel Stehule, reviewed by Petr Jelinek, with a few documentation
tweaks by me.
This commit is contained in:
Robert Haas
2015-03-10 10:59:11 -04:00
parent 4f3924d9cd
commit 865f14a2d3
10 changed files with 124 additions and 24 deletions

View File

@ -533,7 +533,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
*/
%token <str> IDENT FCONST SCONST BCONST XCONST Op
%token <ival> ICONST PARAM
%token TYPECAST DOT_DOT COLON_EQUALS
%token TYPECAST DOT_DOT COLON_EQUALS EQUALS_GREATER
/*
* If you want to make any keyword changes, update the keyword table in
@ -12567,6 +12567,15 @@ func_arg_expr: a_expr
na->location = @1;
$$ = (Node *) na;
}
| param_name EQUALS_GREATER a_expr
{
NamedArgExpr *na = makeNode(NamedArgExpr);
na->name = $1;
na->arg = (Expr *) $3;
na->argnumber = -1; /* until determined */
na->location = @1;
$$ = (Node *) na;
}
;
type_list: Typename { $$ = list_make1($1); }

View File

@ -334,6 +334,7 @@ identifier {ident_start}{ident_cont}*
typecast "::"
dot_dot \.\.
colon_equals ":="
equals_greater "=>"
/*
* "self" is the set of chars that should be returned as single-character
@ -808,6 +809,11 @@ other .
return COLON_EQUALS;
}
{equals_greater} {
SET_YYLLOC();
return EQUALS_GREATER;
}
{self} {
SET_YYLLOC();
return yytext[0];