mirror of
https://github.com/postgres/postgres.git
synced 2025-05-03 22:24:49 +03:00
Fix filtered_base_yylex() to save and restore base_yylval and base_yylloc
properly when doing a lookahead. The lack of this was causing various interesting misbehaviors when one tries to use "with" as a plain identifier.
This commit is contained in:
parent
e85ef6e51e
commit
063560bb8e
@ -14,7 +14,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.69 2007/01/05 22:19:34 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.70 2007/01/06 19:14:17 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -28,8 +28,10 @@
|
|||||||
|
|
||||||
List *parsetree; /* result of parsing is left here */
|
List *parsetree; /* result of parsing is left here */
|
||||||
|
|
||||||
|
static bool have_lookahead; /* is lookahead info valid? */
|
||||||
static int lookahead_token; /* one-token lookahead */
|
static int lookahead_token; /* one-token lookahead */
|
||||||
static bool have_lookahead; /* lookahead_token set? */
|
static YYSTYPE lookahead_yylval; /* yylval for lookahead token */
|
||||||
|
static YYLTYPE lookahead_yylloc; /* yylloc for lookahead token */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -77,11 +79,16 @@ int
|
|||||||
filtered_base_yylex(void)
|
filtered_base_yylex(void)
|
||||||
{
|
{
|
||||||
int cur_token;
|
int cur_token;
|
||||||
|
int next_token;
|
||||||
|
YYSTYPE cur_yylval;
|
||||||
|
YYLTYPE cur_yylloc;
|
||||||
|
|
||||||
/* Get next token --- we might already have it */
|
/* Get next token --- we might already have it */
|
||||||
if (have_lookahead)
|
if (have_lookahead)
|
||||||
{
|
{
|
||||||
cur_token = lookahead_token;
|
cur_token = lookahead_token;
|
||||||
|
base_yylval = lookahead_yylval;
|
||||||
|
base_yylloc = lookahead_yylloc;
|
||||||
have_lookahead = false;
|
have_lookahead = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -102,8 +109,10 @@ filtered_base_yylex(void)
|
|||||||
* (perhaps for SQL99 recursive queries), come back and simplify
|
* (perhaps for SQL99 recursive queries), come back and simplify
|
||||||
* this code.
|
* this code.
|
||||||
*/
|
*/
|
||||||
lookahead_token = base_yylex();
|
cur_yylval = base_yylval;
|
||||||
switch (lookahead_token)
|
cur_yylloc = base_yylloc;
|
||||||
|
next_token = base_yylex();
|
||||||
|
switch (next_token)
|
||||||
{
|
{
|
||||||
case CASCADED:
|
case CASCADED:
|
||||||
cur_token = WITH_CASCADED;
|
cur_token = WITH_CASCADED;
|
||||||
@ -115,7 +124,14 @@ filtered_base_yylex(void)
|
|||||||
cur_token = WITH_CHECK;
|
cur_token = WITH_CHECK;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
/* save the lookahead token for next time */
|
||||||
|
lookahead_token = next_token;
|
||||||
|
lookahead_yylval = base_yylval;
|
||||||
|
lookahead_yylloc = base_yylloc;
|
||||||
have_lookahead = true;
|
have_lookahead = true;
|
||||||
|
/* and back up the output info to cur_token */
|
||||||
|
base_yylval = cur_yylval;
|
||||||
|
base_yylloc = cur_yylloc;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user