mirror of
https://github.com/MariaDB/server.git
synced 2025-11-28 17:36:30 +03:00
124 lines
3.7 KiB
Plaintext
124 lines
3.7 KiB
Plaintext
-- source suite/versioning/common.inc
|
|
|
|
delimiter ~~;
|
|
|
|
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 function get_historical_table_name(table_name_arg varchar(255))
|
|
returns varchar(255)
|
|
begin
|
|
return (select table_name from information_schema.tables
|
|
where table_schema='test' and table_name like concat(table_name_arg, '_%') limit 1);
|
|
end~~
|
|
|
|
create procedure drop_last_historical(table_name_arg varchar(255))
|
|
begin
|
|
call concat_exec2('drop table ', get_historical_table_name(table_name_arg));
|
|
end~~
|
|
|
|
delimiter ;~~
|
|
|
|
set versioning_ddl_survival= on;
|
|
|
|
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_historical_table_name('t'), ' for system_time all');
|
|
|
|
call concat_exec3('select @tm=sys_trx_start from ', get_historical_table_name('t'), ' 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_historical_table_name('t'), ' for system_time all where a=2');
|
|
|
|
call drop_last_historical('t');
|
|
|
|
|
|
set versioning_ddl_survival= off;
|
|
drop table t_vtmd;
|
|
drop table t;
|
|
set versioning_ddl_survival= on;
|
|
|
|
# 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_historical_table_name('t'), ' for system_time all');
|
|
|
|
call concat_exec3('select @tm=sys_trx_start from ', get_historical_table_name('t'), ' 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_historical_table_name('t'), ' for system_time all where a=2');
|
|
|
|
call drop_last_historical('t');
|
|
|
|
|
|
set versioning_ddl_survival= off;
|
|
drop table t_vtmd;
|
|
drop table t;
|
|
set versioning_ddl_survival= on;
|
|
|
|
# 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_historical_table_name('t'), ' for system_time all');
|
|
|
|
call concat_exec3('select @tm=sys_trx_start from ', get_historical_table_name('t'), ' 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_historical_table_name('t'), ' for system_time all where a=2');
|
|
|
|
call drop_last_historical('t');
|
|
|
|
|
|
set versioning_ddl_survival= off;
|
|
drop table t_vtmd;
|
|
drop table t;
|
|
set versioning_ddl_survival= on;
|
|
|
|
# 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_ddl_survival = 0;
|
|
|
|
drop procedure concat_exec2;
|
|
drop procedure concat_exec3;
|
|
drop function get_historical_table_name;
|
|
drop procedure drop_last_historical;
|
|
|
|
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
|