Skip to content

Commit

Permalink
IB, SQL: (0.4) COMMIT_ID-based ordering of transactions
Browse files Browse the repository at this point in the history
IB:
* removed CONCURR_TRX from VTQ;
* new fields in VTQ: COMMIT_ID, ISO_LEVEL.

SQL:
* renamed BEGIN_TS, COMMIT_TS to VTQ_BEGIN_TS, VTQ_COMMIT_TS;
* new functions: VTQ_COMMIT_ID, VTQ_ISO_LEVEL, VTQ_TRX_ID, VTQ_TRX_SEES, VTQ_TRX_SEES_EQ;
* versioned SELECT for IB uses VTQ_TRX_SEES, VTQ_TRX_SEES_EQ.

Closes #71
  • Loading branch information
midenok committed May 5, 2017
1 parent 07cc46a commit d54d36c
Show file tree
Hide file tree
Showing 35 changed files with 1,241 additions and 346 deletions.
6 changes: 3 additions & 3 deletions mysql-test/suite/versioning/common.inc
Expand Up @@ -10,9 +10,9 @@ begin
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
commit_id >= trx_id as B,
begin_ts > '1-1-1 0:0:0' as C,
commit_ts > begin_ts as D
from information_schema.innodb_vtq
where trx_id > @start_trx_id;
select ifnull(max(trx_id), 0)
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/suite/versioning/r/auto_increment.result
Expand Up @@ -6,9 +6,9 @@ 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
commit_id >= trx_id as B,
begin_ts > '1-1-1 0:0:0' as C,
commit_ts > begin_ts as D
from information_schema.innodb_vtq
where trx_id > @start_trx_id;
select ifnull(max(trx_id), 0)
Expand Down Expand Up @@ -93,7 +93,7 @@ A x y x y
1 5 15 5 15
1 6 16 6 16
1 7 17 7 17
call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
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 Down
103 changes: 103 additions & 0 deletions mysql-test/suite/versioning/r/commit_id.result
@@ -0,0 +1,103 @@
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,
commit_id >= trx_id as B,
begin_ts > '1-1-1 0:0:0' as C,
commit_ts > begin_ts 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 table t1(
id int auto_increment primary key)
with system versioning
engine innodb;
set transaction isolation level read uncommitted;
insert into t1 values ();
select iso_level = 'RU' from information_schema.innodb_vtq limit 1;
iso_level = 'RU'
1
set transaction isolation level read committed;
insert into t1 values ();
select iso_level = 'RC' from information_schema.innodb_vtq limit 1;
iso_level = 'RC'
1
set transaction isolation level serializable;
insert into t1 values ();
select iso_level = 'S' from information_schema.innodb_vtq limit 1;
iso_level = 'S'
1
set transaction isolation level repeatable read;
insert into t1 values ();
select iso_level = 'RR' from information_schema.innodb_vtq limit 1;
iso_level = 'RR'
1
set @ts0= now(6);
insert into t1 values ();
select sys_trx_start from t1 where id = last_insert_id() into @tx0;
select trx_id = @tx0 from information_schema.innodb_vtq limit 1;
trx_id = @tx0
1
set @ts1= now(6);
insert into t1 values ();
select sys_trx_start from t1 where id = last_insert_id() into @tx1;
select trx_id = @tx1 from information_schema.innodb_vtq limit 1;
trx_id = @tx1
1
set @ts2= now(6);
insert into t1 values ();
select sys_trx_start from t1 where id = last_insert_id() into @tx2;
select trx_id = @tx2 from information_schema.innodb_vtq limit 1;
trx_id = @tx2
1
set @ts3= now(6);
select
vtq_trx_id(@ts0) < @tx0 as A,
vtq_trx_id(@ts0, true) = @tx0 as B,
vtq_trx_id(@ts1) = @tx0 as C,
vtq_trx_id(@ts1, true) = @tx1 as D,
vtq_trx_id(@ts2) = @tx1 as E,
vtq_trx_id(@ts2, true) = @tx2 as F,
vtq_trx_id(@ts3) = @tx2 as G,
vtq_trx_id(@ts3, true) is null as H;
A B C D E F G H
1 1 1 1 1 1 1 1
select
vtq_commit_id(@ts0) < @tx0 as A,
vtq_commit_id(@ts0, true) = vtq_commit_id(null, @tx0) as B,
vtq_commit_id(@ts1) = vtq_commit_id(null, @tx0) as C,
vtq_commit_id(@ts1, true) = vtq_commit_id(null, @tx1) as D,
vtq_commit_id(@ts2) = vtq_commit_id(null, @tx1) as E,
vtq_commit_id(@ts2, true) = vtq_commit_id(null, @tx2) as F,
vtq_commit_id(@ts3) = vtq_commit_id(null, @tx2) as G,
vtq_commit_id(@ts3, true) is null as H;
A B C D E F G H
1 1 1 1 1 1 1 1
select
vtq_trx_sees(@tx1, @tx0) as A,
not vtq_trx_sees(@tx0, @tx1) as B,
vtq_trx_sees_eq(@tx1, @tx1) as C,
not vtq_trx_sees(@tx1, @tx1) as D,
vtq_trx_sees(@tx2, 0) as E,
vtq_trx_sees(0, @tx2) is null as F,
vtq_trx_sees(-1, @tx2) as H;
A B C D E F H
1 1 1 1 1 1 1
drop table t1;
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
drop procedure verify_vtq;
20 changes: 10 additions & 10 deletions mysql-test/suite/versioning/r/delete.result
Expand Up @@ -6,9 +6,9 @@ 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
commit_id >= trx_id as B,
begin_ts > '1-1-1 0:0:0' as C,
commit_ts > begin_ts as D
from information_schema.innodb_vtq
where trx_id > @start_trx_id;
select ifnull(max(trx_id), 0)
Expand Down Expand Up @@ -164,8 +164,8 @@ XNo sys_end < '2038-01-19 03:14:07'
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'
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
Expand All @@ -176,7 +176,7 @@ XNo commit_ts(sys_end) < '2038-01-19 03:14:07'
7 0
8 0
9 0
XNo commit_ts(sys_end) < '2038-01-19 03:14:07'
XNo vtq_commit_ts(sys_end) < '2038-01-19 03:14:07'
0 1
1 0
2 0
Expand All @@ -187,7 +187,7 @@ XNo commit_ts(sys_end) < '2038-01-19 03:14:07'
7 0
8 0
9 0
XNo commit_ts(sys_end) < '2038-01-19 03:14:07'
XNo vtq_commit_ts(sys_end) < '2038-01-19 03:14:07'
0 1
1 1
2 0
Expand All @@ -207,7 +207,7 @@ XNo
2
4
5
XNo commit_ts(sys_end) < '2038-01-19 03:14:07'
XNo vtq_commit_ts(sys_end) < '2038-01-19 03:14:07'
0 1
1 1
2 0
Expand Down Expand Up @@ -239,7 +239,7 @@ 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)');
call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
x sys_start sys_end
A B C
1 1 1
Expand Down Expand Up @@ -273,7 +273,7 @@ t2_x_all
12
13
14
call test_03('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
t1_x
1
2
Expand Down
24 changes: 12 additions & 12 deletions mysql-test/suite/versioning/r/insert.result
Expand Up @@ -6,9 +6,9 @@ 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
commit_id >= trx_id as B,
begin_ts > '1-1-1 0:0:0' as C,
commit_ts > begin_ts as D
from information_schema.innodb_vtq
where trx_id > @start_trx_id;
select ifnull(max(trx_id), 0)
Expand Down Expand Up @@ -156,8 +156,8 @@ 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)
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.000000
2 3 2038-01-19 03:14:07.000000
40 33 2038-01-19 03:14:07.000000
Expand All @@ -166,8 +166,8 @@ 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)
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.000000
20 33 44 2038-01-19 03:14:07.000000
40 33 44 2038-01-19 03:14:07.000000
Expand All @@ -194,8 +194,8 @@ 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)
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.000000
1001 2001 2038-01-19 03:14:07.000000
1002 2002 2038-01-19 03:14:07.000000
Expand All @@ -205,7 +205,7 @@ x y
1001 2001
1002 2002
3001 4001
x y commit_ts(sys_end)
x y vtq_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
Expand All @@ -222,7 +222,7 @@ 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)');
call test_04('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
id a b
1 1 1
id a b C D
Expand Down Expand Up @@ -257,7 +257,7 @@ x y
7 7001
8 8001
9 9001
call test_05('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_05('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
x y
1 1001
2 2001
Expand Down
20 changes: 10 additions & 10 deletions mysql-test/suite/versioning/r/optimized_fields.result
Expand Up @@ -17,50 +17,50 @@ a b b+0
1 NULL NULL
3 NULL NULL
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
Warning 4067 Attempt to read unversioned field 'b' in historical query
select * from t for system_time as of timestamp now(6);
a b
1 NULL
3 NULL
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
Warning 4067 Attempt to read unversioned field 'b' in historical query
select count(*) from t group by b for system_time as of timestamp now(6);
count(*)
2
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
Warning 4067 Attempt to read unversioned field 'b' in historical query
select * from t for system_time as of timestamp now(6) order by b asc;
a b
1 NULL
3 NULL
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
Warning 4067 Attempt to read unversioned field 'b' in historical query
select * from t for system_time as of timestamp now(6) order by b desc;
a b
1 NULL
3 NULL
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
Warning 4067 Attempt to read unversioned field 'b' in historical query
select * from t group by a having a=2 for system_time as of timestamp now(6);
a b
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
Warning 4067 Attempt to read unversioned field 'b' in historical query
select * from t group by b having b=2 for system_time as of timestamp now(6);
a b
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
Warning 4067 Attempt to read unversioned field 'b' in historical query
select a from t where b=2 for system_time as of timestamp now(6);
a
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
Warning 4067 Attempt to read unversioned field 'b' in historical query
select a from t where b=NULL for system_time as of timestamp now(6);
a
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
Warning 4067 Attempt to read unversioned field 'b' in historical query
select count(*), b from t group by b having b=NULL for system_time as of timestamp now(6);
count(*) b
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
Warning 4067 Attempt to read unversioned field 'b' in historical query
select a, b from t;
a b
1 2
Expand Down
12 changes: 6 additions & 6 deletions mysql-test/suite/versioning/r/select.result
Expand Up @@ -6,9 +6,9 @@ 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
commit_id >= trx_id as B,
begin_ts > '1-1-1 0:0:0' as C,
commit_ts > begin_ts as D
from information_schema.innodb_vtq
where trx_id > @start_trx_id;
select ifnull(max(trx_id), 0)
Expand Down Expand Up @@ -51,7 +51,7 @@ insert into t1(x, y) values(3, 33);
select sys_start from t1 where x = 3 and y = 33 into @t1;
if engine = 'innodb' then
set @x1= @t1;
select commit_ts(@x1) into @t1;
select vtq_commit_ts(@x1) into @t1;
end if;
select x, y from t1;
select x as ASOF_x, y from t1 for system_time as of timestamp @t0;
Expand Down Expand Up @@ -169,7 +169,7 @@ BETWAND_ext_x y
8 108
9 109
3 33
call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_start)');
call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_start)');
x y
0 100
1 101
Expand Down Expand Up @@ -326,7 +326,7 @@ RJ2_x1 y1 x2 y2
1 3 1 2
NULL NULL 2 1
NULL NULL 3 1
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_start)');
call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_start)');
IJ1_x1 y1 x2 y2
1 1 1 2
1 2 1 2
Expand Down

0 comments on commit d54d36c

Please sign in to comment.