Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit063560b

Browse files
committed
Fix filtered_base_yylex() to save and restore base_yylval and base_yylloc
properly when doing a lookahead. The lack of this was causing variousinteresting misbehaviors when one tries to use "with" as a plain identifier.
1 parente85ef6e commit063560b

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

‎src/backend/parser/parser.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.69 2007/01/05 22:19:34 momjian Exp $
17+
* $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.70 2007/01/0619:14:17 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -28,8 +28,10 @@
2828

2929
List*parsetree;/* result of parsing is left here */
3030

31-
staticintlookahead_token;/* one-token lookahead */
32-
staticboolhave_lookahead;/* lookahead_token set? */
31+
staticboolhave_lookahead;/* is lookahead info valid? */
32+
staticintlookahead_token;/* one-token lookahead */
33+
staticYYSTYPElookahead_yylval;/* yylval for lookahead token */
34+
staticYYLTYPElookahead_yylloc;/* yylloc for lookahead token */
3335

3436

3537
/*
@@ -77,11 +79,16 @@ int
7779
filtered_base_yylex(void)
7880
{
7981
intcur_token;
82+
intnext_token;
83+
YYSTYPEcur_yylval;
84+
YYLTYPEcur_yylloc;
8085

8186
/* Get next token --- we might already have it */
8287
if (have_lookahead)
8388
{
8489
cur_token=lookahead_token;
90+
base_yylval=lookahead_yylval;
91+
base_yylloc=lookahead_yylloc;
8592
have_lookahead= false;
8693
}
8794
else
@@ -102,8 +109,10 @@ filtered_base_yylex(void)
102109
* (perhaps for SQL99 recursive queries), come back and simplify
103110
* this code.
104111
*/
105-
lookahead_token=base_yylex();
106-
switch (lookahead_token)
112+
cur_yylval=base_yylval;
113+
cur_yylloc=base_yylloc;
114+
next_token=base_yylex();
115+
switch (next_token)
107116
{
108117
caseCASCADED:
109118
cur_token=WITH_CASCADED;
@@ -115,7 +124,14 @@ filtered_base_yylex(void)
115124
cur_token=WITH_CHECK;
116125
break;
117126
default:
127+
/* save the lookahead token for next time */
128+
lookahead_token=next_token;
129+
lookahead_yylval=base_yylval;
130+
lookahead_yylloc=base_yylloc;
118131
have_lookahead= true;
132+
/* and back up the output info to cur_token */
133+
base_yylval=cur_yylval;
134+
base_yylloc=cur_yylloc;
119135
break;
120136
}
121137
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp