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

Tests: moved to dedicated versioning suite

Run `mtr --suite=versioning` or `mtr versioning.<test-name>`
This commit is contained in:
Aleksey Midenkov
2016-10-18 09:05:49 +00:00
parent 5cf3dd79fa
commit d3b737d910
14 changed files with 2674 additions and 0 deletions

View File

@ -0,0 +1,22 @@
-- source include/have_innodb.inc
set @@session.time_zone='+00:00';
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
delimiter ~~;
create procedure if not exists verify_vtq()
begin
set @i= 0;
select
@i:= @i + 1 as No,
trx_id > 0 as A,
begin_ts > '1-1-1 0:0:0' as B,
commit_ts > begin_ts as C,
concurr_trx is null as D
from information_schema.innodb_vtq
where trx_id > @start_trx_id;
select ifnull(max(trx_id), 0)
into @start_trx_id
from information_schema.innodb_vtq;
end~~
delimiter ;~~

View File

@ -0,0 +1 @@
--loose-innodb-vtq

View File

@ -0,0 +1,99 @@
set @@session.time_zone='+00:00';
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
create procedure if not exists verify_vtq()
begin
set @i= 0;
select
@i:= @i + 1 as No,
trx_id > 0 as A,
begin_ts > '1-1-1 0:0:0' as B,
commit_ts > begin_ts as C,
concurr_trx is null as D
from information_schema.innodb_vtq
where trx_id > @start_trx_id;
select ifnull(max(trx_id), 0)
into @start_trx_id
from information_schema.innodb_vtq;
end~~
create procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
id int unsigned auto_increment primary key,
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
set @str= concat('
create table t2(
id int unsigned auto_increment primary key,
x int unsigned,
y int unsigned)
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values(1, 11);
insert into t2(x, y) values(1, 11);
insert into t1(x, y) values(2, 12);
insert into t2(x, y) values(2, 12);
insert into t1(x, y) values(3, 13);
insert into t2(x, y) values(3, 13);
insert into t1(x, y) values(4, 14);
insert into t2(x, y) values(4, 14);
insert into t1(x, y) values(5, 15);
insert into t2(x, y) values(5, 15);
insert into t1(x, y) values(6, 16);
insert into t2(x, y) values(6, 16);
insert into t1(x, y) values(7, 17);
insert into t2(x, y) values(7, 17);
insert into t1(x, y) values(8, 18);
insert into t2(x, y) values(8, 18);
insert into t1(x, y) values(9, 19);
insert into t2(x, y) values(9, 19);
select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner join t2 on t1.id = t2.id;
delete from t1 where x = 2;
delete from t2 where x = 2;
select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner join t2 on t1.id = t2.id;
delete from t1 where x > 7;
delete from t2 where x > 7;
select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner join t2 on t1.id = t2.id;
drop table t1;
drop table t2;
end~~
call test_01('timestamp(6)', 'myisam', 'sys_end');
A x y x y
1 1 11 1 11
1 2 12 2 12
1 3 13 3 13
1 4 14 4 14
1 5 15 5 15
1 6 16 6 16
1 7 17 7 17
1 8 18 8 18
1 9 19 9 19
A x y x y
1 1 11 1 11
1 3 13 3 13
1 4 14 4 14
1 5 15 5 15
1 6 16 6 16
1 7 17 7 17
1 8 18 8 18
1 9 19 9 19
A x y x y
1 1 11 1 11
1 3 13 3 13
1 4 14 4 14
1 5 15 5 15
1 6 16 6 16
1 7 17 7 17
call verify_vtq;
No A B C D
drop procedure test_01;
drop procedure verify_vtq;

View File

@ -0,0 +1,198 @@
drop table if exists t1;
create table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`XNo` int(10) unsigned DEFAULT NULL,
`Sys_start` timestamp(6) NOT NULL GENERATED AS ROW START,
`Sys_end` timestamp(6) NOT NULL GENERATED AS ROW END,
PERIOD FOR SYSTEM_TIME (`Sys_start`, `Sys_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
# Implicit fields test
create or replace table t1 (
XNo int unsigned
) with system versioning;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`XNo` int(10) unsigned DEFAULT NULL,
`sys_trx_start` timestamp(6) NOT NULL GENERATED AS ROW START,
`sys_trx_end` timestamp(6) NOT NULL GENERATED AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_start2 timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: 'Generated as row start' specified more than once
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end2 timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Second column in 'period for system time' must be equal to 'generated as row end' column
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
Sys_end2 timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Generated as row end specified more than once
create or replace table t1 (
XNo int unsigned,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: 'Generated as row start' not specified
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
Sys_end2 timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: Generated as row end specified more than once
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (sys_insert, sys_remove)
) with system versioning;
ERROR HY000: First column in 'period for system time' must be equal to 'generated as row start' column
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: 'With system versioning' is missing
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_start)
);
ERROR HY000: 'Period for system_time' must contain two different columns
create or replace table t1 (
XNo int unsigned,
Sys_start int generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: System start field must be of type TIMESTAMP
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end int generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: System end field must be of type TIMESTAMP
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end bigint generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
ERROR HY000: System start field must be of type BIGINT UNSIGNED
create or replace table t1 (
XNo int unsigned,
Sys_start bigint generated always as row start,
Sys_end bigint generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
ERROR HY000: System start field must be of type BIGINT UNSIGNED
create or replace table t1 (
XNo int unsigned,
Sys_start bigint unsigned generated always as row start,
Sys_end bigint generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
ERROR HY000: System end field must be of type BIGINT UNSIGNED
create or replace table t1 (
A int with system versioning,
B int
);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`A` int(11) DEFAULT NULL,
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
`sys_trx_start` timestamp(6) NOT NULL GENERATED AS ROW START,
`sys_trx_end` timestamp(6) NOT NULL GENERATED AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
A int with system versioning,
B int
) with system versioning;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`A` int(11) DEFAULT NULL,
`B` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) NOT NULL GENERATED AS ROW START,
`sys_trx_end` timestamp(6) NOT NULL GENERATED AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
A int,
B int without system versioning
);
ERROR HY000: Every field specified unversioned in versioned table
create or replace table t1 (
A int,
B int without system versioning
) with system versioning;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`A` int(11) DEFAULT NULL,
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
`sys_trx_start` timestamp(6) NOT NULL GENERATED AS ROW START,
`sys_trx_end` timestamp(6) NOT NULL GENERATED AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
A int with system versioning,
B int without system versioning
);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`A` int(11) DEFAULT NULL,
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
`sys_trx_start` timestamp(6) NOT NULL GENERATED AS ROW START,
`sys_trx_end` timestamp(6) NOT NULL GENERATED AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
A int with system versioning,
B int without system versioning
) with system versioning;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`A` int(11) DEFAULT NULL,
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
`sys_trx_start` timestamp(6) NOT NULL GENERATED AS ROW START,
`sys_trx_end` timestamp(6) NOT NULL GENERATED AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
A int without system versioning
);
ERROR HY000: Every field specified unversioned in versioned table
create or replace table t1 (
A int without system versioning
) with system versioning;
ERROR HY000: Every field specified unversioned in versioned table
drop table t1;

View File

@ -0,0 +1,310 @@
set @@session.time_zone='+00:00';
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
create procedure if not exists verify_vtq()
begin
set @i= 0;
select
@i:= @i + 1 as No,
trx_id > 0 as A,
begin_ts > '1-1-1 0:0:0' as B,
commit_ts > begin_ts as C,
concurr_trx is null as D
from information_schema.innodb_vtq
where trx_id > @start_trx_id;
select ifnull(max(trx_id), 0)
into @start_trx_id
from information_schema.innodb_vtq;
end~~
create or replace procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create or replace table t1(
XNo int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(XNo) values(0);
insert into t1(XNo) values(1);
insert into t1(XNo) values(2);
insert into t1(XNo) values(3);
insert into t1(XNo) values(4);
insert into t1(XNo) values(5);
insert into t1(XNo) values(6);
insert into t1(XNo) values(7);
insert into t1(XNo) values(8);
insert into t1(XNo) values(9);
set @str= concat('select XNo, ',
fields, " < '2038-01-19 03:14:07'
from t1 for system_time
between timestamp '0000-0-0 0:0:0'
and timestamp '2038-01-19 04:14:07'");
prepare stmt from @str; execute stmt;
delete from t1 where XNo = 0;
execute stmt;
delete from t1 where XNo = 1;
execute stmt;
delete from t1 where XNo > 5;
create view vt1 as select XNo from t1;
select XNo from vt1;
delete from vt1 where XNo = 3;
select XNo from vt1;
execute stmt; drop prepare stmt;
drop view vt1;
drop table t1;
end~~
create or replace procedure test_02(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('create or replace table t1 (
x int,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x) values (1);
select sys_start into @sys_start from t1;
delete from t1;
select * from t1;
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';
drop table t1;
end~~
create or replace procedure test_03(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str0= concat('(
x int,
y int,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
set @str= concat('create or replace table t1', @str0);
prepare stmt from @str; execute stmt; drop prepare stmt;
set @str= concat('create or replace table t2', @str0);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values (1, 1), (2, 2), (3, 3), (14, 4);
insert into t2(x, y) values (11, 1), (12, 2), (13, 32), (14, 4);
delete t1, t2 from t1 join t2 where t1.y = 3 and t2.y = 32;
select x as t1_x from t1;
select x as t2_x from t2;
delete t1, t2 from t1 join t2 where t1.x = t2.x;
select x as t1_x from t1;
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 t2_x_all from t2 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07';
drop table t1;
drop table t2;
end~~
# Basic + delete from view
call test_01('timestamp(6)', 'myisam', 'sys_end');
XNo sys_end < '2038-01-19 03:14:07'
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
XNo sys_end < '2038-01-19 03:14:07'
0 1
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
XNo sys_end < '2038-01-19 03:14:07'
0 1
1 1
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
XNo
2
3
4
5
XNo
2
4
5
XNo sys_end < '2038-01-19 03:14:07'
0 1
1 1
2 0
3 1
4 0
5 0
6 1
7 1
8 1
9 1
call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
XNo commit_ts(sys_end) < '2038-01-19 03:14:07'
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
XNo commit_ts(sys_end) < '2038-01-19 03:14:07'
0 1
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
XNo commit_ts(sys_end) < '2038-01-19 03:14:07'
0 1
1 1
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
XNo
2
3
4
5
XNo
2
4
5
XNo commit_ts(sys_end) < '2038-01-19 03:14:07'
0 1
1 1
2 0
3 1
4 0
5 0
6 1
7 1
8 1
9 1
call verify_vtq;
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
# Check sys_start, sys_end
call test_02('timestamp(6)', 'myisam', 'sys_end');
x sys_start sys_end
A B C
1 1 1
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
x sys_start sys_end
A B C
1 1 1
call verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
# Multi-delete
call test_03('timestamp(6)', 'myisam', 'sys_end');
t1_x
1
2
14
t2_x
11
12
14
t1_x
1
2
t2_x
11
12
t1_x_all
1
2
3
14
t2_x_all
11
12
13
14
call test_03('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
t1_x
1
2
14
t2_x
11
12
14
t1_x
1
2
t2_x
11
12
t1_x_all
1
2
3
14
t2_x_all
11
12
13
14
call verify_vtq;
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
drop procedure test_01;
drop procedure test_02;
drop procedure test_03;
drop procedure verify_vtq;

View File

@ -0,0 +1,336 @@
set @@session.time_zone='+00:00';
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
create procedure if not exists verify_vtq()
begin
set @i= 0;
select
@i:= @i + 1 as No,
trx_id > 0 as A,
begin_ts > '1-1-1 0:0:0' as B,
commit_ts > begin_ts as C,
concurr_trx is null as D
from information_schema.innodb_vtq
where trx_id > @start_trx_id;
select ifnull(max(trx_id), 0)
into @start_trx_id
from information_schema.innodb_vtq;
end~~
create procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values(3, 4);
insert into t1(x, y) values(2, 3);
insert into t1 values(40, 33);
set @str= concat('select x, y, ', fields, ' from t1');
prepare stmt from @str; execute stmt; drop prepare stmt;
drop table t1;
end~~
create procedure test_02(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
id int unsigned auto_increment primary key,
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values(33, 44);
insert into t1(id, x, y) values(20, 33, 44);
insert into t1 values(40, 33, 44);
set @str= concat('select id, x, y, ', fields, ' from t1');
prepare stmt from @str; execute stmt; drop prepare stmt;
drop table t1;
end~~
create procedure test_03(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
create view vt1_1 as select x, y from t1;
create view vt1_2 as select x, y, sys_end from t1;
insert into t1(x, y) values(8001, 9001);
insert into vt1_1(x, y) values(1001, 2001);
insert into vt1_1 values(1002, 2002);
insert into vt1_2(x, y) values(3001, 4001);
set @str= concat('select x, y, ', fields, ' from t1');
prepare stmt from @str; execute stmt; drop prepare stmt;
select x, y from vt1_1;
set @str= concat('select x, y, ', fields, ' from vt1_2');
prepare stmt from @str; execute stmt; drop prepare stmt;
end~~
create procedure test_04(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
id bigint primary key,
a int,
b int)
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1 values(1, 1, 1);
select sys_trx_start, sys_trx_end from t1 into @sys_start, @sys_end;
select id, a, b from t1;
insert into t1 values(2, 2, 2);
select id, a, b, sys_trx_start > @sys_start as C, sys_trx_end = @sys_end as D from t1 where id = 2;
drop table t1;
end~~
create procedure test_05(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
set @str2= concat('create table t1', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
set @str2= concat('create table t2', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
insert into t1(x, y) values
(1, 1000),
(2, 2000),
(3, 3000),
(4, 4000),
(5, 5000),
(6, 6000),
(7, 7000),
(8, 8000),
(9, 9000);
delete from t1 where x >= 1;
insert into t1(x, y) values
(1, 1001),
(2, 2001),
(3, 3001),
(4, 4001),
(5, 5001),
(6, 6001),
(7, 7001),
(8, 8001),
(9, 9001);
insert into t2 select x, y from t1 for system_time between timestamp '0000-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
select x, y from t1;
select x, y from t2;
drop table t1;
drop table t2;
end~~
call test_01('timestamp(6)', 'myisam', 'sys_end');
x y sys_end
3 4 2038-01-19 03:14:07.000000
2 3 2038-01-19 03:14:07.000000
40 33 2038-01-19 03:14:07.000000
call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
x y commit_ts(sys_end)
3 4 2038-01-19 03:14:07.000000
2 3 2038-01-19 03:14:07.000000
40 33 2038-01-19 03:14:07.000000
call test_02('timestamp(6)', 'myisam', 'sys_end');
id x y sys_end
1 33 44 2038-01-19 03:14:07.000000
20 33 44 2038-01-19 03:14:07.000000
40 33 44 2038-01-19 03:14:07.000000
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
id x y commit_ts(sys_end)
1 33 44 2038-01-19 03:14:07.000000
20 33 44 2038-01-19 03:14:07.000000
40 33 44 2038-01-19 03:14:07.000000
call test_03('timestamp(6)', 'myisam', 'sys_end');
x y sys_end
8001 9001 2038-01-19 03:14:07.000000
1001 2001 2038-01-19 03:14:07.000000
1002 2002 2038-01-19 03:14:07.000000
3001 4001 2038-01-19 03:14:07.000000
x y
8001 9001
1001 2001
1002 2002
3001 4001
x y sys_end
8001 9001 2038-01-19 03:14:07.000000
1001 2001 2038-01-19 03:14:07.000000
1002 2002 2038-01-19 03:14:07.000000
3001 4001 2038-01-19 03:14:07.000000
insert into t1(x, y, sys_end) values(8001, 9001, '2015-1-1 1:1:1');
ERROR HY000: Generated field for System Versioning cannot be set by user
insert into vt1_2 values(3002, 4002, '2015-2-2 2:2:2');
ERROR HY000: Generated field for System Versioning cannot be set by user
drop table t1;
drop view vt1_1;
drop view vt1_2;
call test_03('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
x y commit_ts(sys_end)
8001 9001 2038-01-19 03:14:07.000000
1001 2001 2038-01-19 03:14:07.000000
1002 2002 2038-01-19 03:14:07.000000
3001 4001 2038-01-19 03:14:07.000000
x y
8001 9001
1001 2001
1002 2002
3001 4001
x y commit_ts(sys_end)
8001 9001 2038-01-19 03:14:07.000000
1001 2001 2038-01-19 03:14:07.000000
1002 2002 2038-01-19 03:14:07.000000
3001 4001 2038-01-19 03:14:07.000000
insert into t1(x, y, sys_end) values(8001, 9001, 1111111);
ERROR HY000: Generated field for System Versioning cannot be set by user
insert into vt1_2 values(3002, 4002, 2222222);
ERROR HY000: Generated field for System Versioning cannot be set by user
drop table t1;
drop view vt1_1;
drop view vt1_2;
call test_04('timestamp(6)', 'myisam', 'sys_end');
id a b
1 1 1
id a b C D
2 2 2 1 1
call test_04('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
id a b
1 1 1
id a b C D
2 2 2 1 1
call test_05('timestamp(6)', 'myisam', 'sys_end');
x y
1 1001
2 2001
3 3001
4 4001
5 5001
6 6001
7 7001
8 8001
9 9001
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8000
9 9000
1 1001
2 2001
3 3001
4 4001
5 5001
6 6001
7 7001
8 8001
9 9001
call test_05('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
x y
1 1001
2 2001
3 3001
4 4001
5 5001
6 6001
7 7001
8 8001
9 9001
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8000
9 9000
1 1001
2 2001
3 3001
4 4001
5 5001
6 6001
7 7001
8 8001
9 9001
call verify_vtq;
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
create table t1(
x int unsigned,
sys_start bigint unsigned generated always as row start,
sys_end bigint unsigned generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning engine=innodb;
create table t2(x int unsigned) engine=innodb;
start transaction;
insert into t1(x) values(1);
commit;
call verify_vtq;
No A B C D
1 1 1 1 1
start transaction;
insert into t2(x) values(1);
savepoint a;
insert into t1(x) values(1);
rollback to a;
commit;
call verify_vtq;
No A B C D
drop table t1;
drop table t2;
drop procedure test_01;
drop procedure test_02;
drop procedure test_03;
drop procedure test_04;
drop procedure test_05;
drop procedure verify_vtq;

View File

@ -0,0 +1,256 @@
set @@session.time_zone='+00:00';
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
create procedure if not exists verify_vtq()
begin
set @i= 0;
select
@i:= @i + 1 as No,
trx_id > 0 as A,
begin_ts > '1-1-1 0:0:0' as B,
commit_ts > begin_ts as C,
concurr_trx is null as D
from information_schema.innodb_vtq
where trx_id > @start_trx_id;
select ifnull(max(trx_id), 0)
into @start_trx_id
from information_schema.innodb_vtq;
end~~
create procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
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);
set @str= concat('select ', fields, ' from t1 where x = 3 and y = 33 into @t1');
prepare stmt from @str; execute stmt; drop prepare stmt;
select x, y from t1;
select x as AS_OF_x, y from t1 for system_time as of timestamp @t0;
select x as FROM_TO_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
select x as BETWEEN_AND_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
drop table t1;
end~~
create or replace procedure test_02(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str0= concat('(
x int,
y int,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
set @str= concat('create or replace table t1', @str0);
prepare stmt from @str; execute stmt; drop prepare stmt;
set @str= concat('create or replace table t2', @str0);
prepare stmt from @str; execute stmt; drop prepare stmt;
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;
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;
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 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;
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 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;
drop table t1;
drop table t2;
end~~
call test_01('timestamp(6)', 'myisam', 'sys_start');
x y
0 100
1 101
2 102
4 104
5 105
6 106
7 107
3 33
AS_OF_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
FROM_TO_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
BETWEEN_AND_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
3 33
call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_start)');
x y
0 100
1 101
2 102
4 104
5 105
6 106
7 107
3 33
AS_OF_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
FROM_TO_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
BETWEEN_AND_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
3 33
call test_02('timestamp(6)', 'myisam', 'sys_start');
IJ1_x1 y1 x2 y2
1 1 1 2
1 2 1 2
1 3 1 2
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
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
IJ2_x1 y1 x2 y2
1 1 1 2
1 2 1 2
1 3 1 2
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
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
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_start)');
IJ1_x1 y1 x2 y2
1 1 1 2
1 2 1 2
1 3 1 2
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
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
IJ2_x1 y1 x2 y2
1 1 1 2
1 2 1 2
1 3 1 2
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
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
call verify_vtq;
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
drop procedure test_01;
drop procedure test_02;
drop procedure verify_vtq;

View File

@ -0,0 +1,519 @@
set @@session.time_zone='+00:00';
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
create procedure if not exists verify_vtq()
begin
set @i= 0;
select
@i:= @i + 1 as No,
trx_id > 0 as A,
begin_ts > '1-1-1 0:0:0' as B,
commit_ts > begin_ts as C,
concurr_trx is null as D
from information_schema.innodb_vtq
where trx_id > @start_trx_id;
select ifnull(max(trx_id), 0)
into @start_trx_id
from information_schema.innodb_vtq;
end~~
create procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values
(1, 1000),
(2, 2000),
(3, 3000),
(4, 4000),
(5, 5000),
(6, 6000),
(7, 7000),
(8, 8000),
(9, 9000);
select x, y from t1;
update t1 set y = y + 1 where x > 7;
select x, y from t1;
select x, y from t1 for system_time
between timestamp '0000-0-0 0:0:0'
and timestamp '2038-01-19 04:14:07';
drop table t1;
end~~
create procedure test_02(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1 (
id bigint primary key,
a int,
b int without system versioning)
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1 values(1, 1, 1);
set @ins_t= now(6);
select sys_trx_start into @tmp1 from t1;
update t1 set a=11, b=11 where id=1;
select @tmp1 < sys_trx_start, a, b from t1;
select sys_trx_start into @tmp1 from t1;
update t1 set b=1 where id=1;
select @tmp1 = sys_trx_start, b from t1;
drop table t1;
end~~
create procedure test_03(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1 (
x int,
y int)
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1 (x, y) values (1, 1), (2, 1), (3, 1);
start transaction;
update t1 set y= y + 1 where x = 3;
update t1 set y= y + 1 where x = 3;
commit;
select x, y from t1 for system_time
between timestamp '0000-0-0 0:0:0'
and timestamp '2038-01-19 04:14:07';
drop table t1;
end~~
create procedure test_04(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1 (
id int primary key auto_increment,
x int)
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
set @t0= now(6);
insert into t1 (x) values (1);
set @t1= now(6);
update t1 set x= 2 where id = 1;
set @t2= now(6);
update t1 set x= 3 where id = 1;
select x from t1 for system_time as of timestamp @t0;
select x from t1 for system_time as of timestamp @t1;
select x from t1 for system_time as of timestamp @t2;
select x from t1 for system_time as of timestamp now(6);
drop table t1;
end~~
create procedure test_05(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end),
primary key(x, y))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values
(1, 1000),
(2, 2000),
(3, 3000),
(4, 4000),
(5, 5000),
(6, 6000),
(7, 7000),
(8, 8000),
(9, 9000);
insert into t1(x, y) values(3, 3000) on duplicate key update y = y+1;
insert into t1(x, y) values(4, 4000) on duplicate key update y = y+1;
insert into t1(x, y) values(4, 4001) on duplicate key update y = y+1;
insert into t1(x, y) values(4, 4444) on duplicate key update y = y+1;
select x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
select x, y from t1;
drop table t1;
end~~
create procedure test_06(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
set @str2= concat('create table t1', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
set @str2= concat('create table t2', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
insert into t1(x, y) values
(1, 1000),
(2, 2000),
(3, 3000),
(4, 4000),
(5, 5000),
(6, 6000),
(7, 7000),
(8, 8000),
(9, 9000);
insert into t2(x, y) values
(1, 1010),
(2, 2010),
(3, 3010),
(4, 4010),
(5, 5010),
(6, 6010),
(7, 7010),
(8, 8010),
(9, 9010);
update t1, t2 set t1.y = t1.x + t1.y, t2.y = t2.x + t2.y where t1.x > 7 and t2.x < 7;
select x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
select x, y from t1;
select x, y from t2 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
select x, y from t2;
drop table t1;
drop table t2;
end~~
create procedure test_07(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('(
id bigint primary key,
name varchar(128) with system versioning,
salary bigint)
engine ', engine);
set @str2= concat('create table t1', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
set @str2= concat('create table t2', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
insert into t1 values (1, "Jeremy", 3000);
insert into t2 values (1, "Jeremy", 4000);
select sys_trx_start into @tmp1 from t1;
select sys_trx_start into @tmp2 from t2;
update t1, t2 set t1.name= "Jerry", t2.name= "Jerry" where t1.id = t2.id and t1.name = "Jeremy";
select @tmp1 < sys_trx_start as A1, name from t1;
select @tmp2 < sys_trx_start as A2, name from t2;
select sys_trx_start into @tmp1 from t1;
select sys_trx_start into @tmp2 from t2;
update t1, t2 set t1.salary= 2500, t2.salary= 2500 where t1.id = t2.id and t1.name = "Jerry";
select @tmp1 = sys_trx_start as B1, salary from t1;
select @tmp2 = sys_trx_start as B2, salary from t2;
drop table t1;
drop table t2;
end~~
call test_01('timestamp(6)', 'myisam', 'sys_end');
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8000
9 9000
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8001
9 9001
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8001
9 9001
8 8000
9 9000
call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8000
9 9000
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8001
9 9001
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8001
9 9001
8 8000
9 9000
call test_02('timestamp(6)', 'myisam', 'sys_end');
@tmp1 < sys_trx_start a b
1 11 11
@tmp1 = sys_trx_start b
1 1
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
@tmp1 < sys_trx_start a b
1 11 11
@tmp1 = sys_trx_start b
0 1
call test_03('timestamp(6)', 'myisam', 'sys_end');
x y
1 1
2 1
3 3
3 1
3 2
call test_03('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
x y
1 1
2 1
3 3
3 1
call test_04('timestamp(6)', 'myisam', 'sys_end');
x
x
1
x
2
x
3
call test_04('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
x
x
1
x
2
x
3
call test_05('timestamp(6)', 'myisam', 'sys_end');
x y
1 1000
2 2000
3 3001
4 4002
5 5000
6 6000
7 7000
8 8000
9 9000
3 3000
4 4000
4 4001
4 4444
x y
1 1000
2 2000
3 3001
4 4002
4 4444
5 5000
6 6000
7 7000
8 8000
9 9000
call test_05('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
x y
1 1000
2 2000
3 3000
3 3001
4 4000
4 4001
4 4002
4 4444
5 5000
6 6000
7 7000
8 8000
9 9000
x y
1 1000
2 2000
3 3001
4 4002
4 4444
5 5000
6 6000
7 7000
8 8000
9 9000
call test_06('timestamp(6)', 'myisam', 'sys_end');
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8008
9 9009
8 8000
9 9000
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8008
9 9009
x y
1 1011
2 2012
3 3013
4 4014
5 5015
6 6016
7 7010
8 8010
9 9010
1 1010
2 2010
3 3010
4 4010
5 5010
6 6010
x y
1 1011
2 2012
3 3013
4 4014
5 5015
6 6016
7 7010
8 8010
9 9010
call test_06('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8008
9 9009
8 8000
9 9000
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8008
9 9009
x y
1 1011
2 2012
3 3013
4 4014
5 5015
6 6016
7 7010
8 8010
9 9010
1 1010
2 2010
3 3010
4 4010
5 5010
6 6010
x y
1 1011
2 2012
3 3013
4 4014
5 5015
6 6016
7 7010
8 8010
9 9010
call test_07('timestamp(6)', 'myisam', 'sys_end');
A1 name
1 Jerry
A2 name
1 Jerry
B1 salary
1 2500
B2 salary
1 2500
call verify_vtq;
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
drop procedure test_01;
drop procedure test_02;
drop procedure test_03;
drop procedure test_04;
drop procedure test_05;
drop procedure test_06;
drop procedure test_07;
drop procedure verify_vtq;

View File

@ -0,0 +1,68 @@
-- source suite/versioning/common.inc
delimiter ~~;
create procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
id int unsigned auto_increment primary key,
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
set @str= concat('
create table t2(
id int unsigned auto_increment primary key,
x int unsigned,
y int unsigned)
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values(1, 11);
insert into t2(x, y) values(1, 11);
insert into t1(x, y) values(2, 12);
insert into t2(x, y) values(2, 12);
insert into t1(x, y) values(3, 13);
insert into t2(x, y) values(3, 13);
insert into t1(x, y) values(4, 14);
insert into t2(x, y) values(4, 14);
insert into t1(x, y) values(5, 15);
insert into t2(x, y) values(5, 15);
insert into t1(x, y) values(6, 16);
insert into t2(x, y) values(6, 16);
insert into t1(x, y) values(7, 17);
insert into t2(x, y) values(7, 17);
insert into t1(x, y) values(8, 18);
insert into t2(x, y) values(8, 18);
insert into t1(x, y) values(9, 19);
insert into t2(x, y) values(9, 19);
select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner join t2 on t1.id = t2.id;
delete from t1 where x = 2;
delete from t2 where x = 2;
select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner join t2 on t1.id = t2.id;
delete from t1 where x > 7;
delete from t2 where x > 7;
select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner join t2 on t1.id = t2.id;
drop table t1;
drop table t2;
end~~
delimiter ;~~
call test_01('timestamp(6)', 'myisam', 'sys_end');
# Issue #52
# call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call verify_vtq;
drop procedure test_01;
drop procedure verify_vtq;

View File

@ -0,0 +1,172 @@
-- source include/have_innodb.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
show create table t1;
--echo # Implicit fields test
create or replace table t1 (
XNo int unsigned
) with system versioning;
show create table t1;
--error ER_SYS_START_MORE_THAN_ONCE
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_start2 timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
--error ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_END_COLUMN
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end2 timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
--error ER_SYS_END_MORE_THAN_ONCE
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
Sys_end2 timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
--error ER_SYS_START_NOT_SPECIFIED
create or replace table t1 (
XNo int unsigned,
period for system_time (Sys_start, Sys_end)
) with system versioning;
--error ER_SYS_END_MORE_THAN_ONCE
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
Sys_end2 timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
);
--error ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_START_COLUMN
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (sys_insert, sys_remove)
) with system versioning;
--error ER_MISSING_WITH_SYSTEM_VERSIONING
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
);
--error ER_SYS_START_AND_SYS_END_SAME
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_start)
);
--error ER_SYS_START_FIELD_MUST_BE_TIMESTAMP
create or replace table t1 (
XNo int unsigned,
Sys_start int generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
--error ER_SYS_END_FIELD_MUST_BE_TIMESTAMP
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end int generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
--error ER_SYS_START_FIELD_MUST_BE_BIGINT
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end bigint generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
--error ER_SYS_START_FIELD_MUST_BE_BIGINT
create or replace table t1 (
XNo int unsigned,
Sys_start bigint generated always as row start,
Sys_end bigint generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
--error ER_SYS_END_FIELD_MUST_BE_BIGINT
create or replace table t1 (
XNo int unsigned,
Sys_start bigint unsigned generated always as row start,
Sys_end bigint generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
create or replace table t1 (
A int with system versioning,
B int
);
show create table t1;
create or replace table t1 (
A int with system versioning,
B int
) with system versioning;
show create table t1;
--error ER_NO_VERSIONED_FIELDS_IN_VERSIONED_TABLE
create or replace table t1 (
A int,
B int without system versioning
);
create or replace table t1 (
A int,
B int without system versioning
) with system versioning;
show create table t1;
create or replace table t1 (
A int with system versioning,
B int without system versioning
);
show create table t1;
create or replace table t1 (
A int with system versioning,
B int without system versioning
) with system versioning;
show create table t1;
--error ER_NO_VERSIONED_FIELDS_IN_VERSIONED_TABLE
create or replace table t1 (
A int without system versioning
);
--error ER_NO_VERSIONED_FIELDS_IN_VERSIONED_TABLE
create or replace table t1 (
A int without system versioning
) with system versioning;
drop table t1;

View File

@ -0,0 +1,120 @@
-- source suite/versioning/common.inc
delimiter ~~;
create or replace procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create or replace table t1(
XNo int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(XNo) values(0);
insert into t1(XNo) values(1);
insert into t1(XNo) values(2);
insert into t1(XNo) values(3);
insert into t1(XNo) values(4);
insert into t1(XNo) values(5);
insert into t1(XNo) values(6);
insert into t1(XNo) values(7);
insert into t1(XNo) values(8);
insert into t1(XNo) values(9);
set @str= concat('select XNo, ',
fields, " < '2038-01-19 03:14:07'
from t1 for system_time
between timestamp '0000-0-0 0:0:0'
and timestamp '2038-01-19 04:14:07'");
prepare stmt from @str; execute stmt;
delete from t1 where XNo = 0;
execute stmt;
delete from t1 where XNo = 1;
execute stmt;
delete from t1 where XNo > 5;
create view vt1 as select XNo from t1;
select XNo from vt1;
delete from vt1 where XNo = 3;
select XNo from vt1;
execute stmt; drop prepare stmt;
drop view vt1;
drop table t1;
end~~
create or replace procedure test_02(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('create or replace table t1 (
x int,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x) values (1);
select sys_start into @sys_start from t1;
delete from t1;
select * from t1;
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';
drop table t1;
end~~
create or replace procedure test_03(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str0= concat('(
x int,
y int,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
set @str= concat('create or replace table t1', @str0);
prepare stmt from @str; execute stmt; drop prepare stmt;
set @str= concat('create or replace table t2', @str0);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values (1, 1), (2, 2), (3, 3), (14, 4);
insert into t2(x, y) values (11, 1), (12, 2), (13, 32), (14, 4);
delete t1, t2 from t1 join t2 where t1.y = 3 and t2.y = 32;
select x as t1_x from t1;
select x as t2_x from t2;
delete t1, t2 from t1 join t2 where t1.x = t2.x;
select x as t1_x from t1;
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 t2_x_all from t2 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07';
drop table t1;
drop table t2;
end~~
delimiter ;~~
--echo # Basic + delete from view
call test_01('timestamp(6)', 'myisam', 'sys_end');
call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call verify_vtq;
--echo # Check sys_start, sys_end
call test_02('timestamp(6)', 'myisam', 'sys_end');
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call verify_vtq;
--echo # Multi-delete
call test_03('timestamp(6)', 'myisam', 'sys_end');
call test_03('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call verify_vtq;
drop procedure test_01;
drop procedure test_02;
drop procedure test_03;
drop procedure verify_vtq;

View File

@ -0,0 +1,210 @@
-- source suite/versioning/common.inc
delimiter ~~;
create procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values(3, 4);
insert into t1(x, y) values(2, 3);
insert into t1 values(40, 33);
set @str= concat('select x, y, ', fields, ' from t1');
prepare stmt from @str; execute stmt; drop prepare stmt;
drop table t1;
end~~
create procedure test_02(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
id int unsigned auto_increment primary key,
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values(33, 44);
insert into t1(id, x, y) values(20, 33, 44);
insert into t1 values(40, 33, 44);
set @str= concat('select id, x, y, ', fields, ' from t1');
prepare stmt from @str; execute stmt; drop prepare stmt;
drop table t1;
end~~
create procedure test_03(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
create view vt1_1 as select x, y from t1;
create view vt1_2 as select x, y, sys_end from t1;
insert into t1(x, y) values(8001, 9001);
insert into vt1_1(x, y) values(1001, 2001);
insert into vt1_1 values(1002, 2002);
insert into vt1_2(x, y) values(3001, 4001);
set @str= concat('select x, y, ', fields, ' from t1');
prepare stmt from @str; execute stmt; drop prepare stmt;
select x, y from vt1_1;
set @str= concat('select x, y, ', fields, ' from vt1_2');
prepare stmt from @str; execute stmt; drop prepare stmt;
end~~
create procedure test_04(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
id bigint primary key,
a int,
b int)
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1 values(1, 1, 1);
select sys_trx_start, sys_trx_end from t1 into @sys_start, @sys_end;
select id, a, b from t1;
insert into t1 values(2, 2, 2);
select id, a, b, sys_trx_start > @sys_start as C, sys_trx_end = @sys_end as D from t1 where id = 2;
drop table t1;
end~~
create procedure test_05(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
set @str2= concat('create table t1', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
set @str2= concat('create table t2', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
insert into t1(x, y) values
(1, 1000),
(2, 2000),
(3, 3000),
(4, 4000),
(5, 5000),
(6, 6000),
(7, 7000),
(8, 8000),
(9, 9000);
delete from t1 where x >= 1;
insert into t1(x, y) values
(1, 1001),
(2, 2001),
(3, 3001),
(4, 4001),
(5, 5001),
(6, 6001),
(7, 7001),
(8, 8001),
(9, 9001);
insert into t2 select x, y from t1 for system_time between timestamp '0000-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
select x, y from t1;
select x, y from t2;
drop table t1;
drop table t2;
end~~
delimiter ;~~
call test_01('timestamp(6)', 'myisam', 'sys_end');
call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_02('timestamp(6)', 'myisam', 'sys_end');
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_03('timestamp(6)', 'myisam', 'sys_end');
--ERROR ER_GENERATED_FIELD_CANNOT_BE_SET_BY_USER
insert into t1(x, y, sys_end) values(8001, 9001, '2015-1-1 1:1:1');
--ERROR ER_GENERATED_FIELD_CANNOT_BE_SET_BY_USER
insert into vt1_2 values(3002, 4002, '2015-2-2 2:2:2');
drop table t1;
drop view vt1_1;
drop view vt1_2;
call test_03('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
--ERROR ER_GENERATED_FIELD_CANNOT_BE_SET_BY_USER
insert into t1(x, y, sys_end) values(8001, 9001, 1111111);
--ERROR ER_GENERATED_FIELD_CANNOT_BE_SET_BY_USER
insert into vt1_2 values(3002, 4002, 2222222);
drop table t1;
drop view vt1_1;
drop view vt1_2;
call test_04('timestamp(6)', 'myisam', 'sys_end');
call test_04('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_05('timestamp(6)', 'myisam', 'sys_end');
call test_05('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
# VTQ test
call verify_vtq;
create table t1(
x int unsigned,
sys_start bigint unsigned generated always as row start,
sys_end bigint unsigned generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning engine=innodb;
create table t2(x int unsigned) engine=innodb;
start transaction;
insert into t1(x) values(1);
commit;
call verify_vtq;
start transaction;
insert into t2(x) values(1);
savepoint a;
insert into t1(x) values(1);
rollback to a;
commit;
call verify_vtq;
drop table t1;
drop table t2;
drop procedure test_01;
drop procedure test_02;
drop procedure test_03;
drop procedure test_04;
drop procedure test_05;
drop procedure verify_vtq;

View File

@ -0,0 +1,96 @@
-- source suite/versioning/common.inc
delimiter ~~;
create procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
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);
set @str= concat('select ', fields, ' from t1 where x = 3 and y = 33 into @t1');
prepare stmt from @str; execute stmt; drop prepare stmt;
select x, y from t1;
select x as AS_OF_x, y from t1 for system_time as of timestamp @t0;
select x as FROM_TO_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
select x as BETWEEN_AND_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
drop table t1;
end~~
create or replace procedure test_02(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str0= concat('(
x int,
y int,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
set @str= concat('create or replace table t1', @str0);
prepare stmt from @str; execute stmt; drop prepare stmt;
set @str= concat('create or replace table t2', @str0);
prepare stmt from @str; execute stmt; drop prepare stmt;
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;
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;
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 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;
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 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;
drop table t1;
drop table t2;
end~~
delimiter ;~~
call test_01('timestamp(6)', 'myisam', 'sys_start');
call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_start)');
call test_02('timestamp(6)', 'myisam', 'sys_start');
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_start)');
call verify_vtq;
drop procedure test_01;
drop procedure test_02;
drop procedure verify_vtq;

View File

@ -0,0 +1,267 @@
-- source suite/versioning/common.inc
delimiter ~~;
create procedure test_01(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values
(1, 1000),
(2, 2000),
(3, 3000),
(4, 4000),
(5, 5000),
(6, 6000),
(7, 7000),
(8, 8000),
(9, 9000);
select x, y from t1;
update t1 set y = y + 1 where x > 7;
select x, y from t1;
select x, y from t1 for system_time
between timestamp '0000-0-0 0:0:0'
and timestamp '2038-01-19 04:14:07';
drop table t1;
end~~
create procedure test_02(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1 (
id bigint primary key,
a int,
b int without system versioning)
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1 values(1, 1, 1);
set @ins_t= now(6);
select sys_trx_start into @tmp1 from t1;
update t1 set a=11, b=11 where id=1;
select @tmp1 < sys_trx_start, a, b from t1;
select sys_trx_start into @tmp1 from t1;
update t1 set b=1 where id=1;
select @tmp1 = sys_trx_start, b from t1;
drop table t1;
end~~
create procedure test_03(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1 (
x int,
y int)
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1 (x, y) values (1, 1), (2, 1), (3, 1);
start transaction;
update t1 set y= y + 1 where x = 3;
update t1 set y= y + 1 where x = 3;
commit;
select x, y from t1 for system_time
between timestamp '0000-0-0 0:0:0'
and timestamp '2038-01-19 04:14:07';
drop table t1;
end~~
create procedure test_04(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1 (
id int primary key auto_increment,
x int)
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
set @t0= now(6);
insert into t1 (x) values (1);
set @t1= now(6);
update t1 set x= 2 where id = 1;
set @t2= now(6);
update t1 set x= 3 where id = 1;
select x from t1 for system_time as of timestamp @t0;
select x from t1 for system_time as of timestamp @t1;
select x from t1 for system_time as of timestamp @t2;
select x from t1 for system_time as of timestamp now(6);
drop table t1;
end~~
create procedure test_05(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end),
primary key(x, y))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
insert into t1(x, y) values
(1, 1000),
(2, 2000),
(3, 3000),
(4, 4000),
(5, 5000),
(6, 6000),
(7, 7000),
(8, 8000),
(9, 9000);
insert into t1(x, y) values(3, 3000) on duplicate key update y = y+1;
insert into t1(x, y) values(4, 4000) on duplicate key update y = y+1;
insert into t1(x, y) values(4, 4001) on duplicate key update y = y+1;
insert into t1(x, y) values(4, 4444) on duplicate key update y = y+1;
select x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
select x, y from t1;
drop table t1;
end~~
create procedure test_06(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
set @str2= concat('create table t1', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
set @str2= concat('create table t2', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
insert into t1(x, y) values
(1, 1000),
(2, 2000),
(3, 3000),
(4, 4000),
(5, 5000),
(6, 6000),
(7, 7000),
(8, 8000),
(9, 9000);
insert into t2(x, y) values
(1, 1010),
(2, 2010),
(3, 3010),
(4, 4010),
(5, 5010),
(6, 6010),
(7, 7010),
(8, 8010),
(9, 9010);
update t1, t2 set t1.y = t1.x + t1.y, t2.y = t2.x + t2.y where t1.x > 7 and t2.x < 7;
select x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
select x, y from t1;
select x, y from t2 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
select x, y from t2;
drop table t1;
drop table t2;
end~~
create procedure test_07(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
begin
set @str= concat('(
id bigint primary key,
name varchar(128) with system versioning,
salary bigint)
engine ', engine);
set @str2= concat('create table t1', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
set @str2= concat('create table t2', @str);
prepare stmt from @str2; execute stmt; drop prepare stmt;
insert into t1 values (1, "Jeremy", 3000);
insert into t2 values (1, "Jeremy", 4000);
select sys_trx_start into @tmp1 from t1;
select sys_trx_start into @tmp2 from t2;
update t1, t2 set t1.name= "Jerry", t2.name= "Jerry" where t1.id = t2.id and t1.name = "Jeremy";
select @tmp1 < sys_trx_start as A1, name from t1;
select @tmp2 < sys_trx_start as A2, name from t2;
select sys_trx_start into @tmp1 from t1;
select sys_trx_start into @tmp2 from t2;
update t1, t2 set t1.salary= 2500, t2.salary= 2500 where t1.id = t2.id and t1.name = "Jerry";
select @tmp1 = sys_trx_start as B1, salary from t1;
select @tmp2 = sys_trx_start as B2, salary from t2;
drop table t1;
drop table t2;
end~~
delimiter ;~~
call test_01('timestamp(6)', 'myisam', 'sys_end');
call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_02('timestamp(6)', 'myisam', 'sys_end');
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_03('timestamp(6)', 'myisam', 'sys_end');
call test_03('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_04('timestamp(6)', 'myisam', 'sys_end');
call test_04('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_05('timestamp(6)', 'myisam', 'sys_end');
call test_05('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_06('timestamp(6)', 'myisam', 'sys_end');
call test_06('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_07('timestamp(6)', 'myisam', 'sys_end');
# Issue #53
# call test_07('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call verify_vtq;
drop procedure test_01;
drop procedure test_02;
drop procedure test_03;
drop procedure test_04;
drop procedure test_05;
drop procedure test_06;
drop procedure test_07;
drop procedure verify_vtq;