mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-15004 parser greedily parses AS OF TIMESTAMP
* TIMESTAMP precedence fixed.
This commit is contained in:
committed by
Sergei Golubchik
parent
e2f70d6e10
commit
f1bd02d994
@ -63,7 +63,7 @@ select sys_start into @sys_start from t1;
|
|||||||
delete from t1;
|
delete from t1;
|
||||||
select * from t1;
|
select * from t1;
|
||||||
select x = 1 as A, sys_start = @sys_start as B, sys_end > sys_start as C
|
select x = 1 as A, sys_start = @sys_start as B, sys_end > sys_start as C
|
||||||
from t1 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07';
|
from t1 for system_time all;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
end~~
|
end~~
|
||||||
create or replace procedure test_03(
|
create or replace procedure test_03(
|
||||||
@ -91,8 +91,8 @@ select x as t2_x from t2;
|
|||||||
delete t1, t2 from t1 join t2 where t1.x = t2.x;
|
delete t1, t2 from t1 join t2 where t1.x = t2.x;
|
||||||
select x as t1_x from t1;
|
select x as t1_x from t1;
|
||||||
select x as t2_x from t2;
|
select x as t2_x from t2;
|
||||||
select x as t1_x_all from t1 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07';
|
select x as t1_x_all from t1 for system_time all;
|
||||||
select x as t2_x_all from t2 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07';
|
select x as t2_x_all from t2 for system_time all;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
end~~
|
end~~
|
||||||
|
@ -25,7 +25,7 @@ update parent set id=id+1;
|
|||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
|
||||||
delete from child;
|
delete from child;
|
||||||
update parent set id=id+1;
|
update parent set id=id+1;
|
||||||
select * from child for system_time from timestamp '1-1-1' to timestamp now(6);
|
select * from child for system_time from timestamp 0 to timestamp now(6);
|
||||||
parent_id
|
parent_id
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
@ -165,7 +165,7 @@ delete from child where parent_id = 1;
|
|||||||
delete from parent where id = 1;
|
delete from parent where id = 1;
|
||||||
select * from child;
|
select * from child;
|
||||||
parent_id
|
parent_id
|
||||||
select * from child for system_time from timestamp '1-1-1' to timestamp now(6);
|
select * from child for system_time from timestamp 0 to timestamp now(6);
|
||||||
parent_id
|
parent_id
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
|
@ -248,7 +248,7 @@ a b
|
|||||||
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
|
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
|
||||||
a b
|
a b
|
||||||
1 2
|
1 2
|
||||||
select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp;
|
select * from (select * from t1 cross join t2 for system_time as of timestamp ('0-0-0')) as tmp;
|
||||||
a b
|
a b
|
||||||
create or replace table t1(a1 int) with system versioning;
|
create or replace table t1(a1 int) with system versioning;
|
||||||
create or replace table t2(a2 int) with system versioning;
|
create or replace table t2(a2 int) with system versioning;
|
||||||
@ -475,6 +475,16 @@ f1 f2 f3 f1 f2 f3 f4
|
|||||||
3 3 NULL NULL 3 1 1
|
3 3 NULL NULL 3 1 1
|
||||||
3 3 NULL NULL 3 2 1
|
3 3 NULL NULL 3 2 1
|
||||||
4 NULL NULL NULL NULL NULL NULL
|
4 NULL NULL NULL NULL NULL NULL
|
||||||
|
### MDEV-15004 parser greedily parses AS OF TIMESTAMP
|
||||||
|
select timestamp'2016-02-30 08:07:06';
|
||||||
|
ERROR HY000: Incorrect DATETIME value: '2016-02-30 08:07:06'
|
||||||
|
select * from t1 for system_time as of timestamp'2016-02-30 08:07:06';
|
||||||
|
ERROR HY000: Incorrect DATETIME value: '2016-02-30 08:07:06'
|
||||||
|
select timestamp('2003-12-31 12:00:00','12:00:00');
|
||||||
|
timestamp('2003-12-31 12:00:00','12:00:00')
|
||||||
|
2004-01-01 00:00:00
|
||||||
|
select * from t1 for system_time as of timestamp('2003-12-31 12:00:00','12:00:00');
|
||||||
|
f1
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2, t3, t4;
|
drop table t1, t2, t3, t4;
|
||||||
call verify_vtq_dummy(34);
|
call verify_vtq_dummy(34);
|
||||||
|
@ -273,7 +273,7 @@ a b
|
|||||||
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
|
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
|
||||||
a b
|
a b
|
||||||
1 2
|
1 2
|
||||||
select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp;
|
select * from (select * from t1 cross join t2 for system_time as of timestamp ('0-0-0')) as tmp;
|
||||||
a b
|
a b
|
||||||
create or replace table t1(a1 int) with system versioning;
|
create or replace table t1(a1 int) with system versioning;
|
||||||
create or replace table t2(a2 int) with system versioning;
|
create or replace table t2(a2 int) with system versioning;
|
||||||
|
@ -79,7 +79,7 @@ create or replace view vt12 as select * from t1 cross join t2;
|
|||||||
select * from vt12;
|
select * from vt12;
|
||||||
a b
|
a b
|
||||||
1 2
|
1 2
|
||||||
create or replace view vt12 as select * from t1 for system_time as of timestamp '0-0-0' cross join t2;
|
create or replace view vt12 as select * from t1 for system_time as of timestamp ('0-0-0') cross join t2;
|
||||||
select * from vt12;
|
select * from vt12;
|
||||||
a b
|
a b
|
||||||
# VIEW improvements [#183]
|
# VIEW improvements [#183]
|
||||||
|
@ -67,7 +67,7 @@ begin
|
|||||||
delete from t1;
|
delete from t1;
|
||||||
select * from t1;
|
select * from t1;
|
||||||
select x = 1 as A, sys_start = @sys_start as B, sys_end > sys_start as C
|
select x = 1 as A, sys_start = @sys_start as B, sys_end > sys_start as C
|
||||||
from t1 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07';
|
from t1 for system_time all;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
end~~
|
end~~
|
||||||
|
|
||||||
@ -96,8 +96,8 @@ begin
|
|||||||
delete t1, t2 from t1 join t2 where t1.x = t2.x;
|
delete t1, t2 from t1 join t2 where t1.x = t2.x;
|
||||||
select x as t1_x from t1;
|
select x as t1_x from t1;
|
||||||
select x as t2_x from t2;
|
select x as t2_x from t2;
|
||||||
select x as t1_x_all from t1 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07';
|
select x as t1_x_all from t1 for system_time all;
|
||||||
select x as t2_x_all from t2 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07';
|
select x as t2_x_all from t2 for system_time all;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
end~~
|
end~~
|
||||||
|
@ -33,7 +33,7 @@ insert into child values(1);
|
|||||||
update parent set id=id+1;
|
update parent set id=id+1;
|
||||||
delete from child;
|
delete from child;
|
||||||
update parent set id=id+1;
|
update parent set id=id+1;
|
||||||
select * from child for system_time from timestamp '1-1-1' to timestamp now(6);
|
select * from child for system_time from timestamp 0 to timestamp now(6);
|
||||||
|
|
||||||
drop table child;
|
drop table child;
|
||||||
drop table parent;
|
drop table parent;
|
||||||
@ -188,7 +188,7 @@ delete from child where parent_id = 1;
|
|||||||
--echo ## FIXME END
|
--echo ## FIXME END
|
||||||
delete from parent where id = 1;
|
delete from parent where id = 1;
|
||||||
select * from child;
|
select * from child;
|
||||||
select * from child for system_time from timestamp '1-1-1' to timestamp now(6);
|
select * from child for system_time from timestamp 0 to timestamp now(6);
|
||||||
delete from child;
|
delete from child;
|
||||||
|
|
||||||
insert into parent values(1);
|
insert into parent values(1);
|
||||||
@ -198,7 +198,7 @@ if (0)
|
|||||||
{
|
{
|
||||||
update parent set id=id+1;
|
update parent set id=id+1;
|
||||||
select * from child;
|
select * from child;
|
||||||
select * from child for system_time from timestamp '1-1-1' to timestamp now(6);
|
select * from child for system_time from timestamp 0 to timestamp now(6);
|
||||||
}
|
}
|
||||||
## FIXME END
|
## FIXME END
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ insert into t1 values (1);
|
|||||||
insert into t2 values (2);
|
insert into t2 values (2);
|
||||||
select * from (select * from t1 cross join t2) as tmp;
|
select * from (select * from t1 cross join t2) as tmp;
|
||||||
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
|
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
|
||||||
select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp;
|
select * from (select * from t1 cross join t2 for system_time as of timestamp ('0-0-0')) as tmp;
|
||||||
|
|
||||||
create or replace table t1(a1 int) with system versioning;
|
create or replace table t1(a1 int) with system versioning;
|
||||||
create or replace table t2(a2 int) with system versioning;
|
create or replace table t2(a2 int) with system versioning;
|
||||||
@ -297,6 +297,13 @@ select * from
|
|||||||
left join t2 as t2a left join (t3 as t3a inner join t1) on t2a.f2 = t3a.f3 on t1a.f1 = t2a.f2
|
left join t2 as t2a left join (t3 as t3a inner join t1) on t2a.f2 = t3a.f3 on t1a.f1 = t2a.f2
|
||||||
left join (t2 join t3 inner join t4) on t2a.f2 = t1a.f1;
|
left join (t2 join t3 inner join t4) on t2a.f2 = t1a.f1;
|
||||||
|
|
||||||
|
--echo ### MDEV-15004 parser greedily parses AS OF TIMESTAMP
|
||||||
|
--error ER_WRONG_VALUE
|
||||||
|
select timestamp'2016-02-30 08:07:06';
|
||||||
|
--error ER_WRONG_VALUE
|
||||||
|
select * from t1 for system_time as of timestamp'2016-02-30 08:07:06';
|
||||||
|
select timestamp('2003-12-31 12:00:00','12:00:00');
|
||||||
|
select * from t1 for system_time as of timestamp('2003-12-31 12:00:00','12:00:00');
|
||||||
|
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2, t3, t4;
|
drop table t1, t2, t3, t4;
|
||||||
|
@ -168,7 +168,7 @@ insert into t1 values (1);
|
|||||||
insert into t2 values (2);
|
insert into t2 values (2);
|
||||||
select * from (select * from t1 cross join t2) as tmp;
|
select * from (select * from t1 cross join t2) as tmp;
|
||||||
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
|
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
|
||||||
select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp;
|
select * from (select * from t1 cross join t2 for system_time as of timestamp ('0-0-0')) as tmp;
|
||||||
|
|
||||||
create or replace table t1(a1 int) with system versioning;
|
create or replace table t1(a1 int) with system versioning;
|
||||||
create or replace table t2(a2 int) with system versioning;
|
create or replace table t2(a2 int) with system versioning;
|
||||||
|
@ -65,7 +65,7 @@ insert into t1 values (1);
|
|||||||
insert into t2 values (2);
|
insert into t2 values (2);
|
||||||
create or replace view vt12 as select * from t1 cross join t2;
|
create or replace view vt12 as select * from t1 cross join t2;
|
||||||
select * from vt12;
|
select * from vt12;
|
||||||
create or replace view vt12 as select * from t1 for system_time as of timestamp '0-0-0' cross join t2;
|
create or replace view vt12 as select * from t1 for system_time as of timestamp ('0-0-0') cross join t2;
|
||||||
select * from vt12;
|
select * from vt12;
|
||||||
|
|
||||||
--echo # VIEW improvements [#183]
|
--echo # VIEW improvements [#183]
|
||||||
|
@ -884,10 +884,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
|||||||
%parse-param { THD *thd }
|
%parse-param { THD *thd }
|
||||||
%lex-param { THD *thd }
|
%lex-param { THD *thd }
|
||||||
/*
|
/*
|
||||||
Currently there are 125 shift/reduce conflicts.
|
Currently there are 139 shift/reduce conflicts.
|
||||||
We should not introduce new conflicts any more.
|
We should not introduce new conflicts any more.
|
||||||
*/
|
*/
|
||||||
%expect 125
|
%expect 139
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Comments for TOKENS.
|
Comments for TOKENS.
|
||||||
@ -1776,6 +1776,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
|||||||
percentile_function
|
percentile_function
|
||||||
inverse_distribution_function_def
|
inverse_distribution_function_def
|
||||||
function_call_keyword
|
function_call_keyword
|
||||||
|
function_call_keyword_timestamp
|
||||||
function_call_nonkeyword
|
function_call_nonkeyword
|
||||||
function_call_generic
|
function_call_generic
|
||||||
function_call_conflict kill_expr
|
function_call_conflict kill_expr
|
||||||
@ -9200,7 +9201,15 @@ opt_history_unit:
|
|||||||
;
|
;
|
||||||
|
|
||||||
history_point:
|
history_point:
|
||||||
opt_history_unit simple_expr
|
temporal_literal
|
||||||
|
{
|
||||||
|
$$= Vers_history_point(VERS_TIMESTAMP, $1);
|
||||||
|
}
|
||||||
|
| function_call_keyword_timestamp
|
||||||
|
{
|
||||||
|
$$= Vers_history_point(VERS_TIMESTAMP, $1);
|
||||||
|
}
|
||||||
|
| opt_history_unit simple_expr
|
||||||
{
|
{
|
||||||
$$= Vers_history_point($1, $2);
|
$$= Vers_history_point($1, $2);
|
||||||
}
|
}
|
||||||
@ -10099,6 +10108,21 @@ simple_expr:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
function_call_keyword_timestamp:
|
||||||
|
TIMESTAMP '(' expr ')'
|
||||||
|
{
|
||||||
|
$$= new (thd->mem_root) Item_datetime_typecast(thd, $3,
|
||||||
|
AUTO_SEC_PART_DIGITS);
|
||||||
|
if ($$ == NULL)
|
||||||
|
MYSQL_YYABORT;
|
||||||
|
}
|
||||||
|
| TIMESTAMP '(' expr ',' expr ')'
|
||||||
|
{
|
||||||
|
$$= new (thd->mem_root) Item_func_add_time(thd, $3, $5, 1, 0);
|
||||||
|
if ($$ == NULL)
|
||||||
|
MYSQL_YYABORT;
|
||||||
|
}
|
||||||
|
;
|
||||||
/*
|
/*
|
||||||
Function call syntax using official SQL 2003 keywords.
|
Function call syntax using official SQL 2003 keywords.
|
||||||
Because the function name is an official token,
|
Because the function name is an official token,
|
||||||
@ -10222,18 +10246,9 @@ function_call_keyword:
|
|||||||
if ($$ == NULL)
|
if ($$ == NULL)
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| TIMESTAMP '(' expr ')'
|
| function_call_keyword_timestamp
|
||||||
{
|
{
|
||||||
$$= new (thd->mem_root) Item_datetime_typecast(thd, $3,
|
$$= $1;
|
||||||
AUTO_SEC_PART_DIGITS);
|
|
||||||
if ($$ == NULL)
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
|
||||||
| TIMESTAMP '(' expr ',' expr ')'
|
|
||||||
{
|
|
||||||
$$= new (thd->mem_root) Item_func_add_time(thd, $3, $5, 1, 0);
|
|
||||||
if ($$ == NULL)
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
}
|
||||||
| TRIM '(' expr ')'
|
| TRIM '(' expr ')'
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user