Commit f77a4135 authored by kevg's avatar kevg Committed by Aleksey Midenkov

SQL: parsing of QUERY FOR [fixes #159]

Reverts 46e36bbffa7cd8d9eb861a22755025ffe8751449 - SQL: fix assertion failure in parser
parent f8b562f5
......@@ -426,9 +426,19 @@ a a
2 3
3 3
1 NULL
create or replace table t1 (x int) with system versioning;
create or replace table t2 (y int) with system versioning;
insert into t1 values (1), (2), (3);
delete from t1 where x = 3;
insert into t2 values (1);
select * from t1, t2 query for system_time all;
x y
1 1
2 1
3 1
drop view v1;
drop table t1, t2;
call innodb_verify_vtq(24);
call innodb_verify_vtq(27);
No A B C D
1 1 1 1 1
2 1 1 1 1
......@@ -454,6 +464,9 @@ No A B C D
22 1 1 1 1
23 1 1 1 1
24 1 1 1 1
25 1 1 1 1
26 1 1 1 1
27 1 1 1 1
drop procedure test_01;
drop procedure test_02;
drop procedure verify_vtq;
......
......@@ -190,10 +190,17 @@ insert into t1 values (2);
insert into t1 values (3);
select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
create or replace table t1 (x int) with system versioning;
create or replace table t2 (y int) with system versioning;
insert into t1 values (1), (2), (3);
delete from t1 where x = 3;
insert into t2 values (1);
select * from t1, t2 query for system_time all;
drop view v1;
drop table t1, t2;
call innodb_verify_vtq(24);
call innodb_verify_vtq(27);
drop procedure test_01;
drop procedure test_02;
......
......@@ -1368,6 +1368,21 @@ int MYSQLlex(YYSTYPE *yylval, THD *thd)
return FOR_SYM;
}
break;
case QUERY_SYM:
{
CHARSET_INFO *cs= thd->charset();
const char *p= lip->get_ptr();
while (my_isspace(cs, *p))
++p;
if (lip->get_end_of_query() - p > 3 && my_isspace(cs, p[3]) &&
0 == strncasecmp(p, "for", 3))
{
token= lex_one_token(yylval, thd);
lip->add_digest_token(token, yylval);
return QUERY_FOR_SYM;
}
return QUERY_SYM;
}
default:
break;
}
......
......@@ -861,10 +861,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%parse-param { THD *thd }
%lex-param { THD *thd }
/*
Currently there are 106 shift/reduce conflicts.
Currently there are 103 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
%expect 106
%expect 103
/*
Comments for TOKENS.
......@@ -1353,6 +1353,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token PURGE
%token QUARTER_SYM
%token QUERY_SYM
%token QUERY_FOR_SYM /* INTERNAL */
%token QUICK
%token RAISE_SYM /* Oracle-PLSQL-R */
%token RANGE_SYM /* SQL-2003-R */
......@@ -8828,7 +8829,7 @@ trans_or_timestamp:
opt_query_for_system_time_clause:
/* empty */
{}
| QUERY_SYM FOR_SYSTEM_TIME_SYM for_system_time_expr
| QUERY_FOR_SYM SYSTEM_TIME_SYM for_system_time_expr
{
DBUG_ASSERT(Select);
Select->vers_conditions= Lex->vers_conditions;
......@@ -11705,21 +11706,15 @@ date_time_type:
| TIMESTAMP {$$=MYSQL_TIMESTAMP_DATETIME;}
;
table_alias:
/* empty */
| AS
| '='
;
opt_table_alias:
/* empty */ { $$=0; }
| ident
{
$$= (LEX_STRING*) thd->memdup(&$1,sizeof(LEX_STRING));
if ($$ == NULL)
MYSQL_YYABORT;
}
| AS ident
{
$$= (LEX_STRING*) thd->memdup(&$2,sizeof(LEX_STRING));
if ($$ == NULL)
MYSQL_YYABORT;
}
| '=' ident
| table_alias ident
{
$$= (LEX_STRING*) thd->memdup(&$2,sizeof(LEX_STRING));
if ($$ == NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment