Skip to content

Commit e5fe2e8

Browse files
committed
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.
1 parent 4521207 commit e5fe2e8

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/pl/plpgsql/src/gram.y

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.105 2007/07/25 04:19:08 neilc Exp $
12+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.106 2007/11/09 23:58:32 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -181,14 +181,12 @@ static void check_labels(const char *start_label,
181181
%token K_LOG
182182
%token K_LOOP
183183
%token K_MOVE
184-
%token K_NEXT
185184
%token K_NOSCROLL
186185
%token K_NOT
187186
%token K_NOTICE
188187
%token K_NULL
189188
%token K_OPEN
190189
%token K_OR
191-
%token K_QUERY
192190
%token K_PERFORM
193191
%token K_ROW_COUNT
194192
%token K_RAISE
@@ -1169,11 +1167,19 @@ stmt_return : K_RETURN lno
11691167
int tok;
11701168

11711169
tok = yylex();
1172-
if (tok == K_NEXT)
1170+
if (tok == 0)
1171+
yyerror("unexpected end of function definition");
1172+
1173+
/*
1174+
* To avoid making NEXT and QUERY effectively be
1175+
* reserved words within plpgsql, recognize them
1176+
* via yytext.
1177+
*/
1178+
if (pg_strcasecmp(yytext, "next") == 0)
11731179
{
11741180
$$ = make_return_next_stmt($2);
11751181
}
1176-
else if (tok == K_QUERY)
1182+
else if (pg_strcasecmp(yytext, "query") == 0)
11771183
{
11781184
$$ = make_return_query_stmt($2);
11791185
}

src/pl/plpgsql/src/scan.l

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.58 2007/07/25 04:19:09 neilc Exp $
12+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.59 2007/11/09 23:58:32 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -143,15 +143,13 @@ is { return K_IS; }
143143
log { return K_LOG; }
144144
loop { return K_LOOP; }
145145
move { return K_MOVE; }
146-
next { return K_NEXT; }
147146
no{space}+scroll { return K_NOSCROLL; }
148147
not { return K_NOT; }
149148
notice { return K_NOTICE; }
150149
null { return K_NULL; }
151150
open { return K_OPEN; }
152151
or { return K_OR; }
153152
perform { return K_PERFORM; }
154-
query { return K_QUERY; }
155153
raise { return K_RAISE; }
156154
rename { return K_RENAME; }
157155
result_oid { return K_RESULT_OID; }

0 commit comments

Comments
 (0)