Skip to content

Commit

Permalink
simplify versioning tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Feb 23, 2018
1 parent dd7d169 commit 052668f
Show file tree
Hide file tree
Showing 22 changed files with 968 additions and 2,075 deletions.
50 changes: 6 additions & 44 deletions mysql-test/suite/versioning/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,13 @@ begin
from mysql.transaction_registry;
end~~

create function if not exists default_engine()
returns varchar(255)
deterministic
begin
declare e varchar(255);
select engine from information_schema.engines where support='DEFAULT' into e;
return e;
end~~

create function if not exists non_default_engine()
returns varchar(255)
deterministic
begin
if default_engine() = 'InnoDB' then
return 'MyISAM';
end if;
return 'InnoDB';
end~~

create function if not exists sys_datatype(engine varchar(255))
returns varchar(255)
deterministic
begin
if engine = 'InnoDB' then
return 'bigint(20) unsigned';
elseif 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
if @@default_storage_engine = 'InnoDB' then
return concat('vtq_commit_ts(', sys_field, ')');
elseif default_engine() = 'MyISAM' then
elseif @@default_storage_engine = 'MyISAM' then
return sys_field;
end if;
return NULL;
Expand Down Expand Up @@ -92,19 +61,11 @@ begin
end~~
delimiter ;~~

let $default_engine= `select default_engine()`;
let $non_default_engine= `select non_default_engine()`;
let $sys_datatype= timestamp(6);
let $default_engine= `select @@default_storage_engine`;
let $non_default_engine= `select if(@@default_storage_engine = 'InnoDB', 'MyISAM', 'InnoDB')`;
let $sys_datatype_expl= timestamp(6);
let $sys_datatype_uc= TIMESTAMP(6);
let $sys_datatype_expl_uc= TIMESTAMP(6);

let $non_sys_datatype= `select sys_datatype(non_default_engine())`;
let $non_sys_datatype_uc= `select upper(sys_datatype(non_default_engine()))`;
let $sys_datatype_null= $sys_datatype NULL DEFAULT NULL;
let $sys_datatype_default_null= $sys_datatype DEFAULT NULL;
let $sys_datatype_not_null= $sys_datatype NOT NULL DEFAULT '0000-00-00 00:00:00.000000';
let $non_sys_datatype_null= $non_sys_datatype NULL;
let $sys_datatype_max= TIMESTAMP'2038-01-19 03:14:07.999999';

