Recognize RETURN QUERY via a textual test, so that QUERY doesn't need to be

a plpgsql keyword.  This avoids springing a new reserved word on plpgsql
programmers.
For consistency, handle RETURN NEXT the same way.
This commit is contained in:
Tom Lane 2007-11-09 23:58:32 +00:00
parent 4521207390
commit e5fe2e84d7
2 changed files with 12 additions and 8 deletions

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.105 2007/07/25 04:19:08 neilc Exp $
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.106 2007/11/09 23:58:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -181,14 +181,12 @@ static void check_labels(const char *start_label,
%token K_LOG
%token K_LOOP
%token K_MOVE
%token K_NEXT
%token K_NOSCROLL
%token K_NOT
%token K_NOTICE
%token K_NULL
%token K_OPEN
%token K_OR
%token K_QUERY
%token K_PERFORM
%token K_ROW_COUNT
%token K_RAISE
@ -1169,11 +1167,19 @@ stmt_return : K_RETURN lno
int tok;
tok = yylex();
if (tok == K_NEXT)
if (tok == 0)
yyerror("unexpected end of function definition");
/*
* To avoid making NEXT and QUERY effectively be
* reserved words within plpgsql, recognize them
* via yytext.
*/
if (pg_strcasecmp(yytext, "next") == 0)
{
$$ = make_return_next_stmt($2);
}
else if (tok == K_QUERY)
else if (pg_strcasecmp(yytext, "query") == 0)
{
$$ = make_return_query_stmt($2);
}

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.58 2007/07/25 04:19:09 neilc Exp $
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.59 2007/11/09 23:58:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -143,7 +143,6 @@ is { return K_IS; }
log { return K_LOG; }
loop { return K_LOOP; }
move { return K_MOVE; }
next { return K_NEXT; }
no{space}+scroll { return K_NOSCROLL; }
not { return K_NOT; }
notice { return K_NOTICE; }
@ -151,7 +150,6 @@ null { return K_NULL; }
open { return K_OPEN; }
or { return K_OR; }
perform { return K_PERFORM; }
query { return K_QUERY; }
raise { return K_RAISE; }
rename { return K_RENAME; }
result_oid { return K_RESULT_OID; }