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 Nov 15, 2016
1 parent 0c74aaa commit 28e215d
Show file tree
Hide file tree
Showing 34 changed files with 1,231 additions and 336 deletions.
6 changes: 3 additions & 3 deletions mysql-test/suite/versioning/common.inc
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
12 changes: 6 additions & 6 deletions mysql-test/suite/versioning/r/select.result
Original file line number Diff line number Diff line change
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
20 changes: 10 additions & 10 deletions mysql-test/suite/versioning/r/update.result
Original file line number Diff line number Diff line change
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 @@ -258,7 +258,7 @@ x y
9 9001
8 8000
9 9000
call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
x y
1 1000
2 2000
Expand Down Expand Up @@ -296,7 +296,7 @@ A1 x y
1 11 11
A2 x
1 11
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
A1 x y
1 11 11
A2 x
Expand All @@ -308,7 +308,7 @@ x y
3 3
3 1
3 2
call test_03('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
x y
1 1
2 1
Expand All @@ -322,7 +322,7 @@ x
2
x
3
call test_04('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_04('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
x
x
1
Expand Down Expand Up @@ -356,7 +356,7 @@ x y
7 7000
8 8000
9 9000
call test_05('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_05('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
x y
1 1000
2 2000
Expand Down Expand Up @@ -431,7 +431,7 @@ x y
7 7010
8 8010
9 9010
call test_06('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_06('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
x y
1 1000
2 2000
Expand Down Expand Up @@ -489,7 +489,7 @@ B1 salary
1 2500
B2 salary
1 2500
call test_07('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call test_07('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
A1 name
1 Jerry
A2 name
Expand Down
Loading

0 comments on commit 28e215d

Please sign in to comment.