set @@session.time_zone='+00:00'; select ifnull(max(transaction_id), 0) into @start_trx_id from mysql.transaction_registry; set @test_start=now(6); create procedure if not exists verify_vtq() begin set @i= 0; select @i:= @i + 1 as No, transaction_id > 0 as A, commit_id > transaction_id as B, begin_timestamp > @test_start as C, commit_timestamp >= begin_timestamp as D from mysql.transaction_registry where transaction_id > @start_trx_id; select ifnull(max(transaction_id), 0) into @start_trx_id from mysql.transaction_registry; end~~ create function if not exists default_engine() returns varchar(255) deterministic begin declare e varchar(255); select lower(engine) from information_schema.engines where support='DEFAULT' into e; return e; end~~ create function if not exists sys_datatype() returns varchar(255) deterministic begin if default_engine() = 'innodb' then return 'bigint unsigned'; elseif default_engine() = 'myisam' then return 'timestamp(6)'; end if; return NULL; end~~ create function if not exists sys_commit_ts(sys_field varchar(255)) returns varchar(255) deterministic begin if default_engine() = 'innodb' then return concat('vtq_commit_ts(', sys_field, ')'); elseif default_engine() = 'myisam' then return sys_field; end if; return NULL; end~~ create procedure if not exists innodb_verify_vtq(recs int) begin declare i int default 1; if default_engine() = 'innodb' then call verify_vtq; elseif default_engine() = 'myisam' then create temporary table tmp (No int, A bool, B bool, C bool, D bool); while i <= recs do insert into tmp values (i, 1, 1, 1, 1); set i= i + 1; end while; select * from tmp; drop table tmp; end if; end~~ create procedure concat_exec2(a varchar(255), b varchar(255)) begin prepare stmt from concat(a, b); execute stmt; deallocate prepare stmt; end~~ create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) begin prepare stmt from concat(a, b, c); execute stmt; deallocate prepare stmt; end~~ create or replace table t1 ( x int unsigned, y int unsigned ) with system versioning; insert into t1 (x, y) values (0, 100), (1, 101), (2, 102), (3, 103), (4, 104), (5, 105), (6, 106), (7, 107), (8, 108), (9, 109); set @t0= now(6); delete from t1 where x = 3; delete from t1 where x > 7; insert into t1(x, y) values(3, 33); select sys_trx_start from t1 where x = 3 and y = 33 into @t1; select x, y from t1; x y 0 100 1 101 2 102 4 104 5 105 6 106 7 107 3 33 select x as ASOF_x, y from t1 for system_time as of timestamp @t0; ASOF_x y 0 100 1 101 2 102 3 103 4 104 5 105 6 106 7 107 8 108 9 109 select x as FROMTO_x, y from t1 for system_time from '0-0-0 0:0:0' to timestamp @t1; FROMTO_x y 0 100 1 101 2 102 3 103 4 104 5 105 6 106 7 107 8 108 9 109 select x as BETWAND_x, y from t1 for system_time between '0-0-0 0:0:0' and timestamp @t1; BETWAND_x y 0 100 1 101 2 102 3 103 4 104 5 105 6 106 7 107 8 108 9 109 3 33 select x as ALL_x, y from t1 for system_time all; ALL_x y 0 100 1 101 2 102 3 103 4 104 5 105 6 106 7 107 8 108 9 109 3 33 ASOF2_x y 0 100 1 101 2 102 3 103 4 104 5 105 6 106 7 107 8 108 9 109 FROMTO2_x y 0 100 1 101 2 102 3 103 4 104 5 105 6 106 7 107 8 108 9 109 BETWAND2_x y 0 100 1 101 2 102 3 103 4 104 5 105 6 106 7 107 8 108 9 109 3 33 create or replace table t1 ( x int unsigned, y int unsigned ) with system versioning; create or replace table t2 ( x int unsigned, y int unsigned ) with system versioning; insert into t1 values (1, 1), (1, 2), (1, 3), (4, 4), (5, 5); insert into t2 values (1, 2), (2, 1), (3, 1); set @t0= now(6); select t1.x as IJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x; IJ1_x1 y1 x2 y2 1 1 1 2 1 2 1 2 1 3 1 2 select t1.x as LJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x; LJ1_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 RJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x; RJ1_x1 y1 x2 y2 1 1 1 2 1 2 1 2 1 3 1 2 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 system_time as of timestamp @t0; 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 system_time as of timestamp @t0; 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 system_time as of timestamp @t0; 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( A int ) with system versioning; insert into t1 values(1); select * from t1; A 1 create or replace table t1 (x int); insert into t1 values (1); select * from t1 for system_time all; ERROR HY000: System Versioning required: t1 create or replace table t1 (x int) with system versioning; insert into t1 values (1); select * from t1 for system_time all for update; ERROR HY000: Versioned SELECT write-locking of history rows create or replace table t1 (a int not null auto_increment primary key) with system versioning; select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; a create or replace table t1 (a int) with system versioning; create or replace table t2 (a int) with system versioning; insert into t1 values(1); insert into t2 values(1); create view v1 as select * from t2 inner join t1 using (a); select * from v1; a 1 drop view v1; create or replace table t1 (a int) with system versioning; insert into t1 values (1); create view vt1 as select a from t1; select * from t1 natural join vt1; a 1 drop view vt1; create or replace table t1(x int) with system versioning; select * from (t1 as r left join t1 as u using (x)), t1; x x create or replace table t1 (a int) with system versioning; insert into t1 values (1); create trigger read_end after update on t1 for each row set @end = old.sys_trx_end; update t1 set a=2; select @end; @end MAX_RESULT create or replace table t1 (a int) with system versioning; create or replace table t2 (b int) with system versioning; insert into t1 values (1); insert into t2 values (2); select * from (select * from t1 cross join t2) as tmp; a b 1 2 select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2; a b 1 2 select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp; a b create or replace table t1(a1 int) with system versioning; create or replace table t2(a2 int) with system versioning; insert into t1 values(1),(2); insert into t2 values(1),(2); select * from t1 for system_time all natural left join t2 for system_time all; a1 a2 1 1 2 1 1 2 2 2 create or replace table t1(a1 int) with system versioning; create or replace table t2(a2 int) with system versioning; insert into t1 values(1),(2); insert into t2 values(1),(2); create or replace view v1 as select a1 from t1; select * from v1 natural join t2; a1 a2 1 1 2 1 1 2 2 2 select * from v1 natural left join t2; a1 a2 1 1 2 1 1 2 2 2 select * from v1 natural right join t2; a2 a1 1 1 2 1 1 2 2 2 create or replace table t1 (a int) with system versioning; insert into t1 values (1); 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; a a 2 1 3 1 2 2 3 2 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 system_time all; x y 1 1 2 1 3 1 select * from t1 for system_time all, t2 for system_time all system_time all; ERROR HY000: Unused clause: 'SYSTEM_TIME' drop view v1; drop table t1, t2; call innodb_verify_vtq(27); No A B C D 1 1 1 1 1 2 1 1 1 1 3 1 1 1 1 4 1 1 1 1 5 1 1 1 1 6 1 1 1 1 7 1 1 1 1 8 1 1 1 1 9 1 1 1 1 10 1 1 1 1 11 1 1 1 1 12 1 1 1 1 13 1 1 1 1 14 1 1 1 1 15 1 1 1 1 16 1 1 1 1 17 1 1 1 1 18 1 1 1 1 19 1 1 1 1 20 1 1 1 1 21 1 1 1 1 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 verify_vtq; drop procedure innodb_verify_vtq; drop function default_engine; drop function sys_commit_ts; drop function sys_datatype; drop procedure concat_exec2; drop procedure concat_exec3;