mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
SQL: Versioned SHOW CREATE TABLE [closes #125]
This commit is contained in:
parent
448374a228
commit
ac5eb9771e
10 changed files with 449 additions and 5 deletions
|
|
@ -202,6 +202,7 @@ No A B C D
|
|||
11 1 1 1 1
|
||||
12 1 1 1 1
|
||||
drop table t;
|
||||
drop table t_vtmd;
|
||||
drop procedure verify_vtq;
|
||||
drop procedure innodb_verify_vtq;
|
||||
drop function default_engine;
|
||||
|
|
|
|||
231
mysql-test/suite/versioning/r/vtmd_show.result
Normal file
231
mysql-test/suite/versioning/r/vtmd_show.result
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
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: Wrong parameters for `FOR SYSTEM_TIME`: only AS OF allowed here
|
||||
show create table t for system_time from timestamp @tm1 to timestamp @tm1;
|
||||
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME`: only AS OF allowed here
|
||||
show create table t for system_time before timestamp @tm1;
|
||||
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME`: only AS OF allowed here
|
||||
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;
|
||||
|
|
@ -118,5 +118,6 @@ show create table mysql.vtmd_template;
|
|||
|
||||
call verify_vtq;
|
||||
drop table t;
|
||||
drop table t_vtmd;
|
||||
|
||||
-- source suite/versioning/common_finish.inc
|
||||
|
|
|
|||
1
mysql-test/suite/versioning/t/vtmd_show.opt
Normal file
1
mysql-test/suite/versioning/t/vtmd_show.opt
Normal file
|
|
@ -0,0 +1 @@
|
|||
--innodb
|
||||
92
mysql-test/suite/versioning/t/vtmd_show.test
Normal file
92
mysql-test/suite/versioning/t/vtmd_show.test
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
delimiter ~~;
|
||||
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~~
|
||||
delimiter ;~~
|
||||
|
||||
delimiter ~~;
|
||||
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~~
|
||||
delimiter ;~~
|
||||
|
||||
create table t (a int) with system versioning;
|
||||
--error ER_NO_SUCH_TABLE
|
||||
show create table t for system_time as of now;
|
||||
|
||||
set versioning_ddl_survival=on;
|
||||
|
||||
create or replace table t (a int) with system versioning;
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
show create table t for system_time between timestamp @tm1 and timestamp @tm1;
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
show create table t for system_time from timestamp @tm1 to timestamp @tm1;
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
show create table t for system_time before timestamp @tm1;
|
||||
--error ER_VERS_VTMD_ERROR
|
||||
show create table t for system_time as of timestamp '01-01-1990';
|
||||
--error ER_VERS_VTMD_ERROR
|
||||
show create table t for system_time as of timestamp '01-01-2020';
|
||||
drop table t;
|
||||
call drop_archives('t_vtmd');
|
||||
drop table t_vtmd;
|
||||
|
||||
call test_01('myisam');
|
||||
call test_01('innodb');
|
||||
|
||||
drop procedure test_01;
|
||||
drop procedure drop_archives;
|
||||
Loading…
Add table
Add a link
Reference in a new issue