mariadb/mysql-test/suite/versioning/t/ddl.test
2017-09-27 22:08:20 +03:00

105 lines
3.2 KiB
Text

-- 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