1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

for now, remove FOR SYSTEM_TIME at the end of the query

non-standard, redundant, potentially risky in the future,
hides bugs. See #383, #384, #385

Fixed a parser bug where
SELECT * FROM (t1 join t2) FOR SYSTEM_TIME ...
was not an error.
This commit is contained in:
Sergei Golubchik
2017-12-11 14:09:58 +01:00
parent a1141e226d
commit ca6454bcfe
13 changed files with 124 additions and 156 deletions

View File

@ -144,28 +144,47 @@ NULL NULL 2 1
NULL NULL 3 1
delete from t1;
delete from t2;
select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x
for system_time as of timestamp @t0;
explain extended select * from (select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`x` AS `IJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL join `test`.`t2` FOR SYSTEM_TIME ALL where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`sys_trx_end` > @`t0` and `test`.`t1`.`sys_trx_start` <= @`t0` and `test`.`t1`.`sys_trx_end` > @`t0` and `test`.`t1`.`sys_trx_start` <= @`t0` and `test`.`t2`.`sys_trx_end` > @`t0` and `test`.`t2`.`sys_trx_start` <= @`t0`
explain extended select * from (select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`x` AS `LJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL left join `test`.`t2` FOR SYSTEM_TIME ALL on(`test`.`t2`.`x` = `test`.`t1`.`x` and `test`.`t2`.`sys_trx_end` > @`t0` and `test`.`t2`.`sys_trx_start` <= @`t0`) where `test`.`t1`.`sys_trx_end` > @`t0` and `test`.`t1`.`sys_trx_start` <= @`t0` and `test`.`t1`.`sys_trx_end` > @`t0` and `test`.`t1`.`sys_trx_start` <= @`t0`
explain extended select * from (select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`x` AS `RJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t2` FOR SYSTEM_TIME ALL join `test`.`t1` FOR SYSTEM_TIME ALL where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`sys_trx_end` > @`t0` and `test`.`t1`.`sys_trx_start` <= @`t0` and `test`.`t1`.`sys_trx_end` > @`t0` and `test`.`t1`.`sys_trx_start` <= @`t0` and `test`.`t2`.`sys_trx_end` > @`t0` and `test`.`t2`.`sys_trx_start` <= @`t0`
select * from (select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
IJ2_x1 y1 x2 y2
1 1 1 2
1 2 1 2
1 3 1 2
select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x
for system_time as of timestamp @t0;
select * from (select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
LJ2_x1 y1 x2 y2
1 1 1 2
1 2 1 2
1 3 1 2
4 4 NULL NULL
5 5 NULL NULL
select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x
for system_time as of timestamp @t0;
select * from (select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
RJ2_x1 y1 x2 y2
1 1 1 2
1 2 1 2
1 3 1 2
NULL NULL 2 1
NULL NULL 3 1
drop table t1;
drop table t2;
create table t1(
@ -280,8 +299,9 @@ select * from t1, t2 for system_time all;
x y
1 1
2 1
select * from t1 for system_time all, t2 for system_time all for system_time all;
ERROR HY000: Unused clause: 'SYSTEM_TIME'
select * from (select * from t1 for system_time all, t2 for system_time all)
for system_time all as t;
ERROR HY000: SYSTEM_TIME is not allowed outside historical `t`
### Issue #365, bug 4 (related to #226, optimized fields)
create or replace table t1 (i int, b int) with system versioning;
insert into t1 values (0, 0), (0, 0);