1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +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,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);
@@ -40,80 +29,37 @@ 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;
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
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
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
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
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
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
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;

View File

@@ -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`
@@ -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'
@@ -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:
@@ -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);
@@ -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
@@ -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;
@@ -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
@@ -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;
@@ -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]

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);

View File

@@ -1,379 +1,112 @@
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, ' 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 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;
insert into t1(x, y) values(3, 4);
insert delayed into t1(x, y) values(2, 3);
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, ' 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;
select x, y, sys_end < MAXVAL from t1;
x y sys_end < MAXVAL
3 4 0
2 3 0
40 33 0
create or replace 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;
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, ' 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;
select id, x, y, sys_end < MAXVAL from t1;
id x y sys_end < MAXVAL
1 33 44 0
20 33 44 0
40 33 44 0
create or replace table t1(
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 view vt1_1 as select x, y 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);
set @str= concat('select x, y, ', fields, ' from t1');
prepare stmt from @str; execute stmt; drop prepare stmt;
select x, y, sys_end < MAXVAL from t1;
x y sys_end < MAXVAL
8001 9001 0
1001 2001 0
1002 2002 0
select x, y from vt1_1;
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;
x y
8001 9001
1001 2001
1002 2002
drop view vt1_1;
create or replace table t1( id bigint primary key, a int, b int) with system versioning;
insert into t1 values(1, 1, 1);
select row_start, row_end from t1 into @sys_start, @sys_end;
select id, a, b from t1;
id a b
1 1 1
insert into t1 values(2, 2, 2);
select id, a, b, row_start > @sys_start as C, row_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, ' 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 @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);
insert into t1(x, y, sys_start) values
(7, 7001, DEFAULT);
insert into t1(x, y, sys_end) values
(8, 8001, DEFAULT);
insert into t1(x, y, sys_start, sys_end) values
(9, 9001, DEFAULT, DEFAULT);
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.999999
2 3 2038-01-19 03:14:07.999999
40 33 2038-01-19 03:14:07.999999
call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
x y vtq_commit_ts(sys_end)
3 4 2038-01-19 03:14:07.999999
2 3 2038-01-19 03:14:07.999999
40 33 2038-01-19 03:14:07.999999
call test_02('timestamp(6)', 'myisam', 'sys_end');
id x y sys_end
1 33 44 2038-01-19 03:14:07.999999
20 33 44 2038-01-19 03:14:07.999999
40 33 44 2038-01-19 03:14:07.999999
call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
id x y vtq_commit_ts(sys_end)
1 33 44 2038-01-19 03:14:07.999999
20 33 44 2038-01-19 03:14:07.999999
40 33 44 2038-01-19 03:14:07.999999
call test_03('timestamp(6)', 'myisam', 'sys_end');
x y sys_end
8001 9001 2038-01-19 03:14:07.999999
1001 2001 2038-01-19 03:14:07.999999
1002 2002 2038-01-19 03:14:07.999999
x y
8001 9001
1001 2001
1002 2002
drop table t1;
drop view vt1_1;
call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
x y vtq_commit_ts(sys_end)
8001 9001 2038-01-19 03:14:07.999999
1001 2001 2038-01-19 03:14:07.999999
1002 2002 2038-01-19 03:14:07.999999
x y
8001 9001
1001 2001
1002 2002
drop table t1;
drop view vt1_1;
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', 'vtq_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', 'vtq_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(
drop table t1;
create or replace table t1(
x int unsigned,
sys_start bigint unsigned as row start invisible,
sys_end bigint unsigned as row end invisible,
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 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
insert into t2(x) values (1);
create or replace table t1 (
x int,
y int as (x) virtual,
sys_trx_start bigint unsigned as row start invisible,
sys_trx_end bigint unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) engine=innodb with system versioning;
insert into t1 values (1, null);
update t1 set x= x + 1;
select x, y, sys_trx_end = 18446744073709551615 as current from t1 for system_time all;
x y current
2 2 1
1 1 0
create or replace table t1 (
x int,
row_start timestamp(6) as row start invisible,
row_end timestamp(6) as row end invisible,
period for system_time (row_start, row_end)
) with system versioning;
insert into t1 values (1), (2);
insert into t1 (row_start) select row_end from t1;
ERROR HY000: The value specified for generated column 'row_start' in table 't1' ignored
set sql_mode='';
insert into t1 (row_start, row_end) values (DEFAULT, 1);
Warnings:
Warning 1906 The value specified for generated column 'row_end' in table 't1' ignored
set sql_mode=default;
select @@sql_mode into @saved_mode;
set sql_mode= '';
insert into t1 (x, row_start, row_end) values (3, 4, 5);
Warnings:
Warning 1906 The value specified for generated column 'row_start' in table 't1' ignored
Warning 1906 The value specified for generated column 'row_end' in table 't1' ignored
set sql_mode= @saved_mode;
insert into t1 (row_start, row_end) values (DEFAULT, DEFAULT);
select * from t1;
x
1
2
NULL
3
NULL
# MDEV-14792 INSERT without column list into table with explicit versioning columns produces bad data
create or replace table t1 (
i int,
s timestamp(6) as row start,
e timestamp(6) as row end,
c varchar(8),
period for system_time(s, e))
with system versioning;
insert into t1 values (1, null, null, 'foo');
select i, c, e>TIMESTAMP'2038-01-01 00:00:00' AS current_row from t1;
i c current_row
1 foo 1
create or replace table t2 like t1;
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);
insert into t1(x, y, sys_start) values (7, 7001, DEFAULT);
insert into t1(x, y, sys_end) values (8, 8001, DEFAULT);
insert into t1(x, y, sys_start, sys_end) values (9, 9001, DEFAULT, DEFAULT);
insert into t2 select x, y from t1 for system_time all;
select x, y from t1;
x y
1 1001
2 2001
3 3001
4 4001
5 5001
6 6001
7 7001
8 8001
9 9001
select x, y from t2;
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
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;
set timestamp=1000000019;
select now() < sysdate();
now() < sysdate()
1
create table t1 (a int) with system versioning;
insert t1 values (1);
set @a=sysdate(6);
select * from t1 for system_time as of now(6);
a
select * from t1 for system_time as of sysdate(6);
a
1
update t1 set a=2;
delete from t1;
select *, row_start > @a, row_end > @a from t1 for system_time all;
a row_start > @a row_end > @a
1 0 1
2 1 1
#
# MDEV-14871 Server crashes in fill_record / fill_record_n_invoke_before_triggers upon inserting into versioned table with trigger
#
create or replace table t1 (pk int primary key) with system versioning;
create trigger tr before insert on t1 for each row select 1 into @a;
insert into t1 values (1),(2);
drop table t1;
create table t1 (pk int primary key, i int) with system versioning;
replace into t1 values (1,10),(1,100),(1,1000);
select pk,i,row_end > '2038-01-01' from t1 for system_time all;
pk i row_end > '2038-01-01'
1 1000 1
drop table t1;

View File

@@ -0,0 +1,104 @@
create table t1(
x int unsigned,
sys_start bigint unsigned as row start invisible,
sys_end bigint unsigned as row end invisible,
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;
start transaction;
insert into t2(x) values(1);
savepoint a;
insert into t1(x) values(1);
rollback to a;
commit;
insert into t2(x) values (1);
create or replace table t1 (
x int,
y int as (x) virtual,
sys_trx_start bigint unsigned as row start invisible,
sys_trx_end bigint unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) engine=innodb with system versioning;
insert into t1 values (1, null);
update t1 set x= x + 1;
select x, y, sys_trx_end = 18446744073709551615 as current from t1 for system_time all;
x y current
2 2 1
1 1 0
create or replace table t1 (
x int,
row_start timestamp(6) as row start invisible,
row_end timestamp(6) as row end invisible,
period for system_time (row_start, row_end)
) with system versioning;
insert into t1 values (1), (2);
insert into t1 (row_start) select row_end from t1;
ERROR HY000: The value specified for generated column 'row_start' in table 't1' ignored
set sql_mode='';
insert into t1 (row_start, row_end) values (DEFAULT, 1);
Warnings:
Warning 1906 The value specified for generated column 'row_end' in table 't1' ignored
set sql_mode=default;
select @@sql_mode into @saved_mode;
set sql_mode= '';
insert into t1 (x, row_start, row_end) values (3, 4, 5);
Warnings:
Warning 1906 The value specified for generated column 'row_start' in table 't1' ignored
Warning 1906 The value specified for generated column 'row_end' in table 't1' ignored
set sql_mode= @saved_mode;
insert into t1 (row_start, row_end) values (DEFAULT, DEFAULT);
select * from t1;
x
1
2
NULL
3
NULL
# MDEV-14792 INSERT without column list into table with explicit versioning columns produces bad data
create or replace table t1 (
i int,
s timestamp(6) as row start,
e timestamp(6) as row end,
c varchar(8),
period for system_time(s, e))
with system versioning;
insert into t1 values (1, null, null, 'foo');
select i, c, e>TIMESTAMP'2038-01-01 00:00:00' AS current_row from t1;
i c current_row
1 foo 1
drop table t1;
drop table t2;
set timestamp=1000000019;
select now() < sysdate();
now() < sysdate()
1
create table t1 (a int) with system versioning;
insert t1 values (1);
set @a=sysdate(6);
select * from t1 for system_time as of now(6);
a
select * from t1 for system_time as of sysdate(6);
a
1
update t1 set a=2;
delete from t1;
select *, row_start > @a, row_end > @a from t1 for system_time all;
a row_start > @a row_end > @a
1 0 1
2 1 1
#
# MDEV-14871 Server crashes in fill_record / fill_record_n_invoke_before_triggers upon inserting into versioned table with trigger
#
create or replace table t1 (pk int primary key) with system versioning;
create trigger tr before insert on t1 for each row select 1 into @a;
insert into t1 values (1),(2);
drop table t1;
create table t1 (pk int primary key, i int) with system versioning;
replace into t1 values (1,10),(1,100),(1,1000);
select pk,i,row_end > '2038-01-01' from t1 for system_time all;
pk i row_end > '2038-01-01'
1 1000 1
drop table t1;

View File

@@ -1,38 +0,0 @@
--- suite/versioning/r/select_sp.result
+++ suite/versioning/r/select_sp.result
@@ -22,8 +22,6 @@
delete from t1 where x > 7;
insert into t1(x, y) values(3, 33);
select sys_start from t1 where x = 3 and y = 33 into @t1;
-set @x1= @t1;
-select vtq_commit_ts(@x1) into @t1;
select x, y from t1;
x y
0 100
@@ -84,7 +82,7 @@
8 108
9 109
3 33
-select x as ASOF2_x, y from t1 for system_time as of @x0;
+select x as ASOF2_x, y from t1 for system_time as of @t0;
ASOF2_x y
0 100
1 101
@@ -96,7 +94,7 @@
7 107
8 108
9 109
-select x as FROMTO2_x, y from t1 for system_time from @x0 to @x1;
+select x as FROMTO2_x, y from t1 for system_time from '0-0-0 0:0:0' to @t1;
FROMTO2_x y
0 100
1 101
@@ -108,7 +106,7 @@
7 107
8 108
9 109
-select x as BETWAND2_x, y from t1 for system_time between transaction @x0 and transaction @x1;
+select x as BETWAND2_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
BETWAND2_x y
0 100
1 101

View File

@@ -0,0 +1,38 @@
--- select2.result
+++ select2,trx_id.result~
@@ -22,6 +22,8 @@
delete from t1 where x > 7;
insert into t1(x, y) values(3, 33);
select sys_start from t1 where x = 3 and y = 33 into @t1;
+set @x1= @t1;
+select vtq_commit_ts(@x1) into @t1;
select x, y from t1;
x y
0 100
@@ -82,7 +84,7 @@
8 108
9 109
3 33
-select x as ASOF2_x, y from t1 for system_time as of @t0;
+select x as ASOF2_x, y from t1 for system_time as of @x0;
ASOF2_x y
0 100
1 101
@@ -94,7 +96,7 @@
7 107
8 108
9 109
-select x as FROMTO2_x, y from t1 for system_time from '0-0-0 0:0:0' to @t1;
+select x as FROMTO2_x, y from t1 for system_time from @x0 to @x1;
FROMTO2_x y
0 100
1 101
@@ -106,7 +108,7 @@
7 107
8 108
9 109
-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 BETWAND2_x, y from t1 for system_time between transaction @x0 and transaction @x1;
BETWAND2_x y
0 100
1 101

View File

@@ -22,8 +22,6 @@ delete from t1 where x = 3;
delete from t1 where x > 7;
insert into t1(x, y) values(3, 33);
select sys_start from t1 where x = 3 and y = 33 into @t1;
set @x1= @t1;
select vtq_commit_ts(@x1) into @t1;
select x, y from t1;
x y
0 100
@@ -84,7 +82,7 @@ ALL_x y
8 108
9 109
3 33
select x as ASOF2_x, y from t1 for system_time as of @x0;
select x as ASOF2_x, y from t1 for system_time as of @t0;
ASOF2_x y
0 100
1 101
@@ -96,7 +94,7 @@ ASOF2_x y
7 107
8 108
9 109
select x as FROMTO2_x, y from t1 for system_time from @x0 to @x1;
select x as FROMTO2_x, y from t1 for system_time from '0-0-0 0:0:0' to @t1;
FROMTO2_x y
0 100
1 101
@@ -108,7 +106,7 @@ FROMTO2_x y
7 107
8 108
9 109
select x as BETWAND2_x, y from t1 for system_time between transaction @x0 and transaction @x1;
select x as BETWAND2_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
BETWAND2_x y
0 100
1 101

View File

@@ -0,0 +1,13 @@
--- suite/versioning/r/update.result
+++ suite/versioning/r/update.reject
@@ -88,10 +88,8 @@
5 3 1
3 1 0
2 1 0
-3 2 0
4 1 0
5 1 0
-5 2 0
drop table t1;
create table t1 (
id int primary key auto_increment,

View File

@@ -1,345 +1,85 @@
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_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_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);
create table t1(
x int unsigned,
y int unsigned,
sys_trx_start SYS_DATATYPE as row start invisible,
sys_trx_end SYS_DATATYPE as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning;
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;
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8000
9 9000
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';
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8001
9 9001
select x, y from t1 for system_time all;
x y
1 1000
2 2000
3 3000
4 4000
5 5000
6 6000
7 7000
8 8001
9 9001
8 8000
9 9000
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,
x int,
y int without system versioning,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
create table t1 (
id bigint primary key,
x int,
y int without system versioning,
sys_trx_start SYS_DATATYPE as row start invisible,
sys_trx_end SYS_DATATYPE as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning;
insert into t1 values(1, 1, 1);
set @ins_t= now(6);
select sys_trx_start into @tmp1 from t1;
update t1 set x= 11, y= 11 where id = 1;
select @tmp1 < sys_trx_start as A1, x, y from t1;
A1 x y
1 11 11
select sys_trx_start into @tmp1 from t1;
update t1 set y= 1 where id = 1;
select @tmp1 = sys_trx_start as A2, x from t1;
A2 x
1 11
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,
sys_trx_start bigint unsigned as row start invisible,
sys_trx_end bigint unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning
engine ', engine);
prepare stmt from @str; execute stmt; drop prepare stmt;
create table t1 (
x int,
y int,
sys_trx_start SYS_DATATYPE as row start invisible,
sys_trx_end SYS_DATATYPE as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning;
insert into t1 (x, y) values (1, 1), (2, 1), (3, 1), (4, 1), (5, 1);
start transaction;
start transaction;
update t1 set y= y + 1 where x = 3;
update t1 set y= y + 1 where x = 2;
update t1 set y= y + 1 where x = 3;
update t1 set y= y + 1 where x > 3;
update t1 set y= y + 1 where x > 4;
commit;
select x, y, sys_trx_end = 18446744073709551615 as current from t1 for system_time all;
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,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
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,
sys_trx_end ', sys_type, ' as row end invisible,
sys_trx_start ', sys_type, ' as row start invisible,
y int unsigned,
period for system_time (sys_trx_start, sys_trx_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),
(3, 3000),
(4, 4000),
(5, 5000);
insert into t1(x, y) values(3, 3000) 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 all;
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_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_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 without system versioning,
name varchar(128),
salary bigint without system versioning,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_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 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_trx_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('timestamp(6)', 'innodb', 'vtq_commit_ts(sys_trx_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', 'vtq_commit_ts(sys_trx_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 verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
call test_02('timestamp(6)', 'myisam', 'sys_trx_end');
A1 x y
1 11 11
A2 x
1 11
call test_02('timestamp(6)', 'innodb', 'vtq_commit_ts(sys_trx_end)');
A1 x y
1 11 11
A2 x
1 11
call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_end)');
A1 x y
1 11 11
A2 x
1 11
call verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
# Multiple UPDATE of same rows in single transaction create historical
# rows only once (applicable to transaction-based only).
call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_end)');
select x, y, sys_trx_end = MAXVAL as current from t1 for system_time all;
x y current
1 1 1
2 2 1
@@ -348,42 +88,48 @@ x y current
5 3 1
3 1 0
2 1 0
3 2 0
4 1 0
5 1 0
call verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
call test_04('timestamp(6)', 'myisam', 'sys_trx_end');
5 2 0
drop table t1;
create table t1 (
id int primary key auto_increment,
x int,
sys_trx_start SYS_DATATYPE as row start invisible,
sys_trx_end SYS_DATATYPE as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning;
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;
x
select x from t1 for system_time as of timestamp @t1;
x
1
select x from t1 for system_time as of timestamp @t2;
x
2
select x from t1 for system_time as of timestamp now(6);
x
3
call test_04('timestamp(6)', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x
x
1
x
2
x
3
call test_04('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x
x
1
x
2
x
3
call verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
3 1 1 1 1
call test_05('timestamp(6)', 'myisam', 'sys_trx_end');
drop table t1;
create table t1(
x int unsigned,
sys_trx_end SYS_DATATYPE as row end invisible,
sys_trx_start SYS_DATATYPE as row start invisible,
y int unsigned,
period for system_time (sys_trx_start, sys_trx_end),
primary key(x, y))
with system versioning;
insert into t1(x, y) values (1, 1000), (3, 3000), (4, 4000), (5, 5000);
insert into t1(x, y) values(3, 3000) 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 all;
x y
1 1000
3 3000
@@ -391,46 +137,26 @@ x y
4 4000
4 4444
5 5000
select x, y from t1;
x y
1 1000
3 3001
4 4000
4 4444
5 5000
call test_05('timestamp(6)', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x y
1 1000
3 3000
3 3001
4 4000
4 4444
5 5000
x y
1 1000
3 3001
4 4000
4 4444
5 5000
call test_05('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_end)');
x y
1 1000
3 3000
3 3001
4 4000
4 4444
5 5000
x y
1 1000
3 3001
4 4000
4 4444
5 5000
call verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
3 1 1 1 1
call test_06('timestamp(6)', 'myisam', 'sys_trx_end');
drop table t1;
create table t1 (
x int unsigned,
y int unsigned,
sys_trx_start SYS_DATATYPE as row start invisible,
sys_trx_end SYS_DATATYPE as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning;
create table t2 like t1;
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 all;
x y
1 1000
2 2000
@@ -443,6 +169,7 @@ x y
9 9009
8 8000
9 9000
select x, y from t1;
x y
1 1000
2 2000
@@ -453,6 +180,7 @@ x y
7 7000
8 8008
9 9009
select x, y from t2 for system_time all;
x y
1 1011
2 2012
@@ -469,6 +197,7 @@ x y
4 4010
5 5010
6 6010
select x, y from t2;
x y
1 1011
2 2012
@@ -479,161 +208,36 @@ x y
7 7010
8 8010
9 9010
call test_06('timestamp(6)', 'innodb', 'vtq_commit_ts(sys_trx_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', 'vtq_commit_ts(sys_trx_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 verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
3 1 1 1 1
# Optimized fields
call test_07('timestamp(6)', 'myisam', 'sys_trx_end');
drop table t1;
drop table t2;
create table t1 (
id bigint primary key without system versioning,
name varchar(128),
salary bigint without system versioning,
sys_trx_start SYS_DATATYPE as row start invisible,
sys_trx_end SYS_DATATYPE as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning;
create table t2 like t1;
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;
A1 name
1 Jerry
select @tmp2 < sys_trx_start as A2, name from t2;
A2 name
1 Jerry
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;
B1 salary
1 2500
select @tmp2 = sys_trx_start as B2, salary from t2;
B2 salary
1 2500
call test_07('timestamp(6)', 'innodb', 'vtq_commit_ts(sys_trx_end)');
A1 name
1 Jerry
A2 name
1 Jerry
B1 salary
1 2500
B2 salary
1 2500
call test_07('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_trx_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
### Issue #365, bug 7 (duplicate of historical row)
create or replace table t1 (a int primary key, b int)
with system versioning engine myisam;
insert into t1 (a) values (1);
replace t1 values (1,2),(1,3),(2,4);
create or replace table t1 (pk int, a char(3), b char(3), primary key(pk))
engine=innodb with system versioning;
insert into t1 (pk) values (1);
connect con1,localhost,root,,test;
start transaction;
select * from t1 for update;
pk a b
1 NULL NULL
connection default;
update t1 set b = 'foo';
connection con1;
update t1 set a = 'bar';
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
disconnect con1;
connection default;
drop database test;
create database test;
drop table t1;
drop table t2;

View File

@@ -0,0 +1,21 @@
### Issue #365, bug 7 (duplicate of historical row)
create or replace table t1 (a int primary key, b int)
with system versioning engine myisam;
insert into t1 (a) values (1);
replace t1 values (1,2),(1,3),(2,4);
create or replace table t1 (pk int, a char(3), b char(3), primary key(pk))
engine=innodb with system versioning;
insert into t1 (pk) values (1);
connect con1,localhost,root,,test;
start transaction;
select * from t1 for update;
pk a b
1 NULL NULL
connection default;
update t1 set b = 'foo';
connection con1;
update t1 set a = 'bar';
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
disconnect con1;
connection default;
drop table t1;