mariadb/mysql-test/suite/versioning/r/commit_id.result

176 lines
5.2 KiB
Text

set @@session.time_zone='+00:00';
select ifnull(max(transaction_id), 0) into @start_trx_id from mysql.transaction_registry;
set @test_start=now(6);
create procedure if not exists verify_vtq()
begin
set @i= 0;
select
@i:= @i + 1 as No,
transaction_id > 0 as A,
commit_id > transaction_id as B,
begin_timestamp > @test_start as C,
commit_timestamp >= begin_timestamp as D
from mysql.transaction_registry
where transaction_id > @start_trx_id;
select ifnull(max(transaction_id), 0)
into @start_trx_id
from mysql.transaction_registry;
end~~
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 concat_exec2(a varchar(255), b varchar(255))
begin
prepare stmt from concat(a, b);
execute stmt;
deallocate prepare stmt;
end~~
create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255))
begin
prepare stmt from concat(a, b, c);
execute stmt;
deallocate prepare stmt;
end~~
create table t1(
id int auto_increment primary key)
with system versioning
engine innodb;
insert into t1 values ();
set @ts0= now(6);
insert into t1 values ();
select sys_trx_start from t1 where id = last_insert_id() into @tx0;
select transaction_id = @tx0 from mysql.transaction_registry
order by transaction_id desc limit 1;
transaction_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 transaction_id = @tx1 from mysql.transaction_registry
order by transaction_id desc limit 1;
transaction_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 transaction_id = @tx2 from mysql.transaction_registry
order by transaction_id desc limit 1;
transaction_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
set transaction isolation level read uncommitted;
insert into t1 values ();
select sys_trx_start from t1 where id = last_insert_id() into @tx3;
select isolation_level = 'READ-UNCOMMITTED' from mysql.transaction_registry where transaction_id = @tx3;
isolation_level = 'READ-UNCOMMITTED'
1
set transaction isolation level read committed;
insert into t1 values ();
select sys_trx_start from t1 where id = last_insert_id() into @tx4;
select isolation_level = 'READ-COMMITTED' from mysql.transaction_registry where transaction_id = @tx4;
isolation_level = 'READ-COMMITTED'
1
set transaction isolation level serializable;
insert into t1 values ();
select sys_trx_start from t1 where id = last_insert_id() into @tx5;
select isolation_level = 'SERIALIZABLE' from mysql.transaction_registry where transaction_id = @tx5;
isolation_level = 'SERIALIZABLE'
1
set transaction isolation level repeatable read;
insert into t1 values ();
select sys_trx_start from t1 where id = last_insert_id() into @tx6;
select isolation_level = 'REPEATABLE-READ' from mysql.transaction_registry where transaction_id = @tx6;
isolation_level = 'REPEATABLE-READ'
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
8 1 1 1 1
drop procedure verify_vtq;
drop procedure innodb_verify_vtq;
drop function default_engine;
drop function sys_commit_ts;
drop function sys_datatype;
drop procedure concat_exec2;
drop procedure concat_exec3;