mirror of
https://github.com/MariaDB/server.git
synced 2025-05-28 13:01:41 +03:00
Let us introduce the parameter innodb_read_only_compressed that is ON by default, making any ROW_FORMAT=COMPRESSED tables read-only. I developed the ROW_FORMAT=COMPRESSED format based on Heikki Tuuri's rough design between 2005 and 2008. It might have been a good idea back then, but no proper benchmarks were ever run to validate the design or the implementation. The format has been more or less obsolete for years. It limits innodb_page_size to 16384 bytes (the default), and instant ALTER TABLE is not supported. This is the first step towards deprecating and removing write support for ROW_FORMAT=COMPRESSED tables.
173 lines
4.7 KiB
Plaintext
173 lines
4.7 KiB
Plaintext
--source include/have_innodb.inc
|
|
|
|
SET @row_format = @@GLOBAL.innodb_default_row_format;
|
|
|
|
# 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;
|
|
|
|
# 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
|
|
--copy_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.ibd
|
|
--move_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.cfg
|
|
|
|
call mtr.add_suppression("InnoDB: Tried to read .* bytes at offset 0");
|
|
|
|
--error ER_INTERNAL_ERROR
|
|
ALTER TABLE tab IMPORT TABLESPACE;
|
|
--remove_file $MYSQLD_DATADIR/test/tab.ibd
|
|
--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;
|
|
|
|
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;
|
|
|
|
SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed;
|
|
SET GLOBAL innodb_read_only_compressed=ON;
|
|
|
|
--error ER_UNSUPPORTED_COMPRESSED_TABLE
|
|
ALTER TABLE tab ROW_FORMAT=COMPRESSED;
|
|
SET GLOBAL innodb_read_only_compressed=OFF;
|
|
ALTER TABLE tab ROW_FORMAT=COMPRESSED;
|
|
SET GLOBAL innodb_read_only_compressed=ON;
|
|
|
|
# Check by SELECT, no errors
|
|
SELECT * FROM tab;
|
|
|
|
ALTER TABLE tab ROW_FORMAT=Dynamic;
|
|
SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed;
|
|
|
|
# Check no errors
|
|
--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;
|