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

simplify versioning tests

This commit is contained in:
Sergei Golubchik
2018-02-21 21:45:59 +01:00
parent dd7d169593
commit 052668f500
22 changed files with 1041 additions and 2148 deletions

View File

@ -1,17 +1,9 @@
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, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
create or replace table t1(
XNo int unsigned,
sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning;
insert into t1(XNo) values(0);
insert into t1(XNo) values(1);
insert into t1(XNo) values(2);
@ -22,291 +14,98 @@ 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;
select XNo, sys_end < MAXVAL from t1 for system_time all;
XNo sys_end < MAXVAL
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
delete from t1 where XNo = 0;
select "Deleted 0";
execute stmt;
delete from t1 where XNo = 1;
select "Deleted 1";
execute stmt;
delete from t1 where XNo > 5;
select "Deleted >5";
create view vt1 as select XNo from t1;
select XNo as XNo_vt1 from vt1;
XNo_vt1
2
3
4
5
delete from vt1 where XNo = 3;
select "Deleted from VIEW 3";
select XNo as XNo_vt1 from vt1;
execute stmt; drop prepare stmt;
XNo_vt1
2
4
5
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, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
create or replace table t1(
x int,
sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning;
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 all;
x
select x = 1 as A, sys_start = @sys_start as B, sys_end > sys_start as C from t1 for system_time all;
A B C
1 1 1
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, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
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;
create or replace table t1(
x int,
y int,
sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning;
create or replace table t2 like t1;
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;
t1_x
1
2
14
select x as t2_x from t2;
t2_x
11
12
14
delete t1, t2 from t1 join t2 where t1.x = t2.x;
select x as t1_x from t1;
t1_x
1
2
select x as t2_x from t2;
t2_x
11
12
select x as t1_x_all from t1 for system_time all;
t1_x_all
1
2
3
14
select x as t2_x_all from t2 for system_time all;
t2_x_all
11
12
13
14
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
Deleted 0
Deleted 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
Deleted 1
Deleted 1
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
Deleted >5
Deleted >5
XNo_vt1
2
3
4
5
Deleted from VIEW 3
Deleted from VIEW 3
XNo_vt1
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', 'vtq_commit_ts(sys_end)');
XNo vtq_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
Deleted 0
Deleted 0
XNo vtq_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
Deleted 1
Deleted 1
XNo vtq_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
Deleted >5
Deleted >5
XNo_vt1
2
3
4
5
Deleted from VIEW 3
Deleted from VIEW 3
XNo_vt1
2
4
5
XNo vtq_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
A B C
1 1 1
call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
x
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', 'vtq_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
# Update + delete
create or replace table t1 (x int) with system versioning;
insert into t1 values (1);