| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/test_db_charset_latin1.inc |
| 3 |
|
| 4 |
call mtr.add_suppression("Index for table 'tab' is corrupt; try to repair it"); |
| 5 |
|
| 6 |
|
| 7 |
SET @row_format = @@GLOBAL.innodb_default_row_format; |
| 8 |
|
| 9 |
# set the variables |
| 10 |
let $MYSQLD_DATADIR = `SELECT @@datadir`; |
| 11 |
|
| 12 |
--echo # ########################################################### |
| 13 |
--echo # Check with Import/Export tablespace with Default_row_format |
| 14 |
|
| 15 |
# Set row_format=Compact |
| 16 |
SET GLOBAL innodb_default_row_format=Compact; |
| 17 |
|
| 18 |
# Check row_format=Compact |
| 19 |
SELECT @@innodb_default_row_format; |
| 20 |
|
| 21 |
# Check file_per_table=1 |
| 22 |
SELECT @@innodb_file_per_table; |
| 23 |
|
| 24 |
CREATE TABLE tab(a INT) ENGINE=InnoDB; |
| 25 |
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # |
| 26 |
SHOW TABLE STATUS LIKE 'tab'; |
| 27 |
|
| 28 |
INSERT INTO tab VALUES(1); |
| 29 |
INSERT INTO tab VALUES(2); |
| 30 |
|
| 31 |
# Check the rows |
| 32 |
SELECT * FROM tab; |
| 33 |
|
| 34 |
FLUSH TABLE tab FOR EXPORT; |
| 35 |
|
| 36 |
# Take the backup of the ibd and cfg files |
| 37 |
--copy_file $MYSQLD_DATADIR/test/tab.cfg $MYSQLD_DATADIR/tab.cfg |
| 38 |
--copy_file $MYSQLD_DATADIR/test/tab.ibd $MYSQLD_DATADIR/tab.ibd |
| 39 |
|
| 40 |
UNLOCK TABLES; |
| 41 |
|
| 42 |
# Cleanup |
| 43 |
DROP TABLE tab; |
| 44 |
|
| 45 |
# Set the default_row_format=Dynamic |
| 46 |
SET GLOBAL innodb_default_row_format=Dynamic; |
| 47 |
|
| 48 |
CREATE TABLE tab(a INT) ENGINE=InnoDB; |
| 49 |
|
| 50 |
# Remove the *.ibd file |
| 51 |
ALTER TABLE tab DISCARD TABLESPACE; |
| 52 |
|
| 53 |
# Move the *.ibd,*.cfg file into original location |
| 54 |
--move_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.cfg |
| 55 |
--move_file $MYSQLD_DATADIR/tab.ibd $MYSQLD_DATADIR/test/tab.ibd |
| 56 |
|
| 57 |
--error ER_TABLE_SCHEMA_MISMATCH |
| 58 |
ALTER TABLE tab IMPORT TABLESPACE; |
| 59 |
|
| 60 |
--move_file $MYSQLD_DATADIR/test/tab.cfg $MYSQLD_DATADIR/tab.cfg |
| 61 |
--move_file $MYSQLD_DATADIR/test/tab.ibd $MYSQLD_DATADIR/tab.ibd |
| 62 |
|
| 63 |
# Cleanup |
| 64 |
DROP TABLE tab; |
| 65 |
|
| 66 |
# Set the default_row_format=Compact |
| 67 |
SET GLOBAL innodb_default_row_format=Compact; |
| 68 |
|
| 69 |
# Check row_format=Compact |
| 70 |
SELECT @@innodb_default_row_format; |
| 71 |
|
| 72 |
CREATE TABLE tab(a INT) ENGINE=InnoDB; |
| 73 |
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # |
| 74 |
SHOW TABLE STATUS LIKE 'tab'; |
| 75 |
|
| 76 |
# Remove the *.ibd file |
| 77 |
ALTER TABLE tab DISCARD TABLESPACE; |
| 78 |
|
| 79 |
# Move the *ibd,*.cfg file into orginal location |
| 80 |
--copy_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.ibd |
| 81 |
--move_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.cfg |
| 82 |
|
| 83 |
call mtr.add_suppression("InnoDB: Tried to read .* bytes at offset 0"); |
| 84 |
|
| 85 |
--error ER_NOT_KEYFILE |
| 86 |
ALTER TABLE tab IMPORT TABLESPACE; |
| 87 |
--remove_file $MYSQLD_DATADIR/test/tab.ibd |
| 88 |
--move_file $MYSQLD_DATADIR/tab.ibd $MYSQLD_DATADIR/test/tab.ibd |
| 89 |
|
| 90 |
# Check import is successful (because same row_format) |
| 91 |
ALTER TABLE tab IMPORT TABLESPACE; |
| 92 |
|
| 93 |
# Check the rows |
| 94 |
SELECT * FROM tab; |
| 95 |
|
| 96 |
# Cleanup |
| 97 |
DROP TABLE tab; |
| 98 |
|
| 99 |
--echo # ########################################################### |
| 100 |
# Check when Index Column size (3070 bytes) is too long, Change row_format |
| 101 |
# Check when Index Column size (767 bytes), Change row_format |
| 102 |
# Dynamic to Compact to Dynamic |
| 103 |
|
| 104 |
# Set the default_row_format=Dynamic |
| 105 |
SET GLOBAL innodb_default_row_format=Dynamic; |
| 106 |
|
| 107 |
SELECT @@innodb_default_row_format; |
| 108 |
|
| 109 |
CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(3070))) ENGINE= InnoDB; |
| 110 |
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # |
| 111 |
SHOW TABLE STATUS LIKE 'tab'; |
| 112 |
|
| 113 |
INSERT INTO tab(a,b) VALUES(1,'Check with max column size'); |
| 114 |
|
| 115 |
# Check by SELECT, no errors |
| 116 |
SELECT * FROM tab; |
| 117 |
|
| 118 |
# Change row_format to Compact |
| 119 |
SET GLOBAL innodb_default_row_format=COMPACT; |
| 120 |
|
| 121 |
# Check error ERROR 1709 (HY000): Index column size too large |
| 122 |
-- error ER_INDEX_COLUMN_TOO_LONG |
| 123 |
ALTER TABLE tab ROW_FORMAT=COMPACT; |
| 124 |
|
| 125 |
# Cleanup |
| 126 |
DROP TABLE tab; |
| 127 |
|
| 128 |
# Change the default_row_format to default |
| 129 |
SET GLOBAL innodb_default_row_format=Default; |
| 130 |
SELECT @@innodb_default_row_format; |
| 131 |
SET GLOBAL innodb_default_row_format=Dynamic; |
| 132 |
|
| 133 |
# Change row_format to Dynamic |
| 134 |
SELECT @@innodb_default_row_format; |
| 135 |
|
| 136 |
CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(767))) ENGINE= InnoDB; |
| 137 |
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # |
| 138 |
SHOW TABLE STATUS LIKE 'tab'; |
| 139 |
|
| 140 |
INSERT INTO tab(a,b) VALUES(1,'Check with max column size'); |
| 141 |
|
| 142 |
# Check by SELECT, no errors |
| 143 |
SELECT * FROM tab; |
| 144 |
|
| 145 |
# Check no errors because Compact allows 767 bytes |
| 146 |
ALTER TABLE tab ROW_FORMAT=COMPACT; |
| 147 |
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # |
| 148 |
SHOW TABLE STATUS LIKE 'tab'; |
| 149 |
|
| 150 |
# Check by SELECT, no errors |
| 151 |
SELECT * FROM tab; |
| 152 |
|
| 153 |
SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; |
| 154 |
SET GLOBAL innodb_read_only_compressed=ON; |
| 155 |
|
| 156 |
--error ER_UNSUPPORTED_COMPRESSED_TABLE |
| 157 |
ALTER TABLE tab ROW_FORMAT=COMPRESSED; |
| 158 |
SET GLOBAL innodb_read_only_compressed=OFF; |
| 159 |
ALTER TABLE tab ROW_FORMAT=COMPRESSED; |
| 160 |
SET GLOBAL innodb_read_only_compressed=ON; |
| 161 |
|
| 162 |
# Check by SELECT, no errors |
| 163 |
SELECT * FROM tab; |
| 164 |
|
| 165 |
ALTER TABLE tab ROW_FORMAT=Dynamic; |
| 166 |
SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; |
| 167 |
|
| 168 |
# Check no errors |
| 169 |
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # |
| 170 |
SHOW TABLE STATUS LIKE 'tab'; |
| 171 |
|
| 172 |
# Cleanup |
| 173 |
DROP TABLE tab; |
| 174 |
|
| 175 |
SET GLOBAL innodb_default_row_format = @row_format; |
| 176 |
|
| 177 |
--source include/test_db_charset_restore.inc |