[MDEV-16490] It's possible to make a system versioned table without any versioning field Created: 2018-06-14  Updated: 2019-09-12  Resolved: 2019-09-09

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Versioned Tables
Affects Version/s: 10.3, 10.4
Fix Version/s: 10.3.19, 10.4.9

Type: Bug Priority: Major
Reporter: Eugene Kosov (Inactive) Assignee: Nikita Malyavin
Resolution: Fixed Votes: 0
Labels: None


 Description   

Right behaviour looks like this.

et @@system_versioning_alter_history=keep;
create or replace table t (
a int without system versioning
) with system versioning engine=innodb;
versioning.kevg 'innodb'                 [ fail ]
        Test ended at 2018-06-14 21:32:40
 
CURRENT_TEST: versioning.kevg
mysqltest: At line 82: query 'create or replace table t (
a int without system versioning
) with system versioning engine=innodb' failed: 4123: Table `t` must have at least one versioned column

But it's possible to bypass this error with ALTER TABLE:

set @@system_versioning_alter_history=keep;
create or replace table t (
a int
) with system versioning engine=innodb;
alter table t
change column a a int without system versioning;
show create table t;
Table	Create Table
t	CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING

Same with trx_id based tables.



 Comments   
Comment by Nikita Malyavin [ 2018-06-25 ]

This also crashes:

set @@system_versioning_alter_history=keep;
create or replace table t (a int) with system versioning engine=innodb;
alter table t change column a a int without system versioning, drop system versioning;
 
mysqld: ../sql/sql_table.cc:4436: bool vers_prepare_keys(THD*, HA_CREATE_INFO*, Alter_info*, KEY**, uint): Assertion `row_start_field' failed.

Comment by Nikita Malyavin [ 2018-06-26 ]

Both adding and removing system versioning for field while dropping system versioning for whole table will be forbidden with my upcoming patch.

This might be documented as well.

Comment by Nikita Malyavin [ 2018-09-26 ]

Moving back on me — CREATE...SELECT could still be affected with current fix

Generated at Thu Feb 08 08:29:19 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.