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.
99 lines
4.6 KiB
Plaintext
99 lines
4.6 KiB
Plaintext
call mtr.add_suppression("Index for table 'tab' is corrupt; try to repair it");
|
|
SET @row_format = @@GLOBAL.innodb_default_row_format;
|
|
# ###########################################################
|
|
# Check with Import/Export tablespace with Default_row_format
|
|
SET GLOBAL innodb_default_row_format=Compact;
|
|
SELECT @@innodb_default_row_format;
|
|
@@innodb_default_row_format
|
|
compact
|
|
SELECT @@innodb_file_per_table;
|
|
@@innodb_file_per_table
|
|
1
|
|
CREATE TABLE tab(a INT) ENGINE=InnoDB;
|
|
SHOW TABLE STATUS LIKE 'tab';
|
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
|
|
tab InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL 0 N
|
|
INSERT INTO tab VALUES(1);
|
|
INSERT INTO tab VALUES(2);
|
|
SELECT * FROM tab;
|
|
a
|
|
1
|
|
2
|
|
FLUSH TABLE tab FOR EXPORT;
|
|
UNLOCK TABLES;
|
|
DROP TABLE tab;
|
|
SET GLOBAL innodb_default_row_format=Dynamic;
|
|
CREATE TABLE tab(a INT) ENGINE=InnoDB;
|
|
ALTER TABLE tab DISCARD TABLESPACE;
|
|
ALTER TABLE tab IMPORT TABLESPACE;
|
|
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1; .cfg file uses ROW_FORMAT=COMPACT)
|
|
DROP TABLE tab;
|
|
SET GLOBAL innodb_default_row_format=Compact;
|
|
SELECT @@innodb_default_row_format;
|
|
@@innodb_default_row_format
|
|
compact
|
|
CREATE TABLE tab(a INT) ENGINE=InnoDB;
|
|
SHOW TABLE STATUS LIKE 'tab';
|
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
|
|
tab InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL 0 N
|
|
ALTER TABLE tab DISCARD TABLESPACE;
|
|
call mtr.add_suppression("InnoDB: Tried to read .* bytes at offset 0");
|
|
ALTER TABLE tab IMPORT TABLESPACE;
|
|
ERROR HY000: Index for table 'tab' is corrupt; try to repair it
|
|
ALTER TABLE tab IMPORT TABLESPACE;
|
|
SELECT * FROM tab;
|
|
a
|
|
1
|
|
2
|
|
DROP TABLE tab;
|
|
# ###########################################################
|
|
SET GLOBAL innodb_default_row_format=Dynamic;
|
|
SELECT @@innodb_default_row_format;
|
|
@@innodb_default_row_format
|
|
dynamic
|
|
CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(3070))) ENGINE= InnoDB;
|
|
SHOW TABLE STATUS LIKE 'tab';
|
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
|
|
tab InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL 0 N
|
|
INSERT INTO tab(a,b) VALUES(1,'Check with max column size');
|
|
SELECT * FROM tab;
|
|
a b
|
|
1 Check with max column size
|
|
SET GLOBAL innodb_default_row_format=COMPACT;
|
|
ALTER TABLE tab ROW_FORMAT=COMPACT;
|
|
ERROR HY000: Index column size too large. The maximum column size is 767 bytes
|
|
DROP TABLE tab;
|
|
SET GLOBAL innodb_default_row_format=Default;
|
|
SELECT @@innodb_default_row_format;
|
|
@@innodb_default_row_format
|
|
dynamic
|
|
SET GLOBAL innodb_default_row_format=Dynamic;
|
|
SELECT @@innodb_default_row_format;
|
|
@@innodb_default_row_format
|
|
dynamic
|
|
CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(767))) ENGINE= InnoDB;
|
|
SHOW TABLE STATUS LIKE 'tab';
|
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
|
|
tab InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL 0 N
|
|
INSERT INTO tab(a,b) VALUES(1,'Check with max column size');
|
|
SELECT * FROM tab;
|
|
a b
|
|
1 Check with max column size
|
|
ALTER TABLE tab ROW_FORMAT=COMPACT;
|
|
SHOW TABLE STATUS LIKE 'tab';
|
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
|
|
tab InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPACT 0 N
|
|
SELECT * FROM tab;
|
|
a b
|
|
1 Check with max column size
|
|
ALTER TABLE tab ROW_FORMAT=COMPRESSED;
|
|
SELECT * FROM tab;
|
|
a b
|
|
1 Check with max column size
|
|
ALTER TABLE tab ROW_FORMAT=Dynamic;
|
|
SHOW TABLE STATUS LIKE 'tab';
|
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
|
|
tab InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=DYNAMIC 0 N
|
|
DROP TABLE tab;
|
|
SET GLOBAL innodb_default_row_format = @row_format;
|