if ($MTR_COMBINATION_MYISAM)
{
Expand All @@ -114,5 +75,6 @@ if ($MTR_COMBINATION_TRX_ID)
{
let $sys_datatype_expl= bigint(20) unsigned;
let $sys_datatype_expl_uc= BIGINT(20) UNSIGNED;
let $sys_datatype_max= 18446744073709551615;
}
--enable_query_log
3 changes: 0 additions & 3 deletions mysql-test/suite/versioning/common_finish.inc
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
--disable_query_log
drop procedure verify_vtq;
drop procedure verify_vtq_dummy;
drop function default_engine;
drop function non_default_engine;
drop function sys_commit_ts;
drop function sys_datatype;
drop procedure concat_exec2;
drop procedure concat_exec3;
--enable_query_log
94 changes: 20 additions & 74 deletions mysql-test/suite/versioning/r/auto_increment.result
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
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, ' 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;
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;
create table t1(
id int unsigned auto_increment primary key,
x int unsigned,
y 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;
create table t2(
id int unsigned auto_increment primary key,
x int unsigned,
y int unsigned);
insert into t1(x, y) values(1, 11);
insert into t2(x, y) values(1, 11);
insert into t1(x, y) values(2, 12);
Expand All @@ -40,43 +29,6 @@ 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 test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
A x y x y
1 1 11 1 11
1 2 12 2 12
Expand All @@ -87,6 +39,9 @@ A x y x y
1 7 17 7 17
1 8 18 8 18
1 9 19 9 19
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;
A x y x y
1 1 11 1 11
1 3 13 3 13
Expand All @@ -96,24 +51,15 @@ A x y x y
1 7 17 7 17
1 8 18 8 18
1 9 19 9 19
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;
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
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
drop procedure test_01;
drop table t1;
drop table t2;
64 changes: 32 additions & 32 deletions mysql-test/suite/versioning/r/create.result
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ t1 CREATE TABLE `t1` (
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
x3 int unsigned,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end SYS_DATATYPE as row end invisible,
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
period for system_time (x, Sys_end)
) with system versioning;
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end`
create or replace table t1 (
x4 int unsigned,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end2 SYS_DATATYPE as row end invisible,
Sys_start timestamp(6) as row start invisible,
Sys_end2 timestamp(6) as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end2`
create or replace table t1 (
x5 int unsigned,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end SYS_DATATYPE as row end invisible,
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
period for system_time (Sys_start, x)
) with system versioning;
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end`
Expand All @@ -111,29 +111,29 @@ period for system_time (Sys_start, Sys_end)
ERROR HY000: Wrong parameters for `t1`: missing 'AS ROW START'
create or replace table t1 (
x7 int unsigned,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end SYS_DATATYPE as row end invisible,
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
create or replace table t1 (
x8 int unsigned,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end SYS_DATATYPE as row end invisible,
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
period for system_time (sys_insert, sys_remove)
) with system versioning;
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end`
create or replace table t1 (
x9 int unsigned,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end SYS_DATATYPE as row end invisible,
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
create or replace table t1 (
x10 int unsigned,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end SYS_DATATYPE as row end invisible,
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
period for system_time (Sys_start, Sys_start)
);
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
Expand Down Expand Up @@ -247,8 +247,8 @@ tt1 CREATE TEMPORARY TABLE `tt1` (
create or replace table t1 (x23 int) with system versioning;
create or replace table t0(
y int,
st SYS_DATATYPE as row start,
en SYS_DATATYPE as row end,
st timestamp(6) as row start,
en timestamp(6) as row end,
period for system_time (st, en)
) with system versioning;
## For non-versioned table:
Expand All @@ -267,8 +267,8 @@ show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`y` int(11) DEFAULT NULL,
`st` SYS_DATATYPE,
`en` SYS_DATATYPE
`st` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
`en` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000'
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1
## For versioned table
insert into t1 values (1);
Expand All @@ -293,8 +293,8 @@ show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`y` int(11) DEFAULT NULL,
`st` SYS_DATATYPE,
`en` SYS_DATATYPE
`st` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
`en` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000'
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select * from t3 where y > 2;
y st en
Expand All @@ -303,16 +303,16 @@ y
2
### 3. source and target table with visible system fields
create or replace table t3 (
st SYS_DATATYPE as row start invisible,
en SYS_DATATYPE as row end invisible,
st timestamp(6) as row start invisible,
en timestamp(6) as row end invisible,
period for system_time (st, en)
) with system versioning as select * from t0;
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`y` int(11) DEFAULT NULL,
`st` SYS_DATATYPE GENERATED ALWAYS AS ROW START INVISIBLE,
`en` SYS_DATATYPE GENERATED ALWAYS AS ROW END INVISIBLE,
`st` timestamp(6) GENERATED ALWAYS AS ROW START INVISIBLE,
`en` timestamp(6) GENERATED ALWAYS AS ROW END INVISIBLE,
PERIOD FOR SYSTEM_TIME (`st`, `en`)
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select y from t3;
Expand Down Expand Up @@ -424,8 +424,8 @@ ERROR HY000: Duplicate ROW END column `Sys_end`
create or replace table t1 (x30 int) with system versioning;
create or replace table t2 (
y int,
st SYS_DATATYPE as row start invisible,
en SYS_DATATYPE as row end invisible,
st timestamp(6) as row start invisible,
en timestamp(6) as row end invisible,
period for system_time (st, en)
) with system versioning;
create or replace table t3
Expand All @@ -435,13 +435,13 @@ Table Create Table
t3 CREATE TABLE `t3` (
`x30` int(11) DEFAULT NULL,
`y` int(11) DEFAULT NULL,
`st` SYS_DATATYPE NOT NULL INVISIBLE DEFAULT '0000-00-00 00:00:00.000000',
`en` SYS_DATATYPE NOT NULL INVISIBLE DEFAULT '0000-00-00 00:00:00.000000'
`st` timestamp(6) NOT NULL INVISIBLE DEFAULT '0000-00-00 00:00:00.000000',
`en` timestamp(6) NOT NULL INVISIBLE DEFAULT '0000-00-00 00:00:00.000000'
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1
create or replace table t3 (
y int,
st SYS_DATATYPE as row start invisible,
en SYS_DATATYPE as row end invisible,
st timestamp(6) as row start invisible,
en timestamp(6) as row end invisible,
period for system_time (st, en)
) with system versioning
as select x30, y, row_start, row_end, st, en from t1, t2;
Expand All @@ -450,8 +450,8 @@ Table Create Table
t3 CREATE TABLE `t3` (
`x30` int(11) DEFAULT NULL,
`y` int(11) DEFAULT NULL,
`st` SYS_DATATYPE GENERATED ALWAYS AS ROW START INVISIBLE,
`en` SYS_DATATYPE GENERATED ALWAYS AS ROW END INVISIBLE,
`st` timestamp(6) GENERATED ALWAYS AS ROW START INVISIBLE,
`en` timestamp(6) GENERATED ALWAYS AS ROW END INVISIBLE,
PERIOD FOR SYSTEM_TIME (`st`, `en`)
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
# MDEV-14828 Server crashes in JOIN::prepare / setup_fields on 2nd execution of PS [#437]
Expand Down
Loading

0 comments on commit 052668f

Please sign in to comment.