mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Bug#9801 Views: imperfect error message
Backport for 5.5 The root cause of this bug is that the grammar for GROUP BY clauses, when using WITH CUBE or WITH ROLLUP, cause conflicts with the grammar for VIEW, when using WITH CHECK OPTION. The solution is to implement two token look ahead when parsing a WITH token, to disambiguate the non standard WITH CUBE and WITH ROLLUP syntaxes. Patch based on code from Marc Alff and Antony Curtis
This commit is contained in:
@ -24,6 +24,8 @@
|
||||
#include "sp.h"
|
||||
#include "sp_head.h"
|
||||
|
||||
static int lex_one_token(void *arg, void *yythd);
|
||||
|
||||
/*
|
||||
We are using pointer to this variable for distinguishing between assignment
|
||||
to NEW row field (when parsing trigger definition) and structured variable.
|
||||
@ -117,6 +119,8 @@ Lex_input_stream::Lex_input_stream(THD *thd,
|
||||
yylineno(1),
|
||||
yytoklen(0),
|
||||
yylval(NULL),
|
||||
lookahead_token(-1),
|
||||
lookahead_yylval(NULL),
|
||||
m_ptr(buffer),
|
||||
m_tok_start(NULL),
|
||||
m_tok_end(NULL),
|
||||
@ -779,6 +783,60 @@ bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted)
|
||||
*/
|
||||
|
||||
int MYSQLlex(void *arg, void *yythd)
|
||||
{
|
||||
THD *thd= (THD *)yythd;
|
||||
Lex_input_stream *lip= & thd->m_parser_state->m_lip;
|
||||
YYSTYPE *yylval=(YYSTYPE*) arg;
|
||||
int token;
|
||||
|
||||
if (lip->lookahead_token >= 0)
|
||||
{
|
||||
/*
|
||||
The next token was already parsed in advance,
|
||||
return it.
|
||||
*/
|
||||
token= lip->lookahead_token;
|
||||
lip->lookahead_token= -1;
|
||||
*yylval= *(lip->lookahead_yylval);
|
||||
lip->lookahead_yylval= NULL;
|
||||
return token;
|
||||
}
|
||||
|
||||
token= lex_one_token(arg, yythd);
|
||||
|
||||
switch(token) {
|
||||
case WITH:
|
||||
/*
|
||||
Parsing 'WITH' 'ROLLUP' or 'WITH' 'CUBE' requires 2 look ups,
|
||||
which makes the grammar LALR(2).
|
||||
Replace by a single 'WITH_ROLLUP' or 'WITH_CUBE' token,
|
||||
to transform the grammar into a LALR(1) grammar,
|
||||
which sql_yacc.yy can process.
|
||||
*/
|
||||
token= lex_one_token(arg, yythd);
|
||||
switch(token) {
|
||||
case CUBE_SYM:
|
||||
return WITH_CUBE_SYM;
|
||||
case ROLLUP_SYM:
|
||||
return WITH_ROLLUP_SYM;
|
||||
default:
|
||||
/*
|
||||
Save the token following 'WITH'
|
||||
*/
|
||||
lip->lookahead_yylval= lip->yylval;
|
||||
lip->yylval= NULL;
|
||||
lip->lookahead_token= token;
|
||||
return WITH;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
int lex_one_token(void *arg, void *yythd)
|
||||
{
|
||||
reg1 uchar c= 0;
|
||||
bool comment_closed;
|
||||
|
Reference in New Issue
Block a user