[MDEV-7136] Engine specific create table options are inherited on alter table. Created: 2014-11-19  Updated: 2014-11-19  Resolved: 2014-11-19

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table
Affects Version/s: 10.1.1
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Jan Lindström (Inactive) Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

One test case:

-- source include/have_innodb.inc
 
--disable_query_log
let $innodb_compression_algorithm_orig=`SELECT @@innodb_compression_algorithm`;
let $innodb_file_format_orig = `SELECT @@innodb_file_format`;
let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`;
--enable_query_log
 
SET GLOBAL innodb_file_format = `Barracuda`;
SET GLOBAL innodb_file_per_table = ON;
# zlib
set global innodb_compression_algorithm = 1;
 
create table innodb_1(c1 bigint not null, b char(200)) engine=innodb page_compressed=1;
create table innodb_2(c1 bigint not null, b char(200)) engine=innodb row_format=compact page_compressed=1;
create table innodb_3(c1 bigint not null, b char(200)) engine=innodb row_format=dynamic page_compressed=1;
 
show create table innodb_1;
show create table innodb_2;
show create table innodb_3;
 
--source include/restart_mysqld.inc
 
SET GLOBAL innodb_file_format = `Barracuda`;
SET GLOBAL innodb_file_per_table = ON;
# zlib
set global innodb_compression_algorithm = 1;
 
alter table innodb_1 engine=innodb;
alter table innodb_2 engine=innodb;
alter table innodb_3 engine=innodb;
 
show create table innodb_1;
show create table innodb_2;
show create table innodb_3;
 
drop table innodb_1;
drop table innodb_2;
drop table innodb_3;
 
 
# reset system
--disable_query_log
EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig;
EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig;
EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig;
--enable_query_log

I would assume if alter table engine=innodb is issued all engine specific options are not inherited. Currently, this is not true:

SET GLOBAL innodb_file_format = `Barracuda`;
SET GLOBAL innodb_file_per_table = ON;
set global innodb_compression_algorithm = 1;
create table innodb_1(c1 bigint not null, b char(200)) engine=innodb page_compressed=1;
create table innodb_2(c1 bigint not null, b char(200)) engine=innodb row_format=compact page_compressed=1;
create table innodb_3(c1 bigint not null, b char(200)) engine=innodb row_format=dynamic page_compressed=1;
show create table innodb_1;
Table	Create Table
innodb_1	CREATE TABLE `innodb_1` (
  `c1` bigint(20) NOT NULL,
  `b` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `page_compressed`=1
show create table innodb_2;
Table	Create Table
innodb_2	CREATE TABLE `innodb_2` (
  `c1` bigint(20) NOT NULL,
  `b` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT `page_compressed`=1
show create table innodb_3;
Table	Create Table
innodb_3	CREATE TABLE `innodb_3` (
  `c1` bigint(20) NOT NULL,
  `b` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC `page_compressed`=1
SET GLOBAL innodb_file_format = `Barracuda`;
SET GLOBAL innodb_file_per_table = ON;
set global innodb_compression_algorithm = 1;
alter table innodb_1 engine=innodb;
alter table innodb_2 engine=innodb;
alter table innodb_3 engine=innodb;
show create table innodb_1;
Table	Create Table
innodb_1	CREATE TABLE `innodb_1` (
  `c1` bigint(20) NOT NULL,
  `b` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `page_compressed`=1
show create table innodb_2;
Table	Create Table
innodb_2	CREATE TABLE `innodb_2` (
  `c1` bigint(20) NOT NULL,
  `b` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT `page_compressed`=1
show create table innodb_3;
Table	Create Table
innodb_3	CREATE TABLE `innodb_3` (
  `c1` bigint(20) NOT NULL,
  `b` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC `page_compressed`=1
drop table innodb_1;
drop table innodb_2;
drop table innodb_3;



 Comments   
Comment by Jan Lindström (Inactive) [ 2014-11-19 ]

Also 5.5/10.0 may be affected (but not above example).

Comment by Sergei Golubchik [ 2014-11-19 ]

They are intentionally inherited, even if you alter to a different storage engine.
ALTER TABLE changes only what you specified explicitly in the ALTER TABLE statement. If you do

ALTER TABLE t1 ENGINE=innodb

it should only change the storage engine to innodb, and not modify any columns, indexes, table comment, table character set, or any other attributes.

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