mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
231 lines
9.1 KiB
Text
231 lines
9.1 KiB
Text
create or replace procedure drop_archives (in vtmd_name varchar(64))
|
|
begin
|
|
declare archive_name varchar(64);
|
|
declare cur_done bool default false;
|
|
declare cur cursor for
|
|
select cur_tmp.archive_name from cur_tmp;
|
|
declare continue handler for not found set cur_done = true;
|
|
set @tmp= concat('
|
|
create or replace temporary table
|
|
cur_tmp as
|
|
select vtmd.archive_name from ', vtmd_name, ' as vtmd
|
|
for system_time all
|
|
where vtmd.archive_name is not null
|
|
group by vtmd.archive_name');
|
|
prepare stmt from @tmp; execute stmt; drop prepare stmt;
|
|
open cur;
|
|
fetch_loop: loop
|
|
fetch cur into archive_name;
|
|
if cur_done then
|
|
leave fetch_loop;
|
|
end if;
|
|
set @tmp= concat('drop table ', archive_name);
|
|
prepare stmt from @tmp; execute stmt; drop prepare stmt;
|
|
end loop;
|
|
drop table cur_tmp;
|
|
end~~
|
|
create procedure test_01(in engine varchar(64))
|
|
begin
|
|
set @tmp = concat('create table t (a int) with system versioning engine ', engine);
|
|
prepare stmt from @tmp; execute stmt; drop prepare stmt;
|
|
set @tm1 = now(6);
|
|
alter table t add column b int;
|
|
set @tm2 = now(6);
|
|
alter table t add column c int;
|
|
show create table t for system_time as of timestamp @tm1;
|
|
show create table t for system_time as of timestamp @tm2;
|
|
show create table t for system_time as of now;
|
|
show create table t for system_time as of timestamp now(6);
|
|
show create table t;
|
|
set @tm3 = now(6);
|
|
rename table t to tt;
|
|
show create table tt for system_time as of timestamp @tm3;
|
|
set @tm4 = now(6);
|
|
alter table tt add column d int;
|
|
show create table tt for system_time as of timestamp @tm3;
|
|
show create table tt for system_time as of timestamp @tm4;
|
|
show create table tt;
|
|
drop table tt;
|
|
call drop_archives('tt_vtmd');
|
|
drop table tt_vtmd;
|
|
end~~
|
|
create table t (a int) with system versioning;
|
|
show create table t for system_time as of now;
|
|
ERROR 42S02: Table 'test.t_vtmd' doesn't exist
|
|
set versioning_ddl_survival=on;
|
|
create or replace table t (a int) with system versioning;
|
|
show create table t for system_time between timestamp @tm1 and timestamp @tm1;
|
|
ERROR HY000: SYSTEM_TIME range selector is prohibited
|
|
show create table t for system_time from timestamp @tm1 to timestamp @tm1;
|
|
ERROR HY000: SYSTEM_TIME range selector is prohibited
|
|
show create table t for system_time before timestamp @tm1;
|
|
ERROR HY000: SYSTEM_TIME range selector is prohibited
|
|
show create table t for system_time as of timestamp '01-01-1990';
|
|
ERROR HY000: VTMD error: failed to query VTMD table
|
|
show create table t for system_time as of timestamp '01-01-2020';
|
|
ERROR HY000: VTMD error: failed to query VTMD table
|
|
drop table t;
|
|
call drop_archives('t_vtmd');
|
|
drop table t_vtmd;
|
|
call test_01('myisam');
|
|
Table Create Table
|
|
t CREATE TABLE `t` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
t CREATE TABLE `t` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
t CREATE TABLE `t` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
t CREATE TABLE `t` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
t CREATE TABLE `t` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
tt CREATE TABLE `tt` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
tt CREATE TABLE `tt` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
tt CREATE TABLE `tt` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
tt CREATE TABLE `tt` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
`d` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
call test_01('innodb');
|
|
Table Create Table
|
|
t CREATE TABLE `t` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
t CREATE TABLE `t` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
t CREATE TABLE `t` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
t CREATE TABLE `t` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
t CREATE TABLE `t` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
tt CREATE TABLE `tt` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
tt CREATE TABLE `tt` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
tt CREATE TABLE `tt` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
Table Create Table
|
|
tt CREATE TABLE `tt` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) DEFAULT NULL,
|
|
`d` int(11) DEFAULT NULL,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
drop procedure test_01;
|
|
drop procedure drop_archives;
|