mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +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:
@ -102,13 +102,13 @@ emp_id name mgr address
|
|||||||
2 bill 1 New York
|
2 bill 1 New York
|
||||||
3 kate 1 London
|
3 kate 1 London
|
||||||
4 john 1 Paris
|
4 john 1 Paris
|
||||||
with ancestors as (select * from emp natural join addr where 1 for system_time all) select * from ancestors;
|
with ancestors as (select * from (select * from emp natural join addr) for system_time all as t) select * from ancestors;
|
||||||
emp_id name mgr address
|
emp_id name mgr address
|
||||||
1 bill 0 Moscow
|
1 bill 0 Moscow
|
||||||
2 bill 1 New York
|
2 bill 1 New York
|
||||||
3 kate 1 London
|
3 kate 1 London
|
||||||
4 john 1 Paris
|
4 john 1 Paris
|
||||||
select * from emp natural join addr where 1 for system_time all;
|
select * from (select * from emp natural join addr) for system_time all as t;
|
||||||
emp_id name mgr address
|
emp_id name mgr address
|
||||||
1 bill 0 Moscow
|
1 bill 0 Moscow
|
||||||
2 bill 1 New York
|
2 bill 1 New York
|
||||||
|
@ -91,34 +91,29 @@ ancestors
|
|||||||
as
|
as
|
||||||
(
|
(
|
||||||
select e.emp_id, e.name, e.mgr
|
select e.emp_id, e.name, e.mgr
|
||||||
from emp as e
|
from emp for system_time as of timestamp @ts as e
|
||||||
where name = 'bill'
|
where name = 'bill'
|
||||||
for system_time as of timestamp @ts
|
union
|
||||||
union
|
|
||||||
select ee.emp_id, ee.name, ee.mgr
|
select ee.emp_id, ee.name, ee.mgr
|
||||||
from emp as ee, ancestors as a
|
from emp for system_time as of timestamp @ts as ee, ancestors as a
|
||||||
where ee.mgr = a.emp_id
|
where ee.mgr = a.emp_id
|
||||||
for system_time as of timestamp @ts
|
|
||||||
)
|
)
|
||||||
select * from ancestors;
|
select * from ancestors;
|
||||||
emp_id name mgr
|
emp_id name mgr
|
||||||
1 bill 0
|
1 bill 0
|
||||||
2 bill 1
|
2 bill 1
|
||||||
3 kate 1
|
|
||||||
set @tmp= "
|
set @tmp= "
|
||||||
with recursive
|
with recursive
|
||||||
ancestors
|
ancestors
|
||||||
as
|
as
|
||||||
(
|
(
|
||||||
select e.emp_id, e.name, e.mgr
|
select e.emp_id, e.name, e.mgr
|
||||||
from emp as e
|
from emp for system_time as of timestamp @ts as e
|
||||||
where name = 'bill'
|
where name = 'bill'
|
||||||
for system_time as of timestamp @ts
|
|
||||||
union
|
union
|
||||||
select ee.emp_id, ee.name, ee.mgr
|
select ee.emp_id, ee.name, ee.mgr
|
||||||
from emp as ee, ancestors as a
|
from emp for system_time as of timestamp @ts as ee, ancestors as a
|
||||||
where ee.mgr = a.emp_id
|
where ee.mgr = a.emp_id
|
||||||
for system_time as of timestamp @ts
|
|
||||||
)
|
)
|
||||||
select * from ancestors";
|
select * from ancestors";
|
||||||
prepare stmt from @tmp;
|
prepare stmt from @tmp;
|
||||||
@ -126,7 +121,6 @@ execute stmt;
|
|||||||
emp_id name mgr
|
emp_id name mgr
|
||||||
1 bill 0
|
1 bill 0
|
||||||
2 bill 1
|
2 bill 1
|
||||||
3 kate 1
|
|
||||||
drop prepare stmt;
|
drop prepare stmt;
|
||||||
drop table emp;
|
drop table emp;
|
||||||
create or replace table t1 (x int) with system versioning;
|
create or replace table t1 (x int) with system versioning;
|
||||||
@ -155,7 +149,7 @@ with s3 as (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp
|
|||||||
y x
|
y x
|
||||||
10 1
|
10 1
|
||||||
# SYSTEM_TIME propagation from outer to inner
|
# SYSTEM_TIME propagation from outer to inner
|
||||||
select * from (select *, t1.sys_trx_start from t2 for system_time as of current_timestamp, t1) as s4 for system_time as of timestamp @t0;
|
select * from (select *, t1.sys_trx_start from t2 for system_time as of current_timestamp, t1) for system_time as of timestamp @t0 as s4;
|
||||||
y x
|
y x
|
||||||
10 1
|
10 1
|
||||||
with s5 as (select *, t1.sys_trx_start from t2 for system_time as of current_timestamp, t1) select * from s5 for system_time as of timestamp @t0;
|
with s5 as (select *, t1.sys_trx_start from t2 for system_time as of current_timestamp, t1) select * from s5 for system_time as of timestamp @t0;
|
||||||
@ -183,7 +177,7 @@ select * from (select *, vt1.sys_trx_end from t2, vt1) as s0;
|
|||||||
y x
|
y x
|
||||||
10 1
|
10 1
|
||||||
### SYSTEM_TIME clash
|
### SYSTEM_TIME clash
|
||||||
select * from (select * from t1 for system_time all) dt0 for system_time all;
|
select * from (select * from t1 for system_time all) for system_time all as dt0;
|
||||||
ERROR HY000: SYSTEM_TIME is not allowed outside historical `dt0`
|
ERROR HY000: SYSTEM_TIME is not allowed outside historical `dt0`
|
||||||
select * from vt1 for system_time all;
|
select * from vt1 for system_time all;
|
||||||
ERROR HY000: SYSTEM_TIME is not allowed outside historical `vt1`
|
ERROR HY000: SYSTEM_TIME is not allowed outside historical `vt1`
|
||||||
|
@ -25,7 +25,7 @@ a b
|
|||||||
3 NULL
|
3 NULL
|
||||||
Warnings:
|
Warnings:
|
||||||
Warning 4112 Attempt to read unversioned field `b` in historical query
|
Warning 4112 Attempt to read unversioned field `b` in historical query
|
||||||
select count(*) from t group by b for system_time as of timestamp now(6);
|
select count(*) from t for system_time as of timestamp now(6) group by b;
|
||||||
count(*)
|
count(*)
|
||||||
2
|
2
|
||||||
Warnings:
|
Warnings:
|
||||||
@ -44,41 +44,10 @@ a b
|
|||||||
Warnings:
|
Warnings:
|
||||||
Warning 4112 Attempt to read unversioned field `b` in historical query
|
Warning 4112 Attempt to read unversioned field `b` in historical query
|
||||||
Warning 4112 Attempt to read unversioned field `b` in historical query
|
Warning 4112 Attempt to read unversioned field `b` in historical query
|
||||||
select * from t group by a having a=2 for system_time as of timestamp now(6);
|
select * from t for system_time as of timestamp now(6) group by a having a=2;
|
||||||
a b
|
a b
|
||||||
Warnings:
|
Warnings:
|
||||||
Warning 4112 Attempt to read unversioned field `b` in historical query
|
Warning 4112 Attempt to read unversioned field `b` in historical query
|
||||||
select * from t group by b having b=2 for system_time as of timestamp now(6);
|
|
||||||
a b
|
|
||||||
Warnings:
|
|
||||||
Warning 4112 Attempt to read unversioned field `b` in historical query
|
|
||||||
select a from t where b=2 for system_time as of timestamp now(6);
|
|
||||||
a
|
|
||||||
Warnings:
|
|
||||||
Warning 4112 Attempt to read unversioned field `b` in historical query
|
|
||||||
select a from t where b=NULL for system_time as of timestamp now(6);
|
|
||||||
a
|
|
||||||
Warnings:
|
|
||||||
Warning 4112 Attempt to read unversioned field `b` in historical query
|
|
||||||
select a from t where b is NULL for system_time as of timestamp now(6);
|
|
||||||
a
|
|
||||||
1
|
|
||||||
3
|
|
||||||
Warnings:
|
|
||||||
Warning 4112 Attempt to read unversioned field `b` in historical query
|
|
||||||
select count(*), b from t group by b having b=NULL for system_time as of timestamp now(6);
|
|
||||||
count(*) b
|
|
||||||
Warnings:
|
|
||||||
Warning 4112 Attempt to read unversioned field `b` in historical query
|
|
||||||
select a, b from t;
|
|
||||||
a b
|
|
||||||
1 2
|
|
||||||
3 4
|
|
||||||
select count(*) from t for system_time as of timestamp now(6) group by b;
|
|
||||||
count(*)
|
|
||||||
2
|
|
||||||
Warnings:
|
|
||||||
Warning 4112 Attempt to read unversioned field `b` in historical query
|
|
||||||
select * from t for system_time as of timestamp now(6) group by b having b=2;
|
select * from t for system_time as of timestamp now(6) group by b having b=2;
|
||||||
a b
|
a b
|
||||||
Warnings:
|
Warnings:
|
||||||
@ -101,6 +70,10 @@ select count(*), b from t for system_time as of timestamp now(6) group by b havi
|
|||||||
count(*) b
|
count(*) b
|
||||||
Warnings:
|
Warnings:
|
||||||
Warning 4112 Attempt to read unversioned field `b` in historical query
|
Warning 4112 Attempt to read unversioned field `b` in historical query
|
||||||
|
select a, b from t;
|
||||||
|
a b
|
||||||
|
1 2
|
||||||
|
3 4
|
||||||
create or replace table t (
|
create or replace table t (
|
||||||
a int,
|
a int,
|
||||||
b int not null without system versioning
|
b int not null without system versioning
|
||||||
|
@ -144,28 +144,47 @@ NULL NULL 2 1
|
|||||||
NULL NULL 3 1
|
NULL NULL 3 1
|
||||||
delete from t1;
|
delete from t1;
|
||||||
delete from t2;
|
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
|
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;
|
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
|
IJ2_x1 y1 x2 y2
|
||||||
1 1 1 2
|
1 1 1 2
|
||||||
1 2 1 2
|
1 2 1 2
|
||||||
1 3 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
|
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;
|
for system_time as of timestamp @t0 as t;
|
||||||
LJ2_x1 y1 x2 y2
|
LJ2_x1 y1 x2 y2
|
||||||
1 1 1 2
|
1 1 1 2
|
||||||
1 2 1 2
|
1 2 1 2
|
||||||
1 3 1 2
|
1 3 1 2
|
||||||
4 4 NULL NULL
|
4 4 NULL NULL
|
||||||
5 5 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
|
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;
|
for system_time as of timestamp @t0 as t;
|
||||||
RJ2_x1 y1 x2 y2
|
RJ2_x1 y1 x2 y2
|
||||||
1 1 1 2
|
1 1 1 2
|
||||||
1 2 1 2
|
1 2 1 2
|
||||||
1 3 1 2
|
1 3 1 2
|
||||||
NULL NULL 2 1
|
|
||||||
NULL NULL 3 1
|
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
create table t1(
|
create table t1(
|
||||||
@ -280,8 +299,9 @@ select * from t1, t2 for system_time all;
|
|||||||
x y
|
x y
|
||||||
1 1
|
1 1
|
||||||
2 1
|
2 1
|
||||||
select * from t1 for system_time all, t2 for system_time all for system_time all;
|
select * from (select * from t1 for system_time all, t2 for system_time all)
|
||||||
ERROR HY000: Unused clause: 'SYSTEM_TIME'
|
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)
|
### Issue #365, bug 4 (related to #226, optimized fields)
|
||||||
create or replace table t1 (i int, b int) with system versioning;
|
create or replace table t1 (i int, b int) with system versioning;
|
||||||
insert into t1 values (0, 0), (0, 0);
|
insert into t1 values (0, 0), (0, 0);
|
||||||
|
@ -77,12 +77,12 @@ select t1.x as LJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 o
|
|||||||
select t1.x as RJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x;
|
select t1.x as RJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x;
|
||||||
delete from t1;
|
delete from t1;
|
||||||
delete from t2;
|
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
|
select IJ2_x1,y1,x2,y2 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;
|
for system_time as of timestamp @t0 as t;
|
||||||
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
|
select LJ2_x1,y1,x2,y2 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;
|
for system_time as of timestamp @t0 as t;
|
||||||
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
|
select RJ2_x1,y1,x2,y2 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;
|
for system_time as of timestamp @t0 as t;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
end~~
|
end~~
|
||||||
@ -207,8 +207,6 @@ RJ2_x1 y1 x2 y2
|
|||||||
1 1 1 2
|
1 1 1 2
|
||||||
1 2 1 2
|
1 2 1 2
|
||||||
1 3 1 2
|
1 3 1 2
|
||||||
NULL NULL 2 1
|
|
||||||
NULL NULL 3 1
|
|
||||||
create table t1(
|
create table t1(
|
||||||
A int
|
A int
|
||||||
) with system versioning;
|
) with system versioning;
|
||||||
@ -321,8 +319,10 @@ select * from t1, t2 for system_time all;
|
|||||||
x y
|
x y
|
||||||
1 1
|
1 1
|
||||||
2 1
|
2 1
|
||||||
select * from t1 for system_time all, t2 for system_time all for system_time all;
|
select * from (select * from t1 for system_time all, t2 for system_time all) for system_time all as t;
|
||||||
ERROR HY000: Unused clause: 'SYSTEM_TIME'
|
ERROR HY000: SYSTEM_TIME is not allowed outside historical `t`
|
||||||
|
select * from (t1 for system_time all join t2 for system_time all) for system_time all;
|
||||||
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2;
|
drop table t1, t2;
|
||||||
call innodb_verify_vtq(27);
|
call innodb_verify_vtq(27);
|
||||||
|
@ -42,31 +42,32 @@ where d.dept_id = 10
|
|||||||
and d.dept_id = e.dept_id;
|
and d.dept_id = e.dept_id;
|
||||||
emp_id dept_id name salary dept_id name
|
emp_id dept_id name salary dept_id name
|
||||||
1 10 bill 2000 10 accounting
|
1 10 bill 2000 10 accounting
|
||||||
select * from emp e, dept d
|
select * from
|
||||||
|
emp for system_time from timestamp @ts_1 to timestamp @ts_2 e,
|
||||||
|
dept for system_time from timestamp @ts_1 to timestamp @ts_2 d
|
||||||
where d.dept_id = 10
|
where d.dept_id = 10
|
||||||
and d.dept_id = e.dept_id
|
and d.dept_id = e.dept_id;
|
||||||
for system_time from timestamp @ts_1 to timestamp @ts_2;
|
|
||||||
emp_id dept_id name salary sys_trx_start sys_trx_end dept_id name sys_trx_start sys_trx_end
|
emp_id dept_id name salary sys_trx_start sys_trx_end dept_id name sys_trx_start sys_trx_end
|
||||||
|
set statement versioning_asof_timestamp=@ts_0 for
|
||||||
select * from emp e, dept d
|
select * from emp e, dept d
|
||||||
where d.dept_id = 10
|
where d.dept_id = 10
|
||||||
and d.dept_id = e.dept_id
|
and d.dept_id = e.dept_id;
|
||||||
for system_time as of timestamp @ts_0;
|
|
||||||
emp_id dept_id name salary dept_id name
|
emp_id dept_id name salary dept_id name
|
||||||
|
set statement versioning_asof_timestamp=@ts_1 for
|
||||||
select * from emp e, dept d
|
select * from emp e, dept d
|
||||||
where d.dept_id = 10
|
where d.dept_id = 10
|
||||||
and d.dept_id = e.dept_id
|
and d.dept_id = e.dept_id;
|
||||||
for system_time as of timestamp @ts_1;
|
|
||||||
emp_id dept_id name salary dept_id name
|
emp_id dept_id name salary dept_id name
|
||||||
|
set statement versioning_asof_timestamp=@ts_2 for
|
||||||
select * from emp e, dept d
|
select * from emp e, dept d
|
||||||
where d.dept_id = 10
|
where d.dept_id = 10
|
||||||
and d.dept_id = e.dept_id
|
and d.dept_id = e.dept_id;
|
||||||
for system_time as of timestamp @ts_2;
|
|
||||||
emp_id dept_id name salary dept_id name
|
emp_id dept_id name salary dept_id name
|
||||||
1 10 bill 1000 10 accounting
|
1 10 bill 1000 10 accounting
|
||||||
|
set statement versioning_asof_timestamp=@ts_3 for
|
||||||
select * from emp e, dept d
|
select * from emp e, dept d
|
||||||
where d.dept_id = 10
|
where d.dept_id = 10
|
||||||
and d.dept_id = e.dept_id
|
and d.dept_id = e.dept_id;
|
||||||
for system_time as of timestamp @ts_3;
|
|
||||||
emp_id dept_id name salary dept_id name
|
emp_id dept_id name salary dept_id name
|
||||||
1 10 bill 2000 10 accounting
|
1 10 bill 2000 10 accounting
|
||||||
drop table emp, dept;
|
drop table emp, dept;
|
||||||
|
@ -94,8 +94,8 @@ insert emp values (4, 'john', 1);
|
|||||||
insert addr values (4, 'Paris');
|
insert addr values (4, 'Paris');
|
||||||
with ancestors as (select * from emp natural join addr) select * from ancestors;
|
with ancestors as (select * from emp natural join addr) select * from ancestors;
|
||||||
with ancestors as (select * from emp natural join addr) select * from ancestors for system_time all;
|
with ancestors as (select * from emp natural join addr) select * from ancestors for system_time all;
|
||||||
with ancestors as (select * from emp natural join addr where 1 for system_time all) select * from ancestors;
|
with ancestors as (select * from (select * from emp natural join addr) for system_time all as t) select * from ancestors;
|
||||||
select * from emp natural join addr where 1 for system_time all;
|
select * from (select * from emp natural join addr) for system_time all as t;
|
||||||
|
|
||||||
drop table emp;
|
drop table emp;
|
||||||
drop table dept;
|
drop table dept;
|
||||||
|
@ -57,19 +57,18 @@ as
|
|||||||
select * from ancestors";
|
select * from ancestors";
|
||||||
prepare stmt from @tmp; execute stmt; drop prepare stmt;
|
prepare stmt from @tmp; execute stmt; drop prepare stmt;
|
||||||
|
|
||||||
|
#385
|
||||||
with recursive
|
with recursive
|
||||||
ancestors
|
ancestors
|
||||||
as
|
as
|
||||||
(
|
(
|
||||||
select e.emp_id, e.name, e.mgr
|
select e.emp_id, e.name, e.mgr
|
||||||
from emp as e
|
from emp for system_time as of timestamp @ts as e
|
||||||
where name = 'bill'
|
where name = 'bill'
|
||||||
for system_time as of timestamp @ts
|
|
||||||
union
|
union
|
||||||
select ee.emp_id, ee.name, ee.mgr
|
select ee.emp_id, ee.name, ee.mgr
|
||||||
from emp as ee, ancestors as a
|
from emp for system_time as of timestamp @ts as ee, ancestors as a
|
||||||
where ee.mgr = a.emp_id
|
where ee.mgr = a.emp_id
|
||||||
for system_time as of timestamp @ts
|
|
||||||
)
|
)
|
||||||
select * from ancestors;
|
select * from ancestors;
|
||||||
set @tmp= "
|
set @tmp= "
|
||||||
@ -78,14 +77,12 @@ ancestors
|
|||||||
as
|
as
|
||||||
(
|
(
|
||||||
select e.emp_id, e.name, e.mgr
|
select e.emp_id, e.name, e.mgr
|
||||||
from emp as e
|
from emp for system_time as of timestamp @ts as e
|
||||||
where name = 'bill'
|
where name = 'bill'
|
||||||
for system_time as of timestamp @ts
|
|
||||||
union
|
union
|
||||||
select ee.emp_id, ee.name, ee.mgr
|
select ee.emp_id, ee.name, ee.mgr
|
||||||
from emp as ee, ancestors as a
|
from emp for system_time as of timestamp @ts as ee, ancestors as a
|
||||||
where ee.mgr = a.emp_id
|
where ee.mgr = a.emp_id
|
||||||
for system_time as of timestamp @ts
|
|
||||||
)
|
)
|
||||||
select * from ancestors";
|
select * from ancestors";
|
||||||
prepare stmt from @tmp; execute stmt; drop prepare stmt;
|
prepare stmt from @tmp; execute stmt; drop prepare stmt;
|
||||||
@ -112,7 +109,7 @@ with s1 as (select * from t1 for system_time as of timestamp @t0, t2) select * f
|
|||||||
select * from (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) as s2;
|
select * from (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) as s2;
|
||||||
with s3 as (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) select * from s3;
|
with s3 as (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) select * from s3;
|
||||||
--echo # SYSTEM_TIME propagation from outer to inner
|
--echo # SYSTEM_TIME propagation from outer to inner
|
||||||
select * from (select *, t1.sys_trx_start from t2 for system_time as of current_timestamp, t1) as s4 for system_time as of timestamp @t0;
|
select * from (select *, t1.sys_trx_start from t2 for system_time as of current_timestamp, t1) for system_time as of timestamp @t0 as s4;
|
||||||
with s5 as (select *, t1.sys_trx_start from t2 for system_time as of current_timestamp, t1) select * from s5 for system_time as of timestamp @t0;
|
with s5 as (select *, t1.sys_trx_start from t2 for system_time as of current_timestamp, t1) select * from s5 for system_time as of timestamp @t0;
|
||||||
with s6 as (select *, t1.sys_trx_start from t2 for system_time as of current_timestamp, t1) select * from s6 for system_time as of timestamp @t0;
|
with s6 as (select *, t1.sys_trx_start from t2 for system_time as of current_timestamp, t1) select * from s6 for system_time as of timestamp @t0;
|
||||||
|
|
||||||
@ -130,7 +127,7 @@ select * from (select *, vt1.sys_trx_end from t2, vt1) as s0;
|
|||||||
|
|
||||||
--echo ### SYSTEM_TIME clash
|
--echo ### SYSTEM_TIME clash
|
||||||
--error ER_VERS_SYSTEM_TIME_CLASH
|
--error ER_VERS_SYSTEM_TIME_CLASH
|
||||||
select * from (select * from t1 for system_time all) dt0 for system_time all;
|
select * from (select * from t1 for system_time all) for system_time all as dt0;
|
||||||
--error ER_VERS_SYSTEM_TIME_CLASH
|
--error ER_VERS_SYSTEM_TIME_CLASH
|
||||||
select * from vt1 for system_time all;
|
select * from vt1 for system_time all;
|
||||||
--error ER_VERS_SYSTEM_TIME_CLASH
|
--error ER_VERS_SYSTEM_TIME_CLASH
|
||||||
|
@ -9,23 +9,16 @@ select * from t;
|
|||||||
select a from t for system_time as of timestamp now(6);
|
select a from t for system_time as of timestamp now(6);
|
||||||
select a, b, b+0 from t for system_time as of timestamp now(6);
|
select a, b, b+0 from t for system_time as of timestamp now(6);
|
||||||
select * from t for system_time as of timestamp now(6);
|
select * from t for system_time as of timestamp now(6);
|
||||||
select count(*) from t group by b for system_time as of timestamp now(6);
|
select count(*) from t for system_time as of timestamp now(6) group by b;
|
||||||
select * from t for system_time as of timestamp now(6) order by b asc;
|
select * from t for system_time as of timestamp now(6) order by b asc;
|
||||||
select * from t for system_time as of timestamp now(6) order by b desc;
|
select * from t for system_time as of timestamp now(6) order by b desc;
|
||||||
select * from t group by a having a=2 for system_time as of timestamp now(6);
|
select * from t for system_time as of timestamp now(6) group by a having a=2;
|
||||||
select * from t group by b having b=2 for system_time as of timestamp now(6);
|
|
||||||
select a from t where b=2 for system_time as of timestamp now(6);
|
|
||||||
select a from t where b=NULL for system_time as of timestamp now(6);
|
|
||||||
select a from t where b is NULL for system_time as of timestamp now(6);
|
|
||||||
select count(*), b from t group by b having b=NULL for system_time as of timestamp now(6);
|
|
||||||
select a, b from t;
|
|
||||||
|
|
||||||
select count(*) from t for system_time as of timestamp now(6) group by b;
|
|
||||||
select * from t for system_time as of timestamp now(6) group by b having b=2;
|
select * from t for system_time as of timestamp now(6) group by b having b=2;
|
||||||
select a from t for system_time as of timestamp now(6) where b=2;
|
select a from t for system_time as of timestamp now(6) where b=2;
|
||||||
select a from t for system_time as of timestamp now(6) where b=NULL;
|
select a from t for system_time as of timestamp now(6) where b=NULL;
|
||||||
select a from t for system_time as of timestamp now(6) where b is NULL;
|
select a from t for system_time as of timestamp now(6) where b is NULL;
|
||||||
select count(*), b from t for system_time as of timestamp now(6) group by b having b=NULL;
|
select count(*), b from t for system_time as of timestamp now(6) group by b having b=NULL;
|
||||||
|
select a, b from t;
|
||||||
|
|
||||||
create or replace table t (
|
create or replace table t (
|
||||||
a int,
|
a int,
|
||||||
|
@ -84,12 +84,21 @@ select t1.x as RJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2
|
|||||||
delete from t1;
|
delete from t1;
|
||||||
delete from t2;
|
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
|
#384
|
||||||
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)
|
||||||
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;
|
||||||
for system_time as of timestamp @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)
|
||||||
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;
|
||||||
for system_time as of timestamp @t0;
|
#383
|
||||||
|
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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
@ -179,8 +188,9 @@ delete from t1 where x = 3;
|
|||||||
insert into t2 values (1);
|
insert into t2 values (1);
|
||||||
select * from t1, t2 for system_time all;
|
select * from t1, t2 for system_time all;
|
||||||
|
|
||||||
--error ER_VERS_UNUSED_CLAUSE
|
--error ER_VERS_SYSTEM_TIME_CLASH
|
||||||
select * from t1 for system_time all, t2 for system_time all for system_time all;
|
select * from (select * from t1 for system_time all, t2 for system_time all)
|
||||||
|
for system_time all as t;
|
||||||
|
|
||||||
--echo ### Issue #365, bug 4 (related to #226, optimized fields)
|
--echo ### Issue #365, bug 4 (related to #226, optimized fields)
|
||||||
create or replace table t1 (i int, b int) with system versioning;
|
create or replace table t1 (i int, b int) with system versioning;
|
||||||
|
@ -93,12 +93,12 @@ begin
|
|||||||
delete from t1;
|
delete from t1;
|
||||||
delete from t2;
|
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
|
select IJ2_x1,y1,x2,y2 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;
|
for system_time as of timestamp @t0 as t;
|
||||||
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
|
select LJ2_x1,y1,x2,y2 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;
|
for system_time as of timestamp @t0 as t;
|
||||||
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
|
select RJ2_x1,y1,x2,y2 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;
|
for system_time as of timestamp @t0 as t;
|
||||||
|
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
@ -192,8 +192,10 @@ delete from t1 where x = 3;
|
|||||||
insert into t2 values (1);
|
insert into t2 values (1);
|
||||||
select * from t1, t2 for system_time all;
|
select * from t1, t2 for system_time all;
|
||||||
|
|
||||||
--error ER_VERS_UNUSED_CLAUSE
|
--error ER_VERS_SYSTEM_TIME_CLASH
|
||||||
select * from t1 for system_time all, t2 for system_time all for system_time all;
|
select * from (select * from t1 for system_time all, t2 for system_time all) for system_time all as t;
|
||||||
|
--error ER_PARSE_ERROR
|
||||||
|
select * from (t1 for system_time all join t2 for system_time all) for system_time all;
|
||||||
|
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2;
|
drop table t1, t2;
|
||||||
|
@ -44,29 +44,30 @@ select * from emp e, dept d
|
|||||||
where d.dept_id = 10
|
where d.dept_id = 10
|
||||||
and d.dept_id = e.dept_id;
|
and d.dept_id = e.dept_id;
|
||||||
|
|
||||||
select * from emp e, dept d
|
select * from
|
||||||
|
emp for system_time from timestamp @ts_1 to timestamp @ts_2 e,
|
||||||
|
dept for system_time from timestamp @ts_1 to timestamp @ts_2 d
|
||||||
where d.dept_id = 10
|
where d.dept_id = 10
|
||||||
and d.dept_id = e.dept_id
|
and d.dept_id = e.dept_id;
|
||||||
for system_time from timestamp @ts_1 to timestamp @ts_2;
|
|
||||||
|
|
||||||
|
set statement versioning_asof_timestamp=@ts_0 for
|
||||||
select * from emp e, dept d
|
select * from emp e, dept d
|
||||||
where d.dept_id = 10
|
where d.dept_id = 10
|
||||||
and d.dept_id = e.dept_id
|
and d.dept_id = e.dept_id;
|
||||||
for system_time as of timestamp @ts_0;
|
|
||||||
|
|
||||||
|
set statement versioning_asof_timestamp=@ts_1 for
|
||||||
select * from emp e, dept d
|
select * from emp e, dept d
|
||||||
where d.dept_id = 10
|
where d.dept_id = 10
|
||||||
and d.dept_id = e.dept_id
|
and d.dept_id = e.dept_id;
|
||||||
for system_time as of timestamp @ts_1;
|
|
||||||
|
|
||||||
|
set statement versioning_asof_timestamp=@ts_2 for
|
||||||
select * from emp e, dept d
|
select * from emp e, dept d
|
||||||
where d.dept_id = 10
|
where d.dept_id = 10
|
||||||
and d.dept_id = e.dept_id
|
and d.dept_id = e.dept_id;
|
||||||
for system_time as of timestamp @ts_2;
|
|
||||||
|
|
||||||
|
set statement versioning_asof_timestamp=@ts_3 for
|
||||||
select * from emp e, dept d
|
select * from emp e, dept d
|
||||||
where d.dept_id = 10
|
where d.dept_id = 10
|
||||||
and d.dept_id = e.dept_id
|
and d.dept_id = e.dept_id;
|
||||||
for system_time as of timestamp @ts_3;
|
|
||||||
|
|
||||||
drop table emp, dept;
|
drop table emp, dept;
|
||||||
|
@ -892,10 +892,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *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 122 shift/reduce conflicts.
|
||||||
We should not introduce new conflicts any more.
|
We should not introduce new conflicts any more.
|
||||||
*/
|
*/
|
||||||
%expect 125
|
%expect 122
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Comments for TOKENS.
|
Comments for TOKENS.
|
||||||
@ -9138,7 +9138,6 @@ table_expression:
|
|||||||
opt_group_clause
|
opt_group_clause
|
||||||
opt_having_clause
|
opt_having_clause
|
||||||
opt_window_clause
|
opt_window_clause
|
||||||
opt_system_time_clause
|
|
||||||
;
|
;
|
||||||
|
|
||||||
opt_table_expression:
|
opt_table_expression:
|
||||||
@ -9188,31 +9187,6 @@ opt_trans_or_timestamp:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
opt_system_time_clause:
|
|
||||||
/* empty */
|
|
||||||
{}
|
|
||||||
| FOR_SYSTEM_TIME_SYM system_time_expr
|
|
||||||
{
|
|
||||||
DBUG_ASSERT(Select);
|
|
||||||
int used= 0;
|
|
||||||
if (Lex->vers_conditions)
|
|
||||||
{
|
|
||||||
for (TABLE_LIST *table= Select->table_list.first; table; table= table->next_local)
|
|
||||||
{
|
|
||||||
if (!table->vers_conditions)
|
|
||||||
{
|
|
||||||
table->vers_conditions= Lex->vers_conditions;
|
|
||||||
used++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!used)
|
|
||||||
{
|
|
||||||
my_yyabort_error((ER_VERS_UNUSED_CLAUSE, MYF(0), "SYSTEM_TIME"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
opt_for_system_time_clause:
|
opt_for_system_time_clause:
|
||||||
/* empty */
|
/* empty */
|
||||||
{
|
{
|
||||||
@ -11862,7 +11836,10 @@ table_primary_derived:
|
|||||||
!$$->derived->first_select()->next_select())
|
!$$->derived->first_select()->next_select())
|
||||||
$$->select_lex->add_where_field($$->derived->first_select());
|
$$->select_lex->add_where_field($$->derived->first_select());
|
||||||
if ($5)
|
if ($5)
|
||||||
|
{
|
||||||
|
MYSQL_YYABORT_UNLESS(!$3);
|
||||||
$$->vers_conditions= Lex->vers_conditions;
|
$$->vers_conditions= Lex->vers_conditions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Represents derived table with WITH clause */
|
/* Represents derived table with WITH clause */
|
||||||
| '(' get_select_lex subselect_start
|
| '(' get_select_lex subselect_start
|
||||||
|
Reference in New Issue
Block a user