mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Parser: syntax for query system_time [closes #230]
Eliminated `QUERY FOR`.
This commit is contained in:
@@ -76,8 +76,8 @@ insert emp values (4, 'john', 1);
|
||||
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 for system_time all;
|
||||
with ancestors as (select * from emp natural join addr query for system_time all) select * from ancestors;
|
||||
select * from emp natural join addr query for system_time all;
|
||||
with ancestors as (select * from emp natural join addr system_time all) select * from ancestors;
|
||||
select * from emp natural join addr system_time all;
|
||||
|
||||
drop table emp;
|
||||
drop table dept;
|
||||
|
@@ -108,9 +108,9 @@ 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;
|
||||
with s3 as (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) select * from s3;
|
||||
# system_time propagation from outer to inner
|
||||
select * from (select *, t1.sys_trx_start from t2 for system_time as of now, t1) as s4 query for system_time as of timestamp @t0;
|
||||
select * from (select *, t1.sys_trx_start from t2 for system_time as of now, t1) as s4 system_time as of timestamp @t0;
|
||||
with s5 as (select *, t1.sys_trx_start from t2 for system_time as of now, 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 now, t1) select * from s6 query for system_time as of timestamp @t0;
|
||||
with s6 as (select *, t1.sys_trx_start from t2 for system_time as of now, t1) select * from s6 system_time as of timestamp @t0;
|
||||
|
||||
# VIEW instead of t1
|
||||
set @q= concat("create view vt1 as select * from t1 for system_time as of timestamp '", @t0, "'");
|
||||
@@ -123,7 +123,7 @@ select * from (select * from vt1, t2) as s0;
|
||||
# leading table selection
|
||||
select * from (select *, vt1.sys_trx_end from t2, vt1) as s0;
|
||||
# system_time propagation from outer to inner
|
||||
select * from (select *, vt1.sys_trx_start from t2 for system_time as of now, vt1) as s0 query for system_time as of timestamp @t0;
|
||||
select * from (select *, vt1.sys_trx_start from t2 for system_time as of now, vt1) as s0 system_time as of timestamp @t0;
|
||||
|
||||
drop table t1, t2;
|
||||
drop view vt1;
|
||||
|
@@ -9,15 +9,15 @@ select * from t;
|
||||
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 * from t for system_time as of timestamp now(6);
|
||||
select count(*) from t group by b query for system_time as of timestamp now(6);
|
||||
select count(*) from t group by b system_time as of timestamp now(6);
|
||||
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 group by a having a=2 query for system_time as of timestamp now(6);
|
||||
select * from t group by b having b=2 query for system_time as of timestamp now(6);
|
||||
select a from t where b=2 query for system_time as of timestamp now(6);
|
||||
select a from t where b=NULL query for system_time as of timestamp now(6);
|
||||
select a from t where b is NULL query for system_time as of timestamp now(6);
|
||||
select count(*), b from t group by b having b=NULL query for system_time as of timestamp now(6);
|
||||
select * from t group by a having a=2 system_time as of timestamp now(6);
|
||||
select * from t group by b having b=2 system_time as of timestamp now(6);
|
||||
select a from t where b=2 system_time as of timestamp now(6);
|
||||
select a from t where b=NULL system_time as of timestamp now(6);
|
||||
select a from t where b is NULL system_time as of timestamp now(6);
|
||||
select count(*), b from t group by b having b=NULL system_time as of timestamp now(6);
|
||||
select a, b from t;
|
||||
|
||||
drop table t;
|
||||
|
@@ -99,11 +99,11 @@ begin
|
||||
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
|
||||
query for system_time as of timestamp @t0;
|
||||
system_time as of timestamp @t0;
|
||||
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
|
||||
query for system_time as of timestamp @t0;
|
||||
system_time as of timestamp @t0;
|
||||
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
|
||||
query for system_time as of timestamp @t0;
|
||||
system_time as of timestamp @t0;
|
||||
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
@@ -195,10 +195,10 @@ 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;
|
||||
select * from t1, t2 system_time all;
|
||||
|
||||
--error ER_VERS_UNUSED_CLAUSE
|
||||
select * from t1 for system_time all, t2 for system_time all query for system_time all;
|
||||
select * from t1 for system_time all, t2 for system_time all system_time all;
|
||||
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
|
@@ -45,26 +45,26 @@ where d.dept_id = 10
|
||||
select * from emp e, dept d
|
||||
where d.dept_id = 10
|
||||
and d.dept_id = e.dept_id
|
||||
query for system_time from timestamp @ts_1 to timestamp @ts_2;
|
||||
system_time from timestamp @ts_1 to timestamp @ts_2;
|
||||
|
||||
select * from emp e, dept d
|
||||
where d.dept_id = 10
|
||||
and d.dept_id = e.dept_id
|
||||
query for system_time as of timestamp @ts_0;
|
||||
system_time as of timestamp @ts_0;
|
||||
|
||||
select * from emp e, dept d
|
||||
where d.dept_id = 10
|
||||
and d.dept_id = e.dept_id
|
||||
query for system_time as of timestamp @ts_1;
|
||||
system_time as of timestamp @ts_1;
|
||||
|
||||
select * from emp e, dept d
|
||||
where d.dept_id = 10
|
||||
and d.dept_id = e.dept_id
|
||||
query for system_time as of timestamp @ts_2;
|
||||
system_time as of timestamp @ts_2;
|
||||
|
||||
select * from emp e, dept d
|
||||
where d.dept_id = 10
|
||||
and d.dept_id = e.dept_id
|
||||
query for system_time as of timestamp @ts_3;
|
||||
system_time as of timestamp @ts_3;
|
||||
|
||||
drop table emp, dept;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
-- source include/have_innodb.inc
|
||||
|
||||
create table t (a int);
|
||||
--error ER_VERSIONING_REQUIRED
|
||||
--error ER_VERS_UNUSED_CLAUSE
|
||||
truncate t for system_time all;
|
||||
|
||||
delimiter ~~;
|
Reference in New Issue
Block a user