select @@versioning_alter_history; @@versioning_alter_history ERROR create table t( a int ); show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 alter table t drop system versioning; ERROR HY000: Table `t` is not versioned alter table t add system versioning; show create table t; 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 alter table t add column y int; ERROR HY000: Not allowed for versioned `test`.`t`. Change `versioning_alter_history` to proceed with ALTER. alter table t engine innodb; ERROR HY000: Not allowed for versioned `test`.`t`. Change to/from native versioning engine is prohibited. alter table t drop system versioning; show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 set versioning_alter_history= keep; alter table t add column trx_start bigint(20) unsigned generated always as row start, add column trx_end bigint(20) unsigned generated always as row end, add period for system_time(trx_start, trx_end), add system versioning; ERROR HY000: `trx_start` must be of type TIMESTAMP(6) for versioned table `t` alter table t add column trx_start timestamp generated always as row start, add column trx_end timestamp generated always as row end, add period for system_time(trx_start, trx_end), add system versioning; ERROR HY000: `trx_start` must be of type TIMESTAMP(6) for versioned table `t` alter table t add column trx_start timestamp(6) not null generated always as row start, add column trx_end timestamp(6) not null generated always as row end, add period for system_time(trx_start, trx_end), add system versioning; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'generated always as row start, add column trx_end timestamp(6) not null generate' at line 2 alter table t add column trx_start timestamp(6) generated always as row start, add column trx_end timestamp(6) generated always as row end, add period for system_time(trx_start, trx_end), add system versioning; show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL, `trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, `trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING alter table t drop column trx_start, drop column trx_end; alter table t drop system versioning; show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 alter table t add system versioning; show create table t; 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 alter table t add column b int; show create table t; 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 alter table t add column c int; show create table t; 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 alter table t add column d int first; show create table t; Table Create Table t CREATE TABLE `t` ( `d` int(11) DEFAULT NULL, `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 alter table t add column e int after d; show create table t; Table Create Table t CREATE TABLE `t` ( `d` int(11) DEFAULT NULL, `e` int(11) DEFAULT NULL, `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 alter table t drop column a; show create table t; Table Create Table t CREATE TABLE `t` ( `d` int(11) DEFAULT NULL, `e` 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 create or replace table t ( a int, 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)) with system versioning; select * from t for system_time all; a sys_trx_start sys_trx_end alter table t drop column sys_trx_start; alter table t drop column sys_trx_end; select * from t for system_time all; a alter table t drop column sys_trx_start; ERROR 42000: Can't DROP COLUMN `sys_trx_start`; check that it exists alter table t drop column sys_trx_end; ERROR 42000: Can't DROP COLUMN `sys_trx_end`; check that it exists create or replace table t ( a int, 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)) with system versioning; select * from t for system_time all; a sys_trx_start sys_trx_end alter table t drop column sys_trx_start, drop column sys_trx_end; select * from t for system_time all; a create or replace table t( a int ); insert into t values(1); alter table t add system versioning; show create table t; 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 insert into t values(2); select * from t for system_time all; a 1 2 select * from t; a 1 2 update t set a=3 where a=1; select * from t; a 3 2 select * from t for system_time all; a 3 2 1 select sys_trx_start from t where a=3 into @tm; alter table t add column b int; select @tm=sys_trx_start from t where a=3; @tm=sys_trx_start 1 show create table t; 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 select * from t; a b 3 NULL 2 NULL select * from t for system_time all; a b 3 NULL 2 NULL 1 NULL alter table t drop system versioning; select * from t; a b 3 NULL 2 NULL show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 alter table t modify a int with system versioning; ERROR HY000: Table `t` is not versioned alter table t modify a int without system versioning; ERROR HY000: Table `t` is not versioned alter table t add system versioning; alter table t modify a int without system versioning; show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING, `b` 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 alter table t modify a int with system versioning; show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL, `b` 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 create or replace table t( a int ) engine=innodb; insert into t values(1); select * from t; a 1 alter table t add column trx_start timestamp(6) generated always as row start, add column trx_end timestamp(6) generated always as row end, add period for system_time(trx_start, trx_end), add system versioning; ERROR HY000: `trx_start` must be of type BIGINT(20) UNSIGNED for versioned table `t` call verify_vtq; No A B C D alter table t add column trx_start bigint(20) unsigned generated always as row start, add column trx_end bigint(20) unsigned generated always as row end, add period for system_time(trx_start, trx_end), add system versioning; call verify_vtq; No A B C D show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL, `trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, `trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING alter table t drop column trx_start, drop column trx_end; call verify_vtq; No A B C D alter table t drop system versioning, algorithm=copy; call verify_vtq; No A B C D alter table t add system versioning, algorithm=copy; call verify_vtq; No A B C D show create table t; 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 update t set a= 2; select * from t for system_time all; a 2 1 call verify_vtq; No A B C D 1 1 1 1 1 alter table t add column b int, algorithm=copy; show create table t; 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 select * from t; a b 2 NULL call verify_vtq; No A B C D alter table t drop column b, algorithm=copy; show create table t; 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 select * from t for system_time all; a 2 1 call verify_vtq; No A B C D alter table t drop system versioning, algorithm=inplace; call verify_vtq; No A B C D alter table t add system versioning, algorithm=inplace; call verify_vtq; No A B C D show create table t; 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 update t set a= 1; select * from t for system_time all; a 1 2 call verify_vtq; No A B C D 1 1 1 1 1 alter table t add column b int, algorithm=inplace; show create table t; 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 select * from t; a b 1 NULL call verify_vtq; No A B C D alter table t drop column b, algorithm=inplace; show create table t; 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 select * from t for system_time all; a 1 2 alter table t drop system versioning, algorithm=copy; show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 call verify_vtq; No A B C D create or replace table t (a int); insert t values (1),(2),(3),(4); alter table t add b int auto_increment null unique; select * from t; a b 1 1 2 2 3 3 4 4 drop table t; create or replace table t (a int) with system versioning engine=innodb; insert into t values (1), (2), (3); delete from t where a<3; call verify_vtq; No A B C D 1 1 1 1 1 2 1 1 1 1 alter table t add b int not null unique; ERROR 23000: Duplicate entry '...' for key 'b' alter table t add b int auto_increment unique; ERROR 42000: Table 'test/t' uses an extension that doesn't exist in this MariaDB version alter table t add b int auto_increment null unique; call verify_vtq; No A B C D select * from t; a b 3 1 select * from t for system_time all; a b 1 NULL 2 NULL 3 1 insert into t values (4, 0); select * from t for system_time all; a b 1 NULL 2 NULL 3 1 4 2 call verify_vtq; No A B C D 1 1 1 1 1 create or replace table t (a int) with system versioning; insert into t values (1), (2), (3); delete from t where a<3; alter table t add b int not null unique; ERROR 23000: Duplicate entry '...' for key 'b' alter table t add b int auto_increment unique; ERROR 42000: Table '#sql-temporary' uses an extension that doesn't exist in this MariaDB version alter table t add b int auto_increment null unique; select * from t; a b 3 1 select * from t for system_time all; a b 1 NULL 2 NULL 3 1 insert into t values (4, 0); select * from t for system_time all; a b 1 NULL 2 NULL 3 1 4 2 create or replace table t ( a int, 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) ) with system versioning engine innodb; alter table t change column sys_trx_start asdf bigint unsigned; ERROR HY000: Can not change system versioning field `sys_trx_start` create or replace table t ( a int, 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) ) with system versioning engine myisam; alter table t change column sys_trx_start asdf timestamp(6); ERROR HY000: Can not change system versioning field `sys_trx_start` create or replace table t ( a int, 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) ) with system versioning; select * from t; a sys_trx_start sys_trx_end alter table t drop system versioning; ERROR HY000: System versioning field `sys_trx_start` is not hidden alter table t drop column sys_trx_start; select * from t; a sys_trx_end alter table t drop system versioning; ERROR HY000: System versioning field `sys_trx_end` is not hidden alter table t drop column sys_trx_end; select * from t; a alter table t drop system versioning; show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 set versioning_alter_history= SURVIVE; ERROR 42000: Variable 'versioning_alter_history' can't be set to the value of 'SURVIVE' set versioning_alter_history= DROP; ERROR 42000: Variable 'versioning_alter_history' can't be set to the value of 'DROP' drop database test; create database test;