summaryrefslogtreecommitdiff
path: root/mysql-test/suite/versioning/t/ddl.test
blob: 5be62281a6d872100db14389f161bc20c0cb7090 (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
-- source suite/versioning/common.inc

delimiter ~~;
create function get_archive_table_name()
returns varchar(255)
begin
  return (select archive_name from t_vtmd for system_time all where archive_name is not NULL
    order by start desc limit 1);
end~~

create procedure drop_last_archive()
begin
  call concat_exec2('drop table ', get_archive_table_name());
end~~
delimiter ;~~

set versioning_alter_history= survive;

create or replace table t (a int) with system versioning;
insert into t values (1);
update t set a=2 where a=1;
select sys_trx_start from t where a=2 into @tm;
alter table t add column b int;

select * from t;
call concat_exec3('select * from ', get_archive_table_name(), ' for system_time all');

call concat_exec3('select @tm=sys_trx_start from ', get_archive_table_name(), ' for system_time all where a=2');
select @tm<sys_trx_start from t where a=2;
select sys_trx_start from t where a=2 into @tm;
call concat_exec3('select @tm=sys_trx_end from ', get_archive_table_name(), ' for system_time all where a=2');

call drop_last_archive();


set versioning_alter_history= keep;
drop table t_vtmd;
drop table t;
set versioning_alter_history= survive;

# same for INNODB ALGORITHM=COPY
create or replace table t (a int) with system versioning;
insert into t values (1);
update t set a=2 where a=1;
select sys_trx_start from t where a=2 into @tm;
alter table t add column b int;

select * from t;
call concat_exec3('select * from ', get_archive_table_name(), ' for system_time all');

call concat_exec3('select @tm=sys_trx_start from ', get_archive_table_name(), ' for system_time all where a=2');
select @tm<sys_trx_start from t where a=2;
select sys_trx_start from t where a=2 into @tm;
call concat_exec3('select @tm=sys_trx_end from ', get_archive_table_name(), ' for system_time all where a=2');

call drop_last_archive();


set versioning_alter_history= keep;
drop table t_vtmd;
drop table t;
set versioning_alter_history= survive;

# same for INNODB default ALGORITHM
create or replace table t (a int) with system versioning engine innodb;
insert into t values (1);
update t set a=2 where a=1;
select sys_trx_start from t where a=2 into @tm;
alter table t add column b int;

select * from t;
call concat_exec3('select * from ', get_archive_table_name(), ' for system_time all');

call concat_exec3('select @tm=sys_trx_start from ', get_archive_table_name(), ' for system_time all where a=2');
select @tm<sys_trx_start from t where a=2;
select sys_trx_start from t where a=2 into @tm;
call concat_exec3('select @tm=sys_trx_end from ', get_archive_table_name(), ' for system_time all where a=2');

call drop_last_archive();


set versioning_alter_history= keep;
drop table t_vtmd;
drop table t;
set versioning_alter_history= survive;

# no DDL for INNODB explicit ALGORITHM=INPLACE
create or replace table t (a int) with system versioning engine innodb;
insert into t values (1);
update t set a=2 where a=1;
alter table t add column b int, algorithm=inplace;

set versioning_alter_history = keep;

drop function get_archive_table_name;
drop procedure drop_last_archive;

select * from mysql.vtmd_template;
show create table mysql.vtmd_template;

call verify_vtq;
drop table t;
drop table t_vtmd;

-- source suite/versioning/common_finish.inc