1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-09 22:41:56 +03:00

Change the notation for calling functions with named parameters from

"val AS name" to "name := val", as per recent discussion.

This patch catches everything in the original named-parameters patch,
but I'm not certain that no other dependencies snuck in later (grepping
the source tree for all uses of AS soon proved unworkable).

In passing I note that we've dropped the ball at least once on keeping
ecpg's lexer (as opposed to parser) in sync with the backend.  It would
be a good idea to go through all of pgc.l and see if it's in sync now.
I didn't attempt that at the moment.
This commit is contained in:
Tom Lane
2010-05-30 18:10:41 +00:00
parent 2bde07c198
commit b12b7a9038
11 changed files with 105 additions and 102 deletions

View File

@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.711 2010/02/23 22:51:42 tgl Exp $
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.712 2010/05/30 18:10:40 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -444,8 +444,8 @@ static TypeName *TableFuncTypeName(List *columns);
* the set of keywords. PL/pgsql depends on this so that it can share the
* same lexer. If you add/change tokens here, fix PL/pgsql to match!
*
* DOT_DOT and COLON_EQUALS are unused in the core SQL grammar, and so will
* always provoke parse errors. They are needed by PL/pgsql.
* DOT_DOT is unused in the core SQL grammar, and so will always provoke
* parse errors. It is needed by PL/pgsql.
*/
%token <str> IDENT FCONST SCONST BCONST XCONST Op
%token <ival> ICONST PARAM
@ -10212,13 +10212,13 @@ func_arg_expr: a_expr
{
$$ = $1;
}
| a_expr AS param_name
| param_name COLON_EQUALS a_expr
{
NamedArgExpr *na = makeNode(NamedArgExpr);
na->arg = (Expr *) $1;
na->name = $3;
na->name = $1;
na->arg = (Expr *) $3;
na->argnumber = -1; /* until determined */
na->location = @3;
na->location = @1;
$$ = (Node *) na;
}
;
@ -10698,7 +10698,7 @@ AexprConst: Iconst
if (IsA(arg, NamedArgExpr))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("type modifier cannot have AS name"),
errmsg("type modifier cannot have parameter name"),
parser_errposition(arg->location)));
}
t->typmods = $3;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.223 2010/03/17 16:52:38 tgl Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.224 2010/05/30 18:10:40 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1386,12 +1386,12 @@ funcname_signature_string(const char *funcname, int nargs,
{
if (i)
appendStringInfoString(&argbuf, ", ");
appendStringInfoString(&argbuf, format_type_be(argtypes[i]));
if (i >= numposargs)
{
appendStringInfo(&argbuf, " AS %s", (char *) lfirst(lc));
appendStringInfo(&argbuf, "%s := ", (char *) lfirst(lc));
lc = lnext(lc);
}
appendStringInfoString(&argbuf, format_type_be(argtypes[i]));
}
appendStringInfoChar(&argbuf, ')');

View File

@ -24,7 +24,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.166 2010/01/16 17:39:55 tgl Exp $
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.167 2010/05/30 18:10:41 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -317,8 +317,6 @@ ident_cont [A-Za-z\200-\377_0-9\$]
identifier {ident_start}{ident_cont}*
typecast "::"
/* these two token types are used by PL/pgsql, though not in core SQL */
dot_dot \.\.
colon_equals ":="