mirror of
https://github.com/MariaDB/server.git
synced 2025-07-20 10:24:14 +03:00
ALTER TABLE IMPORT doesn't properly handle instant alter metadata.
This patch makes IMPORT read, parse and apply instant alter metadata at the
very beginning of operation. So, cases when source table has some metadata
and destination table doesn't have it now works fine.
DISCARD already removes instant metadata so importing normal table into
instant table worked fine before this patch.
decrypt_decompress(): decrypts and decompresses page if needed
handle_instant_metadata(): this should be the first thing to read source
table. Basically, it applies instant metadata to a destination
dict_table_t object. This is the first thing to read FSP flags so
all possible checks of it were moved to this function.
PageConverter::update_index_page(): it doesn't now read instant metadata.
This logic were moved into handle_instant_metadata()
row_import::match_flags(): this is a first part row_import::match_schema().
As a separate function it's used by handle_instant_metadata().
fil_space_t::is_full_crc32_compressed(): added convenient function
ha_innobase::discard_or_import_tablespace(): do not reload table definition
to read instant metadata because handle_instant_metadata() does it better.
The reverted code was originally added in
4e7ee166a9
ANONYMOUS_VAR: this is a handy thing to use along with make_scope_exit()
full_crc32_import.test shows different results, because no
dict_table_close() and dict_table_open_on_id() happens.
Thus, SHOW CREATE TABLE shows a little bit older table definition.
168 lines
4.4 KiB
Plaintext
168 lines
4.4 KiB
Plaintext
--source include/have_innodb.inc
|
|
|
|
call mtr.add_suppression("Index for table 'tab' is corrupt; try to repair it");
|
|
|
|
|
|
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_NOT_KEYFILE
|
|
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;
|
|
|
|
# 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;
|