mirror of
https://github.com/MariaDB/server.git
synced 2025-12-06 05:42:06 +03:00
InnoDB in Debian uses utf8mb4 as default character set since version 10.0.20-2. This leads to major pain due to keys longer than 767 bytes. MariaDB 10.2 (and MySQL 5.7) introduced the setting innodb_default_row_format that is DYNAMIC by default. These versions also changed the default values of the parameters innodb_large_prefix=ON and innodb_file_format=Barracuda. This would allow longer column index prefixes to be created. The original purpose of these parameters was to allow InnoDB to be downgraded to MySQL 5.1, which is long out of support. Every InnoDB version since MySQL 5.5 does support operation with the relaxed limits. We backport the parameter innodb_default_row_format to MariaDB 10.1, but we will keep its default value at COMPACT. This allows MariaDB 10.1 to be configured so that CREATE TABLE is less likely to encounter a problem with the limitation: loose_innodb_large_prefix=ON loose_innodb_default_row_format=DYNAMIC (Note that the setting innodb_large_prefix was deprecated in MariaDB 10.2 and removed in MariaDB 10.3.) The only observable difference in the behaviour with the default settings should be that ROW_FORMAT=DYNAMIC tables can be created both in the system tablespace and in .ibd files, no matter what innodb_file_format has been assigned to. Unlike MariaDB 10.2, we are not changing the default value of innodb_file_format, so ROW_FORMAT=COMPRESSED tables cannot be created without changing the parameter.
168 lines
4.5 KiB
Plaintext
168 lines
4.5 KiB
Plaintext
--source include/have_innodb.inc
|
|
|
|
SET @row_format = @@GLOBAL.innodb_default_row_format;
|
|
SET @large_prefix = @@GLOBAL.innodb_large_prefix;
|
|
SET @file_format = @@GLOBAL.innodb_file_format;
|
|
SET GLOBAL innodb_file_format = barracuda;
|
|
|
|
# set the variables
|
|
let $MYSQLD_DATADIR = `SELECT @@datadir`;
|
|
|
|
--echo # ###########################################################
|
|
--echo # Check with Import/Export tablespace with Default_row_format
|
|
|
|
# Set row_format=Compact
|
|
SET GLOBAL innodb_default_row_format=Compact;
|
|
|
|
# Check row_format=Compact
|
|
SELECT @@innodb_default_row_format;
|
|
|
|
# Check file_per_table=1
|
|
SELECT @@innodb_file_per_table;
|
|
|
|
CREATE TABLE tab(a INT) ENGINE=InnoDB;
|
|
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 #
|
|
SHOW TABLE STATUS LIKE 'tab';
|
|
|
|
INSERT INTO tab VALUES(1);
|
|
INSERT INTO tab VALUES(2);
|
|
|
|
# Check the rows
|
|
SELECT * FROM tab;
|
|
|
|
FLUSH TABLE tab FOR EXPORT;
|
|
|
|
# Take the backup of the ibd and cfg files
|
|
--copy_file $MYSQLD_DATADIR/test/tab.cfg $MYSQLD_DATADIR/tab.cfg
|
|
--copy_file $MYSQLD_DATADIR/test/tab.ibd $MYSQLD_DATADIR/tab.ibd
|
|
|
|
UNLOCK TABLES;
|
|
|
|
# Cleanup
|
|
DROP TABLE tab;
|
|
|
|
# Set the default_row_format=Dynamic
|
|
SET GLOBAL innodb_default_row_format=Dynamic;
|
|
|
|
CREATE TABLE tab(a INT) ENGINE=InnoDB;
|
|
|
|
# Remove the *.ibd file
|
|
ALTER TABLE tab DISCARD TABLESPACE;
|
|
|
|
# Move the *.ibd,*.cfg file into orginal location
|
|
--move_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.cfg
|
|
--move_file $MYSQLD_DATADIR/tab.ibd $MYSQLD_DATADIR/test/tab.ibd
|
|
|
|
--error ER_TABLE_SCHEMA_MISMATCH
|
|
ALTER TABLE tab IMPORT TABLESPACE;
|
|
|
|
# Take the backup of the ibd and cfg files
|
|
--copy_file $MYSQLD_DATADIR/test/tab.cfg $MYSQLD_DATADIR/tab.cfg
|
|
--copy_file $MYSQLD_DATADIR/test/tab.ibd $MYSQLD_DATADIR/tab.ibd
|
|
|
|
# Cleanup
|
|
DROP TABLE tab;
|
|
|
|
# Remove orphan files
|
|
--remove_file $MYSQLD_DATADIR/test/tab.cfg
|
|
--remove_file $MYSQLD_DATADIR/test/tab.ibd
|
|
|
|
# Set the default_row_format=Compact
|
|
SET GLOBAL innodb_default_row_format=Compact;
|
|
|
|
# Check row_format=Compact
|
|
SELECT @@innodb_default_row_format;
|
|
|
|
CREATE TABLE tab(a INT) ENGINE=InnoDB;
|
|
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 #
|
|
SHOW TABLE STATUS LIKE 'tab';
|
|
|
|
# Remove the *.ibd file
|
|
ALTER TABLE tab DISCARD TABLESPACE;
|
|
|
|
# Move the *ibd,*.cfg file into orginal location
|
|
--move_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.cfg
|
|
--move_file $MYSQLD_DATADIR/tab.ibd $MYSQLD_DATADIR/test/tab.ibd
|
|
|
|
# Check import is successful (because same row_format)
|
|
ALTER TABLE tab IMPORT TABLESPACE;
|
|
|
|
# Check the rows
|
|
SELECT * FROM tab;
|
|
|
|
# Cleanup
|
|
DROP TABLE tab;
|
|
|
|
--echo # ###########################################################
|
|
# Check when Index Column size (3070 bytes) is too long, Change row_format
|
|
# Check when Index Column size (767 bytes), Change row_format
|
|
# Dynamic to Compact to Dynamic
|
|
|
|
# Set the default_row_format=Dynamic
|
|
SET GLOBAL innodb_default_row_format=Dynamic;
|
|
SET GLOBAL innodb_large_prefix=ON;
|
|
|
|
SELECT @@innodb_default_row_format;
|
|
|
|
CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(3070))) ENGINE= InnoDB;
|
|
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 #
|
|
SHOW TABLE STATUS LIKE 'tab';
|
|
|
|
INSERT INTO tab(a,b) VALUES(1,'Check with max column size');
|
|
|
|
# Check by SELECT, no errors
|
|
SELECT * FROM tab;
|
|
|
|
# Change row_format to Compact
|
|
SET GLOBAL innodb_default_row_format=COMPACT;
|
|
|
|
# Check error ERROR 1709 (HY000): Index column size too large
|
|
-- error ER_INDEX_COLUMN_TOO_LONG
|
|
ALTER TABLE tab ROW_FORMAT=COMPACT;
|
|
|
|
# Cleanup
|
|
DROP TABLE tab;
|
|
|
|
# Change the default_row_format to default
|
|
SET GLOBAL innodb_default_row_format=Default;
|
|
SELECT @@innodb_default_row_format;
|
|
SET GLOBAL innodb_default_row_format=Dynamic;
|
|
|
|
# Change row_format to Dynamic
|
|
SELECT @@innodb_default_row_format;
|
|
|
|
CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(767))) ENGINE= InnoDB;
|
|
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 #
|
|
SHOW TABLE STATUS LIKE 'tab';
|
|
|
|
INSERT INTO tab(a,b) VALUES(1,'Check with max column size');
|
|
|
|
# Check by SELECT, no errors
|
|
SELECT * FROM tab;
|
|
|
|
# Check no errors because Compact allows 767 bytes
|
|
ALTER TABLE tab ROW_FORMAT=COMPACT;
|
|
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 #
|
|
SHOW TABLE STATUS LIKE 'tab';
|
|
|
|
# Check by SELECT, no errors
|
|
SELECT * FROM tab;
|
|
|
|
# Check no errors
|
|
ALTER TABLE tab ROW_FORMAT=COMPRESSED;
|
|
|
|
# Check by SELECT, no errors
|
|
SELECT * FROM tab;
|
|
|
|
# Check no errors
|
|
ALTER TABLE tab ROW_FORMAT=Dynamic;
|
|
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 #
|
|
SHOW TABLE STATUS LIKE 'tab';
|
|
|
|
# Cleanup
|
|
DROP TABLE tab;
|
|
|
|
SET GLOBAL innodb_default_row_format = @row_format;
|
|
SET GLOBAL innodb_large_prefix = @large_prefix;
|
|
SET GLOBAL innodb_file_format = @file_format;
|