Commit 64e476e0 authored by unknown's avatar unknown

In this patch, existing tests innodb_bug54679.test and innodb_bug56632.test are

removed and replaced by the comprehensive innodb-create-options.test.
It uses the rules listed in the comments at the top of that test.
  
This patch introduces these differences from previous behavior;
1)  KEY_BLOCK_SIZE=0 is allowed by Innodb in both strict and non-strict mode
with no errors or warnings. It was previously used by the server to set 
KEY_BLOCK_SIZE to undefined.  (Bug#56628)
2)  An explicit valid non-DEFAULT ROW_FORMAT always takes priority over a
valid KEY_BLOCK_SIZE. (bug#56632)
3)  Automatic use of COMPRESSED row format is only done if the ROW_FORMAT
is DEFAULT or unspecified.
4)  ROW_FORMAT=FIXED is prevented in strict mode.

This patch also includes various formatting changes for consistency with
InnoDB coding standards.

Related Bugs
Bug#54679: ALTER TABLE causes compressed row_format to revert to compact
Bug#56628: ALTER TABLE .. KEY_BLOCK_SIZE=0 produces untrue warning or unnecessary error
Bug#56632: ALTER TABLE implicitly changes ROW_FORMAT to COMPRESSED
parent addb1475
This diff is collapsed.
......@@ -83,8 +83,6 @@ test t8 Compact
test t9 Compact
drop table t0,t00,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
alter table t1 key_block_size=0;
Warnings:
Warning 1478 InnoDB: ignoring KEY_BLOCK_SIZE=0.
alter table t1 row_format=dynamic;
SELECT table_schema, table_name, row_format
FROM information_schema.tables WHERE engine='innodb';
......@@ -190,16 +188,9 @@ set global innodb_file_per_table = on;
set global innodb_file_format = `1`;
set innodb_strict_mode = off;
create table t1 (id int primary key) engine = innodb key_block_size = 0;
Warnings:
Warning 1478 InnoDB: ignoring KEY_BLOCK_SIZE=0.
drop table t1;
set innodb_strict_mode = on;
create table t1 (id int primary key) engine = innodb key_block_size = 0;
ERROR HY000: Can't create table 'test.t1' (errno: 1478)
show warnings;
Level Code Message
Warning 1478 InnoDB: invalid KEY_BLOCK_SIZE = 0. Valid values are [1, 2, 4, 8, 16]
Error 1005 Can't create table 'test.t1' (errno: 1478)
create table t2 (id int primary key) engine = innodb key_block_size = 9;
ERROR HY000: Can't create table 'test.t2' (errno: 1478)
show warnings;
......@@ -218,6 +209,7 @@ create table t11(id int primary key) engine = innodb row_format = redundant;
SELECT table_schema, table_name, row_format
FROM information_schema.tables WHERE engine='innodb';
table_schema table_name row_format
test t1 Compact
test t10 Compact
test t11 Redundant
test t3 Compressed
......@@ -227,7 +219,7 @@ test t6 Compressed
test t7 Compressed
test t8 Compressed
test t9 Dynamic
drop table t3, t4, t5, t6, t7, t8, t9, t10, t11;
drop table t1, t3, t4, t5, t6, t7, t8, t9, t10, t11;
create table t1 (id int primary key) engine = innodb
key_block_size = 8 row_format = compressed;
create table t2 (id int primary key) engine = innodb
......@@ -253,16 +245,12 @@ Warning 1478 InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE.
Error 1005 Can't create table 'test.t4' (errno: 1478)
create table t5 (id int primary key) engine = innodb
key_block_size = 8 row_format = default;
ERROR HY000: Can't create table 'test.t5' (errno: 1478)
show warnings;
Level Code Message
Warning 1478 InnoDB: cannot specify ROW_FORMAT = COMPACT with KEY_BLOCK_SIZE.
Error 1005 Can't create table 'test.t5' (errno: 1478)
SELECT table_schema, table_name, row_format
FROM information_schema.tables WHERE engine='innodb';
table_schema table_name row_format
test t1 Compressed
drop table t1;
test t5 Compressed
drop table t1, t5;
create table t1 (id int primary key) engine = innodb
key_block_size = 9 row_format = redundant;
ERROR HY000: Can't create table 'test.t1' (errno: 1478)
......
SET GLOBAL innodb_file_format='Barracuda';
SET GLOBAL innodb_file_per_table=ON;
SET innodb_strict_mode=ON;
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
WHERE TABLE_NAME='bug54679';
TABLE_NAME ROW_FORMAT CREATE_OPTIONS
bug54679 Compressed row_format=COMPRESSED
ALTER TABLE bug54679 ADD COLUMN b INT;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
WHERE TABLE_NAME='bug54679';
TABLE_NAME ROW_FORMAT CREATE_OPTIONS
bug54679 Compressed row_format=COMPRESSED
DROP TABLE bug54679;
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
WHERE TABLE_NAME='bug54679';
TABLE_NAME ROW_FORMAT CREATE_OPTIONS
bug54679 Compact
ALTER TABLE bug54679 KEY_BLOCK_SIZE=1;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
WHERE TABLE_NAME='bug54679';
TABLE_NAME ROW_FORMAT CREATE_OPTIONS
bug54679 Compressed KEY_BLOCK_SIZE=1
ALTER TABLE bug54679 ROW_FORMAT=REDUNDANT;
ERROR HY000: Can't create table '#sql-temporary' (errno: 1478)
SHOW WARNINGS;
Level Code Message
Warning 1478 InnoDB: cannot specify ROW_FORMAT = REDUNDANT with KEY_BLOCK_SIZE.
Error 1005 Can't create table '#sql-temporary' (errno: 1478)
DROP TABLE bug54679;
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
WHERE TABLE_NAME='bug54679';
TABLE_NAME ROW_FORMAT CREATE_OPTIONS
bug54679 Redundant row_format=REDUNDANT
ALTER TABLE bug54679 KEY_BLOCK_SIZE=2;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
WHERE TABLE_NAME='bug54679';
TABLE_NAME ROW_FORMAT CREATE_OPTIONS
bug54679 Compressed row_format=REDUNDANT KEY_BLOCK_SIZE=2
SET GLOBAL innodb_file_format=Antelope;
ALTER TABLE bug54679 KEY_BLOCK_SIZE=4;
ERROR HY000: Can't create table '#sql-temporary' (errno: 1478)
SHOW WARNINGS;
Level Code Message
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
Error 1005 Can't create table '#sql-temporary' (errno: 1478)
ALTER TABLE bug54679 ROW_FORMAT=DYNAMIC;
ERROR HY000: Can't create table '#sql-temporary' (errno: 1478)
SHOW WARNINGS;
Level Code Message
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
Warning 1478 InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE.
Error 1005 Can't create table '#sql-temporary' (errno: 1478)
DROP TABLE bug54679;
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
ERROR HY000: Can't create table 'test.bug54679' (errno: 1478)
SHOW WARNINGS;
Level Code Message
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
Error 1005 Can't create table 'test.bug54679' (errno: 1478)
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB;
SET GLOBAL innodb_file_format=Barracuda;
SET GLOBAL innodb_file_per_table=OFF;
ALTER TABLE bug54679 KEY_BLOCK_SIZE=4;
ERROR HY000: Can't create table '#sql-temporary' (errno: 1478)
SHOW WARNINGS;
Level Code Message
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
Error 1005 Can't create table '#sql-temporary' (errno: 1478)
ALTER TABLE bug54679 ROW_FORMAT=DYNAMIC;
ERROR HY000: Can't create table '#sql-temporary' (errno: 1478)
SHOW WARNINGS;
Level Code Message
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
Error 1005 Can't create table '#sql-temporary' (errno: 1478)
DROP TABLE bug54679;
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
ERROR HY000: Can't create table 'test.bug54679' (errno: 1478)
SHOW WARNINGS;
Level Code Message
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
Error 1005 Can't create table 'test.bug54679' (errno: 1478)
SET GLOBAL innodb_file_per_table=ON;
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
DROP TABLE bug54679;
SET GLOBAL innodb_file_format=Antelope;
SET GLOBAL innodb_file_format_check=Antelope;
SET GLOBAL innodb_file_per_table=0;
This diff is collapsed.
......@@ -173,9 +173,7 @@ set innodb_strict_mode = on;
#Test different values of KEY_BLOCK_SIZE
--error ER_CANT_CREATE_TABLE
create table t1 (id int primary key) engine = innodb key_block_size = 0;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb key_block_size = 9;
......@@ -196,7 +194,7 @@ create table t11(id int primary key) engine = innodb row_format = redundant;
SELECT table_schema, table_name, row_format
FROM information_schema.tables WHERE engine='innodb';
drop table t3, t4, t5, t6, t7, t8, t9, t10, t11;
drop table t1, t3, t4, t5, t6, t7, t8, t9, t10, t11;
#test different values of ROW_FORMAT with KEY_BLOCK_SIZE
create table t1 (id int primary key) engine = innodb
......@@ -217,14 +215,12 @@ create table t4 (id int primary key) engine = innodb
key_block_size = 8 row_format = dynamic;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t5 (id int primary key) engine = innodb
key_block_size = 8 row_format = default;
show warnings;
SELECT table_schema, table_name, row_format
FROM information_schema.tables WHERE engine='innodb';
drop table t1;
drop table t1, t5;
#test multiple errors
--error ER_CANT_CREATE_TABLE
......
# Test Bug #54679 alter table causes compressed row_format to revert to compact
--source include/have_innodb_plugin.inc
let $file_format=`select @@innodb_file_format`;
let $file_format_check=`select @@innodb_file_format_check`;
let $file_per_table=`select @@innodb_file_per_table`;
SET GLOBAL innodb_file_format='Barracuda';
SET GLOBAL innodb_file_per_table=ON;
SET innodb_strict_mode=ON;
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
WHERE TABLE_NAME='bug54679';
# The ROW_FORMAT of the table should be preserved when it is not specified
# in ALTER TABLE.
ALTER TABLE bug54679 ADD COLUMN b INT;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
WHERE TABLE_NAME='bug54679';
DROP TABLE bug54679;
# Check that the ROW_FORMAT conversion to/from COMPRESSED works.
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
WHERE TABLE_NAME='bug54679';
# KEY_BLOCK_SIZE implies COMPRESSED.
ALTER TABLE bug54679 KEY_BLOCK_SIZE=1;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
WHERE TABLE_NAME='bug54679';
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
--error ER_CANT_CREATE_TABLE
ALTER TABLE bug54679 ROW_FORMAT=REDUNDANT;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
SHOW WARNINGS;
DROP TABLE bug54679;
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
WHERE TABLE_NAME='bug54679';
ALTER TABLE bug54679 KEY_BLOCK_SIZE=2;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
WHERE TABLE_NAME='bug54679';
# This prevents other than REDUNDANT or COMPACT ROW_FORMAT for new tables.
SET GLOBAL innodb_file_format=Antelope;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
--error ER_CANT_CREATE_TABLE
ALTER TABLE bug54679 KEY_BLOCK_SIZE=4;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
SHOW WARNINGS;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
--error ER_CANT_CREATE_TABLE
ALTER TABLE bug54679 ROW_FORMAT=DYNAMIC;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
SHOW WARNINGS;
DROP TABLE bug54679;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
--error ER_CANT_CREATE_TABLE
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
SHOW WARNINGS;
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB;
SET GLOBAL innodb_file_format=Barracuda;
# This will prevent ROW_FORMAT=COMPRESSED, because the system tablespace
# cannot be compressed.
SET GLOBAL innodb_file_per_table=OFF;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
--error ER_CANT_CREATE_TABLE
ALTER TABLE bug54679 KEY_BLOCK_SIZE=4;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
SHOW WARNINGS;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
--error ER_CANT_CREATE_TABLE
ALTER TABLE bug54679 ROW_FORMAT=DYNAMIC;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
SHOW WARNINGS;
DROP TABLE bug54679;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
--error ER_CANT_CREATE_TABLE
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
SHOW WARNINGS;
SET GLOBAL innodb_file_per_table=ON;
CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
DROP TABLE bug54679;
EVAL SET GLOBAL innodb_file_format=$file_format;
EVAL SET GLOBAL innodb_file_format_check=$file_format_check;
EVAL SET GLOBAL innodb_file_per_table=$file_per_table;
#
# Bug#56632: ALTER TABLE implicitly changes ROW_FORMAT to COMPRESSED
# http://bugs.mysql.com/56632
#
# Innodb automatically uses compressed mode when the KEY_BLOCK_SIZE
# parameter is used, except if the ROW_FORMAT is also specified, in
# which case the KEY_BLOCK_SIZE is ignored and a warning is shown.
# But Innodb was getting confused when neither of those parameters
# was used on the ALTER statement after they were both used on the
# CREATE.
#
# This will test the results of all 4 combinations of these two
# parameters of the CREATE and ALTER.
#
# Tests 1-5 use INNODB_STRICT_MODE=1 which returns an error
# if there is anything wrong with the statement.
#
# 1) CREATE with ROW_FORMAT=COMPACT & KEY_BLOCK_SIZE=1, ALTER with neither.
# Result; CREATE; fails with error ER_CANT_CREATE_TABLE
# 2) CREATE with ROW_FORMAT=COMPACT, ALTER with KEY_BLOCK_SIZE=1
# Result; CREATE succeeds,
# ALTER quietly converts ROW_FORMAT to compressed.
# 3) CREATE with KEY_BLOCK_SIZE=1, ALTER with ROW_FORMAT=COMPACT
# Result; CREATE quietly converts ROW_FORMAT to compressed,
# ALTER fails with error ER_CANT_CREATE_TABLE.
# 4) CREATE with neither, ALTER with ROW_FORMAT=COMPACT & KEY_BLOCK_SIZE=1
# Result; CREATE succeeds,
# ALTER; fails with error ER_CANT_CREATE_TABLE
# 5) CREATE with KEY_BLOCK_SIZE=3 (invalid), ALTER with neither.
# Result; CREATE; fails with error ER_CANT_CREATE_TABLE
#
# Tests 6-11 use INNODB_STRICT_MODE=0 which automatically makes
# adjustments if the prameters are incompatible.
#
# 6) CREATE with ROW_FORMAT=COMPACT & KEY_BLOCK_SIZE=1, ALTER with neither.
# Result; CREATE succeeds, warns that KEY_BLOCK_SIZE is ignored.
# ALTER succeeds, no warnings.
# 7) CREATE with ROW_FORMAT=COMPACT, ALTER with KEY_BLOCK_SIZE=1
# Result; CREATE succeeds,
# ALTER quietly converts ROW_FORMAT to compressed.
# 8) CREATE with KEY_BLOCK_SIZE=1, ALTER with ROW_FORMAT=COMPACT
# Result; CREATE quietly converts ROW_FORMAT to compressed,
# ALTER succeeds, warns that KEY_BLOCK_SIZE is ignored.
# 9) CREATE with neither, ALTER with ROW_FORMAT=COMPACT & KEY_BLOCK_SIZE=1
# Result; CREATE succeeds,
# ALTER succeeds, warns that KEY_BLOCK_SIZE is ignored.
# 10) CREATE with KEY_BLOCK_SIZE=3 (invalid), ALTER with neither.
# Result; CREATE succeeds, warns that KEY_BLOCK_SIZE=3 is ignored.
# ALTER succeeds, warns that KEY_BLOCK_SIZE=3 is ignored.
# 11) CREATE with KEY_BLOCK_SIZE=3 (invalid), ALTER with ROW_FORMAT=COMPACT.
# Result; CREATE succeeds, warns that KEY_BLOCK_SIZE=3 is ignored.
# ALTER succeeds, warns that KEY_BLOCK_SIZE=3 is ignored.
# 12) CREATE with KEY_BLOCK_SIZE=3 (invalid), ALTER with KEY_BLOCK_SIZE=1.
# Result; CREATE succeeds, warns that KEY_BLOCK_SIZE=3 is ignored.
# ALTER succeeds, quietly converts ROW_FORMAT to compressed.
-- source include/have_innodb_plugin.inc
SET storage_engine=InnoDB;
--disable_query_log
# These values can change during the test
LET $innodb_file_format_orig=`select @@innodb_file_format`;
LET $innodb_file_format_check_orig=`select @@innodb_file_format_check`;
LET $innodb_file_per_table_orig=`select @@innodb_file_per_table`;
LET $innodb_strict_mode_orig=`select @@session.innodb_strict_mode`;
--enable_query_log
SET GLOBAL innodb_file_format=`Barracuda`;
SET GLOBAL innodb_file_per_table=ON;
# Innodb strict mode will cause an error on the CREATE or ALTER when;
# 1. both ROW_FORMAT=COMPACT and KEY_BLOCK_SIZE=1,
# 2. KEY_BLOCK_SIZE is not a valid number (0,1,2,4,8,16).
# With innodb_strict_mode = OFF, These errors are corrected
# and just a warning is returned.
SET SESSION innodb_strict_mode = ON;
--echo # Test 1) CREATE with ROW_FORMAT & KEY_BLOCK_SIZE, ALTER with neither
DROP TABLE IF EXISTS bug56632;
--error ER_CANT_CREATE_TABLE
CREATE TABLE bug56632 ( i INT ) ROW_FORMAT=COMPACT KEY_BLOCK_SIZE=1;
SHOW WARNINGS;
--echo # Test 2) CREATE with ROW_FORMAT, ALTER with KEY_BLOCK_SIZE
DROP TABLE IF EXISTS bug56632;
CREATE TABLE bug56632 ( i INT ) ROW_FORMAT=COMPACT;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
ALTER TABLE bug56632 KEY_BLOCK_SIZE=1;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
--echo # Test 3) CREATE with KEY_BLOCK_SIZE, ALTER with ROW_FORMAT
DROP TABLE IF EXISTS bug56632;
CREATE TABLE bug56632 ( i INT ) KEY_BLOCK_SIZE=1;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
--disable_result_log
--error ER_CANT_CREATE_TABLE
ALTER TABLE bug56632 ROW_FORMAT=COMPACT;
--enable_result_log
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
--echo # Test 4) CREATE with neither, ALTER with ROW_FORMAT & KEY_BLOCK_SIZE
DROP TABLE IF EXISTS bug56632;
CREATE TABLE bug56632 ( i INT );
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
--disable_result_log
--error ER_CANT_CREATE_TABLE
ALTER TABLE bug56632 ROW_FORMAT=COMPACT KEY_BLOCK_SIZE=1;
--enable_result_log
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
--echo # Test 5) CREATE with KEY_BLOCK_SIZE=3 (invalid).
DROP TABLE IF EXISTS bug56632;
--error ER_CANT_CREATE_TABLE
CREATE TABLE bug56632 ( i INT ) KEY_BLOCK_SIZE=3;
SHOW WARNINGS;
SET SESSION innodb_strict_mode = OFF;
--echo # Test 6) CREATE with ROW_FORMAT & KEY_BLOCK_SIZE, ALTER with neither
DROP TABLE IF EXISTS bug56632;
CREATE TABLE bug56632 ( i INT ) ROW_FORMAT=COMPACT KEY_BLOCK_SIZE=1;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
ALTER TABLE bug56632 ADD COLUMN f1 INT;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
--echo # Test 7) CREATE with ROW_FORMAT, ALTER with KEY_BLOCK_SIZE
DROP TABLE IF EXISTS bug56632;
CREATE TABLE bug56632 ( i INT ) ROW_FORMAT=COMPACT;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
ALTER TABLE bug56632 KEY_BLOCK_SIZE=1;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
--echo # Test 8) CREATE with KEY_BLOCK_SIZE, ALTER with ROW_FORMAT
DROP TABLE IF EXISTS bug56632;
CREATE TABLE bug56632 ( i INT ) KEY_BLOCK_SIZE=1;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
ALTER TABLE bug56632 ROW_FORMAT=COMPACT;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
--echo # Test 9) CREATE with neither, ALTER with ROW_FORMAT & KEY_BLOCK_SIZE
DROP TABLE IF EXISTS bug56632;
CREATE TABLE bug56632 ( i INT );
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
ALTER TABLE bug56632 ROW_FORMAT=COMPACT KEY_BLOCK_SIZE=1;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
--echo # Test 10) CREATE with KEY_BLOCK_SIZE=3 (invalid), ALTER with neither.
DROP TABLE IF EXISTS bug56632;
CREATE TABLE bug56632 ( i INT ) KEY_BLOCK_SIZE=3;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
ALTER TABLE bug56632 ADD COLUMN f1 INT;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
--echo # Test 11) CREATE with KEY_BLOCK_SIZE=3 (invalid), ALTER with ROW_FORMAT=COMPACT.
DROP TABLE IF EXISTS bug56632;
CREATE TABLE bug56632 ( i INT ) KEY_BLOCK_SIZE=3;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
ALTER TABLE bug56632 ROW_FORMAT=COMPACT;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
--echo # Test 12) CREATE with KEY_BLOCK_SIZE=3 (invalid), ALTER with KEY_BLOCK_SIZE=1.
DROP TABLE IF EXISTS bug56632;
CREATE TABLE bug56632 ( i INT ) KEY_BLOCK_SIZE=3;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
ALTER TABLE bug56632 KEY_BLOCK_SIZE=1;
SHOW WARNINGS;
SHOW CREATE TABLE bug56632;
SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 'bug56632';
--echo # Cleanup
DROP TABLE IF EXISTS bug56632;
--disable_query_log
EVAL SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig;
EVAL SET GLOBAL innodb_file_format=$innodb_file_format_orig;
EVAL SET GLOBAL innodb_file_format_check=$innodb_file_format_check_orig;
EVAL SET SESSION innodb_strict_mode=$innodb_strict_mode_orig;
--enable_query_log
......@@ -6290,6 +6290,33 @@ create_clustered_index_when_no_primary(
return(error);
}
/*****************************************************************//**
Return a display name for the row format
@return row format name */
const char *get_row_format_name(
/*============================*/
enum row_type row_format) /*!< in: Row Format */
{
switch (row_format) {
case ROW_TYPE_COMPACT:
return("COMPACT");
case ROW_TYPE_COMPRESSED:
return("COMPRESSED");
case ROW_TYPE_DYNAMIC:
return("DYNAMIC");
case ROW_TYPE_REDUNDANT:
return("REDUNDANT");
case ROW_TYPE_DEFAULT:
return("DEFAULT");
case ROW_TYPE_FIXED:
return("FIXED");
default:
break;
}
return("NOT USED");
}
/*****************************************************************//**
Validates the create options. We may build on this function
in future. For now, it checks two specifiers:
......@@ -6307,7 +6334,7 @@ create_options_are_valid(
{
ibool kbs_specified = FALSE;
ibool ret = TRUE;
enum row_type row_type = form->s->row_type;
ut_ad(thd != NULL);
......@@ -6316,13 +6343,28 @@ create_options_are_valid(
return(TRUE);
}
/* Check for a valid Innodb ROW_FORMAT specifier. For example,
ROW_TYPE_FIXED can be sent to Innodb */
switch (row_type) {
case ROW_TYPE_COMPACT:
case ROW_TYPE_COMPRESSED:
case ROW_TYPE_DYNAMIC:
case ROW_TYPE_REDUNDANT:
case ROW_TYPE_DEFAULT:
break;
default:
push_warning(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: invalid ROW_FORMAT specifier.");
ret = FALSE;
}
ut_ad(form != NULL);
ut_ad(create_info != NULL);
/* First check if KEY_BLOCK_SIZE was specified. */
if (create_info->key_block_size
|| (create_info->used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE)) {
/* First check if a non-zero KEY_BLOCK_SIZE was specified. */
if (create_info->key_block_size) {
kbs_specified = TRUE;
switch (create_info->key_block_size) {
case 1:
......@@ -6333,12 +6375,11 @@ create_options_are_valid(
/* Valid value. */
break;
default:
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
push_warning_printf(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: invalid"
" KEY_BLOCK_SIZE = %lu."
" Valid values are"
" [1, 2, 4, 8, 16]",
"InnoDB: invalid KEY_BLOCK_SIZE = %lu."
" Valid values are [1, 2, 4, 8, 16]",
create_info->key_block_size);
ret = FALSE;
}
......@@ -6347,7 +6388,8 @@ create_options_are_valid(
/* If KEY_BLOCK_SIZE was specified, check for its
dependencies. */
if (kbs_specified && !srv_file_per_table) {
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
push_warning(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: KEY_BLOCK_SIZE"
" requires innodb_file_per_table.");
......@@ -6355,101 +6397,58 @@ create_options_are_valid(
}
if (kbs_specified && srv_file_format < DICT_TF_FORMAT_ZIP) {
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
push_warning(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: KEY_BLOCK_SIZE"
" requires innodb_file_format >"
" Antelope.");
"InnoDB: KEY_BLOCK_SIZE requires"
" innodb_file_format > Antelope.");
ret = FALSE;
}
/* Now check for ROW_FORMAT specifier. */
if (create_info->used_fields & HA_CREATE_USED_ROW_FORMAT) {
switch (form->s->row_type) {
const char* row_format_name;
switch (row_type) {
case ROW_TYPE_COMPRESSED:
case ROW_TYPE_DYNAMIC:
row_format_name
= form->s->row_type == ROW_TYPE_COMPRESSED
? "COMPRESSED"
: "DYNAMIC";
/* These two ROW_FORMATs require srv_file_per_table
and srv_file_format > Antelope */
if (!srv_file_per_table) {
push_warning_printf(
thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: ROW_FORMAT=%s"
" requires innodb_file_per_table.",
row_format_name);
get_row_format_name(row_type));
ret = FALSE;
}
if (srv_file_format < DICT_TF_FORMAT_ZIP) {
push_warning_printf(
thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: ROW_FORMAT=%s"
" requires innodb_file_format >"
" Antelope.",
row_format_name);
"InnoDB: ROW_FORMAT=%s requires"
" innodb_file_format > Antelope.",
get_row_format_name(row_type));
ret = FALSE;
}
/* Cannot specify KEY_BLOCK_SIZE with
ROW_FORMAT = DYNAMIC.
However, we do allow COMPRESSED to be
specified with KEY_BLOCK_SIZE. */
if (kbs_specified
&& form->s->row_type == ROW_TYPE_DYNAMIC) {
push_warning_printf(
thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: cannot specify"
" ROW_FORMAT = DYNAMIC with"
" KEY_BLOCK_SIZE.");
ret = FALSE;
}
default:
break;
}
switch (row_type) {
case ROW_TYPE_REDUNDANT:
case ROW_TYPE_COMPACT:
case ROW_TYPE_DEFAULT:
/* Default is COMPACT. */
row_format_name
= form->s->row_type == ROW_TYPE_REDUNDANT
? "REDUNDANT"
: "COMPACT";
/* Cannot specify KEY_BLOCK_SIZE with these
format specifiers. */
case ROW_TYPE_DYNAMIC:
/* KEY_BLOCK_SIZE is only allowed with Compressed or Default */
if (kbs_specified) {
push_warning_printf(
thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: cannot specify"
" ROW_FORMAT = %s with"
" KEY_BLOCK_SIZE.",
row_format_name);
"InnoDB: cannot specify ROW_FORMAT = %s"
" with KEY_BLOCK_SIZE.",
get_row_format_name(row_type));
ret = FALSE;
}
break;
default:
push_warning(thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: invalid ROW_FORMAT specifier.");
ret = FALSE;
}
break;
}
return(ret);
......@@ -6575,8 +6574,7 @@ ha_innobase::create(
goto cleanup;
}
if (create_info->key_block_size
|| (create_info->used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE)) {
if (create_info->key_block_size) {
/* Determine the page_zip.ssize corresponding to the
requested page size (key_block_size) in kilobytes. */
......@@ -6597,7 +6595,8 @@ ha_innobase::create(
}
if (!srv_file_per_table) {
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
push_warning(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: KEY_BLOCK_SIZE"
" requires innodb_file_per_table.");
......@@ -6605,16 +6604,17 @@ ha_innobase::create(
}
if (file_format < DICT_TF_FORMAT_ZIP) {
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
push_warning(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: KEY_BLOCK_SIZE"
" requires innodb_file_format >"
" Antelope.");
"InnoDB: KEY_BLOCK_SIZE requires"
" innodb_file_format > Antelope.");
flags = 0;
}
if (!flags) {
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
push_warning_printf(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: ignoring"
" KEY_BLOCK_SIZE=%lu.",
......@@ -6625,10 +6625,9 @@ ha_innobase::create(
row_type = form->s->row_type;
if (flags) {
/* if KEY_BLOCK_SIZE was specified on this statement and
ROW_FORMAT was not, automatically change ROW_FORMAT to COMPRESSED.*/
if ( (create_info->used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE)
&& !(create_info->used_fields & HA_CREATE_USED_ROW_FORMAT)) {
/* if ROW_FORMAT is set to default,
automatically change it to COMPRESSED.*/
if (row_type == ROW_TYPE_DEFAULT) {
row_type = ROW_TYPE_COMPRESSED;
} else if (row_type != ROW_TYPE_COMPRESSED) {
/* ROW_FORMAT other than COMPRESSED
......@@ -6638,8 +6637,7 @@ ha_innobase::create(
such combinations can be obtained
with ALTER TABLE anyway. */
push_warning_printf(
thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: ignoring KEY_BLOCK_SIZE=%lu"
" unless ROW_FORMAT=COMPRESSED.",
......@@ -6664,33 +6662,24 @@ ha_innobase::create(
}
switch (row_type) {
const char* row_format_name;
case ROW_TYPE_REDUNDANT:
break;
case ROW_TYPE_COMPRESSED:
case ROW_TYPE_DYNAMIC:
row_format_name
= row_type == ROW_TYPE_COMPRESSED
? "COMPRESSED"
: "DYNAMIC";
if (!srv_file_per_table) {
push_warning_printf(
thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: ROW_FORMAT=%s"
" requires innodb_file_per_table.",
row_format_name);
"InnoDB: ROW_FORMAT=%s requires"
" innodb_file_per_table.",
get_row_format_name(row_type));
} else if (file_format < DICT_TF_FORMAT_ZIP) {
push_warning_printf(
thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: ROW_FORMAT=%s"
" requires innodb_file_format >"
" Antelope.",
row_format_name);
"InnoDB: ROW_FORMAT=%s requires"
" innodb_file_format > Antelope.",
get_row_format_name(row_type));
} else {
flags |= DICT_TF_COMPACT
| (DICT_TF_FORMAT_ZIP
......@@ -6702,8 +6691,8 @@ ha_innobase::create(
case ROW_TYPE_NOT_USED:
case ROW_TYPE_FIXED:
default:
push_warning(thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
push_warning(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: assuming ROW_FORMAT=COMPACT.");
case ROW_TYPE_DEFAULT:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment