1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
-- source include/have_innodb.inc
-- source include/not_embedded.inc
create or replace table t1 (
x int,
sys_trx_start bigint(20) unsigned as row start invisible,
sys_trx_end bigint(20) unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
insert into t1 (x) values (1);
--echo # ALTER ADD SYSTEM VERSIONING should write to mysql.transaction_registry
create function check_result (cond boolean)
returns char(50) deterministic
return if(cond = 1, '[CORRECT]', '[INCORRECT]');
set @@system_versioning_alter_history=keep;
create or replace table t1 (x int) engine innodb;
insert into t1 values (1);
alter table t1
add column s bigint unsigned as row start,
add column e bigint unsigned as row end,
add period for system_time(s, e),
add system versioning,
algorithm=inplace;
select s from t1 into @trx_start;
select check_result(count(*) = 1) from mysql.transaction_registry where transaction_id = @trx_start;
create or replace table t1 (x int) engine innodb;
select count(*) from mysql.transaction_registry into @tmp;
alter table t1
add column s bigint unsigned as row start,
add column e bigint unsigned as row end,
add period for system_time(s, e),
add system versioning,
algorithm=inplace;
select check_result(count(*) = @tmp) from mysql.transaction_registry;
create or replace table t1 (x int) engine innodb;
insert into t1 values (1);
alter table t1
add column s bigint unsigned as row start,
add column e bigint unsigned as row end,
add period for system_time(s, e),
add system versioning,
algorithm=copy;
select s from t1 into @trx_start;
select check_result(count(*) = 1) from mysql.transaction_registry where transaction_id = @trx_start;
create or replace table t1 (x int) engine innodb;
select count(*) from mysql.transaction_registry into @tmp;
alter table t1
add column s bigint unsigned as row start,
add column e bigint unsigned as row end,
add period for system_time(s, e),
add system versioning,
algorithm=copy;
# With MDEV-14511 the transaction will be registered even for empty tables.
select check_result(count(*) = @tmp + 1) from mysql.transaction_registry;
--echo # TRX_ID to TIMESTAMP versioning switch
create or replace table t1 (
x int,
sys_start bigint unsigned as row start invisible,
sys_end bigint unsigned as row end invisible,
period for system_time (sys_start, sys_end)
) engine innodb with system versioning;
insert into t1 values (1);
alter table t1 drop column sys_start, drop column sys_end;
select row_end = 18446744073709551615 as transaction_based from t1 for system_time all;
drop table t1;
drop function check_result;
|