1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-31 22:22:30 +03:00

Tests: split versioning.select into combinations

This commit is contained in:
Aleksey Midenkov
2017-03-15 18:36:54 +03:00
parent fb0b3e5902
commit 1894fab11a
18 changed files with 486 additions and 186 deletions

View File

@@ -15,11 +15,56 @@ 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))
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 test_01()
begin
declare engine varchar(255) default default_engine();
declare sys_type varchar(255) default sys_datatype();
declare fields varchar(255) default sys_commit_ts('sys_start');
set @str= concat('
create table t1(
x int unsigned,
@@ -66,14 +111,20 @@ select x as FROMTO2_x, y from t1 for system_time from transaction 0 to transacti
select x as BETWAND2_x, y from t1 for system_time between transaction 0 and transaction @x1;
select x as FROMTO2_ext_x, y from t1 for system_time transaction from 0 to @x1;
select x as BETWAND2_ext_x, y from t1 for system_time transaction between 0 and @x1;
else
select x as ASOF2_x, y from t1 for system_time as of timestamp @t0;
select x as FROMTO2_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
select x as BETWAND2_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
select x as FROMTO2_ext_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
select x as BETWAND2_ext_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
end if;
drop table t1;
end~~
create or replace procedure test_02(
sys_type varchar(255),
engine varchar(255),
fields varchar(255))
create or replace procedure test_02()
begin
declare engine varchar(255) default default_engine();
declare sys_type varchar(255) default sys_datatype();
declare fields varchar(255) default sys_commit_ts('sys_start');
set @str0= concat('(
x int,
y int,
@@ -103,86 +154,7 @@ query 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
ASOF_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
FROMTO_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
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
FROMTO_ext_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
BETWAND_ext_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
3 33
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
call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_start)');
call test_01();
x y
0 100
1 101
@@ -318,40 +290,7 @@ BETWAND2_ext_x y
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', 'vtq_commit_ts(sys_start)');
call test_02();
IJ1_x1 y1 x2 y2
1 1 1 2
1 2 1 2
@@ -386,14 +325,7 @@ NULL NULL 2 1
NULL NULL 3 1
create table t1(
A int
) with system versioning engine=myisam;
insert into t1 values(1);
select * from t1;
A
1
create or replace table t1(
A int
) with system versioning engine=innodb;
) with system versioning;
insert into t1 values(1);
select * from t1;
A
@@ -435,15 +367,7 @@ for each row set @end = old.sys_trx_end;
update t1 set a=2;
select @end;
@end
2038-01-19 03:14:07.000000
create or replace table t1 (a int) with system versioning engine=innodb;
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
18446744073709551615
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);
@@ -467,7 +391,7 @@ a1 a2
1 2
2 2
drop table t1, t2;
call verify_vtq;
call innodb_verify_vtq(19);
No A B C D
1 1 1 1 1
2 1 1 1 1
@@ -480,6 +404,18 @@ No A B C D
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
drop procedure test_01;
drop procedure test_02;
drop procedure verify_vtq;
drop procedure innodb_verify_vtq;
drop function default_engine;
drop function sys_commit_ts;
drop function sys_datatype;