diff options
Diffstat (limited to 'mysql-test/suite/innodb_zip/t')
32 files changed, 9587 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb_zip/t/blob.test b/mysql-test/suite/innodb_zip/t/blob.test new file mode 100644 index 00000000..4f9117f7 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/blob.test @@ -0,0 +1,25 @@ +--source include/innodb_page_size_small.inc + +--echo # +--echo # MDEV-21259 Assertion 'w != NORMAL || mach_read_from_4(ptr) != val' +--echo # failed in mtr_t::write(), btr_free_externally_stored_field() +--echo # + +CREATE TABLE t1 (c TEXT, f2 INT PRIMARY KEY, f3 INT UNIQUE) +ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +SET @level= @@GLOBAL.innodb_compression_level; +SET GLOBAL innodb_compression_level=0; +--connect (prevent_purge,localhost,root) +START TRANSACTION WITH CONSISTENT SNAPSHOT; + +--connection default +INSERT INTO t1 VALUES('a',1,0); +UPDATE t1 SET c= REPEAT('a b ',4096); +REPLACE INTO t1 SELECT * FROM t1; + +--disconnect prevent_purge +--source ../../innodb/include/wait_all_purged.inc + +DROP TABLE t1; +SET GLOBAL innodb_compression_level = @level; diff --git a/mysql-test/suite/innodb_zip/t/bug36169.test b/mysql-test/suite/innodb_zip/t/bug36169.test new file mode 100644 index 00000000..07566b20 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/bug36169.test @@ -0,0 +1,1161 @@ +# +# Bug#36169 create innodb compressed table with too large row size crashed +# http://bugs.mysql.com/36169 +# + +-- source include/innodb_page_size_small.inc + +let $file_per_table=`select @@innodb_file_per_table`; +SET GLOBAL innodb_file_per_table=ON; + +# +# The following is copied from http://bugs.mysql.com/36169 +# (http://bugs.mysql.com/file.php?id=9121) +# Probably it can be simplified but that is not obvious. +# + +# we care only that the following SQL commands do produce errors +# as expected and do not crash the server +-- disable_query_log +-- disable_result_log +call mtr.add_suppression("Cannot add field .* in table .* because after adding it, the row size is"); +# Generating 10 tables +# Creating a table with 94 columns and 24 indexes +DROP TABLE IF EXISTS `table0`; +set innodb_strict_mode=on; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table0` +(`col0` BOOL, +`col1` BOOL, +`col2` TINYINT, +`col3` DATE, +`col4` TIME, +`col5` SET ('test1','test2','test3'), +`col6` TIME, +`col7` TEXT, +`col8` DECIMAL, +`col9` SET ('test1','test2','test3'), +`col10` FLOAT, +`col11` DOUBLE PRECISION, +`col12` ENUM ('test1','test2','test3'), +`col13` TINYBLOB, +`col14` YEAR, +`col15` SET ('test1','test2','test3'), +`col16` NUMERIC, +`col17` NUMERIC, +`col18` BLOB, +`col19` DATETIME, +`col20` DOUBLE PRECISION, +`col21` DECIMAL, +`col22` DATETIME, +`col23` NUMERIC, +`col24` NUMERIC, +`col25` LONGTEXT, +`col26` TINYBLOB, +`col27` TIME, +`col28` TINYBLOB, +`col29` ENUM ('test1','test2','test3'), +`col30` SMALLINT, +`col31` REAL, +`col32` FLOAT, +`col33` CHAR (175), +`col34` TINYTEXT, +`col35` TINYTEXT, +`col36` TINYBLOB, +`col37` TINYBLOB, +`col38` TINYTEXT, +`col39` MEDIUMBLOB, +`col40` TIMESTAMP, +`col41` DOUBLE, +`col42` SMALLINT, +`col43` LONGBLOB, +`col44` VARCHAR (80), +`col45` MEDIUMTEXT, +`col46` NUMERIC, +`col47` BIGINT, +`col48` DATE, +`col49` TINYBLOB, +`col50` DATE, +`col51` BOOL, +`col52` MEDIUMINT, +`col53` FLOAT, +`col54` TINYBLOB, +`col55` LONGTEXT, +`col56` SMALLINT, +`col57` ENUM ('test1','test2','test3'), +`col58` DATETIME, +`col59` MEDIUMTEXT, +`col60` VARCHAR (232), +`col61` NUMERIC, +`col62` YEAR, +`col63` SMALLINT, +`col64` TIMESTAMP, +`col65` BLOB, +`col66` LONGBLOB, +`col67` INT, +`col68` LONGTEXT, +`col69` ENUM ('test1','test2','test3'), +`col70` INT, +`col71` TIME, +`col72` TIMESTAMP, +`col73` TIMESTAMP, +`col74` VARCHAR (170), +`col75` SET ('test1','test2','test3'), +`col76` TINYBLOB, +`col77` BIGINT, +`col78` NUMERIC, +`col79` DATETIME, +`col80` YEAR, +`col81` NUMERIC, +`col82` LONGBLOB, +`col83` TEXT, +`col84` CHAR (83), +`col85` DECIMAL, +`col86` FLOAT, +`col87` INT, +`col88` VARCHAR (145), +`col89` DATE, +`col90` DECIMAL, +`col91` DECIMAL, +`col92` MEDIUMBLOB, +`col93` TIME, +KEY `idx0` (`col69`,`col90`,`col8`), +KEY `idx1` (`col60`), +KEY `idx2` (`col60`,`col70`,`col74`), +KEY `idx3` (`col22`,`col32`,`col72`,`col30`), +KEY `idx4` (`col29`), +KEY `idx5` (`col19`,`col45`(143)), +KEY `idx6` (`col46`,`col48`,`col5`,`col39`(118)), +KEY `idx7` (`col48`,`col61`), +KEY `idx8` (`col93`), +KEY `idx9` (`col31`), +KEY `idx10` (`col30`,`col21`), +KEY `idx11` (`col67`), +KEY `idx12` (`col44`,`col6`,`col8`,`col38`(226)), +KEY `idx13` (`col71`,`col41`,`col15`,`col49`(88)), +KEY `idx14` (`col78`), +KEY `idx15` (`col63`,`col67`,`col64`), +KEY `idx16` (`col17`,`col86`), +KEY `idx17` (`col77`,`col56`,`col10`,`col55`(24)), +KEY `idx18` (`col62`), +KEY `idx19` (`col31`,`col57`,`col56`,`col53`), +KEY `idx20` (`col46`), +KEY `idx21` (`col83`(54)), +KEY `idx22` (`col51`,`col7`(120)), +KEY `idx23` (`col7`(163),`col31`,`col71`,`col14`) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +SET sql_mode = default; + +# Creating a table with 10 columns and 32 indexes +DROP TABLE IF EXISTS `table1`; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table1` +(`col0` CHAR (113), +`col1` FLOAT, +`col2` BIGINT, +`col3` DECIMAL, +`col4` BLOB, +`col5` LONGTEXT, +`col6` SET ('test1','test2','test3'), +`col7` BIGINT, +`col8` BIGINT, +`col9` TINYBLOB, +KEY `idx0` (`col5`(101),`col7`,`col8`), +KEY `idx1` (`col8`), +KEY `idx2` (`col4`(177),`col9`(126),`col6`,`col3`), +KEY `idx3` (`col5`(160)), +KEY `idx4` (`col9`(242)), +KEY `idx5` (`col4`(139),`col2`,`col3`), +KEY `idx6` (`col7`), +KEY `idx7` (`col6`,`col2`,`col0`,`col3`), +KEY `idx8` (`col9`(66)), +KEY `idx9` (`col5`(253)), +KEY `idx10` (`col1`,`col7`,`col2`), +KEY `idx11` (`col9`(242),`col0`,`col8`,`col5`(163)), +KEY `idx12` (`col8`), +KEY `idx13` (`col0`,`col9`(37)), +KEY `idx14` (`col0`), +KEY `idx15` (`col5`(111)), +KEY `idx16` (`col8`,`col0`,`col5`(13)), +KEY `idx17` (`col4`(139)), +KEY `idx18` (`col5`(189),`col2`,`col3`,`col9`(136)), +KEY `idx19` (`col0`,`col3`,`col1`,`col8`), +KEY `idx20` (`col8`), +KEY `idx21` (`col0`,`col7`,`col9`(227),`col3`), +KEY `idx22` (`col0`), +KEY `idx23` (`col2`), +KEY `idx24` (`col3`), +KEY `idx25` (`col2`,`col3`), +KEY `idx26` (`col0`), +KEY `idx27` (`col5`(254)), +KEY `idx28` (`col3`), +KEY `idx29` (`col3`), +KEY `idx30` (`col7`,`col3`,`col0`,`col4`(220)), +KEY `idx31` (`col4`(1),`col0`) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +# Creating a table with 141 columns and 18 indexes +DROP TABLE IF EXISTS `table2`; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table2` +(`col0` BOOL, +`col1` MEDIUMINT, +`col2` VARCHAR (209), +`col3` MEDIUMBLOB, +`col4` CHAR (13), +`col5` DOUBLE, +`col6` TINYTEXT, +`col7` REAL, +`col8` SMALLINT, +`col9` BLOB, +`col10` TINYINT, +`col11` DECIMAL, +`col12` BLOB, +`col13` DECIMAL, +`col14` LONGBLOB, +`col15` SMALLINT, +`col16` LONGBLOB, +`col17` TINYTEXT, +`col18` FLOAT, +`col19` CHAR (78), +`col20` MEDIUMTEXT, +`col21` SET ('test1','test2','test3'), +`col22` MEDIUMINT, +`col23` INT, +`col24` MEDIUMBLOB, +`col25` ENUM ('test1','test2','test3'), +`col26` TINYBLOB, +`col27` VARCHAR (116), +`col28` TIMESTAMP, +`col29` BLOB, +`col30` SMALLINT, +`col31` DOUBLE PRECISION, +`col32` DECIMAL, +`col33` DECIMAL, +`col34` TEXT, +`col35` MEDIUMINT, +`col36` MEDIUMINT, +`col37` BIGINT, +`col38` VARCHAR (253), +`col39` TINYBLOB, +`col40` MEDIUMBLOB, +`col41` BIGINT, +`col42` DOUBLE, +`col43` TEXT, +`col44` BLOB, +`col45` TIME, +`col46` MEDIUMINT, +`col47` DOUBLE PRECISION, +`col48` SET ('test1','test2','test3'), +`col49` DOUBLE PRECISION, +`col50` VARCHAR (97), +`col51` TEXT, +`col52` NUMERIC, +`col53` ENUM ('test1','test2','test3'), +`col54` MEDIUMTEXT, +`col55` MEDIUMINT, +`col56` DATETIME, +`col57` DATETIME, +`col58` MEDIUMTEXT, +`col59` CHAR (244), +`col60` LONGBLOB, +`col61` MEDIUMBLOB, +`col62` DOUBLE, +`col63` SMALLINT, +`col64` BOOL, +`col65` SMALLINT, +`col66` VARCHAR (212), +`col67` TIME, +`col68` REAL, +`col69` BOOL, +`col70` BIGINT, +`col71` DATE, +`col72` TINYINT, +`col73` ENUM ('test1','test2','test3'), +`col74` DATE, +`col75` TIME, +`col76` DATETIME, +`col77` BOOL, +`col78` TINYTEXT, +`col79` MEDIUMINT, +`col80` NUMERIC, +`col81` LONGTEXT, +`col82` SET ('test1','test2','test3'), +`col83` DOUBLE PRECISION, +`col84` NUMERIC, +`col85` VARCHAR (184), +`col86` DOUBLE PRECISION, +`col87` MEDIUMTEXT, +`col88` MEDIUMBLOB, +`col89` BOOL, +`col90` SMALLINT, +`col91` TINYINT, +`col92` ENUM ('test1','test2','test3'), +`col93` BOOL, +`col94` TIMESTAMP, +`col95` BOOL, +`col96` MEDIUMTEXT, +`col97` DECIMAL, +`col98` BOOL, +`col99` DECIMAL, +`col100` MEDIUMINT, +`col101` DOUBLE PRECISION, +`col102` TINYINT, +`col103` BOOL, +`col104` MEDIUMINT, +`col105` DECIMAL, +`col106` NUMERIC, +`col107` TIMESTAMP, +`col108` MEDIUMBLOB, +`col109` TINYBLOB, +`col110` SET ('test1','test2','test3'), +`col111` YEAR, +`col112` TIMESTAMP, +`col113` CHAR (201), +`col114` BOOL, +`col115` TINYINT, +`col116` DOUBLE, +`col117` TINYINT, +`col118` TIMESTAMP, +`col119` SET ('test1','test2','test3'), +`col120` SMALLINT, +`col121` TINYBLOB, +`col122` TIMESTAMP, +`col123` BLOB, +`col124` DATE, +`col125` SMALLINT, +`col126` ENUM ('test1','test2','test3'), +`col127` MEDIUMBLOB, +`col128` DOUBLE PRECISION, +`col129` REAL, +`col130` VARCHAR (159), +`col131` MEDIUMBLOB, +`col132` BIGINT, +`col133` INT, +`col134` SET ('test1','test2','test3'), +`col135` CHAR (198), +`col136` SET ('test1','test2','test3'), +`col137` MEDIUMTEXT, +`col138` SMALLINT, +`col139` BLOB, +`col140` LONGBLOB, +KEY `idx0` (`col14`(139),`col24`(208),`col38`,`col35`), +KEY `idx1` (`col48`,`col118`,`col29`(131),`col100`), +KEY `idx2` (`col86`,`col67`,`col43`(175)), +KEY `idx3` (`col19`), +KEY `idx4` (`col40`(220),`col67`), +KEY `idx5` (`col99`,`col56`), +KEY `idx6` (`col68`,`col28`,`col137`(157)), +KEY `idx7` (`col51`(160),`col99`,`col45`,`col39`(9)), +KEY `idx8` (`col15`,`col52`,`col90`,`col94`), +KEY `idx9` (`col24`(3),`col139`(248),`col108`(118),`col41`), +KEY `idx10` (`col36`,`col92`,`col114`), +KEY `idx11` (`col115`,`col9`(116)), +KEY `idx12` (`col130`,`col93`,`col134`), +KEY `idx13` (`col123`(65)), +KEY `idx14` (`col44`(90),`col86`,`col119`), +KEY `idx15` (`col69`), +KEY `idx16` (`col132`,`col81`(118),`col18`), +KEY `idx17` (`col24`(250),`col7`,`col92`,`col45`) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +# Creating a table with 199 columns and 1 indexes +DROP TABLE IF EXISTS `table3`; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table3` +(`col0` SMALLINT, +`col1` SET ('test1','test2','test3'), +`col2` TINYTEXT, +`col3` DOUBLE, +`col4` NUMERIC, +`col5` DATE, +`col6` BIGINT, +`col7` DOUBLE, +`col8` TEXT, +`col9` INT, +`col10` REAL, +`col11` TINYINT, +`col12` NUMERIC, +`col13` NUMERIC, +`col14` TIME, +`col15` DOUBLE, +`col16` REAL, +`col17` MEDIUMBLOB, +`col18` YEAR, +`col19` TINYTEXT, +`col20` YEAR, +`col21` CHAR (250), +`col22` TINYINT, +`col23` TINYINT, +`col24` SMALLINT, +`col25` DATETIME, +`col26` MEDIUMINT, +`col27` LONGBLOB, +`col28` VARCHAR (106), +`col29` FLOAT, +`col30` MEDIUMTEXT, +`col31` TINYBLOB, +`col32` BIGINT, +`col33` YEAR, +`col34` REAL, +`col35` MEDIUMBLOB, +`col36` LONGTEXT, +`col37` LONGBLOB, +`col38` BIGINT, +`col39` FLOAT, +`col40` TIME, +`col41` DATETIME, +`col42` BOOL, +`col43` BIGINT, +`col44` SMALLINT, +`col45` TIME, +`col46` DOUBLE PRECISION, +`col47` TIME, +`col48` TINYTEXT, +`col49` DOUBLE PRECISION, +`col50` BIGINT, +`col51` NUMERIC, +`col52` TINYBLOB, +`col53` DATE, +`col54` DECIMAL, +`col55` SMALLINT, +`col56` TINYTEXT, +`col57` ENUM ('test1','test2','test3'), +`col58` YEAR, +`col59` TIME, +`col60` TINYINT, +`col61` DECIMAL, +`col62` DOUBLE, +`col63` DATE, +`col64` LONGTEXT, +`col65` DOUBLE, +`col66` VARCHAR (88), +`col67` MEDIUMTEXT, +`col68` DATE, +`col69` MEDIUMINT, +`col70` DECIMAL, +`col71` MEDIUMTEXT, +`col72` LONGTEXT, +`col73` REAL, +`col74` DOUBLE, +`col75` TIME, +`col76` DATE, +`col77` DECIMAL, +`col78` MEDIUMBLOB, +`col79` NUMERIC, +`col80` BIGINT, +`col81` YEAR, +`col82` SMALLINT, +`col83` MEDIUMINT, +`col84` TINYINT, +`col85` MEDIUMBLOB, +`col86` TIME, +`col87` MEDIUMBLOB, +`col88` LONGTEXT, +`col89` BOOL, +`col90` BLOB, +`col91` LONGBLOB, +`col92` YEAR, +`col93` BLOB, +`col94` INT, +`col95` TINYTEXT, +`col96` TINYINT, +`col97` DECIMAL, +`col98` ENUM ('test1','test2','test3'), +`col99` MEDIUMINT, +`col100` TINYINT, +`col101` MEDIUMBLOB, +`col102` TINYINT, +`col103` SET ('test1','test2','test3'), +`col104` TIMESTAMP, +`col105` TEXT, +`col106` DATETIME, +`col107` MEDIUMTEXT, +`col108` CHAR (220), +`col109` TIME, +`col110` VARCHAR (131), +`col111` DECIMAL, +`col112` FLOAT, +`col113` SMALLINT, +`col114` BIGINT, +`col115` LONGBLOB, +`col116` SET ('test1','test2','test3'), +`col117` ENUM ('test1','test2','test3'), +`col118` BLOB, +`col119` MEDIUMTEXT, +`col120` SET ('test1','test2','test3'), +`col121` DATETIME, +`col122` FLOAT, +`col123` VARCHAR (242), +`col124` YEAR, +`col125` MEDIUMBLOB, +`col126` TIME, +`col127` BOOL, +`col128` TINYBLOB, +`col129` DOUBLE, +`col130` TINYINT, +`col131` BIGINT, +`col132` SMALLINT, +`col133` INT, +`col134` DOUBLE PRECISION, +`col135` MEDIUMBLOB, +`col136` SET ('test1','test2','test3'), +`col137` TINYTEXT, +`col138` DOUBLE PRECISION, +`col139` NUMERIC, +`col140` BLOB, +`col141` SET ('test1','test2','test3'), +`col142` INT, +`col143` VARCHAR (26), +`col144` BLOB, +`col145` REAL, +`col146` SET ('test1','test2','test3'), +`col147` LONGBLOB, +`col148` TEXT, +`col149` BLOB, +`col150` CHAR (189), +`col151` LONGTEXT, +`col152` INT, +`col153` FLOAT, +`col154` LONGTEXT, +`col155` DATE, +`col156` LONGBLOB, +`col157` TINYBLOB, +`col158` REAL, +`col159` DATE, +`col160` TIME, +`col161` YEAR, +`col162` DOUBLE, +`col163` VARCHAR (90), +`col164` FLOAT, +`col165` NUMERIC, +`col166` ENUM ('test1','test2','test3'), +`col167` DOUBLE PRECISION, +`col168` DOUBLE PRECISION, +`col169` TINYBLOB, +`col170` TIME, +`col171` SMALLINT, +`col172` TINYTEXT, +`col173` SMALLINT, +`col174` DOUBLE, +`col175` VARCHAR (14), +`col176` VARCHAR (90), +`col177` REAL, +`col178` MEDIUMINT, +`col179` TINYBLOB, +`col180` FLOAT, +`col181` TIMESTAMP, +`col182` REAL, +`col183` DOUBLE PRECISION, +`col184` BIGINT, +`col185` INT, +`col186` MEDIUMTEXT, +`col187` TIME, +`col188` FLOAT, +`col189` TIME, +`col190` INT, +`col191` FLOAT, +`col192` MEDIUMINT, +`col193` TINYINT, +`col194` MEDIUMTEXT, +`col195` DATE, +`col196` TIME, +`col197` YEAR, +`col198` CHAR (206), +KEY `idx0` (`col39`,`col23`) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +# Creating a table with 133 columns and 16 indexes +DROP TABLE IF EXISTS `table4`; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table4` +(`col0` VARCHAR (60), +`col1` NUMERIC, +`col2` LONGTEXT, +`col3` MEDIUMTEXT, +`col4` LONGTEXT, +`col5` LONGBLOB, +`col6` LONGBLOB, +`col7` DATETIME, +`col8` TINYTEXT, +`col9` BLOB, +`col10` BOOL, +`col11` BIGINT, +`col12` TEXT, +`col13` VARCHAR (213), +`col14` TINYBLOB, +`col15` BOOL, +`col16` MEDIUMTEXT, +`col17` DOUBLE, +`col18` TEXT, +`col19` BLOB, +`col20` SET ('test1','test2','test3'), +`col21` TINYINT, +`col22` DATETIME, +`col23` TINYINT, +`col24` ENUM ('test1','test2','test3'), +`col25` REAL, +`col26` BOOL, +`col27` FLOAT, +`col28` LONGBLOB, +`col29` DATETIME, +`col30` FLOAT, +`col31` SET ('test1','test2','test3'), +`col32` LONGBLOB, +`col33` NUMERIC, +`col34` YEAR, +`col35` VARCHAR (146), +`col36` BIGINT, +`col37` DATETIME, +`col38` DATE, +`col39` SET ('test1','test2','test3'), +`col40` CHAR (112), +`col41` FLOAT, +`col42` YEAR, +`col43` TIME, +`col44` DOUBLE, +`col45` NUMERIC, +`col46` FLOAT, +`col47` DECIMAL, +`col48` BIGINT, +`col49` DECIMAL, +`col50` YEAR, +`col51` MEDIUMTEXT, +`col52` LONGBLOB, +`col53` SET ('test1','test2','test3'), +`col54` BLOB, +`col55` FLOAT, +`col56` REAL, +`col57` REAL, +`col58` TEXT, +`col59` MEDIUMBLOB, +`col60` INT, +`col61` INT, +`col62` DATE, +`col63` TEXT, +`col64` DATE, +`col65` ENUM ('test1','test2','test3'), +`col66` DOUBLE PRECISION, +`col67` TINYTEXT, +`col68` TINYBLOB, +`col69` FLOAT, +`col70` BLOB, +`col71` DATETIME, +`col72` DOUBLE, +`col73` LONGTEXT, +`col74` TIME, +`col75` DATETIME, +`col76` VARCHAR (122), +`col77` MEDIUMTEXT, +`col78` MEDIUMTEXT, +`col79` BOOL, +`col80` LONGTEXT, +`col81` TINYTEXT, +`col82` NUMERIC, +`col83` DOUBLE PRECISION, +`col84` DATE, +`col85` YEAR, +`col86` BLOB, +`col87` TINYTEXT, +`col88` DOUBLE PRECISION, +`col89` MEDIUMINT, +`col90` MEDIUMTEXT, +`col91` NUMERIC, +`col92` DATETIME, +`col93` NUMERIC, +`col94` SET ('test1','test2','test3'), +`col95` TINYTEXT, +`col96` SET ('test1','test2','test3'), +`col97` YEAR, +`col98` MEDIUMINT, +`col99` TEXT, +`col100` TEXT, +`col101` TIME, +`col102` VARCHAR (225), +`col103` TINYTEXT, +`col104` TEXT, +`col105` MEDIUMTEXT, +`col106` TINYINT, +`col107` TEXT, +`col108` LONGBLOB, +`col109` LONGTEXT, +`col110` TINYTEXT, +`col111` CHAR (56), +`col112` YEAR, +`col113` ENUM ('test1','test2','test3'), +`col114` TINYBLOB, +`col115` DATETIME, +`col116` DATE, +`col117` TIME, +`col118` MEDIUMTEXT, +`col119` DOUBLE PRECISION, +`col120` FLOAT, +`col121` TIMESTAMP, +`col122` MEDIUMINT, +`col123` YEAR, +`col124` DATE, +`col125` TEXT, +`col126` FLOAT, +`col127` TINYTEXT, +`col128` BOOL, +`col129` NUMERIC, +`col130` TIMESTAMP, +`col131` INT, +`col132` MEDIUMBLOB, +KEY `idx0` (`col130`), +KEY `idx1` (`col30`,`col55`,`col19`(31)), +KEY `idx2` (`col104`(186)), +KEY `idx3` (`col131`), +KEY `idx4` (`col64`,`col93`,`col2`(11)), +KEY `idx5` (`col34`,`col121`,`col22`), +KEY `idx6` (`col33`,`col55`,`col83`), +KEY `idx7` (`col17`,`col87`(245),`col99`(17)), +KEY `idx8` (`col65`,`col120`), +KEY `idx9` (`col82`), +KEY `idx10` (`col9`(72)), +KEY `idx11` (`col88`), +KEY `idx12` (`col128`,`col9`(200),`col71`,`col66`), +KEY `idx13` (`col77`(126)), +KEY `idx14` (`col105`(26),`col13`,`col117`), +KEY `idx15` (`col4`(246),`col130`,`col115`,`col3`(141)) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +# Creating a table with 176 columns and 13 indexes +DROP TABLE IF EXISTS `table5`; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table5` +(`col0` MEDIUMTEXT, +`col1` VARCHAR (90), +`col2` TINYTEXT, +`col3` TIME, +`col4` BOOL, +`col5` TINYTEXT, +`col6` BOOL, +`col7` TIMESTAMP, +`col8` TINYBLOB, +`col9` TINYINT, +`col10` YEAR, +`col11` SET ('test1','test2','test3'), +`col12` TEXT, +`col13` CHAR (248), +`col14` BIGINT, +`col15` TEXT, +`col16` TINYINT, +`col17` NUMERIC, +`col18` SET ('test1','test2','test3'), +`col19` LONGBLOB, +`col20` FLOAT, +`col21` INT, +`col22` TEXT, +`col23` BOOL, +`col24` DECIMAL, +`col25` DOUBLE PRECISION, +`col26` FLOAT, +`col27` TINYBLOB, +`col28` NUMERIC, +`col29` MEDIUMBLOB, +`col30` DATE, +`col31` LONGTEXT, +`col32` DATE, +`col33` FLOAT, +`col34` BIGINT, +`col35` TINYTEXT, +`col36` MEDIUMTEXT, +`col37` TIME, +`col38` INT, +`col39` TINYINT, +`col40` SET ('test1','test2','test3'), +`col41` CHAR (130), +`col42` SMALLINT, +`col43` INT, +`col44` MEDIUMTEXT, +`col45` VARCHAR (126), +`col46` INT, +`col47` DOUBLE PRECISION, +`col48` BIGINT, +`col49` MEDIUMTEXT, +`col50` TINYBLOB, +`col51` MEDIUMINT, +`col52` TEXT, +`col53` VARCHAR (208), +`col54` VARCHAR (207), +`col55` NUMERIC, +`col56` DATETIME, +`col57` ENUM ('test1','test2','test3'), +`col58` NUMERIC, +`col59` TINYBLOB, +`col60` VARCHAR (73), +`col61` MEDIUMTEXT, +`col62` TINYBLOB, +`col63` DATETIME, +`col64` NUMERIC, +`col65` MEDIUMINT, +`col66` DATETIME, +`col67` NUMERIC, +`col68` TINYINT, +`col69` VARCHAR (58), +`col70` DECIMAL, +`col71` MEDIUMTEXT, +`col72` DATE, +`col73` TIME, +`col74` DOUBLE PRECISION, +`col75` DECIMAL, +`col76` MEDIUMBLOB, +`col77` REAL, +`col78` YEAR, +`col79` YEAR, +`col80` LONGBLOB, +`col81` BLOB, +`col82` BIGINT, +`col83` ENUM ('test1','test2','test3'), +`col84` NUMERIC, +`col85` SET ('test1','test2','test3'), +`col86` MEDIUMTEXT, +`col87` LONGBLOB, +`col88` TIME, +`col89` ENUM ('test1','test2','test3'), +`col90` DECIMAL, +`col91` FLOAT, +`col92` DATETIME, +`col93` TINYTEXT, +`col94` TIMESTAMP, +`col95` TIMESTAMP, +`col96` TEXT, +`col97` REAL, +`col98` VARCHAR (198), +`col99` TIME, +`col100` TINYINT, +`col101` BIGINT, +`col102` LONGBLOB, +`col103` LONGBLOB, +`col104` MEDIUMINT, +`col105` MEDIUMTEXT, +`col106` TIMESTAMP, +`col107` SMALLINT, +`col108` NUMERIC, +`col109` DECIMAL, +`col110` FLOAT, +`col111` DECIMAL, +`col112` REAL, +`col113` TINYTEXT, +`col114` FLOAT, +`col115` VARCHAR (7), +`col116` LONGTEXT, +`col117` DATE, +`col118` BIGINT, +`col119` TEXT, +`col120` BIGINT, +`col121` BLOB, +`col122` CHAR (110), +`col123` NUMERIC, +`col124` MEDIUMBLOB, +`col125` NUMERIC, +`col126` NUMERIC, +`col127` BOOL, +`col128` TIME, +`col129` TINYBLOB, +`col130` TINYBLOB, +`col131` DATE, +`col132` INT, +`col133` VARCHAR (123), +`col134` CHAR (238), +`col135` VARCHAR (225), +`col136` LONGTEXT, +`col137` LONGBLOB, +`col138` REAL, +`col139` TINYBLOB, +`col140` DATETIME, +`col141` TINYTEXT, +`col142` LONGBLOB, +`col143` BIGINT, +`col144` VARCHAR (236), +`col145` TEXT, +`col146` YEAR, +`col147` DECIMAL, +`col148` TEXT, +`col149` MEDIUMBLOB, +`col150` TINYINT, +`col151` BOOL, +`col152` VARCHAR (72), +`col153` INT, +`col154` VARCHAR (165), +`col155` TINYINT, +`col156` MEDIUMTEXT, +`col157` DOUBLE PRECISION, +`col158` TIME, +`col159` MEDIUMBLOB, +`col160` LONGBLOB, +`col161` DATETIME, +`col162` DOUBLE PRECISION, +`col163` BLOB, +`col164` ENUM ('test1','test2','test3'), +`col165` TIMESTAMP, +`col166` DATE, +`col167` TINYBLOB, +`col168` TINYBLOB, +`col169` LONGBLOB, +`col170` DATETIME, +`col171` BIGINT, +`col172` VARCHAR (30), +`col173` LONGTEXT, +`col174` TIME, +`col175` FLOAT, +KEY `idx0` (`col16`,`col156`(139),`col97`,`col120`), +KEY `idx1` (`col24`,`col0`(108)), +KEY `idx2` (`col117`,`col173`(34),`col132`,`col82`), +KEY `idx3` (`col2`(86)), +KEY `idx4` (`col2`(43)), +KEY `idx5` (`col83`,`col35`(87),`col111`), +KEY `idx6` (`col6`,`col134`,`col92`), +KEY `idx7` (`col56`), +KEY `idx8` (`col30`,`col53`,`col129`(66)), +KEY `idx9` (`col53`,`col113`(211),`col32`,`col15`(75)), +KEY `idx10` (`col34`), +KEY `idx11` (`col126`), +KEY `idx12` (`col24`) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +# Creating a table with 179 columns and 46 indexes +DROP TABLE IF EXISTS `table6`; +-- error ER_TOO_BIG_ROWSIZE +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table6` +(`col0` ENUM ('test1','test2','test3'), +`col1` MEDIUMBLOB, +`col2` MEDIUMBLOB, +`col3` DATETIME, +`col4` DATE, +`col5` YEAR, +`col6` REAL, +`col7` NUMERIC, +`col8` MEDIUMBLOB, +`col9` TEXT, +`col10` TIMESTAMP, +`col11` DOUBLE, +`col12` DOUBLE, +`col13` SMALLINT, +`col14` TIMESTAMP, +`col15` DECIMAL, +`col16` DATE, +`col17` TEXT, +`col18` LONGBLOB, +`col19` BIGINT, +`col20` FLOAT, +`col21` DATETIME, +`col22` TINYINT, +`col23` MEDIUMBLOB, +`col24` SET ('test1','test2','test3'), +`col25` TIME, +`col26` TEXT, +`col27` LONGTEXT, +`col28` BIGINT, +`col29` REAL, +`col30` YEAR, +`col31` MEDIUMBLOB, +`col32` MEDIUMINT, +`col33` FLOAT, +`col34` TEXT, +`col35` DATE, +`col36` TIMESTAMP, +`col37` REAL, +`col38` BLOB, +`col39` BLOB, +`col40` BLOB, +`col41` TINYBLOB, +`col42` INT, +`col43` TINYINT, +`col44` REAL, +`col45` BIGINT, +`col46` TIMESTAMP, +`col47` BLOB, +`col48` ENUM ('test1','test2','test3'), +`col49` BOOL, +`col50` CHAR (109), +`col51` DOUBLE, +`col52` DOUBLE PRECISION, +`col53` ENUM ('test1','test2','test3'), +`col54` FLOAT, +`col55` DOUBLE PRECISION, +`col56` CHAR (166), +`col57` TEXT, +`col58` TIME, +`col59` DECIMAL, +`col60` TEXT, +`col61` ENUM ('test1','test2','test3'), +`col62` LONGTEXT, +`col63` YEAR, +`col64` DOUBLE, +`col65` CHAR (87), +`col66` DATE, +`col67` BOOL, +`col68` MEDIUMBLOB, +`col69` DATETIME, +`col70` DECIMAL, +`col71` TIME, +`col72` REAL, +`col73` LONGTEXT, +`col74` BLOB, +`col75` REAL, +`col76` INT, +`col77` INT, +`col78` FLOAT, +`col79` DOUBLE, +`col80` MEDIUMINT, +`col81` ENUM ('test1','test2','test3'), +`col82` VARCHAR (221), +`col83` BIGINT, +`col84` TINYINT, +`col85` BIGINT, +`col86` FLOAT, +`col87` MEDIUMBLOB, +`col88` CHAR (126), +`col89` MEDIUMBLOB, +`col90` DATETIME, +`col91` TINYINT, +`col92` DOUBLE, +`col93` NUMERIC, +`col94` DATE, +`col95` BLOB, +`col96` DATETIME, +`col97` TIME, +`col98` LONGBLOB, +`col99` INT, +`col100` SET ('test1','test2','test3'), +`col101` TINYBLOB, +`col102` INT, +`col103` MEDIUMBLOB, +`col104` MEDIUMTEXT, +`col105` FLOAT, +`col106` TINYBLOB, +`col107` VARCHAR (26), +`col108` TINYINT, +`col109` TIME, +`col110` TINYBLOB, +`col111` LONGBLOB, +`col112` TINYTEXT, +`col113` FLOAT, +`col114` TINYINT, +`col115` NUMERIC, +`col116` TIME, +`col117` SET ('test1','test2','test3'), +`col118` DATE, +`col119` SMALLINT, +`col120` BLOB, +`col121` TINYTEXT, +`col122` REAL, +`col123` YEAR, +`col124` REAL, +`col125` BOOL, +`col126` BLOB, +`col127` REAL, +`col128` MEDIUMBLOB, +`col129` TIMESTAMP, +`col130` LONGBLOB, +`col131` MEDIUMBLOB, +`col132` YEAR, +`col133` YEAR, +`col134` INT, +`col135` MEDIUMINT, +`col136` MEDIUMINT, +`col137` TINYTEXT, +`col138` TINYBLOB, +`col139` BLOB, +`col140` SET ('test1','test2','test3'), +`col141` ENUM ('test1','test2','test3'), +`col142` ENUM ('test1','test2','test3'), +`col143` TINYTEXT, +`col144` DATETIME, +`col145` TEXT, +`col146` DOUBLE PRECISION, +`col147` DECIMAL, +`col148` MEDIUMTEXT, +`col149` TINYTEXT, +`col150` SET ('test1','test2','test3'), +`col151` MEDIUMTEXT, +`col152` CHAR (126), +`col153` DOUBLE, +`col154` CHAR (243), +`col155` SET ('test1','test2','test3'), +`col156` SET ('test1','test2','test3'), +`col157` DATETIME, +`col158` DOUBLE, +`col159` NUMERIC, +`col160` DECIMAL, +`col161` FLOAT, +`col162` LONGBLOB, +`col163` LONGTEXT, +`col164` INT, +`col165` TIME, +`col166` CHAR (27), +`col167` VARCHAR (63), +`col168` TEXT, +`col169` TINYBLOB, +`col170` TINYBLOB, +`col171` ENUM ('test1','test2','test3'), +`col172` INT, +`col173` TIME, +`col174` DECIMAL, +`col175` DOUBLE, +`col176` MEDIUMBLOB, +`col177` LONGBLOB, +`col178` CHAR (43), +KEY `idx0` (`col131`(219)), +KEY `idx1` (`col67`,`col122`,`col59`,`col87`(33)), +KEY `idx2` (`col83`,`col42`,`col57`(152)), +KEY `idx3` (`col106`(124)), +KEY `idx4` (`col173`,`col80`,`col165`,`col89`(78)), +KEY `idx5` (`col174`,`col145`(108),`col23`(228),`col141`), +KEY `idx6` (`col157`,`col140`), +KEY `idx7` (`col130`(188),`col15`), +KEY `idx8` (`col52`), +KEY `idx9` (`col144`), +KEY `idx10` (`col155`), +KEY `idx11` (`col62`(230),`col1`(109)), +KEY `idx12` (`col151`(24),`col95`(85)), +KEY `idx13` (`col114`), +KEY `idx14` (`col42`,`col98`(56),`col146`), +KEY `idx15` (`col147`,`col39`(254),`col35`), +KEY `idx16` (`col79`), +KEY `idx17` (`col65`), +KEY `idx18` (`col149`(165),`col168`(119),`col32`,`col117`), +KEY `idx19` (`col64`), +KEY `idx20` (`col93`), +KEY `idx21` (`col64`,`col113`,`col104`(182)), +KEY `idx22` (`col52`,`col111`(189)), +KEY `idx23` (`col45`), +KEY `idx24` (`col154`,`col107`,`col110`(159)), +KEY `idx25` (`col149`(1),`col87`(131)), +KEY `idx26` (`col58`,`col115`,`col63`), +KEY `idx27` (`col95`(9),`col0`,`col87`(113)), +KEY `idx28` (`col92`,`col130`(1)), +KEY `idx29` (`col151`(129),`col137`(254),`col13`), +KEY `idx30` (`col49`), +KEY `idx31` (`col28`), +KEY `idx32` (`col83`,`col146`), +KEY `idx33` (`col155`,`col90`,`col17`(245)), +KEY `idx34` (`col174`,`col169`(44),`col107`), +KEY `idx35` (`col113`), +KEY `idx36` (`col52`), +KEY `idx37` (`col16`,`col120`(190)), +KEY `idx38` (`col28`), +KEY `idx39` (`col131`(165)), +KEY `idx40` (`col135`,`col26`(86)), +KEY `idx41` (`col69`,`col94`), +KEY `idx42` (`col105`,`col151`(38),`col97`), +KEY `idx43` (`col88`), +KEY `idx44` (`col176`(100),`col42`,`col73`(189),`col94`), +KEY `idx45` (`col2`(27),`col27`(116)) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +DROP TABLE IF EXISTS table0; +DROP TABLE IF EXISTS table1; +DROP TABLE IF EXISTS table2; +DROP TABLE IF EXISTS table3; +DROP TABLE IF EXISTS table4; +DROP TABLE IF EXISTS table5; +DROP TABLE IF EXISTS table6; + +EVAL SET GLOBAL innodb_file_per_table=$file_per_table; +SET sql_mode = default; diff --git a/mysql-test/suite/innodb_zip/t/bug52745.test b/mysql-test/suite/innodb_zip/t/bug52745.test new file mode 100644 index 00000000..b642479f --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/bug52745.test @@ -0,0 +1,67 @@ +-- source include/innodb_page_size_small.inc + +CREATE TABLE bug52745 ( + a2 int(10) unsigned DEFAULT NULL, + col37 time DEFAULT NULL, + col38 char(229) CHARACTER SET utf8 DEFAULT NULL, + col39 text, + col40 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + col41 int(10) unsigned DEFAULT NULL, + col42 varchar(248) CHARACTER SET utf8 DEFAULT NULL, + col43 smallint(5) unsigned zerofill DEFAULT NULL, + col44 varchar(150) CHARACTER SET utf8 DEFAULT NULL, + col45 float unsigned zerofill DEFAULT NULL, + col46 binary(1) DEFAULT NULL, + col47 tinyint(4) DEFAULT NULL, + col48 tinyint(1) DEFAULT NULL, + col49 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + col50 binary(1) DEFAULT NULL, + col51 double unsigned zerofill DEFAULT NULL, + col52 int(10) unsigned DEFAULT NULL, + col53 time DEFAULT NULL, + col54 double unsigned DEFAULT NULL, + col55 time DEFAULT NULL, + col56 mediumtext CHARACTER SET latin2, + col57 blob, + col58 decimal(52,16) unsigned zerofill NOT NULL DEFAULT '000000000000000000000000000000000000.0000000000000000', + col59 binary(1) DEFAULT NULL, + col60 longblob, + col61 time DEFAULT NULL, + col62 longtext CHARACTER SET utf8 COLLATE utf8_persian_ci, + col63 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + col64 int(10) unsigned DEFAULT NULL, + col65 date DEFAULT NULL, + col66 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + col67 binary(1) DEFAULT NULL, + col68 tinyblob, + col69 date DEFAULT NULL, + col70 tinyint(3) unsigned zerofill DEFAULT NULL, + col71 varchar(44) CHARACTER SET utf8 DEFAULT NULL, + col72 datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +SET sql_mode = default; +INSERT IGNORE INTO bug52745 SET +col40='0000-00-00 00:00:00', +col51=16547, +col53='7711484', +col54=-28604, +col55='7112612', +col56='wakefulness\'', +col57=repeat('absorbefacient\'',106), +col58=11027, +col59='AM09gW7', +col60=repeat('Noelani\'',16), +col61='2520576', +col62='substitutiv', +col63='19950106155112', +col64=-12038, +col65='86238806', +col66='19600719080256', +col68=repeat('Sagittarius\'',54), +col69='38943902', +col70=1232, +col71='Elora\''; + +SHOW WARNINGS; + +DROP TABLE bug52745; diff --git a/mysql-test/suite/innodb_zip/t/bug53591.test b/mysql-test/suite/innodb_zip/t/bug53591.test new file mode 100644 index 00000000..17c79e0f --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/bug53591.test @@ -0,0 +1,23 @@ +-- source include/innodb_page_size_small.inc + +call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the row size is'); + +let $file_per_table=`select @@innodb_file_per_table`; + +SET GLOBAL innodb_file_per_table=on; +SET GLOBAL innodb_strict_mode=on; + +set old_alter_table=0; + +CREATE TABLE bug53591(a text charset utf8 not null) +ENGINE=InnoDB KEY_BLOCK_SIZE=1; +-- replace_result 8126 {checked_valid} 4030 {checked_valid} 1982 {checked_valid} +-- error ER_TOO_BIG_ROWSIZE +ALTER TABLE bug53591 ADD PRIMARY KEY(a(220)); +-- replace_result 8126 {checked_valid} 4030 {checked_valid} 1982 {checked_valid} +SHOW WARNINGS; + +DROP TABLE bug53591; + +EVAL SET GLOBAL innodb_file_per_table=$file_per_table; +SET GLOBAL innodb_strict_mode=DEFAULT; diff --git a/mysql-test/suite/innodb_zip/t/bug56680.test b/mysql-test/suite/innodb_zip/t/bug56680.test new file mode 100644 index 00000000..54cbc7ca --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/bug56680.test @@ -0,0 +1,135 @@ +#Want to skip this test from daily Valgrind execution +--source include/no_valgrind_without_big.inc +# Embedded server tests do not support restarting. +--source include/not_embedded.inc +# +# Bug #56680 InnoDB may return wrong results from a case-insensitive index +# +-- source include/innodb_page_size_small.inc + +-- disable_query_log +# The flag innodb_change_buffering_debug is only available in debug builds. +# It instructs InnoDB to try to evict pages from the buffer pool when +# change buffering is possible, so that the change buffer will be used +# whenever possible. +-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE +SET GLOBAL innodb_change_buffering_debug = 1; +-- enable_query_log +SET GLOBAL tx_isolation='REPEATABLE-READ'; +SET GLOBAL innodb_file_per_table=on; + +CREATE TABLE bug56680( + a INT AUTO_INCREMENT PRIMARY KEY, + b CHAR(1), + c INT, + INDEX(b)) +ENGINE=InnoDB STATS_PERSISTENT=0; + +INSERT INTO bug56680 VALUES(0,'x',1); +BEGIN; +SELECT b FROM bug56680; + +connect (con1,localhost,root,,); +connection con1; +BEGIN; +UPDATE bug56680 SET b='X'; + +connection default; +# This should return the last committed value 'x', but would return 'X' +# due to a bug in row_search_for_mysql(). +SELECT b FROM bug56680; +# This would always return the last committed value 'x'. +SELECT * FROM bug56680; + +connection con1; +ROLLBACK; +disconnect con1; + +connection default; + +SELECT b FROM bug56680; + +# For the rest of this test, use the READ UNCOMMITTED isolation level +# to see what exists in the secondary index. +SET GLOBAL tx_isolation='READ-UNCOMMITTED'; + +# Create enough rows for the table, so that the insert buffer will be +# used for modifying the secondary index page. There must be multiple +# index pages, because changes to the root page are never buffered. + +INSERT INTO bug56680 SELECT 0,b,c FROM bug56680; +INSERT INTO bug56680 SELECT 0,b,c FROM bug56680; +INSERT INTO bug56680 SELECT 0,b,c FROM bug56680; +INSERT INTO bug56680 SELECT 0,b,c FROM bug56680; +INSERT INTO bug56680 SELECT 0,b,c FROM bug56680; +INSERT INTO bug56680 SELECT 0,b,c FROM bug56680; +INSERT INTO bug56680 SELECT 0,b,c FROM bug56680; +INSERT INTO bug56680 SELECT 0,b,c FROM bug56680; +INSERT INTO bug56680 SELECT 0,b,c FROM bug56680; +INSERT INTO bug56680 SELECT 0,b,c FROM bug56680; +INSERT INTO bug56680 SELECT 0,b,c FROM bug56680; + +BEGIN; +SELECT b FROM bug56680 LIMIT 2; + +connect (con1,localhost,root,,); +connection con1; +BEGIN; +DELETE FROM bug56680 WHERE a=1; +# This should be buffered, if innodb_change_buffering_debug = 1 is in effect. +INSERT INTO bug56680 VALUES(1,'X',1); + +# This should force an insert buffer merge, and return 'X' in the first row. +SELECT b FROM bug56680 LIMIT 3; + +connection default; +SELECT b FROM bug56680 LIMIT 2; +CHECK TABLE bug56680; + +connection con1; +ROLLBACK; +SELECT b FROM bug56680 LIMIT 2; +CHECK TABLE bug56680; + +connection default; +disconnect con1; + +SELECT b FROM bug56680 LIMIT 2; + +CREATE TABLE bug56680_2( + a INT AUTO_INCREMENT PRIMARY KEY, + b VARCHAR(2) CHARSET latin1 COLLATE latin1_german2_ci, + c INT, + INDEX(b)) +ENGINE=InnoDB STATS_PERSISTENT=0; + +INSERT INTO bug56680_2 SELECT 0,_latin1 0xdf,c FROM bug56680; + +BEGIN; +SELECT HEX(b) FROM bug56680_2 LIMIT 2; +DELETE FROM bug56680_2 WHERE a=1; +# This should be buffered, if innodb_change_buffering_debug = 1 is in effect. +INSERT INTO bug56680_2 VALUES(1,'SS',1); + +# This should force an insert buffer merge, and return 'SS' in the first row. +SELECT HEX(b) FROM bug56680_2 LIMIT 3; +CHECK TABLE bug56680_2; + +# Test this with compressed tables. +ALTER TABLE bug56680_2 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +SELECT HEX(b) FROM bug56680_2 LIMIT 2; +DELETE FROM bug56680_2 WHERE a=1; +# This should be buffered, if innodb_change_buffering_debug = 1 is in effect. +INSERT INTO bug56680_2 VALUES(1,_latin1 0xdf,1); + +# This should force an insert buffer merge, and return 0xdf in the first row. +SELECT HEX(b) FROM bug56680_2 LIMIT 3; +CHECK TABLE bug56680_2; + +--let $shutdown_timeout=0 +--source include/restart_mysqld.inc + +CHECK TABLE bug56680_2; +DROP TABLE bug56680_2; +DROP TABLE bug56680; diff --git a/mysql-test/suite/innodb_zip/t/cmp_drop_table-master.opt b/mysql-test/suite/innodb_zip/t/cmp_drop_table-master.opt new file mode 100644 index 00000000..a9a3d8c3 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/cmp_drop_table-master.opt @@ -0,0 +1 @@ +--innodb-buffer-pool-size=8M diff --git a/mysql-test/suite/innodb_zip/t/cmp_drop_table.test b/mysql-test/suite/innodb_zip/t/cmp_drop_table.test new file mode 100644 index 00000000..ae6bfd9f --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/cmp_drop_table.test @@ -0,0 +1,59 @@ +-- source include/innodb_page_size_small.inc +# lazy eviction might not be lazy enough when key rotation +# scans through pages +-- source include/not_encrypted.inc + +let $per_table=`select @@innodb_file_per_table`; + +-- let $query_i_s = SELECT page_size FROM information_schema.innodb_cmpmem WHERE pages_used > 0 + +set global innodb_file_per_table=on; + +create table t1(a text) engine=innodb key_block_size=4; + +-- disable_query_log + +# insert some rows so we are using compressed pages +-- let $i = 10 +while ($i) +{ + insert into t1 values(repeat('abcdefghijklmnopqrstuvwxyz',100)); + dec $i; +} +-- enable_query_log + +# we should be using some 4K pages +-- eval $query_i_s + +drop table t1; + +# because of lazy eviction at drop table there should still be some +# used 4K pages +-- eval $query_i_s + +# create a non-compressed table and insert enough into it to evict +# compressed pages +create table t2(a text) engine=innodb; + +-- disable_query_log + +-- let $i = 500 +while ($i) +{ + insert into t2 values(repeat('abcdefghijklmnopqrstuvwxyz',1000)); + dec $i; +} + +-- enable_query_log + +# now there should be no 4K pages in the buffer pool +-- eval $query_i_s + +drop table t2; + +# +# restore environment to the state it was before this test execution +# + +-- disable_query_log +eval set global innodb_file_per_table=$per_table; diff --git a/mysql-test/suite/innodb_zip/t/cmp_per_index.opt b/mysql-test/suite/innodb_zip/t/cmp_per_index.opt new file mode 100644 index 00000000..37aab727 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/cmp_per_index.opt @@ -0,0 +1 @@ +--innodb_cmp_per_index_reset diff --git a/mysql-test/suite/innodb_zip/t/cmp_per_index.test b/mysql-test/suite/innodb_zip/t/cmp_per_index.test new file mode 100644 index 00000000..d5e682d6 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/cmp_per_index.test @@ -0,0 +1,93 @@ +# +# Test information_schema.innodb_cmp_per_index +# + +-- source include/have_innodb.inc + +# numbers read in this test depend on the page size +-- source include/have_innodb_16k.inc +# include/restart_mysqld.inc does not work in embedded mode +-- source include/not_embedded.inc + +-- vertical_results + +SET @save_enabled= @@GLOBAL.innodb_cmp_per_index_enabled; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +# reset any leftover stats from previous tests +-- disable_query_log +-- disable_result_log +SELECT * FROM information_schema.innodb_cmp_per_index_reset; +-- enable_result_log +-- enable_query_log + +# see that the table is empty +SELECT * FROM information_schema.innodb_cmp_per_index; + +--disable_query_log +SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log +# create a table that uses compression +CREATE TABLE t ( + a INT, + b VARCHAR(512), + c VARCHAR(16), + PRIMARY KEY (a), + INDEX (b(512)), + INDEX (c(16)) +) ENGINE=INNODB KEY_BLOCK_SIZE=2; + +SELECT +database_name, +table_name, +index_name, +compress_ops, +compress_ops_ok, +uncompress_ops +FROM information_schema.innodb_cmp_per_index +ORDER BY 1, 2, 3; + +# insert some data into it +BEGIN; +-- disable_query_log +let $i=128; +while ($i) +{ + -- eval INSERT INTO t VALUES ($i, REPEAT('x', 512), NULL); + dec $i; +} +-- enable_query_log +COMMIT; + +ALTER TABLE t DROP INDEX c; +--disable_query_log +SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; +--enable_query_log + +GRANT USAGE ON *.* TO 'tuser01'@'localhost' IDENTIFIED BY 'cDJvI9s_Uq'; +FLUSH PRIVILEGES; + +-- connect (con1,localhost,tuser01,cDJvI9s_Uq,) +-- connection con1 + +-- error ER_SPECIFIC_ACCESS_DENIED_ERROR +SELECT * FROM information_schema.innodb_cmp_per_index; + +-- connection default +-- disconnect con1 + +DROP USER 'tuser01'@'localhost'; + +SELECT +database_name, +table_name, +index_name, +compress_ops, +compress_ops_ok, +uncompress_ops +FROM information_schema.innodb_cmp_per_index +ORDER BY 1, 2, 3; +DROP TABLE t; + +SET GLOBAL innodb_cmp_per_index_enabled=@save_enabled; diff --git a/mysql-test/suite/innodb_zip/t/create_options.test b/mysql-test/suite/innodb_zip/t/create_options.test new file mode 100644 index 00000000..fce64060 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/create_options.test @@ -0,0 +1,487 @@ +# Tests for various combinations of ROW_FORMAT and KEY_BLOCK_SIZE +# Related bugs; +# Bug#54679: ALTER TABLE causes compressed row_format to revert to compact +# Bug#56628: ALTER TABLE .. KEY_BLOCK_SIZE=0 produces untrue warning or unnecessary error +# Bug#56632: ALTER TABLE implicitly changes ROW_FORMAT to COMPRESSED +# Rules for interpreting CREATE_OPTIONS +# 1) Create options on an ALTER are added to the options on the +# previous CREATE or ALTER statements. +# 2) KEY_BLOCK_SIZE=0 is considered a unspecified value. +# If the current ROW_FORMAT has explicitly been set to COMPRESSED, +# InnoDB will use a default value of 8. Otherwise KEY_BLOCK_SIZE +# will not be used. +# 3) ROW_FORMAT=DEFAULT allows InnoDB to choose its own default, COMPACT. +# 4) ROW_FORMAT=DEFAULT and KEY_BLOCK_SIZE=0 can be used at any time to +# unset or erase the values persisted in the MySQL dictionary and +# by SHOW CTREATE TABLE. +# 5) When incompatible values for ROW_FORMAT and KEY_BLOCK_SIZE are +# both explicitly given, the ROW_FORMAT is always used in non-strict +# mode. +# 6) InnoDB will automatically convert a table to COMPRESSED only if a +# valid non-zero KEY_BLOCK_SIZE has been given and ROW_FORMAT=DEFAULT +# or has not been used on a previous CREATE TABLE or ALTER TABLE. +# 7) InnoDB strict mode is designed to prevent incompatible create +# options from being used together. +# 8) The non-strict behavior is intended to permit you to import a +# mysqldump file into a database that does not support compressed +# tables, even if the source database contained compressed tables. +# All invalid values and/or incompatible combinations of ROW_FORMAT +# and KEY_BLOCK_SIZE are automatically corrected +# +# *** innodb_strict_mode=ON *** +# 1) Valid ROW_FORMATs are COMPRESSED, COMPACT, DEFAULT, DYNAMIC +# & REDUNDANT. All others are rejected. +# 2) Valid KEY_BLOCK_SIZEs are 0,1,2,4,8,16. All others are rejected. +# 3) KEY_BLOCK_SIZE=0 can be used to set it to 'unspecified'. +# 4) KEY_BLOCK_SIZE=1,2,4,8 & 16 are incompatible with COMPACT, DYNAMIC & +# REDUNDANT. +# 5) KEY_BLOCK_SIZE=1,2,4,8 & 16 as well as ROW_FORMAT=COMPRESSED +# are incompatible with innodb_file_per_table=OFF +# 6) KEY_BLOCK_SIZE on an ALTER must occur with ROW_FORMAT=COMPRESSED +# or ROW_FORMAT=DEFAULT if the ROW_FORMAT was previously specified +# as COMPACT, DYNAMIC or REDUNDANT. +# 7) KEY_BLOCK_SIZE on an ALTER can occur without a ROW_FORMAT if the +# previous ROW_FORMAT was DEFAULT, COMPRESSED, or unspecified. +# +# *** innodb_strict_mode=OFF *** +# 1. Ignore a bad KEY_BLOCK_SIZE, defaulting it to 8. +# 2. Ignore a bad ROW_FORMAT, defaulting to COMPACT. +# 3. Ignore a valid KEY_BLOCK_SIZE when an incompatible but valid +# ROW_FORMAT is specified. +# 4. If innodb_file_per_table=OFF +# it will ignore ROW_FORMAT=COMPRESSED and non-zero KEY_BLOCK_SIZEs. +# +# See InnoDB documentation page "SQL Compression Syntax Warnings and Errors" +# This test case does not try to create tables with KEY_BLOCK_SIZE > 4 +# since they are rejected for InnoDB page sizes of 8k and 16k. +# See innodb_16k and innodb_8k for those tests. + +--source include/innodb_page_size_small.inc +SET default_storage_engine=InnoDB; + +# These values can change during the test +LET $innodb_file_per_table_orig=`select @@innodb_file_per_table`; + +SET GLOBAL innodb_file_per_table=ON; + +# The first half of these tests are with strict mode ON. +SET SESSION innodb_strict_mode = ON; + +--echo # Test 1) StrictMode=ON, CREATE and ALTER with each ROW_FORMAT & KEY_BLOCK_SIZE=0 +--echo # KEY_BLOCK_SIZE=0 means 'no KEY_BLOCK_SIZE is specified' +--echo # 'FIXED' is sent to InnoDB since it is used by MyISAM. +--echo # But it is an invalid mode in InnoDB +--error ER_ILLEGAL_HA, 1005 +CREATE TABLE t1 ( i INT ) ROW_FORMAT=FIXED; +SHOW WARNINGS; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=COMPACT KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=DEFAULT KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 ROW_FORMAT=FIXED KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + + + +--echo # Test 2) StrictMode=ON, CREATE with each ROW_FORMAT & a valid non-zero KEY_BLOCK_SIZE +--echo # KEY_BLOCK_SIZE is incompatible with COMPACT, REDUNDANT, & DYNAMIC +DROP TABLE t1; +--error ER_ILLEGAL_HA,1005 +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPACT KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +--error ER_ILLEGAL_HA,1005 +CREATE TABLE t1 ( i INT ) ROW_FORMAT=REDUNDANT KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +--error ER_ILLEGAL_HA,1005 +CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=4; +SHOW WARNINGS; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ADD COLUMN f1 INT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=DEFAULT KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ADD COLUMN f1 INT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + + +--echo # Test 3) StrictMode=ON, ALTER with each ROW_FORMAT & a valid non-zero KEY_BLOCK_SIZE +DROP TABLE t1; +CREATE TABLE t1 ( i INT ); +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 ROW_FORMAT=FIXED KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 ROW_FORMAT=COMPACT KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=4; +SHOW WARNINGS; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 ROW_FORMAT=REDUNDANT KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +ALTER TABLE t1 ROW_FORMAT=DEFAULT KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + + +--echo # Test 4) StrictMode=ON, CREATE with ROW_FORMAT=COMPACT, ALTER with a valid non-zero KEY_BLOCK_SIZE +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPACT; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 KEY_BLOCK_SIZE=4; +SHOW WARNINGS; +ALTER TABLE t1 ROW_FORMAT=DYNAMIC; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +ALTER TABLE t1 ROW_FORMAT=COMPRESSED; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPACT; +ALTER TABLE t1 ROW_FORMAT=DEFAULT KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + +--echo # Test 5) StrictMode=ON, CREATE with a valid KEY_BLOCK_SIZE +--echo # ALTER with each ROW_FORMAT +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) KEY_BLOCK_SIZE=2; +SHOW CREATE TABLE t1; +ALTER TABLE t1 ADD COLUMN f1 INT; +SHOW CREATE TABLE t1; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 ROW_FORMAT=COMPACT; +SHOW WARNINGS; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +SHOW WARNINGS; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 ROW_FORMAT=DYNAMIC; +SHOW WARNINGS; +ALTER TABLE t1 ROW_FORMAT=COMPRESSED; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=DEFAULT KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=COMPACT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + +--echo # Test 6) StrictMode=ON, CREATE with an invalid KEY_BLOCK_SIZE. +DROP TABLE t1; +--error ER_ILLEGAL_HA, 1005 +CREATE TABLE t1 ( i INT ) KEY_BLOCK_SIZE=9; +SHOW WARNINGS; + +--echo # Test 7) StrictMode=ON, Make sure ROW_FORMAT= COMPRESSED & DYNAMIC and +--echo # and a valid non-zero KEY_BLOCK_SIZE +--echo # can be set to default values during strict mode. +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; +ALTER TABLE t1 ADD COLUMN f1 INT; +SHOW WARNINGS; +SHOW CREATE TABLE t1; +ALTER TABLE t1 ROW_FORMAT=DEFAULT KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +ALTER TABLE t1 ADD COLUMN f2 INT; +SHOW WARNINGS; + +--echo # Test 8) StrictMode=ON, Make sure ROW_FORMAT=COMPRESSED +--echo # and a valid non-zero KEY_BLOCK_SIZE are rejected with +--echo # innodb_file_per_table=OFF and that they can be set to default +--echo # values during strict mode. +SET GLOBAL innodb_file_per_table=OFF; +DROP TABLE t1; +--error ER_ILLEGAL_HA,1005 +CREATE TABLE t1 ( i INT ) KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +--error ER_ILLEGAL_HA,1005 +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED; +SHOW WARNINGS; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=REDUNDANT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPACT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=DEFAULT; +SHOW WARNINGS; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 ROW_FORMAT=COMPRESSED; +SHOW WARNINGS; +ALTER TABLE t1 ROW_FORMAT=DYNAMIC; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +SHOW WARNINGS; +ALTER TABLE t1 ROW_FORMAT=COMPACT; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=DEFAULT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +SET GLOBAL innodb_file_per_table=ON; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; +SET GLOBAL innodb_file_per_table=OFF; +ALTER TABLE t1 ADD COLUMN f1 INT; +SHOW WARNINGS; +ALTER TABLE t1 ROW_FORMAT=DEFAULT KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +ALTER TABLE t1 ADD COLUMN f2 INT; +SHOW WARNINGS; +SET GLOBAL innodb_file_per_table=ON; + +--echo ################################################## +SET SESSION innodb_strict_mode = OFF; + +--echo # Test 9) StrictMode=OFF, CREATE and ALTER with each ROW_FORMAT & KEY_BLOCK_SIZE=0 +--echo # KEY_BLOCK_SIZE=0 means 'no KEY_BLOCK_SIZE is specified' +--echo # 'FIXED' is sent to InnoDB since it is used by MyISAM. +--echo # It is an invalid mode in InnoDB, use COMPACT +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=FIXED; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=COMPACT KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=DEFAULT KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=FIXED KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + +--echo # Test 10) StrictMode=OFF, CREATE with each ROW_FORMAT & a valid KEY_BLOCK_SIZE +--echo # KEY_BLOCK_SIZE is ignored with COMPACT, REDUNDANT, & DYNAMIC +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPACT KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=REDUNDANT KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=4; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ADD COLUMN f1 INT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=DEFAULT KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ADD COLUMN f1 INT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + + +--echo # Test 11) StrictMode=OFF, ALTER with each ROW_FORMAT & a valid KEY_BLOCK_SIZE +DROP TABLE t1; +CREATE TABLE t1 ( i INT ); +ALTER TABLE t1 ROW_FORMAT=FIXED KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ); +ALTER TABLE t1 ROW_FORMAT=COMPACT KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ); +ALTER TABLE t1 ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=4; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ); +ALTER TABLE t1 ROW_FORMAT=REDUNDANT KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ); +ALTER TABLE t1 ROW_FORMAT=DEFAULT KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + + +--echo # Test 12) StrictMode=OFF, CREATE with ROW_FORMAT=COMPACT, ALTER with a valid KEY_BLOCK_SIZE +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPACT; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=DYNAMIC; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=COMPRESSED; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 KEY_BLOCK_SIZE=4; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPACT; +ALTER TABLE t1 ROW_FORMAT=DEFAULT KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + +--echo # Test 13) StrictMode=OFF, CREATE with a valid KEY_BLOCK_SIZE +--echo # ALTER with each ROW_FORMAT +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SHOW CREATE TABLE t1; +ALTER TABLE t1 ADD COLUMN f1 INT; +SHOW WARNINGS; +SHOW CREATE TABLE t1; +ALTER TABLE t1 ROW_FORMAT=COMPACT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=DYNAMIC; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=COMPRESSED; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=DEFAULT KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ROW_FORMAT=COMPACT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + +--echo # Test 14) StrictMode=OFF, CREATE with an invalid KEY_BLOCK_SIZE, +--echo # it defaults to half of the page size. +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) KEY_BLOCK_SIZE=15; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + +--echo # Test 15) StrictMode=OFF. +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ADD COLUMN f1 INT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ADD COLUMN f2 INT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ADD COLUMN f1 INT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +ALTER TABLE t1 ADD COLUMN f2 INT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + +--echo # Test 16) StrictMode=OFF, Make sure ROW_FORMAT= COMPRESSED & DYNAMIC and a +--echo valid KEY_BLOCK_SIZE are remembered but not used when innodb_file_per_table=OFF +--echo and then used again when innodb_file_per_table=ON. +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +SET GLOBAL innodb_file_per_table=OFF; +ALTER TABLE t1 ADD COLUMN f1 INT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +SET GLOBAL innodb_file_per_table=ON; +ALTER TABLE t1 ADD COLUMN f2 INT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; +CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +SET GLOBAL innodb_file_per_table=OFF; +ALTER TABLE t1 ADD COLUMN f1 INT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +SET GLOBAL innodb_file_per_table=ON; +ALTER TABLE t1 ADD COLUMN f2 INT; +SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; + + +--echo # Cleanup +DROP TABLE t1; + +--disable_query_log +EVAL SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; +--enable_query_log diff --git a/mysql-test/suite/innodb_zip/t/index_large_prefix.test b/mysql-test/suite/innodb_zip/t/index_large_prefix.test new file mode 100644 index 00000000..a254c4e6 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/index_large_prefix.test @@ -0,0 +1,412 @@ +# Testcase for worklog #5743: Lift the limit of index key prefixes + +--source include/have_innodb.inc +--source include/have_innodb_16k.inc +SET default_storage_engine=InnoDB; + +--disable_query_log +call mtr.add_suppression("Cannot add field .* in table .* because after adding it, the row size is"); +SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log + +let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; + +set global innodb_file_per_table=1; + +-- echo ### Test 1 ### +# Create a table of DYNAMIC format, with a primary index of 1000 bytes in +# size +create table worklog5743(a TEXT not null, primary key (a(1000))) ROW_FORMAT=DYNAMIC; +show warnings; + +# Do some insertion and update to excercise the external cache +# code path +insert into worklog5743 values(repeat("a", 20000)); + +# default session, update the table +update worklog5743 set a = (repeat("b", 16000)); + +# Create a secondary index +create index idx on worklog5743(a(2000)); +show warnings; + +# Start a few sessions to do selections on table being updated in default +# session, so it would rebuild the previous version from undo log. +# 1) Default session: Initiate an update on the externally stored column +# 2) Session con1: Select from table with repeated read +# 3) Session con2: Select from table with read uncommitted +# 4) Default session: rollback updates + +begin; +update worklog5743 set a = (repeat("x", 17000)); + +# Start a new session to select the column to force it build +# an earlier version of the clustered index through undo log. So it should +# just see the result of repeat("b", 16000) +select @@session.tx_isolation; +--connect (con1,localhost,root,,) +select a = repeat("x", 17000) from worklog5743; +select a = repeat("b", 16000) from worklog5743; + +# Start another session doing "read uncommitted" query, it +# should see the uncommitted update +--connect (con2,localhost,root,,) +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a = repeat("x", 17000) from worklog5743; + +# Roll back the transaction +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 2 ### +# Create a table with only a secondary index has large prefix column +create table worklog5743(a1 int, a2 TEXT not null) ROW_FORMAT=DYNAMIC; +show warnings; +create index idx on worklog5743(a1, a2(2000)); +show warnings; + +insert into worklog5743 values(9, repeat("a", 10000)); + +begin; + +update worklog5743 set a1 = 1000; + +# Do a select from another connection that would use the secondary index +--connection con1 +select @@session.tx_isolation; +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; + +# Do read uncommitted in another session, it would show there is no +# row with a1 = 9 +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; + +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 3 ### +# Create a table with a secondary index has small (50 bytes) prefix column +create table worklog5743(a1 int, a2 TEXT not null) ROW_FORMAT=DYNAMIC; + +create index idx on worklog5743(a1, a2(50)); + +insert into worklog5743 values(9, repeat("a", 10000)); + +begin; + +update worklog5743 set a1 = 1000; + +# Do a select from another connection that would use the secondary index +--connection con1 +select @@session.tx_isolation; +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; + +# Do read uncommitted in another session, it would show there is no +# row with a1 = 9 +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; + +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 4 ### +# Create compressed tables with each KEY_BLOCK_SIZE. +create table worklog5743_1(a1 int, a2 TEXT not null) KEY_BLOCK_SIZE=1; +create table worklog5743_2(a1 int, a2 TEXT not null) KEY_BLOCK_SIZE=2; +create table worklog5743_4(a1 int, a2 TEXT not null) KEY_BLOCK_SIZE=4; +create table worklog5743_8(a1 int, a2 TEXT, a3 TEXT) KEY_BLOCK_SIZE=8; +create table worklog5743_16(a1 int, a2 TEXT, a3 TEXT) KEY_BLOCK_SIZE=16; + +# The maximum overall index record (not prefix) length of a +# compressed table is dependent on innodb-page-size (IPS), +# key_block_size (KBS) and the number of fields (NF). +# "Too big row" error (HA_ERR_TOO_BIG_ROW) will be returned if this +# limit is exceeded. +# See page_zip_empty_size() and Bug #47495 for more detail. + +# Test edge cases for indexes using key_block_size=1 +-- error ER_TOO_LONG_KEY,1118 +create index idx2 on worklog5743_1(a2(4000)); +show warnings; +-- error ER_TOO_BIG_ROWSIZE +create index idx3 on worklog5743_1(a2(436)); +show warnings; +# MDEV-27634 stricter compressBound() limit for the s390x DFLTCC instruction +create index idx4 on worklog5743_1(a2(290)); +show warnings; +-- error ER_TOO_BIG_ROWSIZE +create index idx5 on worklog5743_1(a1, a2(430)); +show warnings; +# MDEV-27634 stricter compressBound() limit for the s390x DFLTCC instruction +create index idx6 on worklog5743_1(a1, a2(283)); +show warnings; + +# Test edge cases for indexes using key_block_size=2 +-- error ER_TOO_BIG_ROWSIZE +create index idx2 on worklog5743_2(a2(4000)); +show warnings; +-- error ER_TOO_BIG_ROWSIZE +create index idx3 on worklog5743_2(a2(948)); +show warnings; +# MDEV-27634 stricter compressBound() limit for the s390x DFLTCC instruction +create index idx4 on worklog5743_2(a2(802)); +show warnings; +-- error ER_TOO_BIG_ROWSIZE +create index idx5 on worklog5743_2(a1, a2(942)); +show warnings; +# MDEV-27634 stricter compressBound() limit for the s390x DFLTCC instruction +create index idx6 on worklog5743_2(a1, a2(795)); +show warnings; + +# Test edge cases for indexes using key_block_size=4 +-- error ER_TOO_BIG_ROWSIZE +create index idx2 on worklog5743_4(a2(4000)); +show warnings; +-- error ER_TOO_BIG_ROWSIZE +create index idx3 on worklog5743_4(a2(1972)); +show warnings; +# MDEV-27634 stricter compressBound() limit for the s390x DFLTCC instruction +create index idx4 on worklog5743_4(a2(1826)); +show warnings; +-- error ER_TOO_BIG_ROWSIZE +create index idx5 on worklog5743_4(a1, a2(1966)); +show warnings; +# MDEV-27634 stricter compressBound() limit for the s390x DFLTCC instruction +create index idx6 on worklog5743_4(a1, a2(1819)); +show warnings; + +# Test edge cases for indexes using key_block_size=8 +create index idx2 on worklog5743_8(a2(3073)); +show warnings; +create index idx3 on worklog5743_8(a2(3072)); +show warnings; +-- error ER_TOO_LONG_KEY +create index idx4 on worklog5743_8(a1, a2(3069)); +show warnings; +create index idx5 on worklog5743_8(a1, a2(3068)); +show warnings; +-- error ER_TOO_LONG_KEY +create index idx6 on worklog5743_8(a1, a2(2000), a3(1069)); +show warnings; +create index idx7 on worklog5743_8(a1, a2(2000), a3(1068)); +show warnings; + +# Test edge cases for indexes using key_block_size=16 +create index idx2 on worklog5743_16(a2(3073)); +show warnings; +create index idx3 on worklog5743_16(a2(3072)); +show warnings; +-- error ER_TOO_LONG_KEY +create index idx4 on worklog5743_16(a1, a2(3069)); +show warnings; +create index idx5 on worklog5743_16(a1, a2(3068)); +show warnings; +-- error ER_TOO_LONG_KEY +create index idx6 on worklog5743_16(a1, a2(2000), a3(1069)); +show warnings; +create index idx7 on worklog5743_16(a1, a2(2000), a3(1068)); +show warnings; +set sql_mode= default; + +# Insert a large record into each of these tables. +insert into worklog5743_1 values(9, repeat("a", 10000)); +insert into worklog5743_2 values(9, repeat("a", 10000)); +insert into worklog5743_4 values(9, repeat("a", 10000)); +insert into worklog5743_8 values(9, repeat("a", 10000), repeat("a", 10000)); +insert into worklog5743_16 values(9, repeat("a", 10000), repeat("a", 10000)); + +select a1, left(a2, 20) from worklog5743_1; +select a1, left(a2, 20) from worklog5743_2; +select a1, left(a2, 20) from worklog5743_4; +select a1, left(a2, 20) from worklog5743_8; +select a1, left(a2, 20) from worklog5743_16; + +begin; + +update worklog5743_1 set a1 = 1000; +update worklog5743_2 set a1 = 1000; +update worklog5743_4 set a1 = 1000; +update worklog5743_8 set a1 = 1000; +update worklog5743_16 set a1 = 1000; +select a1, left(a2, 20) from worklog5743_1; +select a1, left(a2, 20) from worklog5743_2; +select a1, left(a2, 20) from worklog5743_4; +select a1, left(a2, 20) from worklog5743_8; +select a1, left(a2, 20) from worklog5743_16; + + +# Do a select from another connection that would use the secondary index +--connection con1 +select @@session.tx_isolation; +explain select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +explain select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +explain select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +explain select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +explain select a1, left(a2, 20) from worklog5743_16 where a1 = 9; +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +select a1, left(a2, 20) from worklog5743_16 where a1 = 9; + +# Do read uncommitted in another session, it would show there is no +# row with a1 = 9 +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +select a1, left(a2, 20) from worklog5743_16 where a1 = 9; + +--connection default +rollback; + +drop table worklog5743_1; +drop table worklog5743_2; +drop table worklog5743_4; +drop table worklog5743_8; +drop table worklog5743_16; + +-- echo ### Test 5 ### +# Create a table with large varchar columns and create indexes +# directly on these large columns to show that prefix limit is +# automatically applied and to show that limit. +create table worklog5743(a1 int, + a2 varchar(20000), + a3 varchar(3073), + a4 varchar(3072), + a5 varchar(3069), + a6 varchar(3068)) + ROW_FORMAT=DYNAMIC; +# Check index creation behavior without STRICT mode +SET sql_mode=''; +create index idx1 on worklog5743(a2); +create index idx2 on worklog5743(a3); +create index idx3 on worklog5743(a4); +show warnings; +SET sql_mode= default; +-- error ER_TOO_LONG_KEY +create index idx4 on worklog5743(a1, a2); +show warnings; +-- error ER_TOO_LONG_KEY +create index idx5 on worklog5743(a1, a5); +show warnings; +create index idx6 on worklog5743(a1, a6); +show warnings; +show create table worklog5743; + +insert into worklog5743 values(9, + repeat("a", 20000), repeat("a", 3073), + repeat("a", 3072), repeat("a", 3069), + repeat("a", 3068)); + +begin; + +update worklog5743 set a1 = 1000; + +# Do a select from another connection that would use the secondary index +--connection con1 +select @@session.tx_isolation; +explain select a1 from worklog5743 where a1 = 9; +select a1 from worklog5743 where a1 = 9; + +# Do read uncommitted, it would show there is no row with a1 = 9 +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a1 from worklog5743 where a1 = 9; + +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 6 ### +# Create a table with old format, and the limit is 768 bytes. +-- error ER_INDEX_COLUMN_TOO_LONG +create table worklog5743(a TEXT not null, primary key (a(1000))) +row_format=compact; + +create table worklog5743(a TEXT) +row_format=compact; + +# Excercise the column length check in ha_innobase::add_index() +-- error ER_INDEX_COLUMN_TOO_LONG +create index idx on worklog5743(a(768)); + +# This should be successful +create index idx on worklog5743(a(767)); + +# Perform some DMLs +insert into worklog5743 values(repeat("a", 20000)); + +begin; +insert into worklog5743 values(repeat("b", 20000)); +update worklog5743 set a = (repeat("x", 25000)); + +# Start a new session to select the table to force it build +# an earlier version of the cluster index through undo log +select @@session.tx_isolation; +--connection con1 +select a = repeat("a", 20000) from worklog5743; +--disconnect con1 + +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a = repeat("x", 25000) from worklog5743; +--disconnect con2 + +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 7 ### +# Some border line tests on the column length. +# We have a limit of 3072 bytes for Barracuda table +create table worklog5743(a TEXT not null) ROW_FORMAT=DYNAMIC; + +# Length exceeds maximum supported key length +# It will be auto-truncated to 3072 +# Check index creation behavior without STRICT mode +SET sql_mode=''; +create index idx1 on worklog5743(a(3073)); +create index idx2 on worklog5743(a(3072)); +show create table worklog5743; +drop table worklog5743; +SET sql_mode= default; + +# We have a limit of 767 bytes for Antelope tables +create table worklog5743(a TEXT not null) ROW_FORMAT=REDUNDANT; +-- error ER_INDEX_COLUMN_TOO_LONG +create index idx on worklog5743(a(768)); +create index idx2 on worklog5743(a(767)); +drop table worklog5743; + +create table worklog5743(a TEXT not null) ROW_FORMAT=COMPACT; +-- error ER_INDEX_COLUMN_TOO_LONG +create index idx on worklog5743(a(768)); +create index idx2 on worklog5743(a(767)); +--disable_query_log +SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; +--enable_query_log +drop table worklog5743; + +eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; diff --git a/mysql-test/suite/innodb_zip/t/index_large_prefix_4k.test b/mysql-test/suite/innodb_zip/t/index_large_prefix_4k.test new file mode 100644 index 00000000..c1c8f49c --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/index_large_prefix_4k.test @@ -0,0 +1,385 @@ +# Testcase for worklog #5743: Lift the limit of index key prefixes + +--source include/have_innodb.inc +--source include/have_innodb_4k.inc +SET default_storage_engine=InnoDB; + +--disable_query_log +call mtr.add_suppression("Cannot add field .* in table .* because after adding it, the row size is"); +--enable_query_log + +let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; + +set global innodb_file_per_table=1; + +-- echo ### Test 1 ### +# Create a table of DYNAMIC format, with a primary index of 768 bytes in +# size +create table worklog5743(a TEXT not null, primary key (a(768))) ROW_FORMAT=DYNAMIC; +show warnings; + +# Do some insertion and update to excercise the external cache +# code path +insert into worklog5743 values(repeat("a", 20000)); + +# default session, update the table +update worklog5743 set a = (repeat("b", 16000)); + +# Create a secondary index +SET sql_mode= ''; +create index idx on worklog5743(a(900)); +show warnings; +SET sql_mode= default; +# Start a few sessions to do selections on table being updated in default +# session, so it would rebuild the previous version from undo log. +# 1) Default session: Initiate an update on the externally stored column +# 2) Session con1: Select from table with repeated read +# 3) Session con2: Select from table with read uncommitted +# 4) Default session: rollback updates + +begin; +update worklog5743 set a = (repeat("x", 17000)); + +# Start a new session to select the column to force it build +# an earlier version of the clustered index through undo log. So it should +# just see the result of repeat("b", 16000) +select @@session.tx_isolation; +--connect (con1,localhost,root,,) +select a = repeat("x", 17000) from worklog5743; +select a = repeat("b", 16000) from worklog5743; + +# Start another session doing "read uncommitted" query, it +# should see the uncommitted update +--connect (con2,localhost,root,,) +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a = repeat("x", 17000) from worklog5743; + +# Roll back the transaction +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 2 ### +# Create a table with only a secondary index has large prefix column +create table worklog5743(a1 int, a2 TEXT not null) ROW_FORMAT=DYNAMIC; +show warnings; +create index idx on worklog5743(a1, a2(750)); +show warnings; + +insert into worklog5743 values(9, repeat("a", 10000)); + +begin; + +update worklog5743 set a1 = 1111; + +# Do a select from another connection that would use the secondary index +--connection con1 +select @@session.tx_isolation; +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; + +# Do read uncommitted in another session, it would show there is no +# row with a1 = 9 +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; + +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 3 ### +# Create a table with a secondary index has small (50 bytes) prefix column +create table worklog5743(a1 int, a2 TEXT not null) ROW_FORMAT=DYNAMIC; + +create index idx on worklog5743(a1, a2(50)); + +insert into worklog5743 values(9, repeat("a", 10000)); + +begin; + +update worklog5743 set a1 = 2222; + +# Do a select from another connection that would use the secondary index +--connection con1 +select @@session.tx_isolation; +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; + +# Do read uncommitted in another session, it would show there is no +# row with a1 = 9 +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; + +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 4 ### +# Create compressed tables with each KEY_BLOCK_SIZE. +create table worklog5743_1(a1 int, a2 TEXT not null) KEY_BLOCK_SIZE=1; +create table worklog5743_2(a1 int, a2 TEXT not null) KEY_BLOCK_SIZE=2; +create table worklog5743_4(a1 int, a2 TEXT not null) KEY_BLOCK_SIZE=4; + +# The maximum overall index record (not prefix) length of a +# compressed table is dependent on innodb-page-size (IPS), +# key_block_size (KBS) and the number of fields (NF). +# "Too big row" error (HA_ERR_TOO_BIG_ROW) will be returned if this +# limit is exceeded. +# See page_zip_empty_size() and Bug #47495 for more detail. + +# Test edge cases for indexes using key_block_size=1 +-- error ER_TOO_BIG_ROWSIZE +create index idx1 on worklog5743_1(a2(4000)); +show warnings; +-- error ER_TOO_BIG_ROWSIZE +create index idx3 on worklog5743_1(a2(436)); +show warnings; +# MDEV-27634 innodb_zip tests failing on s390x +create index idx4 on worklog5743_1(a2(290)); +show warnings; +-- error ER_TOO_BIG_ROWSIZE +create index idx5 on worklog5743_1(a1, a2(430)); +show warnings; +# MDEV-27634 innodb_zip tests failing on s390x +create index idx6 on worklog5743_1(a1, a2(283)); +show warnings; + +# Test edge cases for indexes using key_block_size=2 +SET sql_mode= ''; +set innodb_strict_mode=off; +create index idx1 on worklog5743_2(a2(4000)); +set innodb_strict_mode=on; +show warnings; +show create table worklog5743_2; +drop index idx1 on worklog5743_2; +create index idx3 on worklog5743_2(a2(769)); +show warnings; +create index idx4 on worklog5743_2(a2(768)); +show warnings; +create index idx6 on worklog5743_2(a1, a2(768)); +show warnings; +# Test edge cases for indexes using key_block_size=4 +set innodb_strict_mode=off; +create index idx1 on worklog5743_4(a2(4000)); +set innodb_strict_mode=on; +show warnings; +show create table worklog5743_4; +create index idx3 on worklog5743_4(a2(769)); +show warnings; +create index idx4 on worklog5743_4(a2(768)); +show warnings; +create index idx6 on worklog5743_4(a1, a2(764)); +show warnings; +SET sql_mode= default; +# Insert a large record into each of these tables. +insert into worklog5743_1 values(9, repeat("a", 10000)); +insert into worklog5743_2 values(9, repeat("a", 10000)); +insert into worklog5743_4 values(9, repeat("a", 10000)); + +select a1, left(a2, 20) from worklog5743_1; +select a1, left(a2, 20) from worklog5743_2; +select a1, left(a2, 20) from worklog5743_4; + +begin; + +update worklog5743_1 set a1 = 1000; +update worklog5743_2 set a1 = 1000; +update worklog5743_4 set a1 = 1000; +select a1, left(a2, 20) from worklog5743_1; +select a1, left(a2, 20) from worklog5743_2; +select a1, left(a2, 20) from worklog5743_4; + +# Do a select from another connection that would use the secondary index +--connection con1 +select @@session.tx_isolation; +explain select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +explain select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +explain select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; + +# Do read uncommitted in another session, it would show there is no +# row with a1 = 9 +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; + +--connection default +rollback; + +drop table worklog5743_1; +drop table worklog5743_2; +drop table worklog5743_4; + +-- echo ### Test 5 ### +# Create a table with large varchar columns and create indexes +# directly on these large columns to show that prefix limit is +# automatically applied and to show that limit. + +# This commented form of the test causes an unlimited page split +# on update of the int field - Bug 12636590 - INNODB; UPDATE OF +# LARGE RECORD CAUSES UNLIMITED PAGE SPLITS IN 8K PAGE SIZE +#create table worklog5743(a1 int, +# a2 varchar(20000), +# a3 varchar(3073), +# a4 varchar(3072), +# a5 varchar(3069), +# a6 varchar(3068)) +# ROW_FORMAT=DYNAMIC; +#create index idx1 on worklog5743(a2); +#create index idx2 on worklog5743(a3); +#create index idx3 on worklog5743(a4); +#show warnings; +#-- error ER_TOO_LONG_KEY +#create index idx4 on worklog5743(a1, a2); +#show warnings; +#-- error ER_TOO_LONG_KEY +#create index idx5 on worklog5743(a1, a5); +#show warnings; +#create index idx6 on worklog5743(a1, a6); +#show warnings; +#show create table worklog5743; +# +#insert into worklog5743 values(9, +# repeat("a", 20000), repeat("a", 3073), +# repeat("a", 3072), repeat("a", 3069), +# repeat("a", 3068)); +# + +create table worklog5743(a1 int, a2 varchar(20000)) ROW_FORMAT=DYNAMIC; +-- error ER_TOO_LONG_KEY +create index idx1 on worklog5743(a2); +show warnings; +drop table worklog5743; + +create table worklog5743(a1 int, a2 varchar(3072)) ROW_FORMAT=DYNAMIC; +-- error ER_TOO_LONG_KEY +create index idx1 on worklog5743(a2); +show warnings; +drop table worklog5743; + +create table worklog5743(a1 int, a2 varchar(769)) ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +show warnings; +drop table worklog5743; + +create table worklog5743(a1 int, a2 varchar(768)) ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +show warnings; +insert into worklog5743 values(9, repeat("a", 768)); +update worklog5743 set a1 = 3333; +drop table worklog5743; + +create table worklog5743(a1 int, a2 varchar(765)) ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a1, a2); +show warnings; +drop table worklog5743; + +create table worklog5743(a1 int, a2 varchar(764)) ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a1, a2); +show warnings; +insert into worklog5743 values(9, repeat("a", 764)); + +begin; +update worklog5743 set a1 = 4444; + +# Do a select from another connection that would use the secondary index +--connection con1 +select @@session.tx_isolation; +explain select a1 from worklog5743 where a1 = 9; +select a1 from worklog5743 where a1 = 9; + +# Do read uncommitted, it would show there is no row with a1 = 9 +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a1 from worklog5743 where a1 = 9; + +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 6 ### +create table worklog5743(a TEXT not null, primary key (a(1000))); +drop table worklog5743; + +create table worklog5743(a TEXT) ROW_FORMAT=COMPACT; + +# Excercise the column length check in ha_innobase::add_index() +-- error ER_INDEX_COLUMN_TOO_LONG +create index idx on worklog5743(a(768)); + +# This should be successful +create index idx on worklog5743(a(767)); + +# Perform some DMLs +insert into worklog5743 values(repeat("a", 20000)); + +begin; +insert into worklog5743 values(repeat("b", 20000)); +update worklog5743 set a = (repeat("x", 25000)); + +# Start a new session to select the table to force it build +# an earlier version of the cluster index through undo log +select @@session.tx_isolation; +--connection con1 +select a = repeat("a", 20000) from worklog5743; +--disconnect con1 + +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a = repeat("x", 25000) from worklog5743; +--disconnect con2 + +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 7 ### +# Some border line tests on the column length. +# We have a limit of 3072 bytes for Barracuda table +create table worklog5743(a TEXT not null) ROW_FORMAT=DYNAMIC; + +# Length exceeds maximum supported key length +# It will be auto-truncated to 3072 if the page size were not 4k. +# With this page size, the prefix length is less. +SET sql_mode= ''; +create index idx1 on worklog5743(a(769)); +show warnings; +SET sql_mode= default; +create index idx2 on worklog5743(a(768)); +show warnings; +show create table worklog5743; +insert into worklog5743 values(repeat("a", 768)); +drop table worklog5743; + +# We have a limit of 767 bytes for Antelope tables +create table worklog5743(a TEXT not null) ROW_FORMAT=REDUNDANT; +-- error ER_INDEX_COLUMN_TOO_LONG +create index idx on worklog5743(a(768)); +create index idx2 on worklog5743(a(767)); +drop table worklog5743; + +create table worklog5743(a TEXT not null) ROW_FORMAT=COMPACT; +-- error ER_INDEX_COLUMN_TOO_LONG +create index idx on worklog5743(a(768)); +create index idx2 on worklog5743(a(767)); +drop table worklog5743; + + +eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; diff --git a/mysql-test/suite/innodb_zip/t/index_large_prefix_8k.test b/mysql-test/suite/innodb_zip/t/index_large_prefix_8k.test new file mode 100644 index 00000000..bacde564 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/index_large_prefix_8k.test @@ -0,0 +1,402 @@ +# Testcase for worklog #5743: Lift the limit of index key prefixes + +--source include/have_innodb.inc +--source include/have_innodb_8k.inc +SET default_storage_engine=InnoDB; + +--disable_query_log +call mtr.add_suppression("Cannot add field .* in table .* because after adding it, the row size is"); +--enable_query_log + +let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; + +set global innodb_file_per_table=1; + +-- echo ### Test 1 ### +# Create a table of DYNAMIC format, with a primary index of 1000 bytes in +# size +create table worklog5743(a TEXT not null, primary key (a(1000))) ROW_FORMAT=DYNAMIC; +show warnings; + +# Do some insertion and update to excercise the external cache +# code path +insert into worklog5743 values(repeat("a", 20000)); + +# default session, update the table +update worklog5743 set a = (repeat("b", 16000)); + +# Create a secondary index +SET sql_mode= ''; +create index idx on worklog5743(a(2000)); +show warnings; +SET sql_mode= default; + +# Start a few sessions to do selections on table being updated in default +# session, so it would rebuild the previous version from undo log. +# 1) Default session: Initiate an update on the externally stored column +# 2) Session con1: Select from table with repeated read +# 3) Session con2: Select from table with read uncommitted +# 4) Default session: rollback updates + +begin; +update worklog5743 set a = (repeat("x", 17000)); + +# Start a new session to select the column to force it build +# an earlier version of the clustered index through undo log. So it should +# just see the result of repeat("b", 16000) +select @@session.tx_isolation; +--connect (con1,localhost,root,,) +select a = repeat("x", 17000) from worklog5743; +select a = repeat("b", 16000) from worklog5743; + +# Start another session doing "read uncommitted" query, it +# should see the uncommitted update +--connect (con2,localhost,root,,) +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a = repeat("x", 17000) from worklog5743; + +# Roll back the transaction +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 2 ### +# Create a table with only a secondary index has large prefix column +create table worklog5743(a1 int, a2 TEXT not null) ROW_FORMAT=DYNAMIC; +show warnings; +create index idx on worklog5743(a1, a2(1250)); +show warnings; + +insert into worklog5743 values(9, repeat("a", 10000)); + +begin; + +update worklog5743 set a1 = 1000; + +# Do a select from another connection that would use the secondary index +--connection con1 +select @@session.tx_isolation; +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; + +# Do read uncommitted in another session, it would show there is no +# row with a1 = 9 +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; + +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 3 ### +# Create a table with a secondary index has small (50 bytes) prefix column +create table worklog5743(a1 int, a2 TEXT not null) ROW_FORMAT=DYNAMIC; + +create index idx on worklog5743(a1, a2(50)); + +insert into worklog5743 values(9, repeat("a", 10000)); + +begin; + +update worklog5743 set a1 = 1000; + +# Do a select from another connection that would use the secondary index +--connection con1 +select @@session.tx_isolation; +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; + +# Do read uncommitted in another session, it would show there is no +# row with a1 = 9 +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; + +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 4 ### +# Create compressed tables with each KEY_BLOCK_SIZE. +create table worklog5743_1(a1 int, a2 TEXT not null) KEY_BLOCK_SIZE=1; +create table worklog5743_2(a1 int, a2 TEXT not null) KEY_BLOCK_SIZE=2; +create table worklog5743_4(a1 int, a2 TEXT not null) KEY_BLOCK_SIZE=4; +create table worklog5743_8(a1 int, a2 TEXT, a3 TEXT) KEY_BLOCK_SIZE=8; + +# The maximum overall index record (not prefix) length of a +# compressed table is dependent on innodb-page-size (IPS), +# key_block_size (KBS) and the number of fields (NF). +# "Too big row" error (HA_ERR_TOO_BIG_ROW) will be returned if this +# limit is exceeded. +# See page_zip_empty_size() and Bug #47495 for more detail. + +# Test edge cases for indexes using key_block_size=1 +-- error ER_TOO_BIG_ROWSIZE +create index idx2 on worklog5743_1(a2(4000)); +show warnings; +-- error ER_TOO_BIG_ROWSIZE +create index idx3 on worklog5743_1(a2(436)); +show warnings; +# MDEV-27634 innodb_zip tests failing on s390x +create index idx4 on worklog5743_1(a2(290)); +show warnings; +-- error ER_TOO_BIG_ROWSIZE +create index idx5 on worklog5743_1(a1, a2(430)); +show warnings; +# MDEV-27634 innodb_zip tests failing on s390x +create index idx6 on worklog5743_1(a1, a2(283)); +show warnings; + +# Test edge cases for indexes using key_block_size=2 +-- error ER_TOO_BIG_ROWSIZE +create index idx2 on worklog5743_2(a2(4000)); +show warnings; +-- error ER_TOO_BIG_ROWSIZE +create index idx3 on worklog5743_2(a2(948)); +show warnings; +# MDEV-27634 innodb_zip tests failing on s390x +create index idx4 on worklog5743_2(a2(802)); +show warnings; +-- error ER_TOO_BIG_ROWSIZE +create index idx5 on worklog5743_2(a1, a2(942)); +show warnings; +# MDEV-27634 innodb_zip tests failing on s390x +create index idx6 on worklog5743_2(a1, a2(795)); +show warnings; + +# Test edge cases for indexes using key_block_size=4 +create index idx3 on worklog5743_4(a2(1537)); +show warnings; +create index idx4 on worklog5743_4(a2(1536)); +show warnings; +-- error ER_TOO_LONG_KEY +create index idx5 on worklog5743_4(a1, a2(1533)); +show warnings; +create index idx6 on worklog5743_4(a1, a2(1532)); +show warnings; + +# Test edge cases for indexes using key_block_size=8 +create index idx2 on worklog5743_8(a2(3073)); +show warnings; +create index idx3 on worklog5743_8(a2(3072)); +show warnings; +-- error ER_TOO_LONG_KEY +create index idx4 on worklog5743_8(a1, a2(1533)); +show warnings; +create index idx5 on worklog5743_8(a1, a2(1532)); +show warnings; +SET sql_mode= default; + +# Insert a large record into each of these tables. +insert into worklog5743_1 values(9, repeat("a", 10000)); +insert into worklog5743_2 values(9, repeat("a", 10000)); +insert into worklog5743_4 values(9, repeat("a", 10000)); +insert into worklog5743_8 values(9, repeat("a", 10000), repeat("a", 10000)); + +select a1, left(a2, 20) from worklog5743_1; +select a1, left(a2, 20) from worklog5743_2; +select a1, left(a2, 20) from worklog5743_4; +select a1, left(a2, 20) from worklog5743_8; + +begin; + +update worklog5743_1 set a1 = 1000; +update worklog5743_2 set a1 = 1000; +update worklog5743_4 set a1 = 1000; +update worklog5743_8 set a1 = 1000; +select a1, left(a2, 20) from worklog5743_1; +select a1, left(a2, 20) from worklog5743_2; +select a1, left(a2, 20) from worklog5743_4; +select a1, left(a2, 20) from worklog5743_8; + + +# Do a select from another connection that would use the secondary index +--connection con1 +select @@session.tx_isolation; +explain select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +explain select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +explain select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +explain select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +select a1, left(a2, 20) from worklog5743_8 where a1 = 9; + +# Do read uncommitted in another session, it would show there is no +# row with a1 = 9 +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +select a1, left(a2, 20) from worklog5743_8 where a1 = 9; + +--connection default +rollback; + +drop table worklog5743_1; +drop table worklog5743_2; +drop table worklog5743_4; +drop table worklog5743_8; + +-- echo ### Test 5 ### +# Create a table with large varchar columns and create indexes +# directly on these large columns to show that prefix limit is +# automatically applied and to show that limit. + +# This commented form of the test causes an unlimited page split +# on update of the int field - Bug 12636590 - INNODB; UPDATE OF +# LARGE RECORD CAUSES UNLIMITED PAGE SPLITS IN 8K PAGE SIZE +#create table worklog5743(a1 int, +# a2 varchar(20000), +# a3 varchar(3073), +# a4 varchar(3072), +# a5 varchar(3069), +# a6 varchar(3068)) +# ROW_FORMAT=DYNAMIC; +#create index idx1 on worklog5743(a2); +#create index idx2 on worklog5743(a3); +#create index idx3 on worklog5743(a4); +#show warnings; +#-- error ER_TOO_LONG_KEY +#create index idx4 on worklog5743(a1, a2); +#show warnings; +#-- error ER_TOO_LONG_KEY +#create index idx5 on worklog5743(a1, a5); +#show warnings; +#create index idx6 on worklog5743(a1, a6); +#show warnings; +#show create table worklog5743; +# +#insert into worklog5743 values(9, +# repeat("a", 20000), repeat("a", 3073), +# repeat("a", 3072), repeat("a", 3069), +# repeat("a", 3068)); +# + +create table worklog5743(a1 int, a2 varchar(20000)) ROW_FORMAT=DYNAMIC; +-- error ER_TOO_LONG_KEY +create index idx1 on worklog5743(a2); +drop table worklog5743; + +create table worklog5743(a1 int, a2 varchar(1537)) ROW_FORMAT=DYNAMIC; +-- error ER_TOO_LONG_KEY +create index idx1 on worklog5743(a2); +drop table worklog5743; + +create table worklog5743(a1 int, a2 varchar(1536)) ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +show warnings; +insert into worklog5743 values(9, repeat("a", 1536)); +update worklog5743 set a1 = 1000; +drop table worklog5743; + +create table worklog5743(a1 int, a2 varchar(1533)) ROW_FORMAT=DYNAMIC; +-- error ER_TOO_LONG_KEY +create index idx1 on worklog5743(a1, a2); +show warnings; +drop table worklog5743; + +create table worklog5743(a1 int, a2 varchar(1532)) ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a1, a2); +show warnings; +insert into worklog5743 values(9, repeat("a", 1532)); +update worklog5743 set a1 = 1000; + +begin; +update worklog5743 set a1 = 1000; + +# Do a select from another connection that would use the secondary index +--connection con1 +select @@session.tx_isolation; +explain select a1 from worklog5743 where a1 = 9; +select a1 from worklog5743 where a1 = 9; + +# Do read uncommitted, it would show there is no row with a1 = 9 +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a1 from worklog5743 where a1 = 9; + +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 6 ### +# Create a table with old format, and the limit is 768 bytes. +-- error ER_INDEX_COLUMN_TOO_LONG +create table worklog5743(a TEXT not null, primary key (a(1000))) +row_format=compact; + +create table worklog5743(a TEXT) row_format=compact; + +# Excercise the column length check in ha_innobase::add_index() +-- error ER_INDEX_COLUMN_TOO_LONG +create index idx on worklog5743(a(768)); + +# This should be successful +create index idx on worklog5743(a(767)); + +# Perform some DMLs +insert into worklog5743 values(repeat("a", 20000)); + +begin; +insert into worklog5743 values(repeat("b", 20000)); +update worklog5743 set a = (repeat("x", 25000)); + +# Start a new session to select the table to force it build +# an earlier version of the cluster index through undo log +select @@session.tx_isolation; +--connection con1 +select a = repeat("a", 20000) from worklog5743; +--disconnect con1 + +--connection con2 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +select a = repeat("x", 25000) from worklog5743; +--disconnect con2 + +--connection default +rollback; + +drop table worklog5743; + +-- echo ### Test 7 ### +# Some border line tests on the column length. +# We have a limit of 3072 bytes for Barracuda table +create table worklog5743(a TEXT not null) ROW_FORMAT=DYNAMIC; + +# Length exceeds maximum supported key length +# It will be auto-truncated to 3072 +SET sql_mode= ''; +create index idx1 on worklog5743(a(3073)); +create index idx2 on worklog5743(a(3072)); +SET sql_mode= default; +show create table worklog5743; +drop table worklog5743; + +# We have a limit of 767 bytes for Antelope tables +create table worklog5743(a TEXT not null) ROW_FORMAT=REDUNDANT; +-- error ER_INDEX_COLUMN_TOO_LONG +create index idx on worklog5743(a(768)); +create index idx2 on worklog5743(a(767)); +drop table worklog5743; + +create table worklog5743(a TEXT not null) ROW_FORMAT=COMPACT; +-- error ER_INDEX_COLUMN_TOO_LONG +create index idx on worklog5743(a(768)); +create index idx2 on worklog5743(a(767)); +drop table worklog5743; + + +eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; diff --git a/mysql-test/suite/innodb_zip/t/innochecksum.test b/mysql-test/suite/innodb_zip/t/innochecksum.test new file mode 100644 index 00000000..b78cd432 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/innochecksum.test @@ -0,0 +1,72 @@ +#************************************************************ +# WL6045:Improve Innochecksum +#************************************************************ +--source include/have_innodb.inc +--source include/no_valgrind_without_big.inc +--source include/not_embedded.inc + +let $MYSQLD_DATADIR= `SELECT @@datadir`; +let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err; + +call mtr.add_suppression("InnoDB: Unable to read tablespace .* page no .* into the buffer pool after 100 attempts"); +call mtr.add_suppression("InnoDB: Warning: database page corruption or a failed"); + +CREATE TABLE tab1(c1 INT PRIMARY KEY,c2 VARCHAR(20)) ENGINE=InnoDB; +CREATE INDEX idx1 ON tab1(c2(10)); +INSERT INTO tab1 VALUES(1, 'Innochecksum InnoDB1'); + +--echo # Shutdown the Server +--source include/shutdown_mysqld.inc +--echo # Server Default checksum = innodb + +# +# Not repeatable with --parallel= >1 +# +#--echo [1a]: check the innochecksum when file doesn't exists +#--error 1 +#--exec $INNOCHECKSUM $MYSQLD_DATADIR/test/aa.ibd 2> $SEARCH_FILE +#let SEARCH_PATTERN= Error: $MYSQLD_DATADIR/test/aa.ibd cannot be found; +#--source include/search_pattern_in_file.inc + +--echo [1b]: check the innochecksum without --strict-check +--exec $INNOCHECKSUM $MYSQLD_DATADIR/test/tab1.ibd + +--echo [4]: check the innochecksum with --no-check ignores algorithm check, warning is expected +--error 1 +--exec $INNOCHECKSUM --no-check $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= Error: --no-check must be associated with --write option.; +--source include/search_pattern_in_file.inc + +--echo [5]: check the innochecksum with short form --no-check ignores algorithm check, warning is expected +--error 1 +--exec $INNOCHECKSUM -n $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= Error: --no-check must be associated with --write option.; +--source include/search_pattern_in_file.inc + +--echo [6]: check the innochecksum with full form strict-check & no-check , an error is expected +--error 1 +--exec $INNOCHECKSUM --strict-check=innodb --no-check $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= unknown variable 'strict-check=innodb'; +--source include/search_pattern_in_file.inc + +--echo [7]: check the innochecksum with short form strict-check & no-check , an error is expected +--error 1 +--exec $INNOCHECKSUM -C innodb -n $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= unknown option '-C'; +--source include/search_pattern_in_file.inc + +--error 1 +--exec $INNOCHECKSUM --no-check --write=crc32 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +--let SEARCH_PATTERN= ignoring option '--write' due to invalid value 'crc32' +--source include/search_pattern_in_file.inc + +--error 1 +--exec $INNOCHECKSUM --no-check $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +--let SEARCH_PATTERN= Error: --no-check must be associated with --write option +--source include/search_pattern_in_file.inc + +--exec $INNOCHECKSUM --no-check --write $MYSQLD_DATADIR/test/tab1.ibd +--source include/start_mysqld.inc + +SELECT * FROM tab1; +DROP TABLE tab1; diff --git a/mysql-test/suite/innodb_zip/t/innochecksum_2.opt b/mysql-test/suite/innodb_zip/t/innochecksum_2.opt new file mode 100644 index 00000000..ac26eca3 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/innochecksum_2.opt @@ -0,0 +1 @@ +--skip-innodb-doublewrite diff --git a/mysql-test/suite/innodb_zip/t/innochecksum_2.test b/mysql-test/suite/innodb_zip/t/innochecksum_2.test new file mode 100644 index 00000000..62e792c1 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/innochecksum_2.test @@ -0,0 +1,94 @@ +#************************************************************ +# WL6045:Improve Innochecksum +#************************************************************ +--source include/innodb_page_size_small.inc +--source include/have_debug.inc +# Avoid CrashReporter popup on Mac. +--source include/not_crashrep.inc + +--source include/not_embedded.inc +-- source include/big_test.inc + +--disable_query_log +# This warning occurs due to small buffer pool size(i.e. 8MB). It doesn't occur +# with --mysqld=--innodb_buffer_pool_size=10MB +call mtr.add_suppression("\\[Warning\\] InnoDB: Difficult to find free blocks in the buffer pool.*"); +--enable_query_log +let MYSQLD_BASEDIR= `SELECT @@basedir`; +let MYSQLD_DATADIR= `SELECT @@datadir`; +let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err; +let $restart_noprint=2; + +SET GLOBAL innodb_compression_level=0; +SELECT @@innodb_compression_level; + +CREATE TABLE t1 (j LONGBLOB) ENGINE = InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +INSERT INTO t1 VALUES (repeat('abcdefghijklmnopqrstuvwxyz',200)); +let $i=10; +while ($i > 0) { + INSERT INTO t1 SELECT * from t1; + dec $i; +} + +--echo # stop the server +--source include/shutdown_mysqld.inc + +# Page_type_dump for t1 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $INNOCHECKSUM -v --page-type-dump $MYSQLTEST_VARDIR/tmp/dump.txt $MYSQLD_DATADIR/test/t1.ibd +--file_exists $MYSQLTEST_VARDIR/tmp/dump.txt +--remove_file $MYSQLTEST_VARDIR/tmp/dump.txt + +--echo [1]:# check the both short and long options for "help" +--exec $INNOCHECKSUM --help $MYSQLD_DATADIR/test/t1.ibd > $MYSQLTEST_VARDIR/tmp/help_output_long.txt +--exec $INNOCHECKSUM -I $MYSQLD_DATADIR/test/t1.ibd > $MYSQLTEST_VARDIR/tmp/help_output_short.txt +--diff_files $MYSQLTEST_VARDIR/tmp/help_output_long.txt $MYSQLTEST_VARDIR/tmp/help_output_short.txt + +--echo [2]:# Run the innochecksum when file isn't provided. +--echo # It will print the innochecksum usage similar to --help option. +--error 1 +--exec $INNOCHECKSUM > $MYSQLTEST_VARDIR/tmp/usage.txt +--diff_files $MYSQLTEST_VARDIR/tmp/help_output_long.txt $MYSQLTEST_VARDIR/tmp/usage.txt +--remove_file $MYSQLTEST_VARDIR/tmp/usage.txt + +perl; +use strict; +use warnings; +use File::Copy; +my $dir = $ENV{'MYSQLTEST_VARDIR'}; +my $file= 'help_output_long.txt'; +# open file in write mode +open IN_FILE,"<", "$dir/tmp/$file" or die $!; +open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!; +while(<IN_FILE>) { + unless ($_=~ /^debug.*$/ || $_=~ /\-#, \-\-debug.*$/ || $_=~ /http:.*html/) { + $_=~ s/^\S*innochecksum.+Ver.+[0-9]*\.[0-9]*\.[0-9]*.+$/innochecksum Ver #.#.#/g; + $_=~ s/(Copyright\s\(c\))\s([0-9]*),\s([0-9]*)(.*)/$1 YEAR, YEAR $4/g; + $_=~ s/Usage:.*\[-c/Usage: innochecksum [-c/g; + print OUT_FILE $_; + } +} +close(IN_FILE); +close(OUT_FILE); +# move the new content from tmp file to the orginal file. +move ("$dir/tmp/tmpfile", "$dir/tmp/$file"); +EOF + +--cat_file $MYSQLTEST_VARDIR/tmp/help_output_long.txt +--remove_file $MYSQLTEST_VARDIR/tmp/help_output_long.txt +--remove_file $MYSQLTEST_VARDIR/tmp/help_output_short.txt + +--echo [3]:# check the both short and long options for "count" and exit +--replace_regex /[0-9]+/#/ +--exec $INNOCHECKSUM --count $MYSQLD_DATADIR/test/t1.ibd +--replace_regex /[0-9]+/#/ +--exec $INNOCHECKSUM -c $MYSQLD_DATADIR/test/t1.ibd + +--echo [4]:# Print the version of innochecksum and exit +--replace_regex /.*innochecksum.*Ver.*[0-9]*.[0-9]*.[0-9]*.*/innochecksum Ver #.#.#/ +--exec $INNOCHECKSUM -V $MYSQLD_DATADIR/test/t1.ibd + +--echo # Restart the DB server +--source include/start_mysqld.inc + +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_zip/t/innochecksum_3.combinations b/mysql-test/suite/innodb_zip/t/innochecksum_3.combinations new file mode 100644 index 00000000..79e5f783 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/innochecksum_3.combinations @@ -0,0 +1,5 @@ +[crc32] +--innodb-checksum-algorithm=crc32 + +[full_crc32] +--innodb-checksum-algorithm=full_crc32 diff --git a/mysql-test/suite/innodb_zip/t/innochecksum_3.opt b/mysql-test/suite/innodb_zip/t/innochecksum_3.opt new file mode 100644 index 00000000..287c7ed5 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/innochecksum_3.opt @@ -0,0 +1 @@ +--innodb_checksum_algorithm=crc32 diff --git a/mysql-test/suite/innodb_zip/t/innochecksum_3.test b/mysql-test/suite/innodb_zip/t/innochecksum_3.test new file mode 100644 index 00000000..ef6d8225 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/innochecksum_3.test @@ -0,0 +1,270 @@ +#************************************************************ +# WL6045:Improve Innochecksum +#************************************************************ +--source include/innodb_page_size_small.inc + +--source include/no_valgrind_without_big.inc + +# Embedded server does not support crashing. +--source include/not_embedded.inc + +# Avoid CrashReporter popup on Mac. +--source include/not_crashrep.inc + +--echo # Set the environmental variables +let MYSQLD_BASEDIR= `SELECT @@basedir`; +let MYSQLD_DATADIR= `SELECT @@datadir`; +let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err; + +call mtr.add_suppression("InnoDB: Unable to read tablespace .* page no .* into the buffer pool after 100 attempts"); +call mtr.add_suppression("InnoDB: innodb_checksum_algorithm is set to.*"); + +CREATE TABLE tab1 (pk INTEGER NOT NULL PRIMARY KEY, +linestring_key GEOMETRY NOT NULL, +linestring_nokey GEOMETRY NOT NULL) +ENGINE=InnoDB ; + +INSERT INTO tab1 (pk, linestring_key, linestring_nokey) +VALUES (1, ST_GeomFromText('POINT(10 10) '), ST_GeomFromText('POINT(10 10) ')); + +CREATE INDEX linestring_index ON tab1(linestring_nokey(5)); +ALTER TABLE tab1 ADD KEY (linestring_key(5)); + +--echo # create a compressed table +CREATE TABLE tab2(col_1 CHAR (255) , +col_2 VARCHAR (255), col_3 longtext, +col_4 longtext,col_5 longtext, +col_6 longtext , col_7 int ) +engine = innodb row_format=compressed key_block_size=4; + +CREATE INDEX idx1 ON tab2(col_3(10)); +CREATE INDEX idx2 ON tab2(col_4(10)); +CREATE INDEX idx3 ON tab2(col_5(10)); + +# load the with repeat function +SET @col_1 = repeat('a', 5); +SET @col_2 = repeat('b', 20); +SET @col_3 = repeat('c', 100); +SET @col_4 = repeat('d', 100); +SET @col_5 = repeat('e', 100); +SET @col_6 = repeat('f', 100); + +# insert 5 records +let $i = 5; +while ($i) { + eval INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7) + VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,$i); + dec $i; +} + +--echo # stop the server +--source include/shutdown_mysqld.inc + +--echo [2]: Check the page type summary with shortform for tab1.ibd +--replace_regex /File.*.ibd/File::tab1.ibd/ /[0-9]+/#/ +--exec $INNOCHECKSUM -S $MYSQLD_DATADIR/test/tab1.ibd 2>$MYSQLTEST_VARDIR/tmp/page_summary_short.txt + +--echo [3]: Check the page type summary with longform for tab1.ibd +--replace_regex /File.*.ibd/File::tab1.ibd/ /[0-9]+/#/ +--exec $INNOCHECKSUM --page-type-summary $MYSQLD_DATADIR/test/tab1.ibd 2>$MYSQLTEST_VARDIR/tmp/page_summary_long.txt + +--remove_file $MYSQLTEST_VARDIR/tmp/page_summary_short.txt +--remove_file $MYSQLTEST_VARDIR/tmp/page_summary_long.txt +--echo [4]: Page type dump for with longform for tab1.ibd +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $INNOCHECKSUM --page-type-dump $MYSQLTEST_VARDIR/tmp/dump.txt $MYSQLD_DATADIR/test/tab1.ibd + +perl; +use strict; +use warnings; +use File::Copy; +my $dir = $ENV{'MYSQLTEST_VARDIR'}; +opendir(DIR, $dir) or die $!; +my $file= 'dump.txt'; +# open file in write mode +open IN_FILE,"<", "$dir/tmp/$file" or die $!; +open OUT_FILE, ">", "$dir/tmp/innochecksum_3_tempfile" or die $!; +while(<IN_FILE>) +{ + # Replace the intergers to # and complete file path to file name only. + $_=~ s/Filename.+/Filename::tab1.ibd/g; + $_=~ s/\d+/#/g; + print OUT_FILE $_; +} +close(IN_FILE); +close(OUT_FILE); +# move the new content from tmp file to the orginal file. +move ("$dir/tmp/innochecksum_3_tempfile", "$dir/tmp/$file"); +closedir(DIR); +EOF + +--echo # Print the contents stored in dump.txt +cat_file $MYSQLTEST_VARDIR/tmp/dump.txt; +--remove_file $MYSQLTEST_VARDIR/tmp/dump.txt + +--echo # Variables used by page type dump for ibdata1 +--exec $INNOCHECKSUM -v --page-type-dump $MYSQLTEST_VARDIR/tmp/dump.txt $MYSQLD_DATADIR/ibdata1 > $MYSQLTEST_VARDIR/tmp/page_verbose_summary.txt + +--file_exists $MYSQLTEST_VARDIR/tmp/dump.txt +--remove_file $MYSQLTEST_VARDIR/tmp/dump.txt + +perl; +use strict; +use warnings; +use File::Copy; +my $dir = $ENV{'MYSQLTEST_VARDIR'}; +opendir(DIR, $dir) or die $!; +my $file= 'page_verbose_summary.txt'; +# open file in write mode +open IN_FILE,"<", "$dir/tmp/$file" or die $!; +open OUT_FILE, ">", "$dir/tmp/innochecksum_3_tempfile" or die $!; +while(<IN_FILE>) +{ + # Replace complete file path to file name only. + $_=~ s/$dir/MYSQLTEST_VARDIR/; + # Remove debug option, which is not in all builds + next if (/debug/); + print OUT_FILE $_; +} +close(IN_FILE); +close(OUT_FILE); +# move the new content from tmp file to the orginal file. +move ("$dir/tmp/innochecksum_3_tempfile", "$dir/tmp/$file"); +closedir(DIR); +EOF + +cat_file $MYSQLTEST_VARDIR/tmp/page_verbose_summary.txt; +--remove_file $MYSQLTEST_VARDIR/tmp/page_verbose_summary.txt + +--echo [5]: Page type dump for with shortform for tab1.ibd +--exec $INNOCHECKSUM -D $MYSQLTEST_VARDIR/tmp/dump.txt $MYSQLD_DATADIR/test/tab1.ibd + +perl; +use strict; +use warnings; +use File::Copy; +my $dir = $ENV{'MYSQLTEST_VARDIR'}; +opendir(DIR, $dir) or die $!; +my $file= 'dump.txt'; +# open file in write mode +open IN_FILE,"<", "$dir/tmp/$file" or die $!; +open OUT_FILE, ">", "$dir/tmp/innochecksum_3_tempfile" or die $!; +while(<IN_FILE>) +{ + # Replace the intergers to # and complete file path to file name only. + $_=~ s/Filename.+/Filename::tab1.ibd/g; + $_=~ s/\d+/#/g; + print OUT_FILE $_; +} +close(IN_FILE); +close(OUT_FILE); +# move the new content from tmp file to the orginal file. +move ("$dir/tmp/innochecksum_3_tempfile", "$dir/tmp/$file"); +closedir(DIR); +EOF + +# Print the contents stored in dump.txt +cat_file $MYSQLTEST_VARDIR/tmp/dump.txt; +--remove_file $MYSQLTEST_VARDIR/tmp/dump.txt + +--echo [6]: check the valid lower bound values for option +--echo # allow-mismatches,page,start-page,end-page +--exec $INNOCHECKSUM --allow-mismatches=0 $MYSQLD_DATADIR/test/tab1.ibd +--exec $INNOCHECKSUM -a 0 $MYSQLD_DATADIR/test/tab1.ibd +--exec $INNOCHECKSUM --page=0 $MYSQLD_DATADIR/test/tab1.ibd +--exec $INNOCHECKSUM -p 0 $MYSQLD_DATADIR/test/tab1.ibd +--exec $INNOCHECKSUM --start-page=0 $MYSQLD_DATADIR/test/tab1.ibd +--exec $INNOCHECKSUM -s 0 $MYSQLD_DATADIR/test/tab1.ibd +--exec $INNOCHECKSUM --end-page=0 $MYSQLD_DATADIR/test/tab1.ibd +--exec $INNOCHECKSUM -e 0 $MYSQLD_DATADIR/test/tab1.ibd + +# +# These produce now errors +# +#--echo [7]: check the negative values for option +#--echo # allow-mismatches,page,start-page,end-page. +#--echo # They will reset to zero for negative values. +#--echo # check the invalid lower bound values +#--exec $INNOCHECKSUM --allow-mismatches=-1 $MYSQLD_DATADIR/test/tab1.ibd +#--exec $INNOCHECKSUM -a -1 $MYSQLD_DATADIR/test/tab1.ibd +#--exec $INNOCHECKSUM --page=-1 $MYSQLD_DATADIR/test/tab1.ibd +#--exec $INNOCHECKSUM -p -1 $MYSQLD_DATADIR/test/tab1.ibd +#--exec $INNOCHECKSUM --start-page=-1 $MYSQLD_DATADIR/test/tab1.ibd +#--exec $INNOCHECKSUM -s -1 $MYSQLD_DATADIR/test/tab1.ibd +#--exec $INNOCHECKSUM --end-page=-1 $MYSQLD_DATADIR/test/tab1.ibd +#--exec $INNOCHECKSUM -e -1 $MYSQLD_DATADIR/test/tab1.ibd +# +#--echo [8]: check the valid upper bound values for +#--echo # both short and long options "allow-mismatches" and "end-page" +# +#--exec $INNOCHECKSUM --allow-mismatches=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd +#--exec $INNOCHECKSUM -a 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd +#--exec $INNOCHECKSUM --end-page=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd +#--exec $INNOCHECKSUM -e 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd + +--echo [9]: check the both short and long options "page" and "start-page" when +--echo # seek value is larger than file size. +--error 1 +--exec $INNOCHECKSUM --page=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= Error: Unable to seek to necessary offset; +--source include/search_pattern_in_file.inc + +--error 1 +--exec $INNOCHECKSUM -p 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +--source include/search_pattern_in_file.inc + +--error 1 +--exec $INNOCHECKSUM --start-page=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +--source include/search_pattern_in_file.inc + +--error 1 +--exec $INNOCHECKSUM -s 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +--source include/search_pattern_in_file.inc + +--echo [34]: check the invalid upper bound values for options, allow-mismatches, end-page, start-page and page. +--echo # innochecksum will fail with error code: 1 +--error 1 +--exec $INNOCHECKSUM --allow-mismatches=18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616'; +--source include/search_pattern_in_file.inc + +--error 1 +--exec $INNOCHECKSUM -a 18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616'; +--source include/search_pattern_in_file.inc + +--error 1 +--exec $INNOCHECKSUM --end-page=18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616'; +--source include/search_pattern_in_file.inc + +--error 1 +--exec $INNOCHECKSUM -e 18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616'; +--source include/search_pattern_in_file.inc + +--error 1 +--exec $INNOCHECKSUM --page=18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616'; +--source include/search_pattern_in_file.inc + +--error 1 +--exec $INNOCHECKSUM -p 18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616'; +--source include/search_pattern_in_file.inc + +--error 1 +--exec $INNOCHECKSUM --start-page=18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616'; +--source include/search_pattern_in_file.inc + +--error 1 +--exec $INNOCHECKSUM -s 18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616'; +--source include/search_pattern_in_file.inc +--remove_file $SEARCH_FILE + +# Cleanup +--source include/start_mysqld.inc + +DROP TABLE tab1,tab2; diff --git a/mysql-test/suite/innodb_zip/t/innodb-zip.test b/mysql-test/suite/innodb_zip/t/innodb-zip.test new file mode 100644 index 00000000..507900aa --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/innodb-zip.test @@ -0,0 +1,262 @@ +--source include/innodb_page_size_small.inc + +CREATE DATABASE mysqltest_innodb_zip; +USE mysqltest_innodb_zip; +SELECT table_name, row_format, data_length, index_length + FROM information_schema.tables + WHERE table_schema='mysqltest_innodb_zip'; + +let $per_table=`select @@innodb_file_per_table`; +SET @save_innodb_stats_on_metadata=@@global.innodb_stats_on_metadata; + +--let $query_i_s = SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb' AND table_schema != 'mysql' and table_schema != 'sys' order by table_name + +set session innodb_strict_mode=0; +set global innodb_file_per_table=off; +SET @@global.innodb_stats_on_metadata=ON; + +create table t0(a int primary key) engine=innodb row_format=compressed; +create table t00(a int primary key) engine=innodb +key_block_size=4 row_format=compressed; +create table t1(a int primary key) engine=innodb row_format=dynamic; +create table t2(a int primary key) engine=innodb row_format=redundant; +create table t3(a int primary key) engine=innodb row_format=compact; +create table t4(a int primary key) engine=innodb key_block_size=9; +create table t5(a int primary key) engine=innodb +key_block_size=1 row_format=redundant; + +set global innodb_file_per_table=on; +create table t6(a int primary key) engine=innodb +key_block_size=1 row_format=redundant; +create table t7(a int primary key) engine=innodb +key_block_size=1 row_format=redundant; +create table t8(a int primary key) engine=innodb +key_block_size=1 row_format=fixed; +create table t9(a int primary key) engine=innodb +key_block_size=1 row_format=compact; +create table t10(a int primary key) engine=innodb +key_block_size=1 row_format=dynamic; +create table t11(a int primary key) engine=innodb +key_block_size=1 row_format=compressed; +create table t12(a int primary key) engine=innodb +key_block_size=1; +create table t13(a int primary key) engine=innodb +row_format=compressed; +create table t14(a int primary key) engine=innodb key_block_size=9; + +--replace_result 16384 {valid} 8192 {valid} 4096 {valid} 2048 {valid} +--eval $query_i_s + +drop table t0,t00,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14; +alter table t1 key_block_size=0; +alter table t1 row_format=dynamic; +--replace_result 16384 {valid} 8192 {valid} 4096 {valid} +--eval $query_i_s +alter table t1 row_format=compact; +--replace_result 16384 {valid} 8192 {valid} 4096 {valid} +--eval $query_i_s +alter table t1 row_format=redundant; +--replace_result 16384 {valid} 8192 {valid} 4096 {valid} +--eval $query_i_s +drop table t1; + +create table t1(a int not null, b text, index(b(10))) engine=innodb +key_block_size=1; + +create table t2(b text)engine=innodb; +insert into t2 values(concat('1abcdefghijklmnopqrstuvwxyz', repeat('A',5000))); + +insert into t1 select 1, b from t2; +commit; + +connect (a,localhost,root,,mysqltest_innodb_zip); +connect (b,localhost,root,,mysqltest_innodb_zip); + +connection a; +begin; +update t1 set b=repeat('B',100); + +connection b; +select a,left(b,40) from t1 natural join t2; + +connection a; +rollback; + +connection b; +select a,left(b,40) from t1 natural join t2; + +connection default; +disconnect a; +disconnect b; + +analyze table t1; +analyze table t2; +--replace_result 16384 {valid} 12288 {valid} +--eval $query_i_s +drop table t1,t2; + +# +# Bug #50945 moved to innodb_16k.test, innodb_8k.test, & innodb_4k.test +# + +# +# Test blob column inheritance (mantis issue#36) +# + +create table t1( c1 int not null, c2 blob, c3 blob, c4 blob, + primary key(c1, c2(22), c3(22))) + engine = innodb row_format = dynamic; +begin; +insert into t1 values(1, repeat('A', 20000), repeat('B', 20000), + repeat('C', 20000)); + +update t1 set c3 = repeat('D', 20000) where c1 = 1; +commit; + +# one blob column which is unchanged in update and part of PK +# one blob column which is changed and part of of PK +# one blob column which is not part of PK and is unchanged +select count(*) from t1 where c2 = repeat('A', 20000); +select count(*) from t1 where c3 = repeat('D', 20000); +select count(*) from t1 where c4 = repeat('C', 20000); + +update t1 set c3 = repeat('E', 20000) where c1 = 1; +drop table t1; + +set global innodb_file_per_table = on; + +set innodb_strict_mode = off; +create table t1 (id int primary key) engine = innodb key_block_size = 0; +drop table t1; + +#set strict_mode +set innodb_strict_mode = on; + +#Test different values of KEY_BLOCK_SIZE + +create table t1 (id int primary key) engine = innodb key_block_size = 0; + +--replace_regex / - .*[0-9]*[)]/)/ +--error ER_CANT_CREATE_TABLE +create table t2 (id int primary key) engine = innodb key_block_size = 9; +--replace_regex / - .*[0-9]*[)]/)/ +show warnings; + + +create table t3 (id int primary key) engine = innodb key_block_size = 1; +create table t4 (id int primary key) engine = innodb key_block_size = 2; +create table t5 (id int primary key) engine = innodb key_block_size = 4; +# These tests are now done in innodb_16k, innodb_8k and innodb_4k +# where they get different result depending on page size +# create table t6 (id int primary key) engine = innodb key_block_size = 8; +# create table t7 (id int primary key) engine = innodb key_block_size = 16; + +#check various ROW_FORMAT values. +create table t8 (id int primary key) engine = innodb row_format = compressed; +create table t9 (id int primary key) engine = innodb row_format = dynamic; +create table t10(id int primary key) engine = innodb row_format = compact; +create table t11(id int primary key) engine = innodb row_format = redundant; + +--replace_result 16384 {valid} 8192 {valid} 4096 {valid} 2048 {valid} +--eval $query_i_s +drop table t1, t3, t4, t5, t8, t9, t10, t11; + +#test different values of ROW_FORMAT with KEY_BLOCK_SIZE +create table t1 (id int primary key) engine = innodb +key_block_size = 4 row_format = compressed; + +--replace_regex / - .*[0-9]*[)]/)/ +--error ER_CANT_CREATE_TABLE +create table t2 (id int primary key) engine = innodb +key_block_size = 4 row_format = redundant; +--replace_regex / - .*[0-9]*[)]/)/ +show warnings; + +--replace_regex / - .*[0-9]*[)]/)/ +--error ER_CANT_CREATE_TABLE +create table t3 (id int primary key) engine = innodb +key_block_size = 4 row_format = compact; +--replace_regex / - .*[0-9]*[)]/)/ +show warnings; + +--replace_regex / - .*[0-9]*[)]/)/ +--error ER_CANT_CREATE_TABLE +create table t4 (id int primary key) engine = innodb +key_block_size = 4 row_format = dynamic; +--replace_regex / - .*[0-9]*[)]/)/ +show warnings; + +create table t5 (id int primary key) engine = innodb +key_block_size = 4 row_format = default; + +--eval $query_i_s +drop table t1, t5; + +#test multiple errors +--replace_regex / - .*[0-9]*[)]/)/ +--error ER_CANT_CREATE_TABLE +create table t1 (id int primary key) engine = innodb +key_block_size = 9 row_format = redundant; +--replace_regex / - .*[0-9]*[)]/)/ +show warnings; + +--replace_regex / - .*[0-9]*[)]/)/ +--error ER_CANT_CREATE_TABLE +create table t2 (id int primary key) engine = innodb +key_block_size = 9 row_format = compact; +--replace_regex / - .*[0-9]*[)]/)/ +show warnings; + +--replace_regex / - .*[0-9]*[)]/)/ +--error ER_CANT_CREATE_TABLE +create table t2 (id int primary key) engine = innodb +key_block_size = 9 row_format = dynamic; +--replace_regex / - .*[0-9]*[)]/)/ +show warnings; + +--eval $query_i_s + +#test valid values with innodb_file_per_table unset +set global innodb_file_per_table = off; + +--replace_regex / - .*[0-9]*[)]/)/ +--error ER_CANT_CREATE_TABLE +create table t1 (id int primary key) engine = innodb key_block_size = 1; +--replace_regex / - .*[0-9]*[)]/)/ +show warnings; +--replace_regex / - .*[0-9]*[)]/)/ +--error ER_CANT_CREATE_TABLE +create table t2 (id int primary key) engine = innodb key_block_size = 2; +--replace_regex / - .*[0-9]*[)]/)/ +show warnings; +--replace_regex / - .*[0-9]*[)]/)/ +--error ER_CANT_CREATE_TABLE +create table t3 (id int primary key) engine = innodb key_block_size = 4; +show warnings; + +# Tests for key_block_size = 8 and 16 were moved to innodb_16k, innodb_8k +# and innodb_4k since they get different warnings with smaller page sizes. + +--error ER_CANT_CREATE_TABLE +create table t6 (id int primary key) engine = innodb row_format = compressed; +--replace_regex / - .*[0-9]*[)]/)/ +show warnings; +create table t7 (id int primary key) engine = innodb row_format = dynamic; +show warnings; +create table t8 (id int primary key) engine = innodb row_format = compact; +create table t9 (id int primary key) engine = innodb row_format = redundant; + +--replace_result 16384 {valid} 8192 {valid} 4096 {valid} +--eval $query_i_s +drop table t7, t8, t9; + +# +# restore environment to the state it was before this test execution +# + +-- disable_query_log +eval set global innodb_file_per_table=$per_table; +SET @@global.innodb_stats_on_metadata=@save_innodb_stats_on_metadata; +--enable_query_log + +DROP DATABASE mysqltest_innodb_zip; diff --git a/mysql-test/suite/innodb_zip/t/large_blob-master.opt b/mysql-test/suite/innodb_zip/t/large_blob-master.opt new file mode 100644 index 00000000..7142e676 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/large_blob-master.opt @@ -0,0 +1 @@ +--max_allowed_packet=200M diff --git a/mysql-test/suite/innodb_zip/t/large_blob.test b/mysql-test/suite/innodb_zip/t/large_blob.test new file mode 100644 index 00000000..dd208129 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/large_blob.test @@ -0,0 +1,129 @@ +--echo # +--echo # This tests the use of large blobs in InnoDB. +--echo # + +--source include/have_innodb.inc +--source include/not_debug.inc +--source include/big_test.inc + +--disable_query_log +# These values can change during the test +let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`; + +# Create a 20MB blob that does not compress easily. +# 1000 Random characters is enough to keep compression low. +set @alphabet="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; +set @r=abs(rand()*52) + 1; +set @blob=substr(@alphabet,@r,1); +let $1=1000; +while ($1 > 1) +{ + set @r=abs(rand()*52) + 1; + set @letter=substr(@alphabet,@r,1); + set @blob=concat(@blob,@letter); + dec $1; +} +# The loop above is extremely slow compared to repeat(). +set @longblob=repeat(@blob,200000); +--enable_query_log + +call mtr.add_suppression("InnoDB: Warning: a long semaphore wait"); + +SET GLOBAL innodb_file_per_table = OFF; + +--echo # +--echo # System tablespace, Row Format = Redundant +--echo # +CREATE TABLE t1 ( + c1 INT DEFAULT NULL, + c2 LONGBLOB NOT NULL, + KEY k2 (c2(250), c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES (1, ''); +UPDATE t1 SET c2=@longblob; +DROP TABLE t1; + +--echo # +--echo # System tablespace, Row Format = Compact +--echo # +CREATE TABLE t1 ( + c1 INT DEFAULT NULL, + c2 LONGBLOB NOT NULL, + KEY k2 (c2(250), c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES (1, ''); +UPDATE t1 SET c2=@longblob; +DROP TABLE t1; + +SET GLOBAL innodb_file_per_table = ON; + +--echo # +--echo # Separate tablespace, Row Format = Redundant +--echo # +CREATE TABLE t1 ( + c1 INT DEFAULT NULL, + c2 LONGBLOB NOT NULL, + KEY k2 (c2(250), c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES (1, ''); +UPDATE t1 SET c2=@longblob; +DROP TABLE t1; + +--echo # +--echo # Separate tablespace, Row Format = Compact +--echo # +CREATE TABLE t1 ( + c1 INT DEFAULT NULL, + c2 LONGBLOB NOT NULL, + KEY k2 (c2(250), c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES (1, ''); +UPDATE t1 SET c2=@longblob; +DROP TABLE t1; + +--disable_query_log +SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log +--echo # +--echo # Separate tablespace, Row Format = Compressed, Key Block Size = 2k +--echo # +CREATE TABLE t1 ( + c1 INT DEFAULT NULL, + c2 LONGBLOB NOT NULL, + KEY k2 (c2(250), c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=2; +INSERT INTO t1 VALUES (1, ''); +UPDATE t1 SET c2=@longblob; +DROP TABLE t1; + +--echo # +--echo # Separate tablespace, Row Format = Compressed, Key Block Size = 1k +--echo # +CREATE TABLE t1 ( + c1 INT DEFAULT NULL, + c2 LONGBLOB NOT NULL, + KEY k2 (c2(250), c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=1; +INSERT INTO t1 VALUES (1, ''); +UPDATE t1 SET c2=@longblob; +--disable_query_log +SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; +--enable_query_log +DROP TABLE t1; + +--echo # +--echo # Separate tablespace, Row Format = Dynamic +--echo # +CREATE TABLE t1 ( + c1 INT DEFAULT NULL, + c2 LONGBLOB NOT NULL, + KEY k2 (c2(250), c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES (1, ''); +UPDATE t1 SET c2=@longblob; +DROP TABLE t1; + +--disable_query_log +EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig; +--enable_query_log diff --git a/mysql-test/suite/innodb_zip/t/page_size.opt b/mysql-test/suite/innodb_zip/t/page_size.opt new file mode 100644 index 00000000..9e30213d --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/page_size.opt @@ -0,0 +1,2 @@ +--loose-innodb-sys-indexes +--loose-innodb-sys-tablespaces diff --git a/mysql-test/suite/innodb_zip/t/page_size.test b/mysql-test/suite/innodb_zip/t/page_size.test new file mode 100644 index 00000000..3455ef8e --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/page_size.test @@ -0,0 +1,915 @@ +--source include/innodb_page_size_small.inc +--source include/innodb_checksum_algorithm.inc +SET default_storage_engine=InnoDB; + +--disable_query_log +let $MYSQLD_DATADIR = `select @@datadir`; +let $INNODB_PAGE_SIZE = `select @@innodb_page_size`; + +call mtr.add_suppression("Cannot add field .* in table .* because after adding it, the row size is"); +--enable_query_log + +--echo # Test 1) Show the page size from Information Schema +SELECT variable_value FROM information_schema.global_status + WHERE LOWER(variable_name) = 'innodb_page_size'; + +--echo # Test 3) Query some information_shema tables that are dependent upon +--echo # the page size. +# Show the metadata for tables in schema 'mysql'. +# Pulled from innodb-system-table-view.test +# The IDs of mysql.innodb_table_stats and mysql.innodb_index_stats are +# unpredictable. They depend on whether mtr has created the database for +# this test from scratch or is using a previously created database where +# those tables have been dropped and recreated. Since we cannot force mtr +# to use a freshly created database for this test we do not return the +# table or index IDs. We can return the space IS of mysql schema tables +# since they are created consistently during bootstrap. +SELECT t.name table_name, t.n_cols, t.flag table_flags, + i.name index_name, i.page_no root_page, i.type, + i.n_fields, i.merge_threshold + FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES t, + INFORMATION_SCHEMA.INNODB_SYS_INDEXES i + WHERE t.table_id = i.table_id + AND t.name LIKE 'mysql%' + ORDER BY t.name, i.index_id; + +CREATE TABLE t1 (a INT KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=innodb; +CREATE TABLE t2 (a INT KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=innodb; +CREATE TABLE t3 (a INT KEY, b TEXT) ROW_FORMAT=COMPRESSED ENGINE=innodb; +CREATE TABLE t4 (a INT KEY, b TEXT) ROW_FORMAT=DYNAMIC ENGINE=innodb; + +# Show the metadata for tables in schema 'test'. +# Do not return the space ID since this tablespace may have existed before +# this test runs. The root page number of each index should be consistent +# within a file-per-table tablespace. +SELECT t.name table_name, t.n_cols, t.flag table_flags, + i.name index_name, i.page_no root_page, i.type, + i.n_fields, i.merge_threshold + FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES t, + INFORMATION_SCHEMA.INNODB_SYS_INDEXES i + WHERE t.table_id = i.table_id + AND t.name LIKE 'test%' + ORDER BY t.name, i.name; +--source suite/innodb/include/show_i_s_tablespaces.inc +DROP TABLE t1, t2, t3, t4; + +--echo # Test 4) The maximum row size is dependent upon the page size. +--echo # Each row format has its own amount of overhead that +--echo # varies depending on number of fields and other overhead. + +SET SESSION innodb_strict_mode = ON; + +if ($INNODB_PAGE_SIZE == 4096) { +# Redundant table; 1927 bytes with 10 CHAR fields +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(127) +) ROW_FORMAT=redundant; +DROP TABLE t1; +--replace_regex /> [0-9]*/> max_row_size/ +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(128) +) ROW_FORMAT=redundant; + +# Compact table; 1955 bytes with 10 CHAR fields +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(155) +) ROW_FORMAT=compact; +DROP TABLE t1; +--replace_regex /> [0-9]*/> max_row_size/ +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(156) +) ROW_FORMAT=compact; + +# Compressed table +# MDEV-27634 stricter compressBound() limit for the s390x DFLTCC instruction +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(176) +) ROW_FORMAT=compressed; +DROP TABLE t1; +--replace_regex /> [0-9]*/> max_row_size/ +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(79) +) ROW_FORMAT=compressed; + +# Dynamic table; 1955 bytes with 10 CHAR fields +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(155) +) ROW_FORMAT=dynamic; +DROP TABLE t1; +--replace_regex /> [0-9]*/> max_row_size/ +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(156) +) ROW_FORMAT=dynamic; + +# +# Test the maximum key length +# Moved from innodb-index.test since each page size has its own max key length. +# Max Key Length is 1173 for 4k pages. +# +# InnoDB assumes 3 bytes for each UTF8 character. +# +CREATE TABLE t1 (a varchar(98) character set utf8, + b varchar(98) character set utf8, + c varchar(98) character set utf8, + d varchar(97) character set utf8, + PRIMARY KEY (a,b,c,d)) + ENGINE=innodb; +DROP TABLE t1; +--error ER_TOO_LONG_KEY +CREATE TABLE t1 (a varchar(98) character set utf8, + b varchar(98) character set utf8, + c varchar(98) character set utf8, + d varchar(98) character set utf8, + PRIMARY KEY (a,b,c,d)) + ENGINE=innodb; +CREATE TABLE t1 (a varchar(98) character set utf8, + b varchar(98) character set utf8, + c varchar(98) character set utf8, + d varchar(98) character set utf8, + e varchar(97) character set utf8, + PRIMARY KEY (a), KEY (b,c,d,e)) + ENGINE=innodb; +DROP TABLE t1; +--error ER_TOO_LONG_KEY +CREATE TABLE t1 (a varchar(98) character set utf8, + b varchar(98) character set utf8, + c varchar(98) character set utf8, + d varchar(98) character set utf8, + e varchar(98) character set utf8, + PRIMARY KEY (a), KEY (b,c,d,e)) + ENGINE=innodb; +} +if ($INNODB_PAGE_SIZE == 8192) { +# Redundant table; 3955 bytes with 20 CHAR fields +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(155) +) ROW_FORMAT=redundant; +DROP TABLE t1; +--replace_regex /> [0-9]*/> max_row_size/ +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(156) +) ROW_FORMAT=redundant; + +# Compact table; 4002 bytes with 20 CHAR fields +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(202) +) ROW_FORMAT=compact; +DROP TABLE t1; +--replace_regex /> [0-9]*/> max_row_size/ +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(203) +) ROW_FORMAT=compact; + +# Compressed table +# MDEV-27634 stricter compressBound() limit for the s390x DFLTCC instruction +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(182) +) ROW_FORMAT=compressed; +DROP TABLE t1; +--replace_regex /> [0-9]*/> max_row_size/ +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(106) +) ROW_FORMAT=compressed; + +# Dynamic table; 4002 bytes with 20 CHAR fields +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(202) +) ROW_FORMAT=dynamic; +DROP TABLE t1; +--replace_regex /> [0-9]*/> max_row_size/ +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(203) +) ROW_FORMAT=dynamic; + +# +# Test the maximum key length +# Moved from innodb-index.test since each page size has its own max key length. +# Max Key Length is 1536 for 8k pages. +# +# InnoDB assumes 3 bytes for each UTF8 character. +# +CREATE TABLE t1 (a varchar(128) character set utf8, + b varchar(128) character set utf8, + c varchar(128) character set utf8, + d varchar(128) character set utf8, + PRIMARY KEY (a,b,c,d)) + ENGINE=innodb; +DROP TABLE t1; +--error ER_TOO_LONG_KEY +CREATE TABLE t1 (a varchar(128) character set utf8, + b varchar(128) character set utf8, + c varchar(128) character set utf8, + d varchar(129) character set utf8, + PRIMARY KEY (a,b,c,d)) + ENGINE=innodb; +CREATE TABLE t1 (a varchar(128) character set utf8, + b varchar(128) character set utf8, + c varchar(128) character set utf8, + d varchar(128) character set utf8, + e varchar(128) character set utf8, + PRIMARY KEY (a), KEY (b,c,d,e)) + ENGINE=innodb; +DROP TABLE t1; +--error ER_TOO_LONG_KEY +CREATE TABLE t1 (a varchar(128) character set utf8, + b varchar(128) character set utf8, + c varchar(128) character set utf8, + d varchar(128) character set utf8, + e varchar(129) character set utf8, + PRIMARY KEY (a), KEY (b,c,d,e)) + ENGINE=innodb; +} +if ($INNODB_PAGE_SIZE == 16384) { +# Redundant table; 8011 bytes with 40 char fields +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200), +c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200), +c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200), +c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200), +c36 char(200), c37 char(200), c38 char(200), c39 char(200), c40 char(211) +) ROW_FORMAT=redundant; +DROP TABLE t1; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200), +c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200), +c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200), +c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200), +c36 char(200), c37 char(200), c38 char(200), c39 char(200), c40 char(212) +) ROW_FORMAT=redundant; + +# Compact table; 8096 bytes with 40 CHAR fields +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200), +c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200), +c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200), +c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200), +c36 char(200), c37 char(200), c38 char(200), c39 char(250), c40 char(246) +) ROW_FORMAT=compact; +DROP TABLE t1; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200), +c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200), +c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200), +c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200), +c36 char(200), c37 char(200), c38 char(200), c39 char(250), c40 char(247) +) ROW_FORMAT=compact; + +# Compressed table +# MDEV-27634 stricter compressBound() limit for the s390x DFLTCC instruction +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200), +c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200), +c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200), +c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200), +c36 char(200), c37 char(200), c38 char(196) +) ROW_FORMAT=compressed; +DROP TABLE t1; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200), +c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200), +c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200), +c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200), +c36 char(200), c37 char(200), c38 char(200), c39 char(200), c40 char(160) +) ROW_FORMAT=compressed; + +# Dynamic table; 8096 bytes with 40 CHAR fields +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200), +c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200), +c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200), +c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200), +c36 char(200), c37 char(200), c38 char(200), c39 char(250), c40 char(246) +) ROW_FORMAT=dynamic; +DROP TABLE t1; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE t1 ( +c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), +c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), +c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), +c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200), +c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200), +c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200), +c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200), +c36 char(200), c37 char(200), c38 char(200), c39 char(250), c40 char(247) +) ROW_FORMAT=dynamic; + +# +# Test the maximum key length +# Moved from innodb-index.test since each page size has its own max key length. +# Max Key Length is 3072 for 16k pages. +# Max key Part length is 767 +# InnoDB assumes 3 bytes for each UTF8 character. +# +CREATE TABLE t1 (a varchar(255) character set utf8, + b varchar(255) character set utf8, + c varchar(255) character set utf8, + d varchar(255) character set utf8, + e varchar(4) character set utf8, + PRIMARY KEY (a,b,c,d,e)) + ENGINE=innodb; +DROP TABLE t1; +--error ER_TOO_LONG_KEY +CREATE TABLE t1 (a varchar(255) character set utf8, + b varchar(255) character set utf8, + c varchar(255) character set utf8, + d varchar(255) character set utf8, + e varchar(5) character set utf8, + PRIMARY KEY (a,b,c,d,e)) + ENGINE=innodb; +CREATE TABLE t1 (a varchar(255) character set utf8, + b varchar(255) character set utf8, + c varchar(255) character set utf8, + d varchar(255) character set utf8, + e varchar(255) character set utf8, + f varchar(4) character set utf8, + PRIMARY KEY (a), KEY (b,c,d,e,f)) + ENGINE=innodb; +DROP TABLE t1; +--error ER_TOO_LONG_KEY +CREATE TABLE t1 (a varchar(255) character set utf8, + b varchar(255) character set utf8, + c varchar(255) character set utf8, + d varchar(255) character set utf8, + e varchar(255) character set utf8, + f varchar(5) character set utf8, + PRIMARY KEY (a), KEY (b,c,d,e,f)) + ENGINE=innodb; +} + +--echo # Test 5) KEY_BLOCK_SIZE validation + +if ($INNODB_PAGE_SIZE == 4096) { +--error ER_CANT_CREATE_TABLE +CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; +SHOW WARNINGS; + +--error ER_CANT_CREATE_TABLE +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8; +SHOW WARNINGS; + +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED; +} +if ($INNODB_PAGE_SIZE == 8192) { +--error ER_CANT_CREATE_TABLE +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; +SHOW WARNINGS; + +CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; +} +if ($INNODB_PAGE_SIZE == 16384) { +CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; + +ALTER TABLE t1 KEY_BLOCK_SIZE=8; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; +} +ALTER TABLE t1 KEY_BLOCK_SIZE=4; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; + +ALTER TABLE t1 KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; + +ALTER TABLE t1 KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; + +ALTER TABLE t1 KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; +DROP TABLE t1; + +SET SESSION innodb_strict_mode = OFF; + +CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; + +ALTER TABLE t1 KEY_BLOCK_SIZE=8; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; + +ALTER TABLE t1 KEY_BLOCK_SIZE=4; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; + +ALTER TABLE t1 KEY_BLOCK_SIZE=2; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; + +ALTER TABLE t1 KEY_BLOCK_SIZE=1; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; + +ALTER TABLE t1 KEY_BLOCK_SIZE=0; +SHOW WARNINGS; +SELECT table_name, row_format, create_options + FROM information_schema.tables WHERE table_name = 't1'; +DROP TABLE t1; + + +--echo # Test 6) KEY_BLOCK_SIZE with innodb_file_per_table=OFF +# Moved from innodb-zip.test +SET SESSION innodb_strict_mode = ON; +SET GLOBAL innodb_file_per_table = OFF; +SHOW VARIABLES LIKE 'innodb_file_per_table'; +--error ER_CANT_CREATE_TABLE +CREATE TABLE t4 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=8; +SHOW WARNINGS; +--error ER_CANT_CREATE_TABLE +CREATE TABLE t5 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=16; +SHOW WARNINGS; +SET GLOBAL innodb_file_per_table = ON; + +if ($INNODB_PAGE_SIZE == 16384) { +--echo # Test 7) This series of tests were moved from innodb-index to here +--echo # because the second alter table t1 assumes a 16k page size. +--echo # Moving the test allows the rest of innodb-index to be run on all +--echo # page sizes. The previously disabled portions of this test were +--echo # moved as well. + +CREATE TABLE t2(d varchar(17) PRIMARY KEY) ENGINE=innodb DEFAULT CHARSET=utf8; +CREATE TABLE t3(a int PRIMARY KEY) ENGINE=innodb; + +INSERT INTO t3 VALUES (22),(44),(33),(55),(66); + +INSERT INTO t2 VALUES ('jejdkrun87'),('adfd72nh9k'), +('adfdpplkeock'),('adfdijnmnb78k'),('adfdijn0loKNHJik'); + +CREATE TABLE t1(a int, b blob, c text, d text NOT NULL) +ENGINE=innodb DEFAULT CHARSET=utf8 STATS_PERSISTENT=0; + +INSERT INTO t1 +SELECT a,LEFT(REPEAT(d,100*a),65535),REPEAT(d,20*a),d FROM t2,t3 order by a, d; +DROP TABLE t2, t3; +SELECT COUNT(*) FROM t1 WHERE a=44; +SELECT a, +LENGTH(b),b=LEFT(REPEAT(d,100*a),65535),LENGTH(c),c=REPEAT(d,20*a),d FROM t1 +ORDER BY 1, 2, 3, 4, 5, 6; +# in-place alter table should trigger ER_PRIMARY_CANT_HAVE_NULL +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD PRIMARY KEY (a), ADD KEY (b(20)); +DELETE FROM t1 WHERE d='null'; +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD PRIMARY KEY (a), ADD KEY (b(20)); +DELETE FROM t1 WHERE a%2; +CHECK TABLE t1; +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +# And adding a PRIMARY KEY will also add NOT NULL implicitly! +ALTER TABLE t1 ADD PRIMARY KEY (a,b(255),c(255)), ADD KEY (b(767)); +SELECT COUNT(*) FROM t1 WHERE a=44; +SELECT a, +LENGTH(b), b=LEFT(REPEAT(d,100*a), 65535),LENGTH(c), c=REPEAT(d,20*a), d FROM t1; +SHOW CREATE TABLE t1; +CHECK TABLE t1; +--replace_column 9 # +EXPLAIN SELECT * FROM t1 WHERE b LIKE 'adfd%'; + +# The following tests are disabled because of the introduced timeouts for +# metadata locks at the MySQL level as part of the fix for +# Bug#45225 Locking: hang if drop table with no timeout +# The following commands now play with MySQL metadata locks instead of +# InnoDB locks +# start disabled45225_1 +## +## Test locking +## +# +#CREATE TABLE t2(a int, b varchar(255), PRIMARY KEY(a,b)) ENGINE=innodb; +#INSERT INTO t2 SELECT a,LEFT(b,255) FROM t1; +#DROP TABLE t1; +#RENAME TABLE t2 to t1; +# +#connect (a,localhost,root,,); +#connect (b,localhost,root,,); +#connection a; +#SET innodb_lock_wait_timeout=1; +#begin; +## Obtain an IX lock on the table +#SELECT a FROM t1 limit 1 FOR UPDATE; +#connection b; +#SET innodb_lock_wait_timeout=1; +## This would require an S lock on the table, conflicting with the IX lock. +#--error ER_LOCK_WAIT_TIMEOUT +#CREATE INDEX t1ba ON t1 (b,a); +#connection a; +#commit; +#begin; +## Obtain an IS lock on the table +#SELECT a FROM t1 limit 1 lock in share mode; +#connection b; +## This will require an S lock on the table. No conflict with the IS lock. +#CREATE INDEX t1ba ON t1 (b,a); +## This would require an X lock on the table, conflicting with the IS lock. +#--error ER_LOCK_WAIT_TIMEOUT +#DROP INDEX t1ba ON t1; +#connection a; +#commit; +#EXPLAIN SELECT a FROM t1 ORDER BY b; +#--send +#SELECT a,sleep(2+a/100) FROM t1 ORDER BY b limit 3; +# +## The following DROP INDEX will succeed, altough the SELECT above has +## opened a read view. However, during the execution of the SELECT, +## MySQL should hold a table lock that should block the execution +## of the DROP INDEX below. +# +#connection b; +#SELECT sleep(1); +#DROP INDEX t1ba ON t1; +# +## After the index was dropped, subsequent SELECTs will use the same +## read view, but they should not be accessing the dropped index any more. +# +#connection a; +#reap; +#EXPLAIN SELECT a FROM t1 ORDER BY b; +#SELECT a FROM t1 ORDER BY b limit 3; +#commit; +# +#connection default; +#disconnect a; +#disconnect b; +# +# end disabled45225_1 +DROP TABLE t1; +} + +--echo # Test 8) Test creating a table that could lead to undo log overflow. +CREATE TABLE t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob, + h blob,i blob,j blob,k blob,l blob,m blob,n blob, + o blob,p blob,q blob,r blob,s blob,t blob,u blob) + ENGINE=InnoDB ROW_FORMAT=dynamic; +SET @a = repeat('a', 767); +SET @b = repeat('b', 767); +SET @c = repeat('c', 767); +SET @d = repeat('d', 767); +SET @e = repeat('e', 767); + +# With no indexes defined, we can update all columns to max key part length. +INSERT INTO t1 VALUES (@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a); +UPDATE t1 SET a=@b,b=@b,c=@b,d=@b,e=@b,f=@b,g=@b,h=@b,i=@b,j=@b, + k=@b,l=@b,m=@b,n=@b,o=@b,p=@b,q=@b,r=@b,s=@b,t=@b,u=@b; + +# With this many indexes defined, we can still update all fields. +CREATE INDEX t1a ON t1 (a(767)); +if ($INNODB_PAGE_SIZE == 16384) { +CREATE INDEX t1b ON t1 (b(767)); +CREATE INDEX t1c ON t1 (c(767)); +CREATE INDEX t1d ON t1 (d(767)); +CREATE INDEX t1e ON t1 (e(767)); +} +UPDATE t1 SET a=@c,b=@c,c=@c,d=@c,e=@c,f=@c,g=@c,h=@c,i=@c,j=@c, + k=@c,l=@c,m=@c,n=@c,o=@c,p=@c,q=@c,r=@c,s=@c,t=@c,u=@c; + +# Add one more index and the UNDO record becomes too big to update all columns. +# But a single transaction can update the columns in separate statements. +# because the UNDO records will be smaller. +CREATE INDEX t1f ON t1 (f(767)); +BEGIN; +UPDATE t1 SET a=@d,b=@d,c=@d,d=@d,e=@d,f=@d,g=@d,h=@d,i=@d,j=@d, + k=@d,l=@d,m=@d,n=@d,o=@d,p=@d,q=@d,r=@d,s=@d,t=@d,u=@d; +ROLLBACK; +BEGIN; +UPDATE t1 SET a=@d,b=@d,c=@d,d=@d,e=@d; +UPDATE t1 SET f=@d,g=@d,h=@d,i=@d,j=@d,k=@d,l=@d,m=@d, + n=@d,o=@d,p=@d,q=@d,r=@d,s=@d,t=@d,u=@d; +COMMIT; + +# More indexes can still be added and a single field can still be updated +CREATE INDEX t1g ON t1 (g(767)); +UPDATE t1 SET g=@e; +if ($INNODB_PAGE_SIZE == 16384) { +CREATE INDEX t1h ON t1 (h(767)); +UPDATE t1 SET h=@e; +CREATE INDEX t1i ON t1 (i(767)); +UPDATE t1 SET i=@e; +CREATE INDEX t1j ON t1 (j(767)); +UPDATE t1 SET j=@e; +CREATE INDEX t1k ON t1 (k(767)); +UPDATE t1 SET k=@e; +CREATE INDEX t1l ON t1 (l(767)); +UPDATE t1 SET l=@e; +CREATE INDEX t1m ON t1 (m(767)); +UPDATE t1 SET m=@e; +CREATE INDEX t1n ON t1 (n(767)); +UPDATE t1 SET n=@e; +CREATE INDEX t1o ON t1 (o(767)); +UPDATE t1 SET o=@e; +CREATE INDEX t1p ON t1 (p(767)); +UPDATE t1 SET p=@e; +CREATE INDEX t1q ON t1 (q(767)); +UPDATE t1 SET q=@e; +CREATE INDEX t1r ON t1 (r(767)); +UPDATE t1 SET r=@e; +CREATE INDEX t1s ON t1 (s(767)); +UPDATE t1 SET s=@e; +} + +# Add one more index and we cannot update a column to its defined index length. +# This is a problem. It means that the DDL is allowed to create a table +# that CANNOT be updated. See bug#12953735. +CREATE INDEX t1t ON t1 (t(767)); +BEGIN; +UPDATE t1 SET t=@e; +ROLLBACK; + +CREATE INDEX t1u ON t1 (u(767)); +if ($INNODB_PAGE_SIZE == 4096) +{ +CREATE INDEX t1ut ON t1 (u(767)); +CREATE INDEX t1st ON t1 (s(767)); +} +if ($INNODB_PAGE_SIZE != 4096) +{ +CREATE INDEX t1ut ON t1 (u(767), t(767)); +CREATE INDEX t1st ON t1 (s(767), t(767)); +} + +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--echo # Bug#12547647 UPDATE LOGGING COULD EXCEED LOG PAGE SIZE +# InnoDB cannot know that this undo record would be too big for the undo +# page. Too much of text field is stored in the clustered record in this +# DYNAMIC row formatted record. + +CREATE TABLE bug12547647( +a int NOT NULL, b blob NOT NULL, c text, +PRIMARY KEY (b(10), a), INDEX (c(767)), INDEX(b(767)) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +INSERT INTO bug12547647 VALUES (5,REPEAT('khdfo5AlOq',1900),REPEAT('g',7751)); +COMMIT; +# The following used to cause a hang while doing infinite undo log allocation. +BEGIN; +UPDATE bug12547647 SET c = REPEAT('b',16928); +SHOW WARNINGS; +ROLLBACK; +DROP TABLE bug12547647; + +# +# Bug #13336585 - INNODB: CHANGE BUFFERING WITH 4K PAGES CAN ASSERT +# IF SECONDARY KEY IS NEAR MAX +# If the secondary index tuple is close to half the page size, +# ibuf_insert_low() could return DB_TOO_BIG_RECORD, which is not expected +# in ibuf_insert(). In order to insure this does not happen, WL5756 +# imposes a maximum key length of 768 for 4k pages and 1536 for 8k pages. +# The existing max key Size for 16k pages is 3072. +# + +#-- disable_query_log +# The flag innodb_change_buffering_debug is only available in debug builds. +# It instructs InnoDB to try to evict pages from the buffer pool when +# change buffering is possible, so that the change buffer will be used +# whenever possible. +# This flag is not used currently since it exposes valgrind error in ibuf +# code with the following SQL +#-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE +#SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug; +#-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE +#SET GLOBAL innodb_change_buffering_debug = 1; +#-- enable_query_log + +# make sure the largest possible key entry can be added to the insert buffer. +# Make enough records so that the root page is not a leaf page. +SET SESSION innodb_strict_mode = OFF; +CREATE TABLE t1( + pk01 varchar(48), pk02 varchar(48), pk03 varchar(48), pk04 varchar(48), + pk05 varchar(48), pk06 varchar(48), pk07 varchar(48), pk08 varchar(48), + pk09 varchar(48), pk10 varchar(48), pk11 varchar(48), pk12 varchar(48), + pk13 varchar(48), pk14 varchar(48), pk15 varchar(48), pk16 varchar(48), + sk01 varchar(48), sk02 varchar(48), sk03 varchar(48), sk04 varchar(48), + sk05 varchar(48), sk06 varchar(48), sk07 varchar(48), sk08 varchar(48), + sk09 varchar(48), sk10 varchar(48), sk11 varchar(48), sk12 varchar(48), + sk13 varchar(48), sk14 varchar(48), sk15 varchar(48), sk16 varchar(48), + PRIMARY KEY pk(pk01,pk02,pk03,pk04,pk05,pk06,pk07,pk08, + pk09,pk10,pk11,pk12,pk13,pk14,pk15,pk16), + KEY pk(sk01,sk02,sk03,sk04,sk05,sk06,sk07,sk08, + sk09,sk10,sk11,sk12,sk13,sk14,sk15,sk16)) + ROW_FORMAT=Redundant ENGINE=InnoDB; +SET @r = repeat('a', 48); +INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r, + @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); +SET @r = repeat('b', 48); +INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r, + @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); +SET @r = repeat('c', 48); +INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r, + @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); +SET @r = repeat('d', 48); +INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r, + @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); +SET @r = repeat('e', 48); +INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r, + @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); +DELETE from t1; +DROP TABLE t1; + +# Compressed tables do not compress parent pages. So the whole uncompressed +# secondary tuple including the primary key must be able to fit in half the +# compressed page size. This record length is enforced at index creation. +# So the only way to get an ibuf tuple too big is to make the KEY_BLOCK_SIZE +# the same as the page size. +CREATE TABLE t1( + pk01 varchar(48), pk02 varchar(48), pk03 varchar(48), pk04 varchar(48), + pk05 varchar(48), pk06 varchar(48), pk07 varchar(48), pk08 varchar(48), + pk09 varchar(48), pk10 varchar(48), pk11 varchar(48), pk12 varchar(48), + pk13 varchar(48), pk14 varchar(48), pk15 varchar(48), pk16 varchar(48), + sk01 varchar(48), sk02 varchar(48), sk03 varchar(48), sk04 varchar(48), + sk05 varchar(48), sk06 varchar(48), sk07 varchar(48), sk08 varchar(48), + sk09 varchar(48), sk10 varchar(48), sk11 varchar(48), sk12 varchar(48), + sk13 varchar(48), sk14 varchar(48), sk15 varchar(48), sk16 varchar(48), + PRIMARY KEY pk(pk01,pk02,pk03,pk04,pk05,pk06,pk07,pk08, + pk09,pk10,pk11,pk12,pk13,pk14,pk15,pk16), + KEY pk(sk01,sk02,sk03,sk04,sk05,sk06,sk07,sk08, + sk09,sk10,sk11,sk12,sk13,sk14,sk15,sk16)) + ROW_FORMAT=Compressed KEY_BLOCK_SIZE=4 ENGINE=InnoDB; +SET @r = repeat('a', 48); +INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r, + @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); +SET @r = repeat('b', 48); +INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r, + @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); +SET @r = repeat('c', 48); +INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r, + @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); +SET @r = repeat('d', 48); +INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r, + @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); +SET @r = repeat('e', 48); +INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r, + @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); +DELETE from t1; +DROP TABLE t1; + +#-- disable_query_log +#-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE +#SET GLOBAL innodb_change_buffering_debug = 0; +#-- enable_query_log + +# The following should fail in non-strict mode too. +# (The fix of Bug #50945 only affects REDUNDANT and COMPACT tables.) +if ($INNODB_PAGE_SIZE == 4096) +{ +CREATE TABLE t1( + c text NOT NULL, d text NOT NULL, + PRIMARY KEY (c(767))) +ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII; +DROP TABLE t1; +CREATE TABLE t1( + c text NOT NULL, d text NOT NULL, + PRIMARY KEY (c(767))) +ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2 CHARSET=ASCII; +DROP TABLE t1; +CREATE TABLE t1( + c text NOT NULL, d text NOT NULL, + PRIMARY KEY (c(767))) +ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4 CHARSET=ASCII; +} +if ($INNODB_PAGE_SIZE != 4096) +{ +CREATE TABLE t1( + c text NOT NULL, d text NOT NULL, + PRIMARY KEY (c(767),d(767))) +ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII; +DROP TABLE t1; +CREATE TABLE t1( + c text NOT NULL, d text NOT NULL, + PRIMARY KEY (c(767),d(767))) +ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2 CHARSET=ASCII; +DROP TABLE t1; +CREATE TABLE t1( + c text NOT NULL, d text NOT NULL, + PRIMARY KEY (c(767),d(767))) +ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4 CHARSET=ASCII; +} +DROP TABLE t1; +CREATE TABLE t1(c text, PRIMARY KEY (c(440))) +ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII; +DROP TABLE t1; +--disable_warnings +CREATE TABLE t1(c text, PRIMARY KEY (c(293))) +ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII; +--enable_warnings +INSERT INTO t1 VALUES(REPEAT('A',512)),(REPEAT('B',512)); +DROP TABLE t1; + +--echo # +--echo # MDEV-28950 Assertion `*err == DB_SUCCESS' in btr_page_split_and_insert +--echo # +CREATE TABLE t1(c CHAR(255) NOT NULL) ENGINE=InnoDB; +INSERT INTO t1 VALUES (''); +ALTER TABLE t1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +INSERT INTO t1 VALUES (''),(''),(''); +SET @save_innodb_compression_level= @@innodb_compression_level; +SET GLOBAL innodb_compression_level=0; +INSERT INTO t1 VALUES (''); +SET GLOBAL innodb_compression_level= @save_innodb_compression_level; +DROP TABLE t1; + +--echo # +--echo # MDEV-31158 Assertion ...MTR_MEMO_X_LOCKED in btr_attach_half_pages() +--echo # +--source include/have_innodb.inc + +SET @save_compression_level=@@GLOBAL.innodb_compression_level; +SET GLOBAL innodb_compression_level=0; +CREATE TEMPORARY TABLE t(a SERIAL, prefix VARBINARY(4), pad INT); +INSERT INTO t(prefix, pad) VALUES +(_binary 0xff,160),('',19),(_binary 0x0001,253),(_binary 0x0b11,169), +(_binary 0x0b010001,23),(_binary 0x0b100001,251),(_binary 0x0d,163), +(_binary 0xb3,254),(_binary 0x96,254),(_binary 0xeb,61), +(_binary 0xf231,253),(_binary 0x1db0,253),(_binary 0x0005,101), +(_binary 0x6370,253),(_binary 0x0b12,112),(_binary 0x0b010002,23), +(_binary 0x0b100002,80),(_binary 0x181984,163),(_binary 0x181926,168), +(_binary 0xe1,176),(_binary 0xe2,187),(_binary 0xe6,254),(_binary 0xbb,51), +(_binary 0x1c,248),(_binary 0x8a,94),(_binary 0x14,254); +CREATE TABLE u(a SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, + b VARBINARY(255), KEY(b)) ENGINE=InnoDB + KEY_BLOCK_SIZE=1 ROW_FORMAT=COMPRESSED; +INSERT INTO u SELECT a,CONCAT(prefix,REPEAT(chr(0),pad)) FROM t; +DROP TABLE u, t; +SET GLOBAL innodb_compression_level=@save_compression_level; + +--echo # End of 10.6 tests diff --git a/mysql-test/suite/innodb_zip/t/prefix_index_liftedlimit.test b/mysql-test/suite/innodb_zip/t/prefix_index_liftedlimit.test new file mode 100644 index 00000000..32d7eacd --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/prefix_index_liftedlimit.test @@ -0,0 +1,1330 @@ +######## suite/innodb/t/innodb_prefix_index_liftedlimit.test ########## +# # +# Testcase for worklog WL#5743: Lift the limit of index key prefixes # +# According to WL#5743 - prefix index limit is increased from 767 # +# to 3072 for ROW_FORMAT=DYNAMIC and ROW_FORMAT=COMPRESSED. # +# All sub-test in this file focus on prefix index along with other # +# operations # +# # +# # +# Creation: # +# 2011-05-19 Implemented this test as part of WL#5743 # +# # +###################################################################### + +--source include/have_innodb.inc +--source include/have_innodb_16k.inc + +--disable_query_log +SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log + +call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the row size is'); +# Prefix index with VARCHAR data type , primary/secondary index and DML ops +CREATE TABLE worklog5743 ( +col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , +PRIMARY KEY (col_1_varchar(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072)); +# check IS +SELECT COLUMN_NAME,INDEX_NAME,SUB_PART,INDEX_TYPE FROM +INFORMATION_SCHEMA.STATISTICS WHERE table_name = 'worklog5743' ; +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_varchar = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_varchar = REPEAT("c", 4000) +WHERE col_1_varchar = REPEAT("a", 4000) AND col_2_varchar = REPEAT("o", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varchar = REPEAT("c", 4000) AND col_2_varchar = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_varchar = REPEAT("b", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743; +--error ER_INDEX_COLUMN_TOO_LONG +ALTER TABLE worklog5743 ROW_FORMAT=REDUNDANT; +--error ER_INDEX_COLUMN_TOO_LONG +ALTER TABLE worklog5743 ROW_FORMAT=COMPACT; +ALTER TABLE worklog5743 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; +DROP TABLE worklog5743; + + +#------------------------------------------------------------------------------ +# Prefix index with TEXT data type , primary/secondary index and DML ops +CREATE TABLE worklog5743 ( +col_1_text TEXT (4000) , col_2_text TEXT (4000) , +PRIMARY KEY (col_1_text(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +CREATE INDEX prefix_idx ON worklog5743(col_1_text (3072)); +# check IS +SELECT COLUMN_NAME,INDEX_NAME,SUB_PART,INDEX_TYPE FROM +INFORMATION_SCHEMA.STATISTICS WHERE table_name = 'worklog5743' ; +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_text = REPEAT("a", 4000) , col_2_text = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_text = REPEAT("c", 4000) +WHERE col_1_text = REPEAT("a", 4000) AND col_2_text = REPEAT("o", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("c", 4000) AND col_2_text = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_text = REPEAT("b", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + +#------------------------------------------------------------------------------ +# Prefix index with MEDIUMTEXT data type , primary/secondary index and DML ops +CREATE TABLE worklog5743 ( +col_1_mediumtext MEDIUMTEXT , col_2_mediumtext MEDIUMTEXT , +PRIMARY KEY (col_1_mediumtext(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +CREATE INDEX prefix_idx ON worklog5743(col_1_mediumtext (3072)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_mediumtext = REPEAT("a", 4000),col_2_mediumtext = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_mediumtext = REPEAT("c", 4000) +WHERE col_1_mediumtext = REPEAT("a", 4000) +AND col_2_mediumtext = REPEAT("o", 4000); +SELECT col_1_mediumtext = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_mediumtext = REPEAT("c", 4000) +AND col_2_mediumtext = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_mediumtext = REPEAT("b", 4000); +SELECT col_1_mediumtext = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + + +#------------------------------------------------------------------------------ +# Prefix index with LONGTEXT data type , primary/secondary index and DML ops +CREATE TABLE worklog5743 ( +col_1_longtext LONGTEXT , col_2_longtext LONGTEXT , +PRIMARY KEY (col_1_longtext(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +CREATE INDEX prefix_idx ON worklog5743(col_1_longtext (3072)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_longtext = REPEAT("a", 4000) , col_2_longtext = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_longtext = REPEAT("c", 4000) +WHERE col_1_longtext = REPEAT("a", 4000) +AND col_2_longtext = REPEAT("o", 4000); +SELECT col_1_longtext = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_longtext = REPEAT("c", 4000) +AND col_2_longtext = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_longtext = REPEAT("b", 4000); +SELECT col_1_longtext = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + + +#------------------------------------------------------------------------------ +# Prefix index with BLOB data type , primary/secondary index and DML ops +CREATE TABLE worklog5743 ( +col_1_blob BLOB (4000) , col_2_blob BLOB (4000) , +PRIMARY KEY (col_1_blob(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +CREATE INDEX prefix_idx ON worklog5743(col_1_blob (3072)); +# check IS +SELECT COLUMN_NAME,INDEX_NAME,SUB_PART,INDEX_TYPE FROM +INFORMATION_SCHEMA.STATISTICS WHERE table_name = 'worklog5743' ; +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_blob = REPEAT("a", 4000) , col_2_blob = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_blob = REPEAT("c", 4000) +WHERE col_1_blob = REPEAT("a", 4000) AND col_2_blob = REPEAT("o", 4000); +SELECT col_1_blob = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_blob = REPEAT("c", 4000) AND col_2_blob = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_blob = REPEAT("b", 4000); +SELECT col_1_blob = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + + +#------------------------------------------------------------------------------ +# Prefix index with MEDIUMBLOB data type , primary/secondary index and DML ops +CREATE TABLE worklog5743 ( +col_1_mediumblob MEDIUMBLOB , col_2_mediumblob MEDIUMBLOB , +PRIMARY KEY (col_1_mediumblob(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +CREATE INDEX prefix_idx ON worklog5743(col_1_mediumblob (3072)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_mediumblob = REPEAT("a", 4000),col_2_mediumblob = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_mediumblob = REPEAT("c", 4000) +WHERE col_1_mediumblob = REPEAT("a", 4000) +AND col_2_mediumblob = REPEAT("o", 4000); +SELECT col_1_mediumblob = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_mediumblob = REPEAT("c", 4000) +AND col_2_mediumblob = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_mediumblob = REPEAT("b", 4000); +SELECT col_1_mediumblob = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + +#------------------------------------------------------------------------------ +# Prefix index with LONGBLOB data type , primary/secondary index and DML ops +CREATE TABLE worklog5743 ( +col_1_longblob LONGBLOB , col_2_longblob LONGBLOB , +PRIMARY KEY (col_1_longblob(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +CREATE INDEX prefix_idx ON worklog5743(col_1_longblob (3072)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_longblob = REPEAT("a", 4000) , col_2_longblob = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_longblob = REPEAT("c", 4000) +WHERE col_1_longblob = REPEAT("a", 4000) +AND col_2_longblob = REPEAT("o", 4000); +SELECT col_1_longblob = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_longblob = REPEAT("c", 4000) +AND col_2_longblob = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_longblob = REPEAT("b", 4000); +SELECT col_1_longblob = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + +#------------------------------------------------------------------------------ +# Prefix index with VARBINARY data type , primary/secondary index and DML ops +CREATE TABLE worklog5743 ( +col_1_varbinary VARBINARY (4000) , col_2_varbinary VARBINARY (4000) , +PRIMARY KEY (col_1_varbinary(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +CREATE INDEX prefix_idx ON worklog5743(col_1_varbinary (3072)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_varbinary = REPEAT("a", 4000) , col_2_varbinary = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_varbinary = REPEAT("c", 4000) +WHERE col_1_varbinary = REPEAT("a", 4000) +AND col_2_varbinary = REPEAT("o", 4000); +SELECT col_1_varbinary = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varbinary = REPEAT("c", 4000) +AND col_2_varbinary = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_varbinary = REPEAT("b", 4000); +SELECT col_1_varbinary = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + +#------------------------------------------------------------------------------ +# Prefix index with CHAR data type , composite index and DML ops +CREATE TABLE worklog5743 (col_1_char CHAR (255) , col_2_char CHAR (255), +col_3_char CHAR (255), col_4_char CHAR (255),col_5_char CHAR (255), +col_6_char CHAR (255), col_7_char CHAR (255),col_8_char CHAR (255), +col_9_char CHAR (255), col_10_char CHAR (255),col_11_char CHAR (255), +col_12_char CHAR (255), col_13_char CHAR (255),col_14_char CHAR (255) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 255) , REPEAT("o", 255), +REPEAT("a", 255) , REPEAT("o", 255),REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255),REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255),REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255),REPEAT("a", 255) +); +# Create index with total prefix index length = 3072 +CREATE INDEX prefix_idx ON worklog5743(col_1_char(250),col_2_char(250), +col_3_char(250),col_4_char(250),col_5_char(250),col_6_char(250), +col_7_char(250),col_8_char(250),col_9_char(250),col_10_char(250), +col_11_char(250),col_12_char(250),col_13_char(72) +); +INSERT INTO worklog5743 VALUES(REPEAT("b", 255) , REPEAT("p", 255), +REPEAT("a", 255) , REPEAT("o", 255),REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255),REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255),REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255),REPEAT("a", 255) +); +SELECT col_1_char = REPEAT("a", 255) , col_2_char = REPEAT("o", 255) FROM worklog5743; +UPDATE worklog5743 SET col_1_char = REPEAT("c", 255) +WHERE col_1_char = REPEAT("a", 255) AND col_2_char = REPEAT("o", 255); +SELECT col_1_char = REPEAT("c", 255) FROM worklog5743 +WHERE col_1_char = REPEAT("c", 255) AND col_2_char = REPEAT("o", 255); +INSERT INTO worklog5743 VALUES(REPEAT("a", 255) , REPEAT("o", 255), +REPEAT("a", 255) , REPEAT("o", 255),REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255),REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255),REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255),REPEAT("a", 255) +); +DELETE FROM worklog5743 WHERE col_1_char = REPEAT("b", 255); +SELECT col_1_char = REPEAT("c", 255) FROM worklog5743; +DROP TABLE worklog5743; + +#------------------------------------------------------------------------------ +# Prefix index with BINARY data type , composite index and DML ops +CREATE TABLE worklog5743 (col_1_binary BINARY (255) , col_2_binary BINARY (255), +col_3_binary BINARY(255),col_4_binary BINARY (255),col_5_binary BINARY (255), +col_6_binary BINARY(255),col_7_binary BINARY (255),col_8_binary BINARY (255), +col_9_binary BINARY(255),col_10_binary BINARY (255),col_11_binary BINARY (255), +col_12_binary BINARY(255),col_13_binary BINARY (255),col_14_binary BINARY (255) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 255) , REPEAT("o", 255), +REPEAT("a", 255) , REPEAT("o", 255), REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255), REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255), REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255), REPEAT("a", 255) +); +# Create index with total prefix index length = 3072 +CREATE INDEX prefix_idx ON worklog5743(col_1_binary (250),col_2_binary (250), +col_3_binary (250),col_4_binary (250),col_5_binary (250), +col_6_binary (250),col_7_binary (250),col_8_binary (250), +col_9_binary (250),col_10_binary (250),col_11_binary (250), +col_12_binary (250),col_13_binary (72) +); +INSERT INTO worklog5743 VALUES(REPEAT("b", 255) , REPEAT("p", 255), +REPEAT("a", 255) , REPEAT("o", 255), REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255), REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255), REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255), REPEAT("a", 255) +); +SELECT col_1_binary = REPEAT("a", 255) , col_2_binary = REPEAT("o", 255) FROM worklog5743; +UPDATE worklog5743 SET col_1_binary = REPEAT("c", 255) +WHERE col_1_binary = REPEAT("a", 255) +AND col_2_binary = REPEAT("o", 255); +SELECT col_1_binary = REPEAT("c", 255) FROM worklog5743 +WHERE col_1_binary = REPEAT("c", 255) +AND col_2_binary = REPEAT("o", 255); +INSERT INTO worklog5743 VALUES(REPEAT("a", 255) , REPEAT("o", 255), +REPEAT("a", 255) , REPEAT("o", 255), REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255), REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255), REPEAT("a", 255), +REPEAT("a", 255) , REPEAT("o", 255), REPEAT("a", 255) +); +DELETE FROM worklog5743 WHERE col_1_binary = REPEAT("b", 255); +SELECT col_1_binary = REPEAT("c", 255) FROM worklog5743; +DROP TABLE worklog5743; + +#------------------------------------------------------------------------------ +# Prefix index with VARCHAR data type , primary/seconday index , DML ops +# and COMPRESSED row format. KEY_BLOCK_SIZE is varied as 2 , 4 , 8. + +CREATE TABLE worklog5743_key2 ( +col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , +PRIMARY KEY (col_1_varchar(801)) +) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2, engine = innodb; +INSERT INTO worklog5743_key2 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +#CREATE INDEX prefix_idx ON worklog5743_key2 (col_1_varchar (767)); +INSERT INTO worklog5743_key2 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_varchar = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743_key2; +UPDATE worklog5743_key2 SET col_1_varchar = REPEAT("c", 4000) +WHERE col_1_varchar = REPEAT("a", 4000) AND col_2_varchar = REPEAT("o", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743_key2 +WHERE col_2_varchar = REPEAT("o", 4000); +INSERT INTO worklog5743_key2 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743_key2 WHERE col_1_varchar = REPEAT("b", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743_key2; +DROP TABLE worklog5743_key2; + +CREATE TABLE worklog5743_key4 ( +col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , +PRIMARY KEY (col_1_varchar(1825)) +) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4, engine = innodb; +INSERT INTO worklog5743_key4 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +#CREATE INDEX prefix_idx ON worklog5743_key4 (col_1_varchar (767)); +INSERT INTO worklog5743_key4 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_varchar = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743_key4; +UPDATE worklog5743_key4 SET col_1_varchar = REPEAT("c", 4000) +WHERE col_1_varchar = REPEAT("a", 4000) +AND col_2_varchar = REPEAT("o", 4000); +SELECT col_1_varchar = REPEAT("b", 3500) FROM worklog5743_key4 +WHERE col_1_varchar = REPEAT("c", 4000) AND col_2_varchar = REPEAT("o", 4000); +INSERT INTO worklog5743_key4 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743_key4 WHERE col_1_varchar = REPEAT("b", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743_key4; +DROP TABLE worklog5743_key4; + +# With KEY_BLOCK_SIZE = 8,prefix index limit comes around ~3072 for following +CREATE TABLE worklog5743_key8 ( +col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , +PRIMARY KEY (col_1_varchar(3072)) +) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8, engine = innodb; +INSERT INTO worklog5743_key8 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +#CREATE INDEX prefix_idx ON worklog5743_key8 (col_1_varchar (767)); +INSERT INTO worklog5743_key8 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_varchar = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743_key8; +UPDATE worklog5743_key8 SET col_1_varchar = REPEAT("c", 4000) +WHERE col_1_varchar = REPEAT("a", 4000) AND col_2_varchar = REPEAT("o", 4000); +SELECT col_1_varchar = REPEAT("b", 3500) FROM worklog5743_key8 +WHERE col_1_varchar = REPEAT("c", 4000) AND col_2_varchar = REPEAT("o", 4000); +INSERT INTO worklog5743_key8 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743_key8 WHERE col_1_varchar = REPEAT("b", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743_key8; +DROP TABLE worklog5743_key8; + +# Prefix index with TEXT data type , primary/seconday index , DML ops +# and COMPRESSED row format. KEY_BLOCK_SIZE is varied as 2 , 4 , 8. + +CREATE TABLE worklog5743_key2 ( +col_1_text TEXT (4000) , col_2_text TEXT (4000) , +PRIMARY KEY (col_1_text(801)) +) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2, engine = innodb; +INSERT INTO worklog5743_key2 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +#CREATE INDEX prefix_idx ON worklog5743_key2 (col_1_text (767)); +INSERT INTO worklog5743_key2 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_text = REPEAT("a", 4000) , col_2_text = REPEAT("o", 4000) +FROM worklog5743_key2; +UPDATE worklog5743_key2 SET col_1_text = REPEAT("c", 4000) +WHERE col_1_text = REPEAT("a", 4000) AND col_2_text = REPEAT("o", 4000); +SELECT col_1_text = REPEAT("b", 3500) FROM worklog5743_key2 +WHERE col_1_text = REPEAT("c", 4000) AND col_2_text = REPEAT("o", 4000); +INSERT INTO worklog5743_key2 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743_key2 WHERE col_1_text = REPEAT("b", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743_key2; +DROP TABLE worklog5743_key2; + +CREATE TABLE worklog5743_key4 ( +col_1_text TEXT (4000) , col_2_text TEXT (4000) , +PRIMARY KEY (col_1_text(1825)) +) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4, engine = innodb; +INSERT INTO worklog5743_key4 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +#CREATE INDEX prefix_idx ON worklog5743_key4 (col_1_text (767)); +INSERT INTO worklog5743_key4 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_text = REPEAT("a", 4000) , col_2_text = REPEAT("o", 4000) +FROM worklog5743_key4; +UPDATE worklog5743_key4 SET col_1_text = REPEAT("c", 4000) +WHERE col_1_text = REPEAT("a", 4000) AND col_2_text = REPEAT("o", 4000); +SELECT col_1_text = REPEAT("b", 3500) FROM worklog5743_key4 +WHERE col_1_text = REPEAT("c", 4000) AND col_2_text = REPEAT("o", 4000); +INSERT INTO worklog5743_key4 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743_key4 WHERE col_1_text = REPEAT("b", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743_key4; +DROP TABLE worklog5743_key4; + +# With KEY_BLOCK_SIZE = 8,prefix index limit comes around ~3072 for following +CREATE TABLE worklog5743_key8 ( +col_1_text TEXT (4000) , col_2_text TEXT (4000) , +PRIMARY KEY (col_1_text(3072)) +) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8, engine = innodb; +INSERT INTO worklog5743_key8 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +#CREATE INDEX prefix_idx ON worklog5743_key8 (col_1_text (767)); +INSERT INTO worklog5743_key8 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_text = REPEAT("a", 4000) , col_2_text = REPEAT("o", 4000) +FROM worklog5743_key8; +UPDATE worklog5743_key8 SET col_1_text = REPEAT("c", 4000) +WHERE col_1_text = REPEAT("a", 4000) AND col_2_text = REPEAT("o", 4000); +SELECT col_1_text = REPEAT("b", 3500) FROM worklog5743_key8 +WHERE col_1_text = REPEAT("c", 4000) AND col_2_text = REPEAT("o", 4000); +INSERT INTO worklog5743_key8 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743_key8 WHERE col_1_text = REPEAT("b", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743_key8; +DROP TABLE worklog5743_key8; + +# Prefix index with BLOB data type , primary/seconday index , DML ops +# and COMPRESSED row format. KEY_BLOCK_SIZE is varied as 2 , 4 , 8. + +CREATE TABLE worklog5743_key2 ( +col_1_blob BLOB (4000) , col_2_blob BLOB (4000) , +PRIMARY KEY (col_1_blob(801)) +) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2, engine = innodb; +INSERT INTO worklog5743_key2 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +#CREATE INDEX prefix_idx ON worklog5743_key2 (col_1_blob (767)); +INSERT INTO worklog5743_key2 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_blob = REPEAT("a", 4000) , col_2_blob = REPEAT("o", 4000) +FROM worklog5743_key2; +UPDATE worklog5743_key2 SET col_1_blob = REPEAT("c", 4000) +WHERE col_1_blob = REPEAT("a", 4000) AND col_2_blob = REPEAT("o", 4000); +SELECT col_1_blob = REPEAT("b", 3500) FROM worklog5743_key2 +WHERE col_1_blob = REPEAT("c", 4000) AND col_2_blob = REPEAT("o", 4000); +INSERT INTO worklog5743_key2 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743_key2 WHERE col_1_blob = REPEAT("b", 4000); +SELECT col_1_blob = REPEAT("c", 4000) FROM worklog5743_key2; +DROP TABLE worklog5743_key2; + +CREATE TABLE worklog5743_key4 ( +col_1_blob BLOB (4000) , col_2_blob BLOB (4000) , +PRIMARY KEY (col_1_blob(1825)) +) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4, engine = innodb; +INSERT INTO worklog5743_key4 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +#CREATE INDEX prefix_idx ON worklog5743_key4 (col_1_blob (767)); +INSERT INTO worklog5743_key4 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_blob = REPEAT("a", 4000) , col_2_blob = REPEAT("o", 4000) +FROM worklog5743_key4; +UPDATE worklog5743_key4 SET col_1_blob = REPEAT("c", 4000) +WHERE col_1_blob = REPEAT("a", 4000) AND col_2_blob = REPEAT("o", 4000); +SELECT col_1_blob = REPEAT("b", 3500) FROM worklog5743_key4 +WHERE col_1_blob = REPEAT("c", 4000) AND col_2_blob = REPEAT("o", 4000); +INSERT INTO worklog5743_key4 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743_key4 WHERE col_1_blob = REPEAT("b", 4000); +SELECT col_1_blob = REPEAT("c", 4000) FROM worklog5743_key4; +DROP TABLE worklog5743_key4; + +# With KEY_BLOCK_SIZE = 8,prefix index limit comes around ~3072 for following +CREATE TABLE worklog5743_key8 ( +col_1_blob BLOB (4000) , col_2_blob BLOB (4000) , +PRIMARY KEY (col_1_blob(3072)) +) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8, engine = innodb; +INSERT INTO worklog5743_key8 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +#CREATE INDEX prefix_idx ON worklog5743_key8 (col_1_blob (767)); +INSERT INTO worklog5743_key8 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_blob = REPEAT("a", 4000) , col_2_blob = REPEAT("o", 4000) +FROM worklog5743_key8; +UPDATE worklog5743_key8 SET col_1_blob = REPEAT("c", 4000) +WHERE col_1_blob = REPEAT("a", 4000) AND col_2_blob = REPEAT("o", 4000); +SELECT col_1_blob = REPEAT("b", 3500) FROM worklog5743_key8 +WHERE col_1_blob = REPEAT("c", 4000) AND col_2_blob = REPEAT("o", 4000); +INSERT INTO worklog5743_key8 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743_key8 WHERE col_1_blob = REPEAT("b", 4000); +SELECT col_1_blob = REPEAT("c", 4000) FROM worklog5743_key8; +DROP TABLE worklog5743_key8; + + +#------------------------------------------------------------------------------ +# Create multiple prefix index. We can not create prefix index length > 16K +# as index is written in undo log page which of 16K size. +# So we can create max 2 prefix index of length 3072 on table +CREATE TABLE worklog5743 ( +col_1_varbinary VARBINARY (4000) , col_2_varchar VARCHAR (4000) , +col_3_text TEXT (4000), col_4_blob BLOB (4000), col_5_text TEXT (4000), +col_6_varchar VARCHAR (4000), col_7_binary BINARY (255) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000), +REPEAT("a", 4000) , REPEAT("o", 4000), REPEAT("a", 4000), +REPEAT("a", 4000) , REPEAT("a", 255) +); + +# Update reports ER_UNDO_RECORD_TOO_BIG if we create more than 2 indexes. +# Bug#12547647 - UPDATE LOGGING COULD EXCEED LOG PAGE SIZE +CREATE INDEX prefix_idx1 ON worklog5743(col_1_varbinary (3072)); +CREATE INDEX prefix_idx2 ON worklog5743(col_2_varchar (3072)); + +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000), +REPEAT("a", 4000) , REPEAT("o", 4000), REPEAT("a", 4000), +REPEAT("a", 4000) , REPEAT("a", 255) +); +SELECT col_1_varbinary = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_varbinary = REPEAT("c", 4000) +WHERE col_1_varbinary = REPEAT("a", 4000) AND col_2_varchar = REPEAT("o", 4000); +SELECT col_1_varbinary = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varbinary = REPEAT("c", 4000) AND col_2_varchar = REPEAT("o", 4000); + +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000), +REPEAT("a", 4000) , REPEAT("o", 4000), REPEAT("a", 4000), +REPEAT("a", 4000) , REPEAT("a", 255) +); +DELETE FROM worklog5743 WHERE col_1_varbinary = REPEAT("b", 4000); +SELECT col_1_varbinary = REPEAT("c", 4000) FROM worklog5743; + +# Add 3 more indexes. +# Update used to hang but now ER_UNDO_RECORD_TOO_BIG is reported; +# Bug#12547647 - UPDATE LOGGING COULD EXCEED UNDO LOG PAGE SIZE +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000), +REPEAT("a", 4000) , REPEAT("o", 4000), REPEAT("a", 4000), +REPEAT("a", 4000) , REPEAT("a", 255) +); +CREATE INDEX prefix_idx3 ON worklog5743(col_3_text (3072)); +CREATE INDEX prefix_idx4 ON worklog5743(col_4_blob (3072)); +CREATE INDEX prefix_idx5 ON worklog5743(col_5_text (3072)); +BEGIN; +UPDATE worklog5743 SET col_1_varbinary = REPEAT("c", 4000) +WHERE col_1_varbinary = REPEAT("a", 4000) AND col_2_varchar = REPEAT("o", 4000); +SHOW WARNINGS; +ROLLBACK; +DROP TABLE worklog5743; + +#------------------------------------------------------------------------------ +# Create multiple prefix index. We can not create prefix index length > 16K as +# we write in undo log page which of 16K size. +# so we can create max 5 prefix index of length 3072 on table. +# Similar to above case but with transactions +CREATE TABLE worklog5743 ( +col_1_varbinary VARBINARY (4000) , col_2_varchar VARCHAR (4000) , +col_3_text TEXT (4000), col_4_blob BLOB (4000),col_5_text TEXT (4000), +col_6_varchar VARCHAR (4000), col_7_binary BINARY (255) +) ROW_FORMAT=DYNAMIC, engine = innodb; + + +# Update used to hang if we create following 5 indexes. Fixed in; +# Bug#12547647 - UPDATE LOGGING COULD EXCEED UNDO LOG PAGE SIZE +CREATE INDEX prefix_idx1 ON worklog5743(col_1_varbinary (3072)); +CREATE INDEX prefix_idx2 ON worklog5743(col_2_varchar (3072)); +CREATE INDEX prefix_idx3 ON worklog5743(col_3_text (3072)); +CREATE INDEX prefix_idx4 ON worklog5743(col_4_blob (3072)); +CREATE INDEX prefix_idx5 ON worklog5743(col_5_text (3072)); + +START TRANSACTION; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000), +REPEAT("a", 4000) , REPEAT("o", 4000), REPEAT("a", 4000), +REPEAT("a", 4000) , REPEAT("a", 255) +); +SELECT col_1_varbinary = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743; +ROLLBACK; +START TRANSACTION; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000), +REPEAT("a", 4000) , REPEAT("o", 4000), REPEAT("a", 4000), +REPEAT("a", 4000) , REPEAT("a", 255) +); +COMMIT; +SELECT col_1_varbinary = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743; + +START TRANSACTION; +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000), +REPEAT("a", 4000) , REPEAT("o", 4000), REPEAT("a", 4000), +REPEAT("a", 4000) , REPEAT("a", 255) +); +ROLLBACK; +BEGIN; +UPDATE worklog5743 SET col_1_varbinary = REPEAT("c", 4000) +WHERE col_1_varbinary = REPEAT("a", 4000) +AND col_2_varchar = REPEAT("o", 4000); +SHOW WARNINGS; +ROLLBACK; +SELECT col_1_varbinary = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varbinary = REPEAT("c", 4000) AND col_2_varchar = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000), +REPEAT("a", 4000) , REPEAT("o", 4000), REPEAT("a", 4000), +REPEAT("a", 4000) , REPEAT("a", 255) +); +DELETE FROM worklog5743 WHERE col_1_varbinary = REPEAT("b", 4000); +SELECT col_1_varbinary = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + +#------------------------------------------------------------------------------ +# Prefix index with utf8 charset +# utf8 charcter takes 3 bytes in mysql so prefix index limit is 3072/3 = 1024 +CREATE TABLE worklog5743 ( +col_1_text TEXT (4000) CHARACTER SET 'utf8', +col_2_text TEXT (4000) CHARACTER SET 'utf8', +PRIMARY KEY (col_1_text(1024)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +CREATE INDEX prefix_idx ON worklog5743(col_1_text (1024)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_text = REPEAT("a", 4000) , col_2_text = REPEAT("o", 4000) FROM worklog5743; +UPDATE worklog5743 SET col_1_text = REPEAT("c", 4000) +WHERE col_1_text = REPEAT("a", 4000) AND col_2_text = REPEAT("o", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("c", 4000) AND col_2_text = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_text = REPEAT("b", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + +# Prefix index with utf8 charset + varchar. +CREATE TABLE worklog5743 (col_1_varchar VARCHAR (4000) CHARACTER SET 'utf8', +col_2_varchar VARCHAR (4000) CHARACTER SET 'utf8' , +PRIMARY KEY (col_1_varchar(1024)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (1024)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_varchar = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) FROM worklog5743; +UPDATE worklog5743 SET col_1_varchar = REPEAT("c", 4000) +WHERE col_1_varchar = REPEAT("a", 4000) AND col_2_varchar = REPEAT("o", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varchar = REPEAT("c", 4000) AND col_2_varchar = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_varchar = REPEAT("b", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + +#------------------------------------------------------------------------------ +# prefinx index on utf8 charset with transaction +CREATE TABLE worklog5743 ( +col_1_varbinary VARBINARY (4000) , +col_2_varchar VARCHAR (4000) CHARACTER SET 'utf8', +col_3_text TEXT (4000) CHARACTER SET 'utf8', +col_4_blob BLOB (4000),col_5_text TEXT (4000), +col_6_varchar VARCHAR (4000), col_7_binary BINARY (255) +) ROW_FORMAT=DYNAMIC, engine = innodb; + + +CREATE INDEX prefix_idx2 ON worklog5743(col_2_varchar (500)); +CREATE INDEX prefix_idx3 ON worklog5743(col_3_text (500)); + +START TRANSACTION; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000), +REPEAT("a", 4000) , REPEAT("o", 4000), REPEAT("a", 4000), +REPEAT("a", 4000) , REPEAT("a", 255) +); +SELECT col_1_varbinary = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743; +ROLLBACK; +START TRANSACTION; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000), +REPEAT("a", 4000) , REPEAT("o", 4000), REPEAT("a", 4000), +REPEAT("a", 4000) , REPEAT("a", 255) +); +COMMIT; +SELECT col_1_varbinary = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743; + +START TRANSACTION; +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000), +REPEAT("a", 4000) , REPEAT("o", 4000), REPEAT("a", 4000), +REPEAT("a", 4000) , REPEAT("a", 255) +); +ROLLBACK; +SELECT col_1_varbinary = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varbinary = REPEAT("c", 4000) +AND col_2_varchar = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000), +REPEAT("a", 4000) , REPEAT("o", 4000), REPEAT("a", 4000), +REPEAT("a", 4000) , REPEAT("a", 255) +); +DELETE FROM worklog5743 WHERE col_1_varbinary = REPEAT("b", 4000); +SELECT col_1_varbinary = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + + +#------------------------------------------------------------------------------ +# Prefix index with utf8 charset on TEXT data type with actual utf8 character +# like "स" and "क" +CREATE TABLE worklog5743 ( +col_1_text TEXT (4000) CHARACTER SET 'utf8', +col_2_text TEXT (4000) , +PRIMARY KEY (col_1_text(1024)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("स", 4000) , REPEAT("o", 4000)); +CREATE INDEX prefix_idx ON worklog5743(col_1_text (1024)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_text = REPEAT("स", 4000) , col_2_text = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_text = REPEAT("क", 4000) +WHERE col_1_text = REPEAT("स", 4000) AND col_2_text = REPEAT("o", 4000); +SELECT col_1_text = REPEAT("क", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("c", 4000) AND col_2_text = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_text = REPEAT("b", 4000); +SELECT col_1_text = REPEAT("क", 4000) FROM worklog5743; +DROP TABLE worklog5743; + + +#------------------------------------------------------------------------------ +# Prefix index with transaction when 2 client are ruuning there transaction +# in different sessions.With ISOLATION LEVEL as REPEATABLE READ and +# READ UNCOMMITTED. +CREATE TABLE worklog5743 ( +col_1_text TEXT(4000) , col_2_text TEXT(4000) , +PRIMARY KEY (col_1_text(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 200) , REPEAT("o", 200)); +SELECT col_1_text = REPEAT("a", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; + +--connect (con1,localhost,root,,) +SELECT col_1_text = REPEAT("a", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +SELECT COUNT(*) FROM worklog5743; + +--connect (con2,localhost,root,,) +START TRANSACTION; +INSERT INTO worklog5743 VALUES(REPEAT("b", 200) , REPEAT("o", 200)); +# Uncomment after Bug#12552164 - TRANSACTION CAN NOT SEE OLD VERSION ROWS THAT +# BEING UPDATED +#UPDATE worklog5743 SET col_1_varchar = REPEAT("d", 200) WHERE col_1_varchar = +#REPEAT("a", 200) AND col_2_varchar = REPEAT("o", 200); +SELECT col_1_text = REPEAT("a", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; + +--connection con1 +select @@session.tx_isolation; +SELECT col_1_text = REPEAT("b", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +SELECT col_1_text = REPEAT("b", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; + +START TRANSACTION; + +SELECT col_1_text = REPEAT("a", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +SELECT COUNT(*) FROM worklog5743; + +--connection con2 +COMMIT; +# Wait for commit +let $wait_condition=SELECT COUNT(*)=0 FROM information_schema.processlist +WHERE info='COMMIT'; +--source include/wait_condition.inc + +--connection con1 +SELECT col_1_text = REPEAT("b", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +SELECT col_1_text = REPEAT("a", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +SELECT COUNT(*) FROM worklog5743; +COMMIT; + +--connection default +DROP TABLE worklog5743; + + +#------------------------------------------------------------------------------ +# Prefix index with transaction when 2 client are ruuning there transaction +# in different sessions.With ISOLATION LEVEL as REPEATABLE READ and +# READ UNCOMMITTED. Same as above case but con2 starts tnx before con1 + +CREATE TABLE worklog5743 ( +col_1_text TEXT(4000) , col_2_text TEXT(4000) , +PRIMARY KEY (col_1_text(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 200) , REPEAT("o", 200)); +SELECT col_1_text = REPEAT("a", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; + +--connection con1 +SELECT col_1_text = REPEAT("a", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +SELECT COUNT(*) FROM worklog5743; +START TRANSACTION; + +--connection con2 +START TRANSACTION; +INSERT INTO worklog5743 VALUES(REPEAT("b", 200) , REPEAT("o", 200)); +DELETE FROM worklog5743 WHERE col_1_text = REPEAT("a", 200); +SELECT col_1_text = REPEAT("a", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +COMMIT; +# Wait for commit +let $wait_condition=SELECT COUNT(*)=0 FROM information_schema.processlist +WHERE info='COMMIT'; +--source include/wait_condition.inc + +--connection con1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.tx_isolation; +SELECT col_1_text = REPEAT("b", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; + +SELECT col_1_text = REPEAT("b", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +SELECT COUNT(*) FROM worklog5743; +COMMIT; + +--connection default +DROP TABLE worklog5743; + +#------------------------------------------------------------------------------ + +# Prefix index with transaction when 2 client are ruuning there transaction +# in different sessions.With ISOLATION LEVEL as REPEATABLE READ and +# READ UNCOMMITTED. Same as above cases but with ROLLBACK + +CREATE TABLE worklog5743 ( +col_1_text TEXT(4000) , col_2_text TEXT(4000) , +PRIMARY KEY (col_1_text(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 200) , REPEAT("o", 200)); +SELECT col_1_text = REPEAT("a", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; + +--connection con1 +SELECT col_1_text = REPEAT("a", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +SELECT COUNT(*) FROM worklog5743; +START TRANSACTION; + +--connection con2 +START TRANSACTION; +INSERT INTO worklog5743 VALUES(REPEAT("b", 200) , REPEAT("o", 200)); +DELETE FROM worklog5743 WHERE col_1_text = REPEAT("a", 200); +SELECT col_1_text = REPEAT("a", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +ROLLBACK; +# Wait for rollback +let $wait_condition=SELECT COUNT(*)=0 FROM information_schema.processlist +WHERE info='COMMIT'; +--source include/wait_condition.inc +--disconnect con2 + +--connection con1 +SELECT col_1_text = REPEAT("b", 200) , col_2_text = REPEAT("o", 200) FROM +worklog5743; +SELECT COUNT(*) FROM worklog5743; +COMMIT; + +--connection default +DROP TABLE worklog5743; + +#------------------------------------------------------------------------------ +# Select queries on prefix index column as index will be used in queries. +# Use few select functions , join condition , subqueries. + +CREATE TABLE worklog5743 ( +col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , +PRIMARY KEY (col_1_varchar(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_varchar = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_varchar = REPEAT("c", 4000) +WHERE col_1_varchar = REPEAT("a", 4000) +AND col_2_varchar = REPEAT("o", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varchar = REPEAT("c", 4000) +AND col_2_varchar = REPEAT("o", 4000); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743; + +# Select with Join +SELECT tbl1.col_1_varchar = tbl2.col_1_varchar +FROM worklog5743 tbl1 , worklog5743 tbl2 +WHERE tbl1.col_1_varchar = tbl2.col_1_varchar ; + +# Select in subquey +SELECT tbl1.col_1_varchar = REPEAT("c", 4000) FROM worklog5743 tbl1 +WHERE col_1_varchar IN (SELECT tbl2.col_1_varchar FROM worklog5743 tbl2) ; +SELECT tbl1.col_1_varchar = REPEAT("c", 4000) FROM worklog5743 tbl1 +WHERE col_1_varchar NOT IN (SELECT tbl2.col_1_varchar FROM worklog5743 tbl2) ; +SELECT tbl1.col_1_varchar = REPEAT("c", 4000) FROM worklog5743 tbl1 WHERE +col_1_varchar IN (SELECT tbl2.col_1_varchar FROM worklog5743 tbl2) +AND col_1_varchar = REPEAT("c", 4000); +SELECT tbl1.col_1_varchar = REPEAT("c", 4000) FROM worklog5743 tbl1 +WHERE col_1_varchar in ( +SELECT tbl2.col_1_varchar FROM worklog5743 tbl2 +WHERE tbl1.col_1_varchar != tbl2.col_1_varchar +) ; +SELECT tbl1.col_1_varchar = REPEAT("c", 4000) FROM worklog5743 tbl1 +WHERE col_1_varchar in ( +SELECT tbl2.col_1_varchar FROM worklog5743 tbl2 +WHERE tbl1.col_1_varchar = tbl2.col_1_varchar +) ; + +# function +SELECT +REVERSE(col_1_varchar) = REPEAT("c", 4000) , +REVERSE(REVERSE(col_1_varchar)) = REPEAT("c", 4000) +FROM worklog5743; +SELECT +UPPER(col_1_varchar) = REPEAT("c", 4000) , +UPPER(col_1_varchar) = REPEAT("C", 4000) , +LOWER(UPPER(col_1_varchar)) = REPEAT("c", 4000) +FROM worklog5743; +SELECT +col_1_varchar = REPEAT("c", 4000) +FROM worklog5743 WHERE col_1_varchar like '%c__%'; +SELECT SUBSTRING(INSERT(col_1_varchar, 1, 4, 'kkkk'),1,10) FROM worklog5743 ; +SELECT CONCAT(SUBSTRING(col_1_varchar,-5,3),'append') FROM worklog5743 ; + + +DROP TABLE worklog5743; + +#------------------------------------------------------------------------------ +# Prefix index with NULL values +CREATE TABLE worklog5743 ( +col_1_varchar VARCHAR (4000) , +col_2_varchar VARCHAR (4000) , +UNIQUE INDEX (col_1_varchar(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 +VALUES(concat(REPEAT("a", 2000),REPEAT("b", 1000),REPEAT("c", 1000)), REPEAT("o", 4000)); +INSERT INTO worklog5743 +VALUES(concat(REPEAT("a", 2000),REPEAT("b", 2000)), REPEAT("o", 4000)); +INSERT INTO worklog5743 VALUES(NULL,NULL); +INSERT INTO worklog5743 VALUES(NULL,NULL); +# check IS +SELECT COLUMN_NAME,INDEX_NAME,SUB_PART,INDEX_TYPE +FROM INFORMATION_SCHEMA.STATISTICS WHERE table_name = 'worklog5743' ; +SELECT col_1_varchar FROM worklog5743 WHERE col_1_varchar IS NULL; +SELECT col_1_varchar = concat(REPEAT("a", 2000),REPEAT("b", 2000)) +FROM worklog5743 WHERE col_1_varchar IS NOT NULL ORDER BY 1; + + +DROP TABLE worklog5743; + +# ----------------------------------------------------------------------------- +# Try drop and add secondary prefix index +CREATE TABLE worklog5743 ( +col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , +PRIMARY KEY (col_1_varchar(3072))) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +# Create index +CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +# Drop index +DROP INDEX prefix_idx ON worklog5743; + +SELECT col_1_varchar = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_varchar = REPEAT("c", 4000) +WHERE col_1_varchar = REPEAT("a", 4000) AND col_2_varchar = REPEAT("o", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varchar = REPEAT("c", 4000) AND col_2_varchar = REPEAT("o", 4000); +# Again add index +CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072)); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_varchar = REPEAT("b", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + +# ----------------------------------------------------------------------------- + +# Try drop and add primary prefix index +CREATE TABLE worklog5743 ( +col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , +PRIMARY KEY `prefix_primary` (col_1_varchar(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +# Create index +CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +# Drop index +ALTER TABLE worklog5743 DROP PRIMARY KEY; + +SELECT col_1_varchar = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_varchar = REPEAT("c", 4000) +WHERE col_1_varchar = REPEAT("a", 4000) +AND col_2_varchar = REPEAT("o", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varchar = REPEAT("c", 4000) +AND col_2_varchar = REPEAT("o", 4000); +# Again add index +ALTER TABLE worklog5743 ADD PRIMARY KEY (col_1_varchar(3072)); + +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +--error ER_DUP_ENTRY +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_varchar = REPEAT("b", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + + +# ----------------------------------------------------------------------------- + +# Try drop and add both (primary/secondary) prefix index +CREATE TABLE worklog5743 ( +col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , +PRIMARY KEY `prefix_primary` (col_1_varchar(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +# Create index +CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +# Drop primary index +ALTER TABLE worklog5743 DROP PRIMARY KEY; +# Drop secondary index +DROP INDEX prefix_idx ON worklog5743; + +SELECT col_1_varchar = REPEAT("a", 4000) , col_2_varchar = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_varchar = REPEAT("c", 4000) +WHERE col_1_varchar = REPEAT("a", 4000) AND col_2_varchar = REPEAT("o", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varchar = REPEAT("c", 4000) AND col_2_varchar = REPEAT("o", 4000); +# Again add index +ALTER TABLE worklog5743 ADD PRIMARY KEY (col_1_varchar(3072)); +CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072)); + +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +--error ER_DUP_ENTRY +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +DELETE FROM worklog5743 WHERE col_1_varchar = REPEAT("b", 4000); +SELECT col_1_varchar = REPEAT("c", 4000) FROM worklog5743; +DROP TABLE worklog5743; + + +# ----------------------------------------------------------------------------- +# Drop index from differnt session +CREATE TABLE worklog5743 ( +col_1_varchar VARCHAR(4000) , col_2_varchar VARCHAR(4000) , +PRIMARY KEY (col_1_varchar (3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("c", 3500) , REPEAT("o", 3500)); +CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072)); + +--connection con1 +SELECT col_1_varchar = REPEAT("c", 3500) , col_2_varchar = REPEAT("o", 3500) +FROM worklog5743; + +--connection default +START TRANSACTION; +INSERT INTO worklog5743 VALUES(REPEAT("a", 3500) , REPEAT("o", 3500)); +SELECT col_1_varchar = REPEAT("b", 3500) FROM worklog5743 +WHERE col_2_varchar = REPEAT("o", 3500); +COMMIT; + +--connection con1 +START TRANSACTION; +INSERT INTO worklog5743 VALUES(REPEAT("k", 3500),REPEAT("p", 3500)); +# Drop primary index +ALTER TABLE worklog5743 DROP PRIMARY KEY; +UPDATE worklog5743 SET col_1_varchar = REPEAT("b", 3500) +WHERE col_1_varchar = REPEAT("a", 3500) +AND col_2_varchar = REPEAT("o", 3500); +SELECT col_1_varchar = REPEAT("b", 3500) FROM worklog5743 +WHERE col_2_varchar = REPEAT("o", 3500); + +--connection default +DELETE FROM worklog5743 WHERE col_1_varchar = REPEAT("b", 3500); +SELECT col_1_varchar = REPEAT("a", 3500) FROM worklog5743 +WHERE col_2_varchar = REPEAT("p", 3500); + +--connection con1 +COMMIT; +--disconnect con1 + +--connection default +DROP TABLE worklog5743; + + + +# ----------------------------------------------------------------------------- +# Create prefix index with length < 3072 , length = 3072 , length > 3072 +# - varbinary data type + secondary index +CREATE TABLE worklog5743 ( +col_1_varbinary VARBINARY (4000) , col_2_varbinary VARBINARY (4000) , +PRIMARY KEY (col_1_varbinary(3072))) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +# Create index of 3072 +CREATE INDEX prefix_idx ON worklog5743(col_1_varbinary (3072)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_varbinary = REPEAT("a", 4000) , col_2_varbinary = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_varbinary = REPEAT("c", 4000) +WHERE col_1_varbinary = REPEAT("a", 4000) +AND col_2_varbinary = REPEAT("o", 4000); +SELECT col_1_varbinary = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varbinary = REPEAT("c", 4000) +AND col_2_varbinary = REPEAT("o", 4000); +DELETE FROM worklog5743 WHERE col_1_varbinary = REPEAT("c", 4000); +SELECT col_1_varbinary = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varbinary = REPEAT("c", 4000) +AND col_2_varbinary = REPEAT("o", 4000); +# Drop index +DROP INDEX prefix_idx ON worklog5743; +SELECT col_1_varbinary = REPEAT("b", 4000) FROM worklog5743 +WHERE col_1_varbinary = REPEAT("b", 4000) +AND col_2_varbinary = REPEAT("p", 4000); + + +# Again add index length < 3072 +CREATE INDEX prefix_idx ON worklog5743(col_1_varbinary (2000)); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +SELECT col_1_varbinary = REPEAT("a", 4000) FROM worklog5743; +UPDATE worklog5743 SET col_1_varbinary = REPEAT("c", 4000) +WHERE col_1_varbinary = REPEAT("a", 4000) +AND col_2_varbinary = REPEAT("o", 4000); +DELETE FROM worklog5743 WHERE col_1_varbinary = REPEAT("c", 4000); +SELECT col_1_varbinary = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varbinary = REPEAT("c", 4000) +AND col_2_varbinary = REPEAT("o", 4000); +# Drop index +DROP INDEX prefix_idx ON worklog5743; + +# Again add index length > 3072. +# index prefix larger than 3072 will be truncated to 3072 +# For the ROW_FORMAT of REDUNDANT or COMPACT, which do +# not support prefix > 767, the create index will be rejected. +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE INDEX prefix_idx ON worklog5743(col_1_varbinary (4000)); +SET sql_mode = default; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +SELECT col_1_varbinary = REPEAT("a", 4000) FROM worklog5743; +UPDATE worklog5743 SET col_1_varbinary = REPEAT("c", 4000) +WHERE col_1_varbinary = REPEAT("a", 4000) +AND col_2_varbinary = REPEAT("o", 4000); +DELETE FROM worklog5743 WHERE col_1_varbinary = REPEAT("c", 4000); +SELECT col_1_varbinary = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_varbinary = REPEAT("c", 4000) +AND col_2_varbinary = REPEAT("o", 4000); + + +DROP TABLE worklog5743; + +# ----------------------------------------------------------------------------- +# Create prefix index with length < 3072 , length = 3072 , length > 3072 +# text data type + secondary index +CREATE TABLE worklog5743 (col_1_text TEXT (4000) , col_2_text TEXT (4000) , +PRIMARY KEY (col_1_text(500)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +# Create index of 3072 +CREATE INDEX prefix_idx ON worklog5743(col_1_text (3072)); +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_text = REPEAT("a", 4000) , col_2_text = REPEAT("o", 4000) +FROM worklog5743; +UPDATE worklog5743 SET col_1_text = REPEAT("c", 4000) +WHERE col_1_text = REPEAT("a", 4000) +AND col_2_text = REPEAT("o", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("c", 4000) AND col_2_text = REPEAT("o", 4000); +DELETE FROM worklog5743 WHERE col_1_text = REPEAT("c", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("c", 4000) AND col_2_text = REPEAT("o", 4000); +# Drop index +DROP INDEX prefix_idx ON worklog5743; +SELECT col_1_text = REPEAT("b", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("b", 4000) AND col_2_text = REPEAT("p", 4000); + +# Again add index length < 3072 +CREATE INDEX prefix_idx ON worklog5743(col_1_text (1000)); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +SELECT col_1_text = REPEAT("a", 4000) FROM worklog5743; +UPDATE worklog5743 SET col_1_text = REPEAT("c", 4000) +WHERE col_1_text = REPEAT("a", 4000) AND col_2_text = REPEAT("o", 4000); +DELETE FROM worklog5743 WHERE col_1_text = REPEAT("c", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("c", 4000) AND col_2_text = REPEAT("o", 4000); +# Drop index +DROP INDEX prefix_idx ON worklog5743; + +# Again add index length > 3072. +# index prefix larger than 3072 will be truncated to 3072 +# In STRICT mode, the statement will fail with error. +# For ROW_FORMAT of REDUNDANT or COMPACT, which does not support prefix > 767, +# the create index will be rejected. +# --error ER_TOO_LONG_KEY +CREATE INDEX prefix_idx ON worklog5743(col_1_text (4000)); +#CREATE INDEX prefix_idx ON worklog5743(col_1_text (3072)); +SHOW CREATE TABLE worklog5743; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +SELECT col_1_text = REPEAT("a", 4000) FROM worklog5743; +UPDATE worklog5743 SET col_1_text = REPEAT("c", 4000) +WHERE col_1_text = REPEAT("a", 4000) AND col_2_text = REPEAT("o", 4000); +DELETE FROM worklog5743 WHERE col_1_text = REPEAT("c", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("c", 4000) AND col_2_text = REPEAT("o", 4000); + +DROP TABLE worklog5743; + + +# ----------------------------------------------------------------------------- +# Create prefix index with length < 948 , length = 948 , length > 948 +# For compressed row type + primary key +CREATE TABLE worklog5743 ( +col_1_text TEXT (4000) , col_2_text TEXT (4000) , +PRIMARY KEY (col_1_text(801)) +) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2, engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000)); +# Create index of 767 +INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); +SELECT col_1_text = REPEAT("a", 4000) , col_2_text = REPEAT("o", 4000) FROM worklog5743; +UPDATE worklog5743 SET col_1_text = REPEAT("c", 4000) +WHERE col_1_text = REPEAT("a", 4000) +AND col_2_text = REPEAT("o", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("c", 4000) +AND col_2_text = REPEAT("o", 4000); +DELETE FROM worklog5743 WHERE col_1_text = REPEAT("c", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("c", 4000) +AND col_2_text = REPEAT("o", 4000); +# Drop index +#DROP INDEX prefix_idx ON worklog5743; +ALTER TABLE worklog5743 DROP PRIMARY KEY; +SELECT col_1_text = REPEAT("b", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("b", 4000) +AND col_2_text = REPEAT("p", 4000); + +# Again add index length < 767 +ALTER TABLE worklog5743 ADD PRIMARY KEY (col_1_text (700)); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +SELECT col_1_text = REPEAT("a", 4000) FROM worklog5743; +UPDATE worklog5743 SET col_1_text = REPEAT("c", 4000) +WHERE col_1_text = REPEAT("a", 4000) +AND col_2_text = REPEAT("o", 4000); +DELETE FROM worklog5743 WHERE col_1_text = REPEAT("c", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("c", 4000) +AND col_2_text = REPEAT("o", 4000); +# Drop index +ALTER TABLE worklog5743 DROP PRIMARY KEY; + +# Again add index length > 948. Expect error 'to big row ' due to exceed +# in key length. +-- error ER_TOO_BIG_ROWSIZE +ALTER TABLE worklog5743 ADD PRIMARY KEY (col_1_text (950)); +INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000)); +SELECT col_1_text = REPEAT("a", 4000) FROM worklog5743; +UPDATE worklog5743 SET col_1_text = REPEAT("c", 4000) +WHERE col_1_text = REPEAT("a", 4000) +AND col_2_text = REPEAT("o", 4000); +DELETE FROM worklog5743 WHERE col_1_text = REPEAT("c", 4000); +SELECT col_1_text = REPEAT("c", 4000) FROM worklog5743 +WHERE col_1_text = REPEAT("c", 4000) +AND col_2_text = REPEAT("o", 4000); + +DROP TABLE worklog5743; + +# ----------------------------------------------------------------------------- +# Create prefix index with length < 3072 , length = 3072 , length > 3072 +# data types VARCHAR +CREATE TABLE worklog5743 ( +col_1_varchar VARCHAR (4000) , PRIMARY KEY (col_1_varchar(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +ALTER TABLE worklog5743 DROP PRIMARY KEY; +ALTER TABLE worklog5743 ADD PRIMARY KEY (col_1_varchar (900)); +ALTER TABLE worklog5743 DROP PRIMARY KEY; +# Again add index length > 3072. Expect error.Length exceeds maximum supported +# key length +# Again add index length > 3072. +# index prefix larger than 3072 will be truncated to 3072. +# For ROW_FORMAT of REDUNDANT or COMPACT, which do +# not support prefix > 767, the create index will be rejected. +# Index length is truncated only for 'create index' , but error if we add +# prefix index with length > 3072 +--error ER_TOO_LONG_KEY +ALTER TABLE worklog5743 ADD PRIMARY KEY (col_1_varchar (3073)); +DROP TABLE worklog5743; + + +CREATE TABLE worklog5743 ( +col_1_BLOB BLOB (4000) , PRIMARY KEY (col_1_BLOB(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +ALTER TABLE worklog5743 DROP PRIMARY KEY; +ALTER TABLE worklog5743 ADD PRIMARY KEY (col_1_BLOB (500)); +ALTER TABLE worklog5743 DROP PRIMARY KEY; +# Negative case +# Again add index length > 3072. Expect error.Length exceeds maximum supported +# key length +# Index length is truncated only for 'create index' , but error if we add +# prefix index with length > 3072 +--error ER_TOO_LONG_KEY +ALTER TABLE worklog5743 ADD PRIMARY KEY (col_1_BLOB (3073)); + +DROP TABLE worklog5743; + +# ----------------------------------------------------------------------------- +# Error on adding larger prefix if violates unique index. +CREATE TABLE worklog5743 ( +col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) +) ROW_FORMAT=DYNAMIC, engine = innodb; +INSERT INTO worklog5743 +VALUES(concat(REPEAT("a", 2000),REPEAT("b", 1000),REPEAT("c", 1000)), +REPEAT("o", 4000)); +INSERT INTO worklog5743 +VALUES(concat(REPEAT("a", 2000),REPEAT("b", 2000)), REPEAT("o", 4000)); +--error ER_DUP_ENTRY +ALTER TABLE worklog5743 ADD PRIMARY KEY `pk_idx` (col_1_varchar(3000)); +DROP TABLE worklog5743; + +# ----------------------------------------------------------------------------- +CREATE TABLE worklog5743 ( +col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , +PRIMARY KEY (col_1_varchar(3072)) +) ROW_FORMAT=DYNAMIC, engine = innodb; +DROP TABLE worklog5743; + + +# ----------------------------------------------------------------------------- +# Backward compatibility test - Index length > 767 is truncated for REDUNDANT +# and COMPACT +CREATE TABLE worklog5743 ( +col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , +PRIMARY KEY (col_1_varchar(767)) +) engine = innodb; +INSERT INTO worklog5743 VALUES(REPEAT('a',4000),REPEAT('b',4000)); +# Prefix index > 767 is truncated with REDUNDANT and COMPACT +--enable_info +CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (1000)); +--error ER_INDEX_COLUMN_TOO_LONG +ALTER TABLE worklog5743 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE; +--error ER_INDEX_COLUMN_TOO_LONG +ALTER TABLE worklog5743 ROW_FORMAT=REDUNDANT, ALGORITHM=COPY; +--disable_info +SHOW CREATE TABLE worklog5743; +--disable_query_log +SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; +--enable_query_log +DROP TABLE worklog5743; diff --git a/mysql-test/suite/innodb_zip/t/recover.test b/mysql-test/suite/innodb_zip/t/recover.test new file mode 100644 index 00000000..194ef10a --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/recover.test @@ -0,0 +1,42 @@ +--source include/innodb_page_size_small.inc +--source include/not_embedded.inc + +# This test kills the server, which could corrupt some mysql.* tables +# that are not created with ENGINE=InnoDB. +# Flush any non-InnoDB tables to prevent that from happening. +FLUSH TABLES; + +--echo # +--echo # MDEV-21892 Assertion 'index != clust_index || row_get_rec_trx_id()' +--echo # +connect (con1,localhost,root); +CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +INSERT INTO t1 VALUES (1),(2); +BEGIN; +--error ER_DUP_ENTRY +UPDATE t1 SET pk=1; +connection default; + +--echo # +--echo # MDEV-12720 recovery fails with "Generic error" +--echo # for ROW_FORMAT=compressed +--echo # +CREATE TABLE a(i INT PRIMARY KEY AUTO_INCREMENT, s VARCHAR(255)) ENGINE=InnoDB +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +BEGIN; +insert into a(i) select null; +insert into a select null, uuid() from a a, a b, a c; +insert into a select null, uuid() from a a, a b, a c; +insert into a select null, uuid() from a a, a b, a c; +SET GLOBAL innodb_flush_log_at_trx_commit=1; +COMMIT; + +--let $shutdown_timeout=0 +--source include/restart_mysqld.inc +disconnect con1; + +SELECT * FROM t1; +DROP TABLE t1; +SELECT COUNT(*) from a; +DROP TABLE a; diff --git a/mysql-test/suite/innodb_zip/t/restart.opt b/mysql-test/suite/innodb_zip/t/restart.opt new file mode 100644 index 00000000..d7564300 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/restart.opt @@ -0,0 +1,2 @@ +--loose-innodb-sys-tables +--loose-innodb-sys-tablespaces diff --git a/mysql-test/suite/innodb_zip/t/restart.test b/mysql-test/suite/innodb_zip/t/restart.test new file mode 100644 index 00000000..c442b919 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/restart.test @@ -0,0 +1,606 @@ +# +# These test make sure that tables are visible after rebooting +# +--source include/innodb_page_size_small.inc +--source include/have_partition.inc +--source include/not_embedded.inc +--source include/innodb_checksum_algorithm.inc +--source include/have_symlink.inc + +SET default_storage_engine=InnoDB; +LET $MYSQLD_DATADIR = `select @@datadir`; +LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`; + +--disable_query_log +# This error is expected in the error log for this test. +call mtr.add_suppression("\\[ERROR\\] InnoDB: Error number 17 means 'File exists'"); +call mtr.add_suppression("\\[ERROR\\] InnoDB: Operating system error number (17|80) in a file operation."); +call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot create file .*t55_restart.isl"); +call mtr.add_suppression("\\[ERROR\\] InnoDB: The link file: .* already exists."); +call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot open datafile for read-only:"); +call mtr.add_suppression("\\[ERROR\\] InnoDB: Operating system error number 2 in a file operation."); +call mtr.add_suppression("\\[ERROR\\] InnoDB: The error means the system cannot find the path specified."); +--enable_query_log + +--echo # +--echo # A series of tests to make sure tables are opened after restart. +--echo # Bug#13357607 Compressed file-per-table tablespaces fail to open +--echo # +# This bug was introduced without a regression test failing since +# there were no tests showing that tablespaces could be created and +# then read after reboot. +# + +--disable_query_log +let $MYSQL_DATA_DIR= `select @@datadir`; +let $data_directory = DATA DIRECTORY='$MYSQL_TMP_DIR/alt_dir'; + +let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; +--enable_query_log + +set global innodb_file_per_table=on; + +--echo # +--echo # Create and insert records into a REDUNDANT row formatted table. +--echo # +CREATE TABLE t1_restart(c1 DOUBLE AUTO_INCREMENT KEY, c2 CHAR(10), c3 VARCHAR(100), c4 DATE, c5 TEXT) + ROW_FORMAT=REDUNDANT ENGINE=InnoDB; +INSERT INTO t1_restart VALUES (1000000000, 'MySQL', 'InnoDB', '2011-11-11', 'Read this after reboot'); +INSERT INTO t1_restart (SELECT 0, c2, c3, c4, c5 FROM t1_restart); +INSERT INTO t1_restart (SELECT 0, c2, c3, c4, c5 FROM t1_restart); +INSERT INTO t1_restart (SELECT 0, c2, c3, c4, c5 FROM t1_restart); +INSERT INTO t1_restart (SELECT 0, c2, c3, c4, c5 FROM t1_restart); +SHOW CREATE TABLE t1_restart; +SELECT count(*) FROM t1_restart; + +--echo # +--echo # Create and insert records into a COMPACT row formatted table. +--echo # +CREATE TABLE t2_restart(c1 DOUBLE AUTO_INCREMENT KEY, c2 CHAR(10), c3 VARCHAR(100), c4 DATE, c5 TEXT) + ROW_FORMAT=COMPACT ENGINE=InnoDB; +INSERT INTO t2_restart VALUES (1000000000, 'MySQL', 'InnoDB', '2011-11-11', 'Read this after reboot'); +INSERT INTO t2_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart); +INSERT INTO t2_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart); +INSERT INTO t2_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart); +INSERT INTO t2_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart); +SHOW CREATE TABLE t2_restart; +SELECT count(*) FROM t2_restart; + +--echo # +--echo # Create and insert records into a COMPRESSED row formatted table. +--echo # +CREATE TABLE t3_restart(c1 DOUBLE AUTO_INCREMENT KEY, c2 CHAR(10), c3 VARCHAR(100), c4 DATE, c5 TEXT) + ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2 ENGINE=InnoDB; +INSERT INTO t3_restart VALUES (1000000000, 'MySQL', 'InnoDB', '2011-11-11', 'Read this after reboot'); +INSERT INTO t3_restart (SELECT 0, c2, c3, c4, c5 FROM t3_restart); +INSERT INTO t3_restart (SELECT 0, c2, c3, c4, c5 FROM t3_restart); +INSERT INTO t3_restart (SELECT 0, c2, c3, c4, c5 FROM t3_restart); +INSERT INTO t3_restart (SELECT 0, c2, c3, c4, c5 FROM t3_restart); +SHOW CREATE TABLE t3_restart; +SELECT count(*) FROM t3_restart; + +--echo # +--echo # Create and insert records into a DYNAMIC row formatted table. +--echo # +CREATE TABLE t4_restart(c1 DOUBLE AUTO_INCREMENT KEY, c2 CHAR(10), c3 VARCHAR(100), c4 DATE, c5 TEXT) + ROW_FORMAT=DYNAMIC ENGINE=InnoDB; +INSERT INTO t4_restart VALUES (1000000000, 'MySQL', 'InnoDB', '2011-11-11', 'Read this after reboot'); +INSERT INTO t4_restart (SELECT 0, c2, c3, c4, c5 FROM t4_restart); +INSERT INTO t4_restart (SELECT 0, c2, c3, c4, c5 FROM t4_restart); +INSERT INTO t4_restart (SELECT 0, c2, c3, c4, c5 FROM t4_restart); +INSERT INTO t4_restart (SELECT 0, c2, c3, c4, c5 FROM t4_restart); +SHOW CREATE TABLE t4_restart; +SELECT count(*) FROM t4_restart; + +--echo # +--echo # Create and insert records into a table that uses a remote DATA DIRECTORY. +--echo # +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval CREATE TABLE t5_restart(c1 DOUBLE AUTO_INCREMENT KEY, c2 CHAR(10), c3 VARCHAR(100), c4 DATE, c5 TEXT) + ROW_FORMAT=DYNAMIC ENGINE=InnoDB $data_directory; +INSERT INTO t5_restart VALUES (1000000000, 'MySQL', 'InnoDB', '2011-11-11', 'Read this after reboot'); +INSERT INTO t5_restart (SELECT 0, c2, c3, c4, c5 FROM t5_restart); +INSERT INTO t5_restart (SELECT 0, c2, c3, c4, c5 FROM t5_restart); +INSERT INTO t5_restart (SELECT 0, c2, c3, c4, c5 FROM t5_restart); +INSERT INTO t5_restart (SELECT 0, c2, c3, c4, c5 FROM t5_restart); +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t5_restart; +SELECT count(*) FROM t5_restart; + +--echo # +--echo # Create and insert records into a partitioned table that uses +--echo # a remote DATA DIRECTORY for each partition. +--echo # +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval CREATE TABLE t6_restart( + c1 INT AUTO_INCREMENT KEY, c2 CHAR(10), c3 VARCHAR(100), c4 DATE, c5 TEXT) + ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2 ENGINE=InnoDB + PARTITION BY HASH(c1) ( + PARTITION p0 DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir', + PARTITION p1 DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir', + PARTITION p2 DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir'); +INSERT INTO t6_restart VALUES (0, 'MySQL', 'InnoDB', '2011-11-11', 'Read this after reboot'); +INSERT INTO t6_restart (SELECT 0, c2, c3, c4, c5 FROM t6_restart); +INSERT INTO t6_restart (SELECT 0, c2, c3, c4, c5 FROM t6_restart); +INSERT INTO t6_restart (SELECT 0, c2, c3, c4, c5 FROM t6_restart); +INSERT INTO t6_restart (SELECT 0, c2, c3, c4, c5 FROM t6_restart); +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t6_restart; +SELECT count(*) FROM t6_restart; + +--echo # +--echo # Create and insert records into a subpartitioned table that uses +--echo # a remote DATA DIRECTORY for each subpartition. +--echo # +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval CREATE TABLE t7_restart( + c1 INT AUTO_INCREMENT KEY, c2 CHAR(10), c3 VARCHAR(100), c4 DATE, c5 TEXT) + ROW_FORMAT=DYNAMIC ENGINE=InnoDB + PARTITION BY RANGE(c1) SUBPARTITION BY HASH(c1) ( + PARTITION p0 VALUES LESS THAN (10) ( + SUBPARTITION s0 DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir', + SUBPARTITION s1 DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir'), + PARTITION p1 VALUES LESS THAN MAXVALUE ( + SUBPARTITION s2 DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir', + SUBPARTITION s3 DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir')); +INSERT INTO t7_restart VALUES (0, 'MySQL', 'InnoDB', '2011-11-11', 'Read this after reboot'); +INSERT INTO t7_restart (SELECT 0, c2, c3, c4, c5 FROM t7_restart); +INSERT INTO t7_restart (SELECT 0, c2, c3, c4, c5 FROM t7_restart); +INSERT INTO t7_restart (SELECT 0, c2, c3, c4, c5 FROM t7_restart); +INSERT INTO t7_restart (SELECT 0, c2, c3, c4, c5 FROM t7_restart); +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t7_restart; +SELECT count(*) FROM t7_restart; + +--echo # +--echo # Show these tables in information_schema. +--echo # +--source suite/innodb/include/show_i_s_tables.inc +--source suite/innodb/include/show_i_s_tablespaces.inc + +--echo # +--echo # Shutdown the server and list the tablespace OS files +--echo # +--source include/shutdown_mysqld.inc + +--echo ---- MYSQL_DATA_DIR/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt +--echo ---- MYSQL_TMP_DIR/alt_dir +--list_files $MYSQL_TMP_DIR/alt_dir +--echo ---- MYSQL_TMP_DIR/alt_dir/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/alt_dir/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt + +--echo # +--echo # Start the server and show that tables are still visible and accessible. +--echo # +--source include/start_mysqld.inc + +SHOW VARIABLES LIKE 'innodb_file_per_table'; +SHOW CREATE TABLE t1_restart; +SHOW CREATE TABLE t2_restart; +SHOW CREATE TABLE t3_restart; +SHOW CREATE TABLE t4_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t5_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t6_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t7_restart; + +INSERT INTO t1_restart (SELECT 0, c2, c3, c4, c5 FROM t1_restart); +INSERT INTO t2_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart); +INSERT INTO t3_restart (SELECT 0, c2, c3, c4, c5 FROM t3_restart); +INSERT INTO t4_restart (SELECT 0, c2, c3, c4, c5 FROM t4_restart); +INSERT INTO t5_restart (SELECT 0, c2, c3, c4, c5 FROM t5_restart); +INSERT INTO t6_restart (SELECT 0, c2, c3, c4, c5 FROM t6_restart); +INSERT INTO t7_restart (SELECT 0, c2, c3, c4, c5 FROM t7_restart); + +SELECT count(*) FROM t1_restart; +SELECT count(*) FROM t2_restart; +SELECT count(*) FROM t3_restart; +SELECT count(*) FROM t4_restart; +SELECT count(*) FROM t5_restart; +SELECT count(*) FROM t6_restart; +SELECT count(*) FROM t7_restart; + +--echo # +--echo # Show these tables in information_schema. +--echo # +--source suite/innodb/include/show_i_s_tables.inc +--source suite/innodb/include/show_i_s_tablespaces.inc + +DROP TABLE t1_restart; +DROP TABLE t2_restart; +DROP TABLE t3_restart; +# Tablespace for t4_restart will be moved later from default directory to a new directory +# and an ISL file will be created not using InnoDB. +# Table t5_restart will be expanded. +# Tables t6_restart and t7_restart will be truncated. + +--echo # +--echo # Truncate the remote tablespaces. +--echo # +TRUNCATE TABLE t5_restart; +ALTER TABLE t6_restart TRUNCATE PARTITION p2; +ALTER TABLE t7_restart TRUNCATE PARTITION p1; + +--source suite/innodb/include/show_i_s_tablespaces.inc + +INSERT INTO t5_restart VALUES (1000000000, 'MySQL', 'InnoDB', '2011-11-11', 'Read this after reboot'); +INSERT INTO t5_restart (SELECT 0, c2, c3, c4, c5 FROM t5_restart); +INSERT INTO t5_restart (SELECT 0, c2, c3, c4, c5 FROM t5_restart); +INSERT INTO t5_restart (SELECT 0, c2, c3, c4, c5 FROM t5_restart); + +SELECT count(*) FROM t5_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t5_restart; + +SELECT count(*) FROM t6_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t6_restart; + +SELECT count(*) FROM t7_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t7_restart; + +--echo # +--echo # Shutdown the server and make a backup of a tablespace +--echo # +--source include/shutdown_mysqld.inc + +--copy_file $MYSQL_TMP_DIR/alt_dir/test/t5_restart.ibd $MYSQL_TMP_DIR/alt_dir/test/t5_restart.ibd.bak +--copy_file $MYSQL_DATA_DIR/test/t5_restart.isl $MYSQL_DATA_DIR/test/t5_restart.isl.bak +--copy_file $MYSQL_DATA_DIR/test/t5_restart.frm $MYSQL_DATA_DIR/test/t5_restart.frm.bak + +--echo ---- MYSQL_DATA_DIR/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt +--echo ---- MYSQL_TMP_DIR/alt_dir/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/alt_dir/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt + +--echo # +--echo # Start the server and show the tablespaces. +--echo # +--source include/start_mysqld.inc + +SHOW VARIABLES LIKE 'innodb_file_per_table'; + +--source suite/innodb/include/show_i_s_tablespaces.inc + +SELECT count(*) FROM t5_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t5_restart; + +SELECT count(*) FROM t6_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t6_restart; + +SELECT count(*) FROM t7_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t7_restart; + +--echo # +--echo # Try to rename a tablespace to a file that already exists +--echo # + +--copy_file $MYSQL_DATA_DIR/test/t5_restart.frm.bak $MYSQL_DATA_DIR/test/t55_restart.frm +--error ER_TABLE_EXISTS_ERROR +RENAME TABLE t5_restart TO t55_restart; +--remove_file $MYSQL_DATA_DIR/test/t55_restart.frm +--remove_file $MYSQL_DATA_DIR/test/t5_restart.frm.bak + +--copy_file $MYSQL_DATA_DIR/test/t5_restart.isl.bak $MYSQL_DATA_DIR/test/t55_restart.isl +--error ER_ERROR_ON_RENAME +RENAME TABLE t5_restart TO t55_restart; +--remove_file $MYSQL_DATA_DIR/test/t55_restart.isl +--remove_file $MYSQL_DATA_DIR/test/t5_restart.isl.bak + +#--copy_file $MYSQL_TMP_DIR/alt_dir/test/t5_restart.ibd.bak $MYSQL_TMP_DIR/alt_dir/test/t55_restart.ibd +# This RENAME TABLE works of Linux but gets ER_ERROR_ON_RENAME on Windows +#--error ER_ERROR_ON_RENAME +#RENAME TABLE t5_restart TO t55_restart; +#--remove_file $MYSQL_TMP_DIR/alt_dir/test/t55_restart.ibd +--remove_file $MYSQL_TMP_DIR/alt_dir/test/t5_restart.ibd.bak + +--echo ---- MYSQL_DATA_DIR/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt +--echo ---- MYSQL_TMP_DIR/alt_dir/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/alt_dir/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt + +--echo # +--echo # Rename file table and tablespace +--echo # + +RENAME TABLE t5_restart TO t55_restart; +RENAME TABLE t6_restart TO t66_restart; +RENAME TABLE t7_restart TO t77_restart; + +--source suite/innodb/include/show_i_s_tablespaces.inc + +INSERT INTO t55_restart (SELECT 0, c2, c3, c4, c5 FROM t55_restart); +SELECT count(*) FROM t55_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t55_restart; + +INSERT INTO t66_restart (SELECT 0, c2, c3, c4, c5 FROM t66_restart); +SELECT count(*) FROM t66_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t66_restart; + +INSERT INTO t77_restart (SELECT 0, c2, c3, c4, c5 FROM t77_restart); +SELECT count(*) FROM t77_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t77_restart; + +--echo ---- MYSQL_DATA_DIR/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt +--echo ---- MYSQL_TMP_DIR/alt_dir/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/alt_dir/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt + +--echo # +--echo # Restart the server +--echo # +--source include/restart_mysqld.inc +SHOW VARIABLES LIKE 'innodb_file_per_table'; + +--source suite/innodb/include/show_i_s_tablespaces.inc + +INSERT INTO t55_restart (SELECT 0, c2, c3, c4, c5 FROM t55_restart); +SELECT count(*) FROM t55_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t55_restart; + +INSERT INTO t66_restart (SELECT 0, c2, c3, c4, c5 FROM t66_restart); +SELECT count(*) FROM t66_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t66_restart; + +INSERT INTO t77_restart (SELECT 0, c2, c3, c4, c5 FROM t77_restart); +SELECT count(*) FROM t77_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t77_restart; + +--echo # +--echo # Shutdown the server +--echo # +--source include/shutdown_mysqld.inc + +--echo # +--echo # Move the remote tablespaces to a new location and change the ISL files +--echo # +--mkdir $MYSQL_TMP_DIR/new_dir +--mkdir $MYSQL_TMP_DIR/new_dir/test +--echo ---- MYSQL_DATA_DIR/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt +--echo ---- MYSQL_TMP_DIR/alt_dir/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/alt_dir/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt +--echo ---- MYSQL_TMP_DIR/new_dir/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/new_dir/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt + +--echo # Moving tablespace 't4_restart' from MYSQL_DATA_DIR to MYSQL_TMP_DIR/new_dir +--copy_file $MYSQL_DATA_DIR/test/t4_restart.ibd $MYSQL_TMP_DIR/new_dir/test/t4_restart.ibd +--remove_file $MYSQL_DATA_DIR/test/t4_restart.ibd +--exec echo $MYSQL_TMP_DIR/new_dir/test/t4_restart.ibd > $MYSQL_DATA_DIR/test/t4_restart.isl + +--echo # Moving tablespace 't55_restart' from MYSQL_TMP_DIR/alt_dir to MYSQL_TMP_DIR/new_dir +--copy_file $MYSQL_TMP_DIR/alt_dir/test/t55_restart.ibd $MYSQL_TMP_DIR/new_dir/test/t55_restart.ibd +--remove_file $MYSQL_TMP_DIR/alt_dir/test/t55_restart.ibd +--remove_file $MYSQL_DATA_DIR/test/t55_restart.isl +--exec echo $MYSQL_TMP_DIR/new_dir/test/t55_restart.ibd > $MYSQL_DATA_DIR/test/t55_restart.isl + +--echo # Moving tablespace 't66_restart' from MYSQL_TMP_DIR/alt_dir to MYSQL_TMP_DIR/new_dir +--copy_file $MYSQL_TMP_DIR/alt_dir/test/t66_restart#P#p0.ibd $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p0.ibd +--copy_file $MYSQL_TMP_DIR/alt_dir/test/t66_restart#P#p1.ibd $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p1.ibd +--copy_file $MYSQL_TMP_DIR/alt_dir/test/t66_restart#P#p2.ibd $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p2.ibd +--remove_file $MYSQL_TMP_DIR/alt_dir/test/t66_restart#P#p0.ibd +--remove_file $MYSQL_TMP_DIR/alt_dir/test/t66_restart#P#p1.ibd +--remove_file $MYSQL_TMP_DIR/alt_dir/test/t66_restart#P#p2.ibd +--remove_file $MYSQL_DATA_DIR/test/t66_restart#P#p0.isl +--remove_file $MYSQL_DATA_DIR/test/t66_restart#P#p1.isl +--remove_file $MYSQL_DATA_DIR/test/t66_restart#P#p2.isl +--exec echo $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p0.ibd > $MYSQL_DATA_DIR/test/t66_restart#P#p0.isl +--exec echo $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p1.ibd > $MYSQL_DATA_DIR/test/t66_restart#P#p1.isl +--exec echo $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p2.ibd > $MYSQL_DATA_DIR/test/t66_restart#P#p2.isl + +--echo # Moving tablespace 't77_restart' from MYSQL_TMP_DIR/alt_dir to MYSQL_TMP_DIR/new_dir +--copy_file $MYSQL_TMP_DIR/alt_dir/test/t77_restart#P#p0#SP#s0.ibd $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s0.ibd +--copy_file $MYSQL_TMP_DIR/alt_dir/test/t77_restart#P#p0#SP#s1.ibd $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s1.ibd +--copy_file $MYSQL_TMP_DIR/alt_dir/test/t77_restart#P#p1#SP#s2.ibd $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p1#SP#s2.ibd +--copy_file $MYSQL_TMP_DIR/alt_dir/test/t77_restart#P#p1#SP#s3.ibd $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p1#SP#s3.ibd +--remove_file $MYSQL_TMP_DIR/alt_dir/test/t77_restart#P#p0#SP#s0.ibd +--remove_file $MYSQL_TMP_DIR/alt_dir/test/t77_restart#P#p0#SP#s1.ibd +--remove_file $MYSQL_TMP_DIR/alt_dir/test/t77_restart#P#p1#SP#s2.ibd +--remove_file $MYSQL_TMP_DIR/alt_dir/test/t77_restart#P#p1#SP#s3.ibd +--remove_file $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s0.isl +--remove_file $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s1.isl +--remove_file $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s2.isl +--remove_file $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s3.isl +--exec echo $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s0.ibd > $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s0.isl +--exec echo $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s1.ibd > $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s1.isl +--exec echo $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p1#SP#s2.ibd > $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s2.isl +--exec echo $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p1#SP#s3.ibd > $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s3.isl + +--echo ---- MYSQL_DATA_DIR/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt +--echo ---- MYSQL_TMP_DIR/alt_dir/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/alt_dir/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt +--echo ---- MYSQL_TMP_DIR/new_dir/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/new_dir/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt + +--echo # +--echo # Start the server and check tablespaces. +--echo # +--source include/start_mysqld.inc + +--source suite/innodb/include/show_i_s_tablespaces.inc + +INSERT INTO t4_restart (SELECT 0, c2, c3, c4, c5 FROM t4_restart); +SELECT count(*) FROM t4_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t4_restart; + +INSERT INTO t55_restart (SELECT 0, c2, c3, c4, c5 FROM t55_restart); +SELECT count(*) FROM t55_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t55_restart; + +INSERT INTO t66_restart (SELECT 0, c2, c3, c4, c5 FROM t66_restart); +SELECT count(*) FROM t66_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t66_restart; + +INSERT INTO t77_restart (SELECT 0, c2, c3, c4, c5 FROM t77_restart); +SELECT count(*) FROM t77_restart; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t77_restart; + + +--echo # +--echo # Shutdown the server +--echo # +--source include/shutdown_mysqld.inc + +--echo # +--echo # Move the remote tablespaces back to the default datadir and delete the ISL file. +--echo # + +--echo ---- MYSQL_DATA_DIR/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt +--echo ---- MYSQL_TMP_DIR/new_dir/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/new_dir/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt + +--echo # Moving 't4_restart' from MYSQL_TMP_DIR/new_dir to MYSQL_DATA_DIR +--copy_file $MYSQL_TMP_DIR/new_dir/test/t4_restart.ibd $MYSQL_DATA_DIR/test/t4_restart.ibd +--remove_file $MYSQL_TMP_DIR/new_dir/test/t4_restart.ibd +--remove_file $MYSQL_DATA_DIR/test/t4_restart.isl + +--echo # Moving 't55_restart' from MYSQL_TMP_DIR/new_dir to MYSQL_DATA_DIR +--copy_file $MYSQL_TMP_DIR/new_dir/test/t55_restart.ibd $MYSQL_DATA_DIR/test/t55_restart.ibd +--remove_file $MYSQL_TMP_DIR/new_dir/test/t55_restart.ibd +--remove_file $MYSQL_DATA_DIR/test/t55_restart.isl + +--echo # Moving 't66_restart' from MYSQL_TMP_DIR/new_dir to MYSQL_DATA_DIR +--copy_file $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p0.ibd $MYSQL_DATA_DIR/test/t66_restart#P#p0.ibd +--copy_file $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p1.ibd $MYSQL_DATA_DIR/test/t66_restart#P#p1.ibd +--copy_file $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p2.ibd $MYSQL_DATA_DIR/test/t66_restart#P#p2.ibd +--remove_file $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p0.ibd +--remove_file $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p1.ibd +--remove_file $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p2.ibd +--remove_file $MYSQL_DATA_DIR/test/t66_restart#P#p0.isl +--remove_file $MYSQL_DATA_DIR/test/t66_restart#P#p1.isl +--remove_file $MYSQL_DATA_DIR/test/t66_restart#P#p2.isl + +--echo # Moving 't77_restart' from MYSQL_TMP_DIR/new_dir to MYSQL_DATA_DIR +--copy_file $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s0.ibd $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s0.ibd +--copy_file $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s1.ibd $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s1.ibd +--copy_file $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p1#SP#s2.ibd $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s2.ibd +--copy_file $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p1#SP#s3.ibd $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s3.ibd +--remove_file $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s0.ibd +--remove_file $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s1.ibd +--remove_file $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p1#SP#s2.ibd +--remove_file $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p1#SP#s3.ibd +--remove_file $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s0.isl +--remove_file $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s1.isl +--remove_file $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s2.isl +--remove_file $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s3.isl + +--echo ---- MYSQL_DATA_DIR/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt +--echo ---- MYSQL_TMP_DIR/new_dir/test +--list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/new_dir/test +--replace_result #P# #p# #SP# #sp# +--cat_file $MYSQLD_DATADIR.files.txt +--remove_file $MYSQLD_DATADIR.files.txt + +--echo # +--echo # Start the server and check tablespaces. +--echo # +-- source include/start_mysqld.inc + +--source suite/innodb/include/show_i_s_tablespaces.inc + +INSERT INTO t4_restart (SELECT 0, c2, c3, c4, c5 FROM t4_restart); +SELECT count(*) FROM t4_restart; +SHOW CREATE TABLE t4_restart; + +INSERT INTO t55_restart (SELECT 0, c2, c3, c4, c5 FROM t55_restart); +SELECT count(*) FROM t55_restart; +SHOW CREATE TABLE t55_restart; + +INSERT INTO t66_restart (SELECT 0, c2, c3, c4, c5 FROM t66_restart); +SELECT count(*) FROM t66_restart; +SHOW CREATE TABLE t66_restart; + +INSERT INTO t77_restart (SELECT 0, c2, c3, c4, c5 FROM t77_restart); +SELECT count(*) FROM t77_restart; +SHOW CREATE TABLE t77_restart; + + +--echo # +--echo # Cleanup +--echo # + +DROP TABLE t4_restart; +DROP TABLE t55_restart; +DROP TABLE t66_restart; +DROP TABLE t77_restart; + +--rmdir $MYSQL_TMP_DIR/alt_dir/test +--rmdir $MYSQL_TMP_DIR/alt_dir +--rmdir $MYSQL_TMP_DIR/new_dir/test +--rmdir $MYSQL_TMP_DIR/new_dir + +-- disable_query_log +eval set global innodb_file_per_table=$innodb_file_per_table_orig; +-- enable_query_log + diff --git a/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test b/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test new file mode 100644 index 00000000..36dcd1e4 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test @@ -0,0 +1,658 @@ +# mysql-test-run.pl --embedded cannot restart the server. +--source include/not_embedded.inc + +# This test case needs to crash the server. Needs a debug server. +--source include/have_debug.inc + +# Valgrind can hang or return spurious messages on DBUG_SUICIDE +--source include/not_valgrind.inc + +# Avoid CrashReporter popup on Mac +--source include/not_crashrep.inc + +--source include/innodb_page_size_small.inc +--source include/default_charset.inc +--source include/have_sequence.inc + +call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded\\."); +call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* because the .ibd file is missing. Please refer to .* for how to resolve the issue\\."); +call mtr.add_suppression("InnoDB: Page 0 at offset 0 looks corrupted in file"); +call mtr.add_suppression("InnoDB: Page for tablespace "); +call mtr.add_suppression("InnoDB: Invalid FSP_SPACE_FLAGS=0x"); +call mtr.add_suppression("InnoDB: Unknown index id .* on page"); +call mtr.add_suppression("InnoDB: Operating system error number"); +call mtr.add_suppression("InnoDB: Error number \\d+ means"); +call mtr.add_suppression("InnoDB: Cannot open datafile .*t1\\.ibd"); +call mtr.add_suppression("InnoDB: Ignoring tablespace for test/t1 "); +call mtr.add_suppression("InnoDB: Cannot save statistics for table `test`\\.`t1` because the \\.ibd file is missing"); +call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed read of file '.*ibdata1' page"); +call mtr.add_suppression("InnoDB: File '.*ibdata1' is corrupted"); +FLUSH TABLES; + +let MYSQLD_DATADIR =`SELECT @@datadir`; + +SET SESSION innodb_strict_mode=1; + +# Create the table that we will use for crash recovery (during IMPORT) +CREATE TABLE t1 (c1 INT) ENGINE = Innodb +ROW_FORMAT=COMPRESSED; +INSERT INTO t1 VALUES (1), (2), (3), (4); + +FLUSH TABLES t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF +UNLOCK TABLES; + +DROP TABLE t1; + +CREATE TABLE t1 (c1 INT) ENGINE = Innodb +ROW_FORMAT=COMPRESSED; +INSERT INTO t1 VALUES (1); + +ALTER TABLE t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +EOF + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +##### Before commit crash +SET SESSION debug_dbug="+d,ib_import_before_commit_crash"; + +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +# Write file to make mysql-test-run.pl start up the server again +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +# Execute the statement that causes the crash +--error 2013 +ALTER TABLE t1 IMPORT TABLESPACE; + +--enable_reconnect +--source include/wait_until_connected_again.inc +--disable_reconnect + +#### Before commit crash + +# Check that the DD is consistent after recovery + +##### Before checkpoint crash +SET SESSION debug_dbug="+d,ib_import_before_checkpoint_crash"; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM t1; + +# Don't start up the server right away. +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +# Execute the statement that causes the crash +--error 2013 +ALTER TABLE t1 IMPORT TABLESPACE; + +# After the above test the results are non-deterministic, +# delete the old tablespace files and drop the table, +# recreate the table and do a proper import. +-- source include/wait_until_disconnected.inc +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +--echo # Restart and reconnect to the server +--enable_reconnect +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--source include/wait_until_connected_again.inc +--disable_reconnect + +#### Before checkpoint crash + +# After the above test the results are non-deterministic, recreate the table +# and do a proper import. + +DROP TABLE t1; + +SET SESSION innodb_strict_mode=1; + +CREATE TABLE t1 (c1 INT) ENGINE = Innodb +ROW_FORMAT=COMPRESSED; + +ALTER TABLE t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +ALTER TABLE t1 IMPORT TABLESPACE; +CHECK TABLE t1; + +SELECT COUNT(*) FROM t1; + +INSERT INTO t1 VALUES(400), (500), (600); + +SELECT * FROM t1; + +DROP TABLE t1; + +# Test handling of internal failure error +CREATE TABLE t1 (c1 INT) ENGINE = Innodb +ROW_FORMAT=COMPRESSED; + +ALTER TABLE t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +# Test failure after reset of space id and LSN in the tablespace +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET SESSION debug_dbug="+d,ib_import_internal_error"; + +--error ER_INTERNAL_ERROR +ALTER TABLE t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug=@saved_debug_dbug; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +ALTER TABLE t1 IMPORT TABLESPACE; + +DROP TABLE t1; + + +# Test failure after reset of space id and LSN in the tablespace +CREATE TABLE t1 (c1 INT) ENGINE = Innodb +ROW_FORMAT=COMPRESSED; + +ALTER TABLE t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +# Test failure after reset of space id and LSN in the tablespace +SET SESSION debug_dbug="+d,ib_import_reset_space_and_lsn_failure"; + +--error ER_INTERNAL_ERROR +ALTER TABLE t1 IMPORT TABLESPACE; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +SET SESSION debug_dbug=@saved_debug_dbug; + +# Test failure after attempting a tablespace open +SET SESSION debug_dbug="+d,ib_import_open_tablespace_failure"; + +--replace_result \\ / +--error ER_GET_ERRMSG +ALTER TABLE t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug=@saved_debug_dbug; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +# Test failure after ibuf check +SET SESSION debug_dbug="+d,ib_import_check_bitmap_failure"; + +# Need proper mapping of error codes :-( +--error ER_NOT_KEYFILE +ALTER TABLE t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug=@saved_debug_dbug; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +# Test failure after adjusting the cluster index root page +SET SESSION debug_dbug="+d,ib_import_cluster_root_adjust_failure"; + +--error ER_NOT_KEYFILE +ALTER TABLE t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug=@saved_debug_dbug; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +# Test failure after importing the cluster index +SET SESSION debug_dbug="+d,ib_import_cluster_failure"; + +--error ER_NOT_KEYFILE +ALTER TABLE t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug=@saved_debug_dbug; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +# Test failure after importing the secondary index(es) +SET SESSION debug_dbug="+d,ib_import_sec_root_adjust_failure"; + +--error ER_NOT_KEYFILE +ALTER TABLE t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug=@saved_debug_dbug; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +ALTER TABLE t1 IMPORT TABLESPACE; +DROP TABLE t1; + +# +# Create a large table with delete marked records, disable purge during +# the update so that we can test the IMPORT purge code. +# +CREATE TABLE t1 ( + c1 BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 BIGINT, + c3 VARCHAR(2048), + c4 VARCHAR(2048), + INDEX idx1(c2), + INDEX idx2(c3(512)), + INDEX idx3(c4(512))) Engine=InnoDB + ROW_FORMAT=COMPRESSED; + +# Stop purge so that it doesn't remove the delete marked entries. +connect (purge_control,localhost,root); +START TRANSACTION WITH CONSISTENT SNAPSHOT; +connection default; + +INSERT INTO t1 +SELECT 1 + seq, 1 + (seq MOD 4), + REPEAT(SUBSTR('abcd', 1 + (seq MOD 4), 1), 2048), + REPEAT(SUBSTR('abcd', 1 + (seq MOD 4), 1), 2048) +FROM seq_0_to_127; + +DELETE FROM t1 WHERE c2 = 1; + +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c2 = c2 + c1; +UPDATE t1 SET c3 = REPEAT("c2", 1024); +UPDATE t1 SET c4 = REPEAT("c4", 1024); + +SHOW CREATE TABLE t1; + +FLUSH TABLES t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF + +UNLOCK TABLES; + +# Enable normal operation +connection purge_control; +COMMIT; +disconnect purge_control; +connection default; + +DROP TABLE t1; + +CREATE TABLE t1 ( + c1 BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 BIGINT, + c3 VARCHAR(2048), + c4 VARCHAR(2048), + INDEX idx1(c2), + INDEX idx2(c3(512)), + INDEX idx3(c4(512))) Engine=InnoDB + ROW_FORMAT=COMPRESSED; + +SELECT c1, c2 FROM t1; + +ALTER TABLE t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +ALTER TABLE t1 IMPORT TABLESPACE; +CHECK TABLE t1; + +SELECT c1,c2 FROM t1; + +SHOW CREATE TABLE t1; + +DROP TABLE t1; + +#### +# Create a table and save the tablespace and .cfg file, we need to create +# a Btree that has several levels +CREATE TABLE t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +INSERT INTO t1 +SELECT 100, REPEAT('Karanbir', 128), REPEAT('Ajeeth', 1200) +FROM seq_1_to_256; +FLUSH TABLES t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE t1; + +CREATE TABLE t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_trigger_corruption_1"; + +--error ER_INTERNAL_ERROR +ALTER TABLE t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug=@saved_debug_dbug; + +DROP TABLE t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +# + +CREATE TABLE t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM t1; + +# Restore files +let INNODB_PAGE_SIZE=`select @@innodb_page_size`; +let MYSQLD_DATADIR=`select @@datadir`; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +my $page; +my $ps = $ENV{INNODB_PAGE_SIZE}; +my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd"; +open(FILE, "+<$file") || die "Unable to open $file"; +binmode FILE; +sysseek(FILE, 4*$ps, 0) || die "Unable to seek $file\n"; +die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; +substr($page,24,2)='42'; +sysseek(FILE, 4*$ps, 0) || die "Unable to rewind $file\n"; +syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; +close(FILE) || die "Unable to close $file"; +EOF + +# Following alter is failing +--error ER_INTERNAL_ERROR,ER_NOT_KEYFILE +ALTER TABLE t1 IMPORT TABLESPACE; + +DROP TABLE t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +CREATE TABLE t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_trigger_corruption_2"; + +--error ER_INNODB_INDEX_CORRUPT +ALTER TABLE t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug=@saved_debug_dbug; + +DROP TABLE t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +CREATE TABLE t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_trigger_corruption_3"; + +--error ER_NOT_KEYFILE +ALTER TABLE t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug=@saved_debug_dbug; + +DROP TABLE t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +CREATE TABLE t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM t1; + +SET SESSION debug_dbug="+d,ib_import_create_index_failure_1"; + +ALTER TABLE t1 ADD INDEX idx(c1); + +SET SESSION debug_dbug=@saved_debug_dbug; + +DROP TABLE t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +# + +CREATE TABLE t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +SET SESSION debug_dbug="+d,fil_space_create_failure"; + +--replace_result \\ / +--error ER_GET_ERRMSG +ALTER TABLE t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug=@saved_debug_dbug; + +DROP TABLE t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +# + +CREATE TABLE t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +SET SESSION debug_dbug="+d,dict_tf_to_fsp_flags_failure"; + +--replace_result \\ / +--error ER_GET_ERRMSG +ALTER TABLE t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug=@saved_debug_dbug; + +DROP TABLE t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +# + +CREATE TABLE t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +SET SESSION debug_dbug="+d,fsp_flags_is_valid_failure"; + +--error ER_NOT_KEYFILE +ALTER TABLE t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug=@saved_debug_dbug; + +DROP TABLE t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +--disable_query_log +call mtr.add_suppression("'Resource temporarily unavailable'"); +call mtr.add_suppression("Got error -1 when reading table '.*'"); +call mtr.add_suppression("InnoDB: Table '.*' tablespace is set as discarded."); +call mtr.add_suppression("InnoDB: Tablespace '.*' exists in the cache"); +call mtr.add_suppression("InnoDB: Freeing existing tablespace '.*' entry from the cache with id.*"); +call mtr.add_suppression("InnoDB: The table .* doesn't have a corresponding tablespace, it was discarded"); +call mtr.add_suppression("There was an error writing to the meta data file"); +call mtr.add_suppression("InnoDB: Trying to import a tablespace, but could not open the tablespace file"); +call mtr.add_suppression("Unsupported tablespace format"); +call mtr.add_suppression("Page is marked as free"); +call mtr.add_suppression("t1.ibd: Page .* at offset .* looks corrupted"); +call mtr.add_suppression("but tablespace with that id or name does not exist"); +call mtr.add_suppression("Could not find a valid tablespace file for '.*t1'"); +call mtr.add_suppression("Index for table 't1' is corrupt; try to repair it"); +--enable_query_log + +#cleanup +--remove_file $MYSQLTEST_VARDIR/tmp/t1.cfg +--remove_file $MYSQLTEST_VARDIR/tmp/t1.ibd diff --git a/mysql-test/suite/innodb_zip/t/wl5522_zip.test b/mysql-test/suite/innodb_zip/t/wl5522_zip.test new file mode 100644 index 00000000..dbb698cc --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/wl5522_zip.test @@ -0,0 +1,477 @@ +# Not supported in embedded +--source include/not_embedded.inc + +-- source include/innodb_page_size_small.inc +-- source include/have_sequence.inc + +call mtr.add_suppression("InnoDB: Unable to import tablespace .* because it already exists. Please DISCARD the tablespace before IMPORT\\."); +call mtr.add_suppression("InnoDB: Cannot save statistics for table `test`\\.`t1` because the \\.ibd file is missing"); + +SET SESSION innodb_strict_mode=1; + +let $MYSQLD_TMPDIR = `SELECT @@tmpdir`; +let $MYSQLD_DATADIR = `SELECT @@datadir`; + +CREATE TABLE t1 +(a INT AUTO_INCREMENT PRIMARY KEY, + b char(22), + c varchar(255), + KEY (b)) +ENGINE = InnoDB ROW_FORMAT=COMPRESSED ; + +CREATE TEMPORARY TABLE t (b char(22),c varchar(255)); +INSERT INTO t VALUES +('Apa', 'Filler........'), +('Banan', 'Filler........'), ('Cavalry', '..asdasdfaeraf'), +('Devotion', 'asdfuihknaskdf'), ('Evolution', 'lsjndofiabsoibeg'); + +INSERT INTO t1 (b,c) SELECT b,c FROM t,seq_1_to_128; +DROP TEMPORARY TABLE t; +SELECT COUNT(*) FROM t1; +SELECT * FROM t1 ORDER BY b,a DESC LIMIT 3; +SELECT * FROM t1 ORDER BY a DESC LIMIT 3; +--list_files $MYSQLD_DATADIR/test +--echo # Restarting server +-- source include/restart_mysqld.inc +--echo # Done restarting server +FLUSH TABLE t1 FOR EXPORT; +--echo # List before copying files +--list_files $MYSQLD_DATADIR/test +--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_TMPDIR/t1.cfg +--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_TMPDIR/t1.ibd +UNLOCK TABLES; +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +SELECT COUNT(*) FROM t1; +SELECT * FROM t1 ORDER BY b,a DESC LIMIT 3; +SELECT * FROM t1 ORDER BY a DESC LIMIT 3; +--echo # Restarting server +-- source include/restart_mysqld.inc +--echo # Done restarting server +--echo # List before t1 DISCARD +--list_files $MYSQLD_DATADIR/test +ALTER TABLE t1 DISCARD TABLESPACE; +--echo # List after t1 DISCARD +--list_files $MYSQLD_DATADIR/test +--copy_file $MYSQLD_TMPDIR/t1.cfg $MYSQLD_DATADIR/test/t1.cfg +--copy_file $MYSQLD_TMPDIR/t1.ibd $MYSQLD_DATADIR/test/t1.ibd +ALTER TABLE t1 IMPORT TABLESPACE; +ALTER TABLE t1 ENGINE InnoDB; +SELECT COUNT(*) FROM t1; +SELECT * FROM t1 ORDER BY b,a DESC LIMIT 3; +SELECT * FROM t1 ORDER BY a DESC LIMIT 3; +--list_files $MYSQLD_DATADIR/test +SELECT COUNT(*) FROM t1; +SELECT * FROM t1 ORDER BY b,a DESC LIMIT 3; +SELECT * FROM t1 ORDER BY a DESC LIMIT 3; +DROP TABLE t1; +--remove_file $MYSQLD_TMPDIR/t1.cfg +--remove_file $MYSQLD_TMPDIR/t1.ibd + +# restore session variable +SET SESSION innodb_strict_mode=1; + +let MYSQLD_DATADIR =`SELECT @@datadir`; + +# Try importing when tablespace already exists +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +INSERT INTO t1(c2) VALUES(1); +--error ER_TABLESPACE_EXISTS +ALTER TABLE t1 IMPORT TABLESPACE; +SELECT * FROM t1; +DROP TABLE t1; + +# Export/import on the same instance, with --innodb-file-per-table=1 +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2; + +INSERT INTO t1 SELECT seq,1 FROM seq_1_to_16; + +--list_files $MYSQLD_DATADIR/test + +FLUSH TABLES t1 FOR EXPORT; +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF + +--list_files $MYSQLD_DATADIR/test + +UNLOCK TABLES; + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +--list_files $MYSQLD_DATADIR/test + +ALTER TABLE t1 IMPORT TABLESPACE; +CHECK TABLE t1; + +SELECT COUNT(*) FROM t1; + +DROP TABLE t1; + +# Export/import on the same instance, with --innodb-file-per-table=1 +# Insert some more records to move the LSN forward and then drop the +# table and restore +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +INSERT INTO t1 SELECT seq,1 FROM seq_1_to_16; + +--list_files $MYSQLD_DATADIR/test +FLUSH TABLES t1 FOR EXPORT; +SELECT COUNT(*) FROM t1; +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF +--list_files $MYSQLD_DATADIR/test +UNLOCK TABLES; + +--list_files $MYSQLD_DATADIR/test + +# Move the LSN forward +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +--list_files $MYSQLD_DATADIR/test + +ALTER TABLE t1 IMPORT TABLESPACE; +CHECK TABLE t1; + +SELECT COUNT(*) FROM t1; + +DROP TABLE t1; + +# Export/import on the same instance, with --innodb-file-per-table=1 +# Insert some more records to move the LSN forward and then drop the +# table and restore, this time the table has a secondary index too. +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX(c2)) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED; + +INSERT INTO t1 SELECT seq,1 FROM seq_1_to_16; + +FLUSH TABLES t1 FOR EXPORT; +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF +--list_files $MYSQLD_DATADIR/test +UNLOCK TABLES; + +# Move the LSN forward +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX(c2)) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +ALTER TABLE t1 IMPORT TABLESPACE; +CHECK TABLE t1; + +SELECT COUNT(*) FROM t1 WHERE c2 = 1; + +DROP TABLE t1; + +# Export/import on the same instance, with --innodb-file-per-table=1 +# Insert some more records to move the LSN forward and then drop the +# table and restore, this time the table has a secondary index too. +# Rename the index on the create so that the IMPORT fails, drop index +# Create with proper name and then do an IMPORT. +let $KEY_BLOCK_SIZE=`SELECT CONCAT('KEY_BLOCK_SIZE=', FLOOR(@@innodb_page_size/1024))`; +--replace_result $KEY_BLOCK_SIZE KEY_BLOCK_SIZE=16 +eval CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED $KEY_BLOCK_SIZE; + +INSERT INTO t1 SELECT seq,1 FROM seq_1_to_16; + +FLUSH TABLES t1 FOR EXPORT; +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF +UNLOCK TABLES; + +# Move the LSN forward +DROP TABLE t1; + +--replace_result $KEY_BLOCK_SIZE KEY_BLOCK_SIZE=16 +eval CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX x(c2)) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED $KEY_BLOCK_SIZE; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +# This is really a name mismatch error, need better error codes. +-- error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE t1 IMPORT TABLESPACE; + +ALTER TABLE t1 DROP INDEX x; +ALTER TABLE t1 ADD INDEX idx(c2); + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_restore_tablespaces("test", "t1"); +EOF + +ALTER TABLE t1 IMPORT TABLESPACE; +CHECK TABLE t1; + +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_cleanup("test", "t1"); +EOF + +DROP TABLE t1; + +# +# Export/import on the same instance, with --innodb-file-per-table=0 +# This should fail because it is not supported +SET GLOBAL innodb_file_per_table = 0; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT) ENGINE=InnoDB; + +INSERT INTO t1 SELECT seq,1 FROM seq_1_to_16; +SHOW CREATE TABLE t1; + +# This should fail, InnoDB should return a warning +FLUSH TABLES t1 FOR EXPORT; + +UNLOCK TABLES; + +DROP TABLE t1; + +# +# Tests that check for schema mismatch during IMPORT +# + +SET GLOBAL innodb_file_per_table = 1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED; + +INSERT INTO t1 SELECT seq,1 FROM seq_1_to_16; + +SHOW CREATE TABLE t1; + +FLUSH TABLES t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE t1; + +# Table without the secondary index +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +# This should fail because of a missing secondary index +-- error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE t1 IMPORT TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +DROP TABLE t1; + +# Table with an additional column +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, + c3 INT, INDEX idx(c2)) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +# This should fail because the table has an additional column +-- error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE t1 IMPORT TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +DROP TABLE t1; + +# Change the column type of c2 +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 BIGINT, INDEX idx(c2)) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +# This should fail because c2 is now a BIGINT and not INT +-- error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE t1 IMPORT TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +DROP TABLE t1; + +# This should fail because KEY_BLOCK_SIZE is different +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +# This should fail because KEY_BLOCK_SIZE=1 +# does not match the implicit KEY_BLOCK_SIZE of the exported table. +# Need better error message for following +--replace_regex /\(.*\)// +-- error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE t1 IMPORT TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +DROP TABLE t1; + + +# This should be OK. +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +ALTER TABLE t1 IMPORT TABLESPACE; +CHECK TABLE t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; +ib_cleanup("test", "t1"); +EOF + +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +DROP TABLE t1; + +call mtr.add_suppression("Got error -1 when reading table '.*'"); +call mtr.add_suppression("InnoDB: Error: tablespace id and flags in file '.*'"); +call mtr.add_suppression("InnoDB: The table .* doesn't have a corresponding tablespace, it was discarded"); + +# cleanup +--remove_file $MYSQLTEST_VARDIR/tmp/t1.cfg +--remove_file $MYSQLTEST_VARDIR/tmp/t1.ibd diff --git a/mysql-test/suite/innodb_zip/t/wl6344_compress_level.test b/mysql-test/suite/innodb_zip/t/wl6344_compress_level.test new file mode 100644 index 00000000..d44dbfd7 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/wl6344_compress_level.test @@ -0,0 +1,109 @@ +#******************************************************************* +# This testcase is to test the funcitionality of wl#6344 +# When the innodb_compression_level=0 create a table with page size +# 1K and load data +# When the innodb_compression_level=9 create a table with page size +# 1K and load data +# compare the size of the both tables. +# The size of the table when compression level=0 should be +# greater than the +# the size of the table when compression level=9 +#******************************************************************* +--source include/innodb_page_size_small.inc + +SET @save_innodb_stats_persistent = @@GLOBAL.innodb_stats_persistent; +SET GLOBAL innodb_stats_persistent = OFF; +SET @save_innodb_compression_level = @@global.innodb_compression_level; +SET global innodb_compression_level=0; + +-- echo #create table with 1K block size +CREATE TABLE tab5 (col_1 CHAR (255) , +col_2 VARCHAR (121), col_3 longtext, +col_4 longtext,col_5 longtext, +col_6 longtext , col_7 longtext , +col_8 longtext ,col_9 longtext , +col_10 longtext ,col_11 int auto_increment primary key) +ENGINE = innodb ROW_FORMAT=compressed key_block_size=1; + +-- echo #create indexes +CREATE INDEX idx1 ON tab5(col_4(10)); +CREATE INDEX idx2 ON tab5(col_5(10)); +CREATE INDEX idx3 ON tab5(col_6(10)); +CREATE INDEX idx4 ON tab5(col_7(10)); +CREATE INDEX idx5 ON tab5(col_8(10)); +CREATE INDEX idx6 ON tab5(col_11); + +--echo #load the with repeat function +SET @col_1 = repeat('a', 100); +SET @col_2 = repeat('b', 100); +SET @col_3 = repeat('c', 100); +SET @col_4 = repeat('d', 100); +SET @col_5 = repeat('e', 100); +SET @col_6 = repeat('f', 100); +SET @col_7 = repeat('g', 100); +SET @col_8 = repeat('h', 100); +SET @col_9 = repeat('i', 100); +SET @col_10 = repeat('j', 100); + +--echo #insert 10 records +BEGIN; +let $i = 10; +while ($i) { + +eval INSERT INTO tab5(col_1,col_2,col_3,col_4,col_5,col_6,col_7,col_8,col_9,col_10) +VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,@col_7,@col_8,@col_9,@col_10); +dec $i; + +} +COMMIT; + +--echo #set the compression level=9 (High compress) +SET global innodb_compression_level=9; + +-- echo #create table with 1K block size +CREATE TABLE tab6 (col_1 CHAR (255) , +col_2 VARCHAR (121), col_3 longtext, +col_4 longtext,col_5 longtext, +col_6 longtext , col_7 longtext , +col_8 longtext ,col_9 longtext , +col_10 longtext ,col_11 int auto_increment primary key) +ENGINE = innodb ROW_FORMAT=compressed key_block_size=1; + +-- echo #create indexes +CREATE INDEX idx1 ON tab6(col_4(10)); +CREATE INDEX idx2 ON tab6(col_5(10)); +CREATE INDEX idx3 ON tab6(col_6(10)); +CREATE INDEX idx4 ON tab6(col_7(10)); +CREATE INDEX idx5 ON tab6(col_8(10)); +CREATE INDEX idx6 ON tab6(col_11); + +--echo #insert 10 records +BEGIN; +let $i = 10; +while ($i) { + +eval INSERT INTO tab6(col_1,col_2,col_3,col_4,col_5,col_6,col_7,col_8,col_9,col_10) +VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,@col_7,@col_8,@col_9,@col_10); +dec $i; +} +COMMIT; + +-- echo #diff the sizes of the No compressed table and high compressed table +SET @size=(SELECT +(SELECT (SUM(DATA_LENGTH+INDEX_LENGTH)/1024/1024) +FROM INFORMATION_SCHEMA.TABLES +WHERE table_name='tab5' AND ENGINE='InnoDB' AND table_schema='test') +- +(SELECT SUM(DATA_LENGTH+INDEX_LENGTH)/1024/1024 +FROM INFORMATION_SCHEMA.TABLES +WHERE table_name='tab6' AND ENGINE='InnoDB' AND table_schema='test') +FROM DUAL); + +--echo #check the size of the table, it should not be Negative value +--echo #The results of this query Test pass = 1 and fail=0 +SELECT @size >= 0; + +DROP TABLE tab5, tab6; + +SET GLOBAL innodb_compression_level = @save_innodb_compression_level; +SET GLOBAL innodb_stats_persistent = @save_innodb_stats_persistent; diff --git a/mysql-test/suite/innodb_zip/t/wl6347_comp_indx_stat.test b/mysql-test/suite/innodb_zip/t/wl6347_comp_indx_stat.test new file mode 100644 index 00000000..be9a05b3 --- /dev/null +++ b/mysql-test/suite/innodb_zip/t/wl6347_comp_indx_stat.test @@ -0,0 +1,1360 @@ +--echo #****************************************************************** +--echo # Test 1: Test the interaction between stats and compression level +--echo # and logging of compressed pages configuration +--echo # This testcase is to verify the table/idex level compression stats +--echo # When the flags are set as follows +--echo # innodb_cmp_per_index_enabled=ON and innodb_compression_level=0 +--echo # page size 1K,2K,4K,8K,16K +--echo # check the size and compression stats of the table tab5 +--echo #****************************************************************** + +# This test case needs InnoDB. +-- source include/have_innodb.inc +-- source include/not_embedded.inc +-- source include/have_innodb_16k.inc +-- source include/big_test.inc + +-- vertical_results + +let MYSQLD_DATADIR=`SELECT @@datadir`; +let $innodb_compression_level = `SELECT @@global.innodb_compression_level`; + +--echo # set the flags +SET GLOBAL innodb_file_per_table=on; +SET GLOBAL innodb_cmp_per_index_enabled=ON; +SET GLOBAL innodb_compression_level=0; +--disable_query_log +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log + +--echo #****************************************************************** +--echo # Test 1-1K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=0 with page size 1K +--echo #****************************************************************** + +--echo # create a table with page size=1K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=1; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for deterministic reasons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +-- source include/restart_mysqld.inc + +--echo # set the flag on (default off) +SET GLOBAL innodb_cmp_per_index_enabled=ON; +--disable_query_log +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log + +--echo # set the flags +SET GLOBAL innodb_file_per_table=on; +SET GLOBAL innodb_compression_level=0; + +--echo # fetch the compressed page and check the stats +--echo # The stats figure may be different/same for each restart. +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table +-- echo # testcase : pass = 1 fail = 0 +SET @comp_val=0; +SET @uncomp_val=1; +--source suite/innodb_zip/include/innodb_stats_restart.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 1-2K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=0 with page size 2K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=0; +SET GLOBAL innodb_cmp_per_index_enabled=1; + +--echo # create a table with page size=2K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=2; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +-- source include/restart_mysqld.inc + +--echo # set the flag on (default off) +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # set the flags +SET GLOBAL innodb_file_per_table=on; +SET GLOBAL innodb_compression_level=0; + +--echo # fetch the compressed page and check the stats +--echo # The stats figure may be different/same for each restart. +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table +-- echo # testcase : pass = 1 fail = 0 +SET @comp_val=0; +SET @uncomp_val=2; +--source suite/innodb_zip/include/innodb_stats_restart.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 1-4K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=0 with page size 4K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=0; +SET GLOBAL innodb_cmp_per_index_enabled=1; +--disable_query_log +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log + +--echo # create a table with page size=4K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=4; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 1-8K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=0 with page size 8K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=0; +SET GLOBAL innodb_cmp_per_index_enabled=1; + +--echo # create a table with page size=8K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=8; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 1-16K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=0 with page size 16K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=0; +SET GLOBAL innodb_cmp_per_index_enabled=1; + +--echo # create a table with page size=16K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=16; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 2: test the interaction between wl6347 & wl6344 (2.2) +--echo # This testcase is to verify the table/idex level compression stats +--echo # When the flags are set as follows +--echo # innodb_cmp_per_index_enabled=ON and innodb_compression_level=9 +--echo # page size 1K,2K,4K,8K,16K +--echo # check the size and compression stats of the table tab5 +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=0; +SET GLOBAL innodb_cmp_per_index_enabled=1; + +--echo # set the flags +SET GLOBAL innodb_file_per_table=on; +SET GLOBAL innodb_compression_level=9; + + +--echo #****************************************************************** +--echo # Test 2-1K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=9 with page size 1K +--echo #****************************************************************** + +--echo # create a table with page size=1K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=1; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 65536 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 2097152 +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +-- source include/restart_mysqld.inc + +--echo # set the flag on (default off) +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # set the flags +SET GLOBAL innodb_file_per_table=on; +SET GLOBAL innodb_compression_level=9; + + +--echo # fetch the compressed page and check the stats +--echo # The stats figure may be different/same for each restart. +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table +-- echo # testcase : pass = 1 fail = 0 +SET @comp_val=0; +SET @uncomp_val=1; +--source suite/innodb_zip/include/innodb_stats_restart.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 2-2K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=9 with page size 2K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; +--disable_query_log +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log + +--echo # create a table with page size=2K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=2; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 65536 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 2097152 +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +-- source include/restart_mysqld.inc + +--echo # set the flag on (default off) +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # set the flags +SET GLOBAL innodb_file_per_table=on; +SET GLOBAL innodb_compression_level=9; + + +--echo # fetch the compressed page and check the stats +--echo # The stats figure may be different/same for each restart. +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table +-- echo # testcase : pass = 1 fail = 0 +SET @comp_val=0; +SET @uncomp_val=1; +--source suite/innodb_zip/include/innodb_stats_restart.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 2-4K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=9 with page size 4K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; +--disable_query_log +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log + +--echo # create a table with page size=4K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=4; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 65536 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 159744 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 2-8K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=9 with page size 8K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # create a table with page size=8K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=8; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 122880 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 212992 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 2-16K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=9 with page size 16K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # create a table with page size=16K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=16; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 245760 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 344064 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 3: test the interaction between wl6347 & wl6344 (2.3) +--echo # This testcase is to verify the table/idex level compression stats +--echo # When the flags are set as follows +--echo # innodb_cmp_per_index_enabled=ON and +--echo # innodb_compression_level=6 (default) +--echo # page size 1K,2K,4K,8K,16K +--echo # check the size and compression stats of the table tab5 +--echo #****************************************************************** + +--echo #****************************************************************** +--echo # Test 3-1K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=Def with page size 1K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +SET GLOBAL innodb_compression_level=default; + +--echo # create a table with page size=1K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=1; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 65536 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 65536 +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 3-2K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=Def with page size 2K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +SET GLOBAL innodb_compression_level=default; + +--echo # create a table with page size=2K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=2; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 65536 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 86016 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 3-4K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=Def with page size 4K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +SET GLOBAL innodb_compression_level=default; + +--echo # create a table with page size=4K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=4; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 65536 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 86016 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 3-8K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=Def with page size 8K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +SET GLOBAL innodb_compression_level=default; + +--echo # create a table with page size=8K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=8; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 122880 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 172032 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 3-16K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=Def with page size 16K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +SET GLOBAL innodb_compression_level=default; + +--echo # create a table with page size=16K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=16; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 245760 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +--echo # The size of the file with 0 compress = 344064 +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 4: test the interaction between wl6347 & wl6344 (2.5 & 2.6) +--echo # This testcase is to verify the table/idex level compression stats +--echo # When the flags are set as follows +--echo # innodb_cmp_per_index_enabled=ON and +--echo # Innodb_compression_failure_threshold_pct=0 +--echo # page size 1K,2K,4K,8K,16K +--echo # check the size and compression stats of the table tab5 +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # set the flags +SET GLOBAL innodb_compression_failure_threshold_pct=0; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # check the flags +SELECT @@innodb_cmp_per_index_enabled; +SELECT @@innodb_compression_failure_threshold_pct; +SELECT @@innodb_file_per_table; +SELECT @@innodb_compression_level; + +--echo #****************************************************************** +--echo # Test 4-1K: innodb_cmp_per_index_enabled=ON and Innodb_compression_failure_threshold_pct=0 with page size 1K +--echo #****************************************************************** + +--echo # create a table with page size=1K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=1; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +-- source include/restart_mysqld.inc + +--echo # set the flag on (default off) +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # set the flags +SET GLOBAL innodb_compression_failure_threshold_pct=0; +SET GLOBAL innodb_file_per_table=on; + + +--echo # fetch the compressed page and check the stats +--echo # The stats figure may be different/same for each restart. +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table +-- echo # testcase : pass = 1 fail = 0 +SET @comp_val=0; +SET @uncomp_val=1; +--source suite/innodb_zip/include/innodb_stats_restart.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 4-2K: innodb_cmp_per_index_enabled=ON and Innodb_compression_failure_threshold_pct=0 with page size 2K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; +--disable_query_log +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log + +--echo # create a table with page size=2K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=2; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 4-4K: innodb_cmp_per_index_enabled=ON and Innodb_compression_failure_threshold_pct=0 with page size 4K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # create a table with page size=4K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=4; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 4-8K: innodb_cmp_per_index_enabled=ON and Innodb_compression_failure_threshold_pct=0 with page size 8K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # create a table with page size=8K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=8; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 4-16K: innodb_cmp_per_index_enabled=ON and Innodb_compression_failure_threshold_pct=0 with page size 16K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # create a table with page size=16K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=16; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 5: test the interaction between wl6347 & wl6344 (2.7) +--echo # This testcase is to verify the table/idex level compression stats +--echo # When the flags are set as follows +--echo # innodb_cmp_per_index_enabled=ON and +--echo # Innodb_compression_failure_threshold_pct=10 +--echo # page size 1K,2K,4K,8K,16K +--echo # check the size and compression stats of the table tab5 +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # set the flags +SET GLOBAL innodb_file_per_table=on; +SET GLOBAL innodb_cmp_per_index_enabled=ON; +SET GLOBAL innodb_compression_failure_threshold_pct=10; +SET GLOBAL innodb_compression_level=Default; + + +--echo # check the flags +SELECT @@innodb_cmp_per_index_enabled; +SELECT @@innodb_compression_failure_threshold_pct; +SELECT @@innodb_file_per_table; +SELECT @@innodb_compression_level; + +--echo #****************************************************************** +--echo # Test 5-1K: innodb_cmp_per_index_enabled=ON and Innodb_compression_failure_threshold_pct=10 with page size 1K +--echo #****************************************************************** + +--echo # create a table with page size=1K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=1; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +-- source include/restart_mysqld.inc + +--echo # set the flag on (default off) +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # set the flags +SET GLOBAL innodb_compression_failure_threshold_pct=10; +SET GLOBAL innodb_file_per_table=on; +SET GLOBAL innodb_compression_failure_threshold_pct=10; + + +--echo # fetch the compressed page and check the stats +--echo # The stats figure may be different/same for each restart. +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table +-- echo # testcase : pass = 1 fail = 0 +SET @comp_val=0; +SET @uncomp_val=1; +--source suite/innodb_zip/include/innodb_stats_restart.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 5-2K: innodb_cmp_per_index_enabled=ON and Innodb_compression_failure_threshold_pct=10 with page size 2K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; +SET GLOBAL innodb_compression_failure_threshold_pct=10; +--disable_query_log +SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log + +--echo # create a table with page size=2K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=2; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=2; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 5-4K: innodb_cmp_per_index_enabled=ON and Innodb_compression_failure_threshold_pct=10 with page size 4K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # create a table with page size=4K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=4; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 5-8K: innodb_cmp_per_index_enabled=ON and Innodb_compression_failure_threshold_pct=10 with page size 8K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; +SET GLOBAL innodb_compression_failure_threshold_pct=10; + +--echo # create a table with page size=8K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=8; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 5-16K: innodb_cmp_per_index_enabled=ON and Innodb_compression_failure_threshold_pct=10 with page size 16K +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=OFF; +SET GLOBAL innodb_cmp_per_index_enabled=ON; + +--echo # create a table with page size=16K +--echo # create indexes on each column.(total 9 indexes) +let $block_size=16; +--source suite/innodb_zip/include/innodb_create_tab_indx.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # for determintic resons simple data should be inserted. +--echo # insert some 100 records +let $i = 100; +--source suite/innodb_zip/include/innodb_load_data.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed page and check the stats +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +--echo # fetch the compressed same page once again and check the stats +--echo # the stat figures should be same as above query +--source suite/innodb_zip/include/innodb_fetch_records.inc + +--echo # check the stats of the table & size of the table +SET @inl_val=1; +--source suite/innodb_zip/include/innodb_stats_comp_index.inc + +DROP TABLE tab5; + +--echo #****************************************************************** +--echo # Test 6: Create multiple tables & indexes having same name in 2 diff DB's +--echo # Check the stats of the table. (1.1) +--echo #****************************************************************** + +--echo # reset the stat table before starting next testcase +SET GLOBAL innodb_cmp_per_index_enabled=0; +SET GLOBAL innodb_cmp_per_index_enabled=1; + +SET GLOBAL innodb_file_per_table=ON; +SET GLOBAL innodb_compression_level=default; +SET GLOBAL innodb_compression_failure_threshold_pct=default; + + +--echo # create a table page size=1K +CREATE TABLE tab5(col_1 TINYBLOB, col_2 TINYTEXT,col_3 BLOB, +col_4 TEXT,col_5 MEDIUMBLOB,col_6 MEDIUMTEXT, +col_7 LONGBLOB,col_8 LONGTEXT,col_9 VARCHAR(255)) +ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +CREATE INDEX idx1 ON tab5(col_1(10)); + +--echo # check the stats of the table +SELECT database_name,table_name,index_name,compress_ops,compress_ops_ok +FROM information_schema.innodb_cmp_per_index +WHERE database_name='test' and table_name='tab5' +ORDER BY index_name,table_name,database_name ; + +CREATE DATABASE sb; +USE sb; + +--echo # create a table page size=1K (testcase-1) +CREATE TABLE tab5(col_1 TINYBLOB, col_2 TINYTEXT,col_3 BLOB, +col_4 TEXT,col_5 MEDIUMBLOB,col_6 MEDIUMTEXT, +col_7 LONGBLOB,col_8 LONGTEXT,col_9 VARCHAR(255)) +ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +CREATE INDEX idx1 ON tab5(col_1(10)); + +SELECT database_name,table_name,index_name,compress_ops,compress_ops_ok +FROM information_schema.innodb_cmp_per_index +WHERE database_name='sb' and table_name='tab5' +ORDER BY index_name,table_name,database_name ; + +DROP TABLE tab5, test.tab5; +DROP DATABASE sb; + +--echo # reset the flags +eval SET GLOBAL innodb_file_per_table=default; +eval SET GLOBAL innodb_cmp_per_index_enabled=default; +--disable_query_log +eval SET GLOBAL innodb_compression_level=$innodb_compression_level; +SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; +--enable_query_log +eval SET GLOBAL innodb_compression_failure_threshold_pct=default; |