diff options
Diffstat (limited to 'mysql-test/suite/innodb/t')
88 files changed, 8310 insertions, 1022 deletions
diff --git a/mysql-test/suite/innodb/t/add_constraint.test b/mysql-test/suite/innodb/t/add_constraint.test index eabf06434f4..7e86a7e5f97 100644 --- a/mysql-test/suite/innodb/t/add_constraint.test +++ b/mysql-test/suite/innodb/t/add_constraint.test @@ -10,7 +10,7 @@ create table t2(a int, b int, key(a),key(b))engine=innodb; alter table t2 add constraint b foreign key (b) references t1(a); alter table t1 add constraint b1 foreign key (b) references t2(a); ---replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ --error ER_CANT_CREATE_TABLE alter table t2 add constraint b1 foreign key (b) references t1(a); diff --git a/mysql-test/suite/innodb/t/alter_key_block_size-11757.test b/mysql-test/suite/innodb/t/alter_key_block_size-11757.test new file mode 100644 index 00000000000..50a909870ba --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_key_block_size-11757.test @@ -0,0 +1,23 @@ +# +# MDEV-11757 KEY_BLOCK_SIZE strangeness when UNCOMPRESSing COMPRESSed InnoDB tables +# +source include/have_innodb.inc; +set global innodb_file_format=barracuda; + +create table t1 ( + id1 bigint(20) not null, + id2 bigint(20) not null, + primary key (id1), + unique key id2 (id2) +) engine=innodb row_format=compressed key_block_size=8; +show create table t1; +alter table t1 row_format=dynamic; +show create table t1; +alter table t1 key_block_size=0; +show create table t1; +alter table t1 drop primary key, add primary key (id1), + drop key id2, add unique (id2); +show create table t1; +drop table t1; + +set global innodb_file_format=default; diff --git a/mysql-test/suite/innodb/t/binlog_consistent.test b/mysql-test/suite/innodb/t/binlog_consistent.test index 1915479fb76..a97bef4cf38 100644 --- a/mysql-test/suite/innodb/t/binlog_consistent.test +++ b/mysql-test/suite/innodb/t/binlog_consistent.test @@ -72,6 +72,7 @@ connection con3; --echo # Connection con3 COMMIT; FLUSH LOGS; +--source include/wait_for_binlog_checkpoint.inc connection default; --echo # Connection default @@ -102,6 +103,7 @@ eval INSERT INTO t3 VALUES (11, '$bigdata'); # So here, we check that the values are consistent with SHOW MASTER STATUS, # which uses a different code path and did not have the bug. +--source include/wait_for_binlog_checkpoint.inc --let $snap_file= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_file', Value, 1) --let $snap_pos= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1) diff --git a/mysql-test/suite/innodb/t/data_types.opt b/mysql-test/suite/innodb/t/data_types.opt new file mode 100644 index 00000000000..3ad568c816e --- /dev/null +++ b/mysql-test/suite/innodb/t/data_types.opt @@ -0,0 +1 @@ +--loose-innodb-sys-columns diff --git a/mysql-test/suite/innodb/t/data_types.test b/mysql-test/suite/innodb/t/data_types.test new file mode 100644 index 00000000000..0978146361c --- /dev/null +++ b/mysql-test/suite/innodb/t/data_types.test @@ -0,0 +1,118 @@ +# +# MDEV-5248 Serious incompatibility and data corruption of DATETIME and DATE types due to get_innobase_type_from_mysql_type refactor combined with InnoDB Online DDL +# + +# +# This test records what *internal type codes* innodb is using for every +# MariaDB data type. THEY MUST ALWAYS BE THE SAME AND NEVER CHANGE! +# Otherwise we create a compatibility problem and possible silent data +# corruption too, see MDEV-5248 +# + +--source include/have_innodb.inc + +CREATE TABLE t1 +( + t1_BIGINT BIGINT, + t1_BIGINT_UNSIGNED BIGINT UNSIGNED, + t1_BINARY_100 BINARY(100), + t1_BIT_2 BIT(2), + t1_BIT_20 BIT(20), + t1_BLOB BLOB, + t1_CHAR_100 CHAR(100), + t1_CHAR_100_BINARY CHAR(100) BINARY, + t1_DATE DATE, + t1_DATETIME DATETIME, + t1_DATETIME_6 DATETIME(6), + t1_DECIMAL_10_3 DECIMAL(10,3), + t1_DECIMAL_10_3_UNSIGNED DECIMAL(10,3) UNSIGNED, + t1_DOUBLE DOUBLE, + t1_DOUBLE_UNSIGNED DOUBLE UNSIGNED, + t1_ENUM ENUM('a', 'b', 'c'), + t1_ENUM_BINARY ENUM('a','b') BINARY, + t1_ENUM_256 ENUM('a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', + 'a10', 'a11', 'a12', 'a13', 'a14', 'a15', 'a16', 'a17', 'a18', 'a19', + 'a20', 'a21', 'a22', 'a23', 'a24', 'a25', 'a26', 'a27', 'a28', 'a29', + 'a30', 'a31', 'a32', 'a33', 'a34', 'a35', 'a36', 'a37', 'a38', 'a39', + 'a40', 'a41', 'a42', 'a43', 'a44', 'a45', 'a46', 'a47', 'a48', 'a49', + 'a50', 'a51', 'a52', 'a53', 'a54', 'a55', 'a56', 'a57', 'a58', 'a59', + 'a60', 'a61', 'a62', 'a63', 'a64', 'a65', 'a66', 'a67', 'a68', 'a69', + 'a70', 'a71', 'a72', 'a73', 'a74', 'a75', 'a76', 'a77', 'a78', 'a79', + 'a80', 'a81', 'a82', 'a83', 'a84', 'a85', 'a86', 'a87', 'a88', 'a89', + 'a90', 'a91', 'a92', 'a93', 'a94', 'a95', 'a96', 'a97', 'a98', 'a99', + 'a100', 'a101', 'a102', 'a103', 'a104', 'a105', 'a106', 'a107', 'a108', + 'a109', 'a110', 'a111', 'a112', 'a113', 'a114', 'a115', 'a116', 'a117', + 'a118', 'a119', 'a120', 'a121', 'a122', 'a123', 'a124', 'a125', 'a126', + 'a127', 'a128', 'a129', 'a130', 'a131', 'a132', 'a133', 'a134', 'a135', + 'a136', 'a137', 'a138', 'a139', 'a140', 'a141', 'a142', 'a143', 'a144', + 'a145', 'a146', 'a147', 'a148', 'a149', 'a150', 'a151', 'a152', 'a153', + 'a154', 'a155', 'a156', 'a157', 'a158', 'a159', 'a160', 'a161', 'a162', + 'a163', 'a164', 'a165', 'a166', 'a167', 'a168', 'a169', 'a170', 'a171', + 'a172', 'a173', 'a174', 'a175', 'a176', 'a177', 'a178', 'a179', 'a180', + 'a181', 'a182', 'a183', 'a184', 'a185', 'a186', 'a187', 'a188', 'a189', + 'a190', 'a191', 'a192', 'a193', 'a194', 'a195', 'a196', 'a197', 'a198', + 'a199', 'a200', 'a201', 'a202', 'a203', 'a204', 'a205', 'a206', 'a207', + 'a208', 'a209', 'a210', 'a211', 'a212', 'a213', 'a214', 'a215', 'a216', + 'a217', 'a218', 'a219', 'a220', 'a221', 'a222', 'a223', 'a224', 'a225', + 'a226', 'a227', 'a228', 'a229', 'a230', 'a231', 'a232', 'a233', 'a234', + 'a235', 'a236', 'a237', 'a238', 'a239', 'a240', 'a241', 'a242', 'a243', + 'a244', 'a245', 'a246', 'a247', 'a248', 'a249', 'a250', 'a251', 'a252', + 'a253', 'a254', 'a255', 'a256'), + t1_FLOAT FLOAT, + t1_FLOAT_UNSIGNED FLOAT UNSIGNED, + t1_INT INT, + t1_INT_UNSIGNED INT UNSIGNED, + t1_LONGBLOB LONGBLOB, + t1_LONGTEXT LONGTEXT, + t1_MEDIUMBLOB MEDIUMBLOB, + t1_MEDIUMINT MEDIUMINT, + t1_MEDIUMINT_UNSIGNED MEDIUMINT UNSIGNED, + t1_MEDIUMTEXT MEDIUMTEXT, + t1_SET SET('a', 'b', 'c'), + t1_SET_BINARY SET('a','b') BINARY, + t1_SET_9 SET('a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9'), + t1_SMALLINT SMALLINT, + t1_SMALLINT_UNSIGNED SMALLINT UNSIGNED, + t1_TEXT TEXT, + t1_TIME TIME, + t1_TIME_4 TIME(4), + t1_TIMESTAMP TIMESTAMP, + t1_TIMESTAMP_5 TIMESTAMP(5), + t1_TINYBLOB TINYBLOB, + t1_TINYINT TINYINT, + t1_TINYINT_UNSIGNED TINYINT UNSIGNED, + t1_TINYTEXT TINYTEXT, + t1_VARBINARY_100 VARBINARY(100), + t1_VARCHAR_10 VARCHAR(10), + t1_VARCHAR_10_BINARY VARCHAR(10) BINARY, + t1_VARCHAR_500 VARCHAR(500), + t1_VARCHAR_500_BINARY VARCHAR(500) BINARY, + t1_YEAR_2 YEAR(2), + t1_YEAR_4 YEAR(4) +) ENGINE=InnoDB; + +SELECT + name, + CASE mtype + WHEN 1 THEN "DATA_VARCHAR" + WHEN 2 THEN "DATA_CHAR" + WHEN 3 THEN "DATA_FIXBINARY" + WHEN 4 THEN "DATA_BINARY" + WHEN 5 THEN "DATA_BLOB" + WHEN 6 THEN "DATA_INT" + WHEN 7 THEN "DATA_SYS_CHILD" + WHEN 8 THEN "DATA_SYS" + WHEN 9 THEN "DATA_FLOAT" + WHEN 10 THEN "DATA_DOUBLE" + WHEN 11 THEN "DATA_DECIMAL" + WHEN 12 THEN "DATA_VARMYSQL" + WHEN 13 THEN "DATA_MYSQL" + WHEN 63 THEN "DATA_MTYPE_MAX" + ELSE mtype + END AS mtype, + IF((prtype & 512) = 512,"UNSIGNED","") AS is_unsigned +FROM information_schema.INNODB_SYS_COLUMNS +WHERE name LIKE "t1\_%" +ORDER BY name; + +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/group_commit_binlog_pos.test b/mysql-test/suite/innodb/t/group_commit_binlog_pos.test index 72798a68a1e..213dbc9d3d8 100644 --- a/mysql-test/suite/innodb/t/group_commit_binlog_pos.test +++ b/mysql-test/suite/innodb/t/group_commit_binlog_pos.test @@ -17,6 +17,19 @@ # Test that we get the correct position when we group commit several # transactions together. +# What we really want to test here is what happens when a group of +# transactions get written only partially to disk inside InnoDB before +# the crash. But that is hard to test in mysql-test-run automated +# tests. Instead, we use debug_sync to tightly control when each +# transaction is written to the redo log. And we set +# innodb_flush_log_at_trx_commit=3 so that we can write out +# transactions individually - as with +# innodb_flush_log_at_trx_commit=1, all commits are written together, +# as part of a commit_checkpoint. +# (Note that we do not have to restore innodb_flush_log_at_trx_commit, as +# we crash the server). +SET GLOBAL innodb_flush_log_at_trx_commit=3; + CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb; INSERT INTO t1 VALUES (0); diff --git a/mysql-test/suite/innodb/t/group_commit_binlog_pos_no_optimize_thread.test b/mysql-test/suite/innodb/t/group_commit_binlog_pos_no_optimize_thread.test index e9a234577e2..3ae3c50085d 100644 --- a/mysql-test/suite/innodb/t/group_commit_binlog_pos_no_optimize_thread.test +++ b/mysql-test/suite/innodb/t/group_commit_binlog_pos_no_optimize_thread.test @@ -17,6 +17,19 @@ # Test that we get the correct position when we group commit several # transactions together. +# What we really want to test here is what happens when a group of +# transactions get written only partially to disk inside InnoDB before +# the crash. But that is hard to test in mysql-test-run automated +# tests. Instead, we use debug_sync to tightly control when each +# transaction is written to the redo log. And we set +# innodb_flush_log_at_trx_commit=3 so that we can write out +# transactions individually - as with +# innodb_flush_log_at_trx_commit=1, all commits are written together, +# as part of a commit_checkpoint. +# (Note that we do not have to restore innodb_flush_log_at_trx_commit, as +# we crash the server). +SET GLOBAL innodb_flush_log_at_trx_commit=3; + CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb; INSERT INTO t1 VALUES (0); diff --git a/mysql-test/suite/innodb/t/group_commit_crash.test b/mysql-test/suite/innodb/t/group_commit_crash.test index 12c92d19244..cad349819bd 100644 --- a/mysql-test/suite/innodb/t/group_commit_crash.test +++ b/mysql-test/suite/innodb/t/group_commit_crash.test @@ -9,6 +9,8 @@ --source include/have_debug.inc --source include/have_log_bin.inc +call mtr.add_suppression("InnoDB: Warning: database page corruption or a failed"); + let $file_format_max=`SELECT @@innodb_file_format_max`; CREATE TABLE t1(a CHAR(255), b CHAR(255), @@ -66,7 +68,7 @@ while ($numtests) # table and binlog should be in sync. SELECT * FROM t1 ORDER BY id; --replace_column 2 # 5 # - SHOW BINLOG EVENTS LIMIT 2,1; + SHOW BINLOG EVENTS LIMIT 4,1; delete from t1; diff --git a/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test b/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test index 2de09d6b0b6..8d1f460b64b 100644 --- a/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test +++ b/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test @@ -9,6 +9,8 @@ --source include/have_debug.inc --source include/have_log_bin.inc +call mtr.add_suppression("InnoDB: Warning: database page corruption or a failed"); + let $file_format_max=`SELECT @@innodb_file_format_max`; CREATE TABLE t1(a CHAR(255), b CHAR(255), @@ -66,7 +68,7 @@ while ($numtests) # table and binlog should be in sync. SELECT * FROM t1 ORDER BY id; --replace_column 2 # 5 # - SHOW BINLOG EVENTS LIMIT 2,1; + SHOW BINLOG EVENTS LIMIT 4,1; delete from t1; diff --git a/mysql-test/suite/innodb/t/help_url.test b/mysql-test/suite/innodb/t/help_url.test new file mode 100644 index 00000000000..bcf74c31619 --- /dev/null +++ b/mysql-test/suite/innodb/t/help_url.test @@ -0,0 +1,8 @@ +# +# MDEV-4273 MYSQL_VERSION_MAJOR.MYSQL_VERSION_MINOR not replaced +# +--source include/have_innodb.inc +--source include/not_embedded.inc + +create table innodb_table_monitor (a int) engine=InnoDB; +drop table innodb_table_monitor; diff --git a/mysql-test/suite/innodb/t/innochecksum.opt b/mysql-test/suite/innodb/t/innochecksum.opt new file mode 100644 index 00000000000..cc738d97434 --- /dev/null +++ b/mysql-test/suite/innodb/t/innochecksum.opt @@ -0,0 +1,2 @@ +--innodb_file_per_table=1 +--innodb_file_format=Barracuda diff --git a/mysql-test/suite/innodb/t/innochecksum.test b/mysql-test/suite/innodb/t/innochecksum.test new file mode 100644 index 00000000000..34df2801880 --- /dev/null +++ b/mysql-test/suite/innodb/t/innochecksum.test @@ -0,0 +1,70 @@ +# +# Test innochecksum +# + +# Don't test under embedded +source include/not_embedded.inc; +# Require InnoDB +source include/have_innodb.inc; + +if (!$INNOCHECKSUM) { + --echo Need innochecksum binary + --die Need innochecksum binary +} + +--echo # Create and populate a table +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB; +INSERT INTO t1 (b) VALUES ('corrupt me'); +--disable_query_log +--let $i = 1000 +while ($i) +{ + INSERT INTO t1 (b) VALUES (REPEAT('abcdefghijklmnopqrstuvwxyz', 100)); + dec $i; +} +--enable_query_log +INSERT INTO t1 (b) VALUES ('corrupt me'); + +CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) +ROW_FORMAT=COMPRESSED ENGINE=InnoDB ; + +INSERT INTO t2(b) SELECT b from t1; + +CREATE TABLE t3 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) +ROW_FORMAT=COMPRESSED ENGINE=InnoDB KEY_BLOCK_SIZE=16; + +INSERT INTO t3(b) SELECT b from t1; + +let $MYSQLD_DATADIR=`select @@datadir`; +let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd; +let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd; +let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd; + +--echo # Write file to make mysql-test-run.pl expect the "crash", but don't +--echo # start it until it's told to +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +--echo # We give 30 seconds to do a clean shutdown because we do not want +--echo # to redo apply the pages of t1.ibd at the time of recovery. +--echo # We want SQL to initiate the first access to t1.ibd. +shutdown_server 30; + +--echo # Wait until disconnected. +--source include/wait_until_disconnected.inc + +--echo # Run innochecksum on t1 +--exec $INNOCHECKSUM $t1_IBD + +--echo # Run innochecksum on t2 +--exec $INNOCHECKSUM $t2_IBD + +--echo # Run innochecksum on t3 +--exec $INNOCHECKSUM $t3_IBD + +--echo # Write file to make mysql-test-run.pl start up the server again +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--enable_reconnect +--source include/wait_until_connected_again.inc + +--echo # Cleanup +DROP TABLE t1, t2, t3; diff --git a/mysql-test/suite/innodb/t/innodb-agregate.test b/mysql-test/suite/innodb/t/innodb-agregate.test new file mode 100644 index 00000000000..e15548c087a --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-agregate.test @@ -0,0 +1,18 @@ +--source include/have_innodb.inc + +# +# MDEV-9667: Server hangs after select count(distinct name) from t2 where a=8366 and b>=5 and b<=5; +# + +create table t2 (a smallint(6) not null, b int(10) not null, name varchar(20), primary key(a,b), key(name)) engine=InnoDB; + +insert into t2 values (8355,3,"sanja"),(8355,4,"wlad"),(8366,5, "lawrin"),(8366,6,"markusjm"); + +select count(distinct name) from t2 where a=8366 and b>=5 and b<=5; +select count(distinct name) from t2 where a=8366 and b=5; +select count(distinct name) from t2 where a=8366 and b between 5 and 5.5; +select sum(distinct a) from t2 where a=8366 and b>=5 and b<=5; +select sum(distinct a) from t2 where a=8366 and b=5; +select sum(distinct a) from t2 where a=8366 and b between 5 and 5.5; + +drop table t2; diff --git a/mysql-test/suite/innodb/t/innodb-alter-discard.test b/mysql-test/suite/innodb/t/innodb-alter-discard.test new file mode 100644 index 00000000000..80678cef0a6 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-alter-discard.test @@ -0,0 +1,46 @@ +#Bug#13955083 ALLOW IN-PLACE DDL OPERATIONS ON MISSING OR DISCARDED TABLESPACES + +--source include/not_embedded.inc +--source include/have_innodb.inc + +let $MYSQLD_DATADIR=`select @@datadir`; +SET GLOBAL innodb_file_per_table=1; +CREATE TABLE t(a INT)ENGINE=InnoDB; + +# Shut down the server +-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +-- shutdown_server +-- source include/wait_until_disconnected.inc + +# Remove the tablespace file. +let IBD=$MYSQLD_DATADIR/test/t.ibd; +perl; +unlink "$ENV{IBD}" || die "Unable to unlink $ENV{IBD}\n"; +EOF + +# Restart the server. +-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +-- enable_reconnect +-- source include/wait_until_connected_again.inc + +call mtr.add_suppression("InnoDB: Error: trying to open a table, but could not$"); +call mtr.add_suppression("MySQL is trying to open a table handle but the \.ibd file for$"); +call mtr.add_suppression("InnoDB: Table 'test/t'$"); +call mtr.add_suppression("Could not find a valid tablespace file for"); +call mtr.add_suppression("InnoDB: Tablespace open failed for '\"test\"\.\"t\"', ignored"); +call mtr.add_suppression("InnoDB: Failed to find tablespace for table '\"test\"\.\"t\"' in the cache"); +call mtr.add_suppression("InnoDB: Cannot delete tablespace [0-9]+.*not found"); +call mtr.add_suppression("Table .*t in the InnoDB data dictionary has tablespace id .*, but tablespace with that id or name does not exist"); + +# The ER_NO_SUCH_TABLE is being thrown by ha_innobase::open(). +# The table does exist, only the tablespace does not exist. +--error ER_NO_SUCH_TABLE_IN_ENGINE +SELECT * FROM t; + +--error ER_NO_SUCH_TABLE_IN_ENGINE +ALTER TABLE t ADD INDEX (a), ALGORITHM=INPLACE; +--error ER_NO_SUCH_TABLE +ALTER TABLE t1 ADD INDEX (a), ALGORITHM=COPY; + +ALTER TABLE t DISCARD TABLESPACE; +DROP TABLE t; diff --git a/mysql-test/suite/innodb/t/innodb-alter-table.test b/mysql-test/suite/innodb/t/innodb-alter-table.test new file mode 100644 index 00000000000..45342b4a218 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-alter-table.test @@ -0,0 +1,173 @@ +--source include/have_innodb.inc + +# +# MMDEV-8386: MariaDB creates very big tmp file and hangs on xtradb +# +drop database if exists moodle19; +create database moodle19; +use moodle19; + +CREATE TABLE `mdl_course_modules` ( + `id` bigint(10) NOT NULL AUTO_INCREMENT, + `course` bigint(10) NOT NULL DEFAULT '0', + `module` bigint(10) NOT NULL DEFAULT '0', + `instance` bigint(10) NOT NULL DEFAULT '0', + `section` bigint(10) NOT NULL DEFAULT '0', + `idnumber` varchar(100) DEFAULT NULL, + `added` bigint(10) NOT NULL DEFAULT '0', + `delay` varchar(10) NOT NULL DEFAULT '0', + `score` smallint(4) NOT NULL DEFAULT '0', + `indent` mediumint(5) NOT NULL DEFAULT '0', + `visible` tinyint(1) NOT NULL DEFAULT '1', + `checkboxesforprereqs` tinyint(1) NOT NULL DEFAULT '0', + `stylewhencomplete` varchar(200) DEFAULT '', + `checkboxforcomplete` tinyint(1) NOT NULL DEFAULT '0', + `stylewhenlocked` varchar(200) DEFAULT 'locked', + `visiblewhenlocked` tinyint(1) NOT NULL DEFAULT '1', + `visibleold` tinyint(1) NOT NULL DEFAULT '1', + `groupmode` smallint(4) NOT NULL DEFAULT '0', + `groupingid` bigint(10) NOT NULL DEFAULT '0', + `groupmembersonly` smallint(4) NOT NULL DEFAULT '0', + `completion` tinyint(1) NOT NULL DEFAULT '0', + `completiongradeitemnumber` bigint(10) DEFAULT NULL, + `completionview` tinyint(1) NOT NULL DEFAULT '0', + `completionexpected` bigint(10) NOT NULL DEFAULT '0', + `availablefrom` bigint(10) NOT NULL DEFAULT '0', + `availableuntil` bigint(10) NOT NULL DEFAULT '0', + `showavailability` tinyint(1) NOT NULL DEFAULT '0', + `showdescription` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `mdl_courmodu_vis_ix` (`visible`), + KEY `mdl_courmodu_cou_ix` (`course`), + KEY `mdl_courmodu_mod_ix` (`module`), + KEY `mdl_courmodu_ins_ix` (`instance`), + KEY `mdl_courmodu_idncou_ix` (`idnumber`,`course`), + KEY `mdl_courmodu_gro_ix` (`groupingid`) +) ENGINE=InnoDB AUTO_INCREMENT=447023 DEFAULT CHARSET=utf8 COMMENT='course_modules table retrofitted from MySQL'; + +let $num= 2701; +--disable_query_log +--echo # Inserting $num rows into the table... +while ($num) +{ + eval INSERT INTO mdl_course_modules VALUES ($num,4,5,5,24,NULL,1141569781,'',0,0,1,0,'',0,'locked',1,1,0,0,0,0,NULL,0,0,0,0,0,0); + dec $num; +} +--enable_query_log +ALTER TABLE moodle19.mdl_course_modules ADD stefantest LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci AFTER showdescription; + +drop database moodle19; + +# +# Mdev-9469: Incorrect key file on alter table +# +use test; + +CREATE TABLE `w_findispmon05u` ( +`atpkey` INT(11) NOT NULL DEFAULT '0', +`atzo05` INT(11) NULL DEFAULT NULL, +`pos` BIGINT(21) NULL DEFAULT NULL, +`f5BnvB` INT(9) NULL DEFAULT NULL, +`f5atbvb` INT(11) NULL DEFAULT NULL, +`f5atbwmg` INT(11) NULL DEFAULT NULL, +`f5pBneu` BIGINT(12) NULL DEFAULT NULL, +`atbwdt` INT(11) NULL DEFAULT NULL, +`atbwzt` INT(11) NULL DEFAULT NULL, +`atbart` VARCHAR(10) NULL DEFAULT NULL +) +COLLATE='utf8_general_ci' +ENGINE=InnoDB; +ALTER TABLE `w_findispmon05u` +CHANGE COLUMN `atpkey` `f5atpkey` INT(11) NOT NULL DEFAULT '0' FIRST, +CHANGE COLUMN `atzo05` `f5atzo05` INT(11) NULL DEFAULT NULL AFTER `f5atpkey`, +CHANGE COLUMN `atbwdt` `f5atbwdt` INT(11) NULL DEFAULT NULL AFTER `f5pBneu`, +CHANGE COLUMN `atbwzt` `f5atbwzt` INT(11) NULL DEFAULT NULL AFTER `f5atbwdt`, +CHANGE COLUMN `atbart` `f5atbart` VARCHAR(10) NULL DEFAULT NULL AFTER `f5atbwzt`, +ADD INDEX `atpkey` (`f5atpkey`), +ADD INDEX `inatkey` (`f5atzo05`, `pos`), +ADD INDEX `pos` (`pos`, `f5atzo05`); + +SHOW WARNINGS; +SHOW CREATE TABLE `w_findispmon05u`; + +DROP TABLE `w_findispmon05u`; + +CREATE TABLE t ( + a INT NOT NULL, + b INT NOT NULL, + PRIMARY KEY (a) +) ENGINE=INNODB; + +ALTER TABLE t + CHANGE COLUMN b c INT NOT NULL, + ADD UNIQUE INDEX (c); + +SHOW WARNINGS; +SHOW CREATE TABLE t; + +# this should fail +--error 1072 +ALTER TABLE t + CHANGE COLUMN c b INT NOT NULL, + ADD UNIQUE INDEX (c); + +DROP TABLE t; + +# +# Check Foreign Keys +# +CREATE TABLE parent ( + a INT NOT NULL, + b INT NOT NULL, + PRIMARY KEY (a) +) ENGINE=INNODB; + +CREATE TABLE child ( + a INT NOT NULL, + b INT NOT NULL, + PRIMARY KEY (a) +) ENGINE=INNODB; + +ALTER TABLE child + CHANGE COLUMN b c INT NOT NULL, + ADD FOREIGN KEY (c) REFERENCES parent(a); + +SHOW WARNINGS; + +SHOW CREATE TABLE child; + +DROP TABLE child, parent; + +# +# MDEV-10535: ALTER TABLE causes standalone/wsrep cluster crash +# +CREATE TABLE IF NOT EXISTS ticket ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + mask VARCHAR(16) DEFAULT '' NOT NULL, + subject VARCHAR(255) DEFAULT '' NOT NULL, + is_closed TINYINT(1) UNSIGNED DEFAULT 0 NOT NULL, + is_deleted TINYINT(1) UNSIGNED DEFAULT 0 NOT NULL, + team_id INT UNSIGNED DEFAULT 0 NOT NULL, + category_id INT UNSIGNED DEFAULT 0 NOT NULL, + first_message_id INT UNSIGNED DEFAULT 0 NOT NULL, + created_date INT UNSIGNED, + updated_date INT UNSIGNED, + due_date INT UNSIGNED, + first_wrote_address_id INT UNSIGNED NOT NULL DEFAULT 0, + last_wrote_address_id INT UNSIGNED NOT NULL DEFAULT 0, + spam_score DECIMAL(4,4) NOT NULL DEFAULT 0, + spam_training VARCHAR(1) NOT NULL DEFAULT '', + interesting_words VARCHAR(255) NOT NULL DEFAULT '', + next_action VARCHAR(255) NOT NULL DEFAULT '', + PRIMARY KEY (id) +) ENGINE=InnoDB; + +ALTER TABLE ticket + CHANGE COLUMN team_id group_id INT UNSIGNED NOT NULL DEFAULT 0, + CHANGE COLUMN category_id bucket_id INT UNSIGNED NOT NULL DEFAULT 0, + ADD COLUMN org_id INT UNSIGNED NOT NULL DEFAULT 0, + ADD INDEX org_id (org_id); + +SHOW CREATE TABLE ticket; + +DROP TABLE ticket; diff --git a/mysql-test/suite/innodb/t/innodb-alter-tempfile.test b/mysql-test/suite/innodb/t/innodb-alter-tempfile.test new file mode 100644 index 00000000000..e1e736fc678 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-alter-tempfile.test @@ -0,0 +1,82 @@ +# Not supported in embedded +--source include/not_embedded.inc + +# This test case needs to crash the server. Needs a debug server. +--source include/have_debug.inc + +# Don't test this under valgrind, memory leaks will occur. +--source include/not_valgrind.inc + +# Avoid CrashReporter popup on Mac +--source include/not_crashrep.inc + +# InnoDB is required +--source include/have_innodb.inc + +--echo # +--echo # Bug #18734396 INNODB IN-PLACE ALTER FAILURES BLOCK FUTURE ALTERS +--echo # +--echo # Temporary tablename will be unique. This makes sure that future +--echo # in-place ALTERs of the same table will not be blocked due to +--echo # temporary tablename. + +# As we intentionally crash below, there could be partially written +# pages that are then recovered from the doublewrite buffer +call mtr.add_suppression("InnoDB: Warning: database page corruption or a failed +"); +call mtr.add_suppression("InnoDB: file read of space .* page .*"); +call mtr.add_suppression("InnoDB: Trying to recover it from the doublewrite buffer."); + +let datadir= `select @@datadir`; + +--let $_server_id= `SELECT @@server_id` +--let $_expect_file_name=$MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect + +--echo # Crash the server in ha_innobase::commit_inplace_alter_table() +CREATE TABLE t1 (f1 INT NOT NULL, f2 INT NOT NULL) ENGINE=innodb; +SET debug='d,innodb_alter_commit_crash_before_commit'; + +let $orig_table_id = `SELECT table_id + FROM information_schema.innodb_sys_tables + WHERE name = 'test/t1'`; + +--echo # Write file to make mysql-test-run.pl expect crash +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +--echo # Execute the statement that causes the crash +--error 2013 +ALTER TABLE t1 ADD PRIMARY KEY (f2, f1); +--echo # Startup the server after the crash +--source include/start_mysqld.inc + +--echo # Read and remember the temporary table name +let $temp_table_name = `SELECT SUBSTRING(name,6) + FROM information_schema.innodb_sys_tables + WHERE name LIKE "test/#sql-ib$orig_table_id%"`; +# This second copy is an environment variable for the perl script below. +let temp_table_name = $temp_table_name; +show create table t1; +--echo # Consecutive Alter table does not create same temporary file name +ALTER TABLE t1 ADD PRIMARY KEY (f2, f1); +--echo # Shutdown the server to allow manual recovery +--source include/shutdown_mysqld.inc + +--echo # Manual recovery begin. The dictionary was not updated +--echo # and the files were not renamed. The rebuilt table +--echo # was left behind on purpose, to faciliate data recovery. + +perl; +my @frm_file = glob "$ENV{'datadir'}/test/#sql-*.frm"; +my $target_frm = "$ENV{'datadir'}/test/$ENV{'temp_table_name'}.frm"; +rename($frm_file[0], $target_frm); +EOF +--echo # Manual recovery end +--echo # Startup the server after manual recovery +--source include/start_mysqld.inc + +--echo # Drop the orphaned rebuilt table. +--disable_query_log +eval DROP TABLE `#mysql50#$temp_table_name`; +--enable_query_log +show create table t1; +drop table t1; diff --git a/mysql-test/suite/innodb/t/innodb-alter-timestamp.test b/mysql-test/suite/innodb/t/innodb-alter-timestamp.test new file mode 100644 index 00000000000..c0b17ee6440 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-alter-timestamp.test @@ -0,0 +1,27 @@ +--source include/have_innodb.inc + +CREATE TABLE t1 ( + `i1` INT(10) UNSIGNED NOT NULL, + `d1` TIMESTAMP NULL DEFAULT NULL +) ENGINE=innodb; + +show create table t1; + +INSERT INTO t1 (i1) VALUES (1), (2), (3), (4), (5); +select * from t1; +set sql_mode = 'STRICT_ALL_TABLES,NO_ZERO_DATE'; +ALTER TABLE t1 CHANGE `d1` `d1` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL; +drop table t1; + +CREATE TABLE t1 ( + `i1` INT(10) UNSIGNED NOT NULL, + `d1` TIMESTAMP NULL DEFAULT NULL +) ENGINE=innodb; +INSERT INTO t1 (i1) VALUES (1), (2), (3), (4), (5); +ALTER TABLE t1 CHANGE `d1` `d1` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; +drop table t1; +set sql_mode = ''; + + + + diff --git a/mysql-test/suite/innodb/t/innodb-autoinc-44030.test b/mysql-test/suite/innodb/t/innodb-autoinc-44030.test index 07e9ca30fd6..256e7d838ea 100644 --- a/mysql-test/suite/innodb/t/innodb-autoinc-44030.test +++ b/mysql-test/suite/innodb/t/innodb-autoinc-44030.test @@ -1,11 +1,7 @@ ---source include/have_innodb.inc -# embedded server ignores 'delayed', so skip this +-- source include/have_innodb.inc +# embedded server does not support restarting -- source include/not_embedded.inc ---disable_warnings -drop table if exists t1; ---enable_warnings - # # 44030: Error: (1500) Couldn't read the MAX(ID) autoinc value from # the index (PRIMARY) @@ -27,8 +23,17 @@ SELECT * FROM t1; # to be enabled. Also, see http://bugs.mysql.com/bug.php?id=47621. #-- error ER_AUTOINC_READ_FAILED,1467 INSERT INTO t1 VALUES(null); +# Before WL#5534, the following statement would copy the table, +# and effectively set AUTO_INCREMENT to 4, because while copying +# it would write values 1,2,3 to the column. +# WL#5534 makes this an in-place ALTER, setting AUTO_INCREMENT=3 for real. +# However, to keep compatibility with ALGORITHM=COPY MySQL 5.6.11 will +# go back to the original behaviour, setting AUTO_INCREMENT to 4. +--enable_info ALTER TABLE t1 AUTO_INCREMENT = 3; +--disable_info SHOW CREATE TABLE t1; INSERT INTO t1 VALUES(null); +INSERT INTO t1 VALUES(null); SELECT * FROM t1; DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-bigblob.opt b/mysql-test/suite/innodb/t/innodb-bigblob.opt new file mode 100644 index 00000000000..06cc9e2b979 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-bigblob.opt @@ -0,0 +1,2 @@ +--max-allowed-packet=128M +--innodb-log-file-size=210M diff --git a/mysql-test/suite/innodb/t/innodb-bigblob.test b/mysql-test/suite/innodb/t/innodb-bigblob.test new file mode 100644 index 00000000000..7665c890316 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-bigblob.test @@ -0,0 +1,20 @@ +-- source include/have_innodb.inc +-- source include/big_test.inc +-- source include/not_embedded.inc + +--disable_query_log +let $status_orig=`SELECT @@innodb_status_output`; +--enable_query_log + +call mtr.add_suppression("Resizing redo log from *"); +call mtr.add_suppression("Starting to delete and rewrite log files."); +call mtr.add_suppression("New log files created, LSN=*"); + +create table foo (id varchar(37) not null, content longblob) engine=INNODB; +insert into foo (id, content) values('xyz', ''); +update foo set content=repeat('a', 43941888) where id='xyz'; +drop table foo; + +--disable_query_log +EVAL SET GLOBAL innodb_status_output = $status_orig; +--enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb-bug-14068765.test b/mysql-test/suite/innodb/t/innodb-bug-14068765.test new file mode 100644 index 00000000000..185e8849e21 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-bug-14068765.test @@ -0,0 +1,73 @@ +-- source include/have_innodb.inc +--disable_warnings + +DROP TABLE IF EXISTS t1; +--enable_warnings +let MYSQLD_DATADIR =`SELECT @@datadir`; +let $innodb_file_per_table = `SELECT @@innodb_file_per_table`; +let $innodb_file_format = `SELECT @@innodb_file_format`; + +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +#SET GLOBAL innodb_file_format = `Barracuda`; +#SELECT @@innodb_file_format; + +# Export/import on the same instance, with --innodb-file-per-table=1 +CREATE DATABASE testdb_wl5522; + +CREATE TABLE testdb_wl5522.t1(col1 bit(1) , col2 boolean,col3 tinyint , col4 smallint , col5 mediumint ,col6 int , col7 bigint , col8 float (14,3) ,col9 double (14,3), col10 VARCHAR(20) CHARACTER SET utf8 , col11 TEXT CHARACTER SET binary , col12 ENUM('a','b','c') CHARACTER SET binary ,col13 TEXT CHARACTER SET latin1 COLLATE latin1_general_cs ,col14 CHAR(20) , col15 VARBINARY (400) , col16 BINARY(40), col17 BLOB (400) , col18 int not null primary key,col19 DATE ,col20 DATETIME , col21 TIMESTAMP ,col22 TIME , col23 YEAR ) ENGINE = Innodb; + + +CREATE INDEX idx1 ON testdb_wl5522.t1(col18); +CREATE INDEX prefix_idx ON testdb_wl5522.t1(col14 (10)); +CREATE UNIQUE INDEX idx2 ON testdb_wl5522.t1(col12); +CREATE UNIQUE INDEX idx3 ON testdb_wl5522.t1(col8); + +INSERT INTO testdb_wl5522.t1 VALUES (1,1,-128,32767,-8388608,2147483647,-9223372036854775808, 92233720368.222,-92233720368.222,'aaa', 'aaaaaaaaaa','b','bbbbb','ccccc',REPEAT('d',40),REPEAT('d',40),REPEAT('d',40), 1,'1000-01-01','3000-12-31 23:59:59.99','1990-01-01 00:00:01.00','01:59:59.00','1901'); + +INSERT INTO testdb_wl5522.t1 VALUES (NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,3,NULL,NULL,NULL,NULL,NULL); + +--error ER_BAD_NULL_ERROR +INSERT INTO testdb_wl5522.t1 VALUES (NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); + +--error ER_DUP_ENTRY +INSERT INTO testdb_wl5522.t1 VALUES (NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,NULL,NULL,NULL,NULL,NULL); + +FLUSH TABLES testdb_wl5522.t1 WITH READ LOCK; +SELECT COUNT(*) FROM testdb_wl5522.t1; +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1; + +CREATE TABLE testdb_wl5522.t1(col1 bit(1) , col2 boolean,col3 tinyint , col4 smallint , col5 mediumint ,col6 int , col7 bigint , col8 float (14,3) ,col9 double (14,3), col10 VARCHAR(20) CHARACTER SET utf8 , col11 TEXT CHARACTER SET binary , col12 ENUM('a','b','c') CHARACTER SET binary ,col13 TEXT CHARACTER SET latin1 COLLATE latin1_general_cs ,col14 CHAR(20) , col15 VARBINARY (400) , col16 BINARY(40), col17 BLOB (400) , col18 int not null primary key,col19 DATE ,col20 DATETIME , col21 TIMESTAMP ,col22 TIME , col23 YEAR ) ENGINE = Innodb; + + +CREATE INDEX idx1 ON testdb_wl5522.t1(col18); +CREATE INDEX prefix_idx ON testdb_wl5522.t1(col14 (10)); +CREATE UNIQUE INDEX idx2 ON testdb_wl5522.t1(col12); +CREATE UNIQUE INDEX idx3 ON testdb_wl5522.t1(col8); + +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; + +CHECK TABLE testdb_wl5522.t1; + +SELECT COUNT(*) FROM testdb_wl5522.t1; + +DROP TABLE testdb_wl5522.t1; + +DROP DATABASE testdb_wl5522; + +eval SET GLOBAL INNODB_FILE_FORMAT=$innodb_file_format; +eval SET GLOBAL INNODB_FILE_PER_TABLE=$innodb_file_per_table; diff --git a/mysql-test/suite/innodb/t/innodb-bug-14084530.test b/mysql-test/suite/innodb/t/innodb-bug-14084530.test new file mode 100644 index 00000000000..94a2d6b2252 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-bug-14084530.test @@ -0,0 +1,52 @@ +-- source include/have_innodb.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +let MYSQLD_DATADIR =`SELECT @@datadir`; +let $innodb_file_per_table = `SELECT @@innodb_file_per_table`; +let $innodb_file_format = `SELECT @@innodb_file_format`; + +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +SET AUTOCOMMIT = 0; + +# Export/import on the same instance, with --innodb-file-per-table=1 +CREATE DATABASE testdb_wl5522; +CREATE TABLE testdb_wl5522.t1 (c1 int ) engine = Innodb; + +BEGIN; +INSERT INTO testdb_wl5522.t1 VALUES (1),(123),(331); +ROLLBACK; + +SELECT c1 FROM testdb_wl5522.t1; + +FLUSH TABLES testdb_wl5522.t1 FOR EXPORT; +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1; + +CREATE TABLE testdb_wl5522.t1 (c1 int ) ENGINE = Innodb; +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; +CHECK TABLE testdb_wl5522.t1; +SELECT c1 FROM testdb_wl5522.t1; + +SET AUTOCOMMIT = 1; +DROP TABLE testdb_wl5522.t1; +DROP DATABASE testdb_wl5522; +eval SET GLOBAL INNODB_FILE_FORMAT=$innodb_file_format; +eval SET GLOBAL INNODB_FILE_PER_TABLE=$innodb_file_per_table; diff --git a/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test b/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test index 83d2b07b725..8cbe4938cab 100644 --- a/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test +++ b/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test @@ -1,3 +1,8 @@ +if (`select plugin_auth_version < "5.6.17" from information_schema.plugins where plugin_name='innodb'`) +{ + --skip Not fixed in InnoDB before 5.6.17 +} + --echo # --echo # Bug#69122 - INNODB DOESN'T REDO-LOG INSERT BUFFER MERGE --echo # OPERATION IF IT IS DONE IN-PLACE diff --git a/mysql-test/suite/innodb/t/innodb-corrupted-table.test b/mysql-test/suite/innodb/t/innodb-corrupted-table.test new file mode 100644 index 00000000000..94c5454429f --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-corrupted-table.test @@ -0,0 +1,46 @@ +--source include/have_innodb.inc +--source include/not_embedded.inc + +# +# MDEV-9918: [ERROR] mysqld got signal 11 during ALTER TABLE `name` COLUMN ADD +# + +call mtr.add_suppression("Table .* has a primary key in InnoDB data dictionary, but not in MySQL.*"); +call mtr.add_suppression("InnoDB: Table .* contains .* indexes inside InnoDB, which is different from the number of indexes .* defined in the MySQL.*"); + +create table t1 (pk int, i int, key(i)) engine=InnoDB; +insert into t1 values (1,1),(2,2); + +--let $datadir= `select @@datadir` + +flush tables; + +--echo # Save the .frm file without the PK + +--copy_file $datadir/test/t1.frm $MYSQLTEST_VARDIR/tmp/t1.frm + +alter table t1 add primary key (pk); + +--echo # Stop the server, replace the frm with the old one and restart the server + +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--shutdown_server 10 +--source include/wait_until_disconnected.inc + +--remove_file $datadir/test/t1.frm +--copy_file $MYSQLTEST_VARDIR/tmp/t1.frm $datadir/test/t1.frm + +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--enable_reconnect +--source include/wait_until_connected_again.inc + +show create table t1; +select * from t1; +alter table t1 add j int; +show warnings; +show create table t1; +alter table t1 add primary key (pk); +show warnings; +show create table t1; +# Cleanup +drop table t1; diff --git a/mysql-test/suite/innodb/t/innodb-fk-warnings.test b/mysql-test/suite/innodb/t/innodb-fk-warnings.test index fe92f1345f4..f45ae00d788 100644 --- a/mysql-test/suite/innodb/t/innodb-fk-warnings.test +++ b/mysql-test/suite/innodb/t/innodb-fk-warnings.test @@ -48,10 +48,10 @@ create table t2(a int, b int, constraint a foreign key a (a) references t1(a), constraint a foreign key a (a) references t1(b)) engine=innodb; show warnings; create table t2(a int, b int, constraint a foreign key a (a) references t1(a)) engine=innodb; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ --error 1005 alter table t2 add constraint b foreign key (b) references t2(b); ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ show warnings; drop table t2, t1; @@ -60,10 +60,10 @@ drop table t2, t1; # create table t1 (f1 integer primary key) engine=innodb; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ --error 1005 alter table t1 add constraint c1 foreign key (f1) references t11(f1); ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ show warnings; drop table t1; @@ -72,15 +72,30 @@ drop table t1; # create temporary table t1(a int not null primary key, b int, key(b)) engine=innodb; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +# remove echos and uncomment the commented when MDEV-8569 is fixed +--echo create temporary table t2(a int, foreign key(a) references t1(a)) engine=innodb; +--echo ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed") +--echo show warnings; +--echo Level Code Message +--echo Warning 150 Create table `mysqld.1`.`t2` with foreign key constraint failed. Referenced table `mysqld.1`.`t1` not found in the data dictionary close to foreign key(a) references t1(a)) engine=innodb. +--echo Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed") +--echo Warning 1215 Cannot add foreign key constraint +--echo alter table t1 add foreign key(b) references t1(a); +--echo ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed") +--echo show warnings; +--echo Level Code Message +--echo Warning 150 Alter table `mysqld.1`.`t1` with foreign key constraint failed. Referenced table `mysqld.1`.`t1` not found in the data dictionary close to foreign key(b) references t1(a). +--echo Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed") +--echo Warning 1215 Cannot add foreign key constraint +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ --error 1005 create temporary table t2(a int, foreign key(a) references t1(a)) engine=innodb; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ show warnings; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ --error 1005 alter table t1 add foreign key(b) references t1(a); ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ show warnings; drop table t1; @@ -88,17 +103,17 @@ drop table t1; # Column numbers do not match # create table t1(a int not null primary key, b int, key(b)) engine=innodb; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ ---error 1005 +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +--error 1239 alter table t1 add foreign key(a,b) references t1(a); ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ show warnings; drop table t1; create table t1(a int not null primary key, b int, key(b)) engine=innodb; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ ---error 1005 +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +--error 1239 alter table t1 add foreign key(a) references t1(a,b); ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ show warnings; drop table t1; @@ -106,15 +121,15 @@ drop table t1; # ON UPDATE/DELETE SET NULL on NOT NULL column # create table t1 (f1 integer not null primary key) engine=innodb; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ --error 1005 alter table t1 add constraint c1 foreign key (f1) references t1(f1) on update set null; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ show warnings; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ --error 1005 create table t2(a int not null, foreign key(a) references t1(f1) on delete set null) engine=innodb; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ show warnings; drop table t1; @@ -122,9 +137,9 @@ drop table t1; # Incorrect types # create table t1 (id int not null primary key, f1 int, f2 int, key(f1)) engine=innodb; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ --error 1005 create table t2(a char(20), key(a), foreign key(a) references t1(f1)) engine=innodb; ---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ show warnings; drop table t1; diff --git a/mysql-test/suite/innodb/t/innodb-fk.test b/mysql-test/suite/innodb/t/innodb-fk.test index fd8dce7594c..17e926e8647 100644 --- a/mysql-test/suite/innodb/t/innodb-fk.test +++ b/mysql-test/suite/innodb/t/innodb-fk.test @@ -115,11 +115,11 @@ CREATE TABLE t2 ( CONSTRAINT fk2 FOREIGN KEY (f2) REFERENCES t1 (`id`) ON DELETE CASCADE ) ENGINE=InnoDB; ---replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9_a-f-]*/#sql-temporary/ --error 1005 ALTER TABLE t2 ADD CONSTRAINT fk3 FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE CASCADE; ---replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/ +--replace_regex /#sql-[0-9_a-f-]*/#sql-temporary/ show warnings; drop table t2; @@ -165,3 +165,66 @@ show create table `kg_test2`.`person2`; SHOW WARNINGS; DROP DATABASE kg_test2; DROP DATABASE kg_test1; + +# +# MDEV-7627: Some symbols in table name can cause to Error Code: 1050 when created FK +# + +CREATE TABLE `#departaments` ( + `id_depart` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id_depart`) +) ENGINE=INNODB DEFAULT CHARSET=utf8; + +CREATE TABLE `#departaments_tree` ( + `id_depart` INT(10) UNSIGNED NOT NULL, + `id_depart_in` INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (`id_depart`,`id_depart_in`), + CONSTRAINT `#departaments_tree_ibfk_1` FOREIGN KEY (`id_depart`) REFERENCES `#departaments` (`id_depart`) +) ENGINE=INNODB DEFAULT CHARSET=utf8; + +ALTER TABLE `#departaments_tree` + ADD FOREIGN KEY (`id_depart_in`) REFERENCES `#departaments`(`id_depart`); + +SHOW CREATE TABLE `#departaments_tree`; + +DROP TABLE `#departaments_tree`; +DROP TABLE `#departaments`; + +CREATE TABLE `boroda` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `a` INT(11) UNSIGNED DEFAULT NULL, + `b` INT(11) UNSIGNED DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`), + CONSTRAINT `boroda_ibfk_1` FOREIGN KEY (`a`) REFERENCES `boroda` (`id`) +) ENGINE=INNODB DEFAULT CHARSET=utf8; + +ALTER TABLE `boroda` + ADD FOREIGN KEY (`b`) REFERENCES `boroda`(`id`); + +ALTER TABLE `boroda` DROP FOREIGN KEY `boroda_ibfk_2`; + +RENAME TABLE `boroda` TO `#boroda`; + +ALTER TABLE `#boroda` +ADD FOREIGN KEY (`b`) REFERENCES `#boroda`(`id`); + +SHOW CREATE TABLE `#boroda`; +DROP TABLE `#boroda`; + +CREATE TABLE `boroda` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `a` INT(11) UNSIGNED DEFAULT NULL, + `b` INT(11) UNSIGNED DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`), + CONSTRAINT `boroda_ibfk_1` FOREIGN KEY (`a`) REFERENCES `boroda` (`id`) +) ENGINE=INNODB DEFAULT CHARSET=utf8; + +RENAME TABLE `boroda` TO `bor#oda`; + +ALTER TABLE `bor#oda` +ADD FOREIGN KEY (`b`) REFERENCES `bor#oda`(`id`); + +SHOW CREATE TABLE `bor#oda`; +DROP TABLE `bor#oda`; diff --git a/mysql-test/suite/innodb/t/innodb-get-fk.test b/mysql-test/suite/innodb/t/innodb-get-fk.test new file mode 100644 index 00000000000..c1ab54fab45 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-get-fk.test @@ -0,0 +1,63 @@ +-- source include/have_innodb.inc +# need to restart server +-- source include/not_embedded.inc +CREATE SCHEMA `repro`; + +CREATE TABLE `repro`.`crew` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`code` varchar(50) NOT NULL, +`name` varchar(50) NOT NULL, +`created_at` timestamp NULL DEFAULT NULL, +`updated_at` timestamp NULL DEFAULT NULL, +PRIMARY KEY (`id`), +KEY `code` (`code`) +) ENGINE=InnoDB; + +CREATE TABLE `repro`.`pilot` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`code` varchar(50) NOT NULL, +`name` varchar(50) NOT NULL, +`created_at` timestamp NULL DEFAULT NULL, +`updated_at` timestamp NULL DEFAULT NULL, +PRIMARY KEY (`id`), +KEY `code` (`code`) +) ENGINE=InnoDB; + +CREATE TABLE `repro`.`crew_role_assigned` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`crew_id` int(11) NOT NULL, +`role_code` varchar(50) NOT NULL, +PRIMARY KEY (`id`), +KEY `fk_crewRoleAssigned_roleCode` (`role_code`), +CONSTRAINT `fk_crewRoleAssigned_crewId` FOREIGN KEY (`crew_id`) REFERENCES `repro`.`crew` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, +CONSTRAINT `fk_crewRoleAssigned_pilotId` FOREIGN KEY (`crew_id`) REFERENCES `repro`.`pilot` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB COMMENT="This is a comment about tables"; + +-- let $restart_parameters=--innodb-read-only +-- source include/restart_mysqld.inc + +--error ER_CANT_LOCK +ALTER TABLE `repro`.`crew_role_assigned` COMMENT = 'innodb_read_only'; +SHOW CREATE TABLE `repro`.`crew_role_assigned`; + +-- let $restart_parameters= +-- source include/restart_mysqld.inc + +ALTER TABLE `repro`.`crew_role_assigned` COMMENT = "This is a new comment about tables"; +SHOW CREATE TABLE `repro`.`crew_role_assigned`; + +-- let $restart_parameters=--innodb-read-only +-- source include/restart_mysqld.inc + +# +# Below create table should contain also fk definitions +# +SHOW CREATE TABLE `repro`.`crew_role_assigned`; + +-- let $restart_parameters= +-- source include/restart_mysqld.inc + +DROP TABLE `repro`.`crew_role_assigned`; +DROP TABLE `repro`.`pilot`; +DROP TABLE `repro`.`crew`; +DROP SCHEMA `repro`; diff --git a/mysql-test/suite/innodb/t/innodb-index.test b/mysql-test/suite/innodb/t/innodb-index.test index cea9055b873..8598647de66 100644 --- a/mysql-test/suite/innodb/t/innodb-index.test +++ b/mysql-test/suite/innodb/t/innodb-index.test @@ -1,5 +1,8 @@ -- source include/have_innodb.inc +let $innodb_file_format_orig=`select @@innodb_file_format`; +let $innodb_file_format_max_orig=`select @@innodb_file_format_max`; + let $MYSQLD_DATADIR= `select @@datadir`; let $per_table=`select @@innodb_file_per_table`; @@ -7,127 +10,16 @@ let $format=`select @@innodb_file_format`; set global innodb_file_per_table=on; set global innodb_file_format='Barracuda'; -# Bug #12429576 - Test an assertion failure on purge. -CREATE TABLE t1_purge ( -A INT, -B BLOB, C BLOB, D BLOB, E BLOB, -F BLOB, G BLOB, H BLOB, -PRIMARY KEY (B(767), C(767), D(767), E(767), A), -INDEX (A) -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; - -INSERT INTO t1_purge VALUES (1, -REPEAT('b', 766), REPEAT('c', 766), REPEAT('d', 766), REPEAT('e', 766), -REPEAT('f', 766), REPEAT('g', 766), REPEAT('h', 766)); - -CREATE TABLE t2_purge ( -A INT PRIMARY KEY, -B BLOB, C BLOB, D BLOB, E BLOB, -F BLOB, G BLOB, H BLOB, I BLOB, -J BLOB, K BLOB, L BLOB, -INDEX (B(767))) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; - -INSERT INTO t2_purge VALUES (1, -REPEAT('b', 766), REPEAT('c', 766), REPEAT('d', 766), REPEAT('e', 766), -REPEAT('f', 766), REPEAT('g', 766), REPEAT('h', 766), REPEAT('i', 766), -REPEAT('j', 766), REPEAT('k', 766), REPEAT('l', 766)); - -CREATE TABLE t3_purge ( -A INT, -B VARCHAR(800), C VARCHAR(800), D VARCHAR(800), E VARCHAR(800), -F VARCHAR(800), G VARCHAR(800), H VARCHAR(800), -PRIMARY KEY (B(767), C(767), D(767), E(767), A), -INDEX (A) -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; - -INSERT INTO t3_purge SELECT * FROM t1_purge; - -CREATE TABLE t4_purge ( -A INT PRIMARY KEY, -B VARCHAR(800), C VARCHAR(800), D VARCHAR(800), E VARCHAR(800), -F VARCHAR(800), G VARCHAR(800), H VARCHAR(800), I VARCHAR(800), -J VARCHAR(800), K VARCHAR(800), L VARCHAR(800), -INDEX (B(767))) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; - -INSERT INTO t4_purge SELECT * FROM t2_purge; - -# This would trigger the failure (Bug #12429576) -# if purge gets a chance to run before DROP TABLE t1_purge, .... -DELETE FROM t1_purge; -DELETE FROM t2_purge; -DELETE FROM t3_purge; -DELETE FROM t4_purge; -# Instead of doing a --sleep 10, wait until the rest of the tests in -# this file complete before dropping the tables. By then, the purge thread -# will have delt with the updates above. - -# Bug#12637786 - Bad assert by purge thread for records with external data -# used in secondary indexes. -SET @r=REPEAT('a',500); -CREATE TABLE t12637786(a INT, - v1 VARCHAR(500), v2 VARCHAR(500), v3 VARCHAR(500), - v4 VARCHAR(500), v5 VARCHAR(500), v6 VARCHAR(500), - v7 VARCHAR(500), v8 VARCHAR(500), v9 VARCHAR(500), - v10 VARCHAR(500), v11 VARCHAR(500), v12 VARCHAR(500), - v13 VARCHAR(500), v14 VARCHAR(500), v15 VARCHAR(500), - v16 VARCHAR(500), v17 VARCHAR(500), v18 VARCHAR(500) -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; -CREATE INDEX idx1 ON t12637786(a,v1); -INSERT INTO t12637786 VALUES(9,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); -UPDATE t12637786 SET a=1000; -DELETE FROM t12637786; -# We need to activate the purge thread at this point to make sure it does not -# assert and is able to clean up the old versions of secondary index entries. -# But instead of doing a --sleep 10, wait until the rest of the tests in -# this file complete before dropping the table. By then, the purge thread -# will have delt with the updates above. - -# Bug#12963823 - Test that the purge thread does not crash when -# the number of indexes has changed since the UNDO record was logged. -create table t12963823(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) - engine=innodb row_format=dynamic; -SET @r = repeat('a', 767); -insert into t12963823 values (@r,@r,@r,@r, @r,@r,@r,@r, @r,@r,@r,@r, @r,@r,@r,@r); -create index ndx_a on t12963823 (a(500)); -create index ndx_b on t12963823 (b(500)); -create index ndx_c on t12963823 (c(500)); -create index ndx_d on t12963823 (d(500)); -create index ndx_e on t12963823 (e(500)); -create index ndx_f on t12963823 (f(500)); -create index ndx_k on t12963823 (k(500)); -create index ndx_l on t12963823 (l(500)); - -SET @r = repeat('b', 500); -update t12963823 set a=@r,b=@r,c=@r,d=@r; -update t12963823 set e=@r,f=@r,g=@r,h=@r; -update t12963823 set i=@r,j=@r,k=@r,l=@r; -update t12963823 set m=@r,n=@r,o=@r,p=@r; -alter table t12963823 drop index ndx_a; -alter table t12963823 drop index ndx_b; -create index ndx_g on t12963823 (g(500)); -create index ndx_h on t12963823 (h(500)); -create index ndx_i on t12963823 (i(500)); -create index ndx_j on t12963823 (j(500)); -create index ndx_m on t12963823 (m(500)); -create index ndx_n on t12963823 (n(500)); -create index ndx_o on t12963823 (o(500)); -create index ndx_p on t12963823 (p(500)); -show create table t12963823; -# We need to activate the purge thread at this point to see if it crashes -# but instead of doing a --sleep 10, wait until the rest of the tests in -# this file complete before dropping the table. By then, the purge thread -# will have delt with the updates above. +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS; # Bug#13654923 BOGUS DEBUG ASSERTION IN INDEX CREATION FOR ZERO-LENGTH RECORD create table t1(a varchar(2) primary key) engine=innodb; insert into t1 values(''); +--enable_info create index t1a1 on t1(a(1)); +--disable_info drop table t1; -eval set global innodb_file_per_table=$per_table; -eval set global innodb_file_format=$format; - create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb; insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak'); commit; @@ -135,19 +27,30 @@ commit; alter table t1 add index b (b), add index b (b); --error ER_DUP_FIELDNAME alter table t1 add index (b,b); +--enable_info alter table t1 add index d2 (d); +--disable_info show create table t1; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 force index(d2) order by d; select * from t1 force index (d2) order by d; --error ER_DUP_ENTRY alter table t1 add unique index (b); show create table t1; +--enable_info alter table t1 add index (b); +--disable_info show create table t1; +--enable_info alter table t1 add unique index (c), add index (d); +--disable_info show create table t1; +analyze table t1; explain select * from t1 force index(c) order by c; +--enable_info alter table t1 add primary key (a), drop index c; show create table t1; --error ER_MULTIPLE_PRI_KEY @@ -155,16 +58,23 @@ alter table t1 add primary key (c); --error ER_DUP_ENTRY alter table t1 drop primary key, add primary key (b); create unique index c on t1 (c); +--disable_info show create table t1; +analyze table t1; explain select * from t1 force index(c) order by c; select * from t1 force index(c) order by c; +--enable_info alter table t1 drop index b, add index (b); +--disable_info show create table t1; insert into t1 values(6,1,'ggg','ggg'); select * from t1; select * from t1 force index(b) order by b; select * from t1 force index(c) order by c; select * from t1 force index(d) order by d; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 force index(b) order by b; explain select * from t1 force index(c) order by c; explain select * from t1 force index(d) order by d; @@ -174,11 +84,16 @@ drop table t1; create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb; insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ad','ad'),(4,4,'afe','afe'); commit; +--enable_info alter table t1 add index (c(2)); show create table t1; alter table t1 add unique index (d(10)); show create table t1; +--disable_info insert into t1 values(5,1,'ggg','ggg'); +-- disable_result_log +analyze table t1; +-- enable_result_log select * from t1; select * from t1 force index(c) order by c; select * from t1 force index(d) order by d; @@ -186,10 +101,15 @@ explain select * from t1 order by b; explain select * from t1 force index(c) order by c; explain select * from t1 force index(d) order by d; show create table t1; +--enable_info alter table t1 drop index d; +--disable_info insert into t1 values(8,9,'fff','fff'); select * from t1; select * from t1 force index(c) order by c; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 order by b; explain select * from t1 force index(c) order by c; explain select * from t1 order by d; @@ -199,23 +119,38 @@ drop table t1; create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb; insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe'); commit; +--enable_info alter table t1 add unique index (b,c); +--disable_info insert into t1 values(8,9,'fff','fff'); select * from t1; select * from t1 force index(b) order by b; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 force index(b) order by b; show create table t1; +--enable_info alter table t1 add index (b,c); +--disable_info insert into t1 values(11,11,'kkk','kkk'); select * from t1; select * from t1 force index(b) order by b; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 force index(b) order by b; show create table t1; +--enable_info alter table t1 add unique index (c,d); +--disable_info insert into t1 values(13,13,'yyy','aaa'); select * from t1; select * from t1 force index(b) order by b; select * from t1 force index(c) order by c; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 force index(b) order by b; explain select * from t1 force index(c) order by c; show create table t1; @@ -224,9 +159,9 @@ drop table t1; create table t1(a int not null, b int not null, c int, primary key (a), key (b)) engine = innodb; create table t3(a int not null, c int not null, d int, primary key (a), key (c)) engine = innodb; create table t4(a int not null, d int not null, e int, primary key (a), key (d)) engine = innodb; -create table t2(a int not null, b int not null, c int not null, d int not null, e int, -foreign key (b) references t1(b) on delete cascade, -foreign key (c) references t3(c), foreign key (d) references t4(d)) +create table t2(a int not null, b int, c int, d int, e int, +foreign key (b) references t1(b) on delete set null, +foreign key (c) references t3(c), foreign key (d) references t4(d) on update set null) engine = innodb; --error ER_DROP_INDEX_FK alter table t1 drop index b; @@ -238,38 +173,80 @@ alter table t4 drop index d; alter table t2 drop index b; --error ER_DROP_INDEX_FK alter table t2 drop index b, drop index c, drop index d; +--error ER_FK_COLUMN_CANNOT_CHANGE +alter table t2 MODIFY b INT NOT NULL, ALGORITHM=COPY; +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +set @old_sql_mode = @@sql_mode; +set @@sql_mode = 'STRICT_TRANS_TABLES'; +--error ER_FK_COLUMN_NOT_NULL +alter table t2 MODIFY b INT NOT NULL, ALGORITHM=INPLACE; +set @@sql_mode = @old_sql_mode; + +SET FOREIGN_KEY_CHECKS=0; +--error ER_FK_COLUMN_CANNOT_DROP +alter table t2 DROP COLUMN b, ALGORITHM=COPY; +--error ER_FK_COLUMN_CANNOT_DROP +alter table t2 DROP COLUMN b; +--error ER_FK_COLUMN_CANNOT_DROP_CHILD +alter table t1 DROP COLUMN b, ALGORITHM=COPY; +--error ER_FK_COLUMN_CANNOT_DROP_CHILD +alter table t1 DROP COLUMN b; +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; + +--enable_info # Apparently, the following makes mysql_alter_table() drop index d. create unique index dc on t2 (d,c); create index dc on t1 (b,c); # This should preserve the foreign key constraints. -alter table t2 add primary key (a); +--disable_info +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +# And adding a PRIMARY KEY will also add NOT NULL implicitly! +set @@sql_mode = 'STRICT_TRANS_TABLES'; +--enable_info +--error ER_FK_COLUMN_NOT_NULL +alter table t2 add primary key (alpha), change a alpha int, +change b beta int not null, change c charlie int not null; +--error ER_FK_COLUMN_NOT_NULL +alter table t2 add primary key (alpha), change a alpha int, +change c charlie int not null, change d delta int not null; +alter table t2 add primary key (alpha), change a alpha int, +change b beta int, modify c int not null; +--disable_info +set @@sql_mode = @old_sql_mode; insert into t1 values (1,1,1); insert into t3 values (1,1,1); insert into t4 values (1,1,1); insert into t2 values (1,1,1,1,1); commit; +--enable_info alter table t4 add constraint dc foreign key (a) references t1(a); +--disable_info show create table t4; ---replace_regex /'test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +# mysqltest first does replace_regex, then replace_result +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLD_DATADIR ./ master-data/ '' # a foreign key 'test/dc' already exists --error ER_CANT_CREATE_TABLE alter table t3 add constraint dc foreign key (a) references t1(a); +SET FOREIGN_KEY_CHECKS=0; +--error ER_FK_FAIL_ADD_SYSTEM +alter table t3 add constraint dc foreign key (a) references t1(a); +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; show create table t3; -# this should be fixed by MySQL (see Bug #51451) ---error ER_WRONG_NAME_FOR_INDEX -alter table t2 drop index b, add index (b); +--enable_info +alter table t2 drop index b, add index (beta); +--disable_info show create table t2; --error ER_ROW_IS_REFERENCED_2 delete from t1; --error ER_CANT_DROP_FIELD_OR_KEY drop index dc on t4; -# there is no foreign key dc on t3 ---replace_regex /'[^']*test\/#sql2-[0-9a-f-]*'/'#sql2-temporary'/ -# Embedded server doesn't chdir to data directory ---replace_result $MYSQLD_DATADIR ./ master-data/ '' ---error ER_ERROR_ON_RENAME +--enable_info +--error ER_CANT_DROP_FIELD_OR_KEY alter table t3 drop foreign key dc; alter table t4 drop foreign key dc; +--disable_info select * from t2; delete from t1; select * from t2; @@ -311,10 +288,15 @@ drop table t1; create table t1(a int not null, b int not null, c int, primary key (a), key(c)) engine=innodb; insert into t1 values (5,1,5),(4,2,4),(3,3,3),(2,4,2),(1,5,1); +--enable_info alter table t1 add unique index (b); +--disable_info insert into t1 values (10,20,20),(11,19,19),(12,18,18),(13,17,17); show create table t1; check table t1; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 force index(c) order by c; explain select * from t1 order by a; explain select * from t1 force index(b) order by b; @@ -325,11 +307,14 @@ drop table t1; create table t1(a int not null, b int not null) engine=innodb; insert into t1 values (1,1); +--enable_info alter table t1 add primary key(b); +--disable_info insert into t1 values (2,2); show create table t1; check table t1; select * from t1; +analyze table t1; explain select * from t1; explain select * from t1 order by a; explain select * from t1 order by b; @@ -338,205 +323,19 @@ drop table t1; create table t1(a int not null) engine=innodb; insert into t1 values (1); +--enable_info alter table t1 add primary key(a); +--disable_info insert into t1 values (2); show create table t1; check table t1; commit; select * from t1; +analyze table t1; explain select * from t1; explain select * from t1 order by a; drop table t1; -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; - -# r2667 The following test is disabled because MySQL behavior changed. -# r2667 The test was added with this comment: -# r2667 -# r2667 ------------------------------------------------------------------------ -# r2667 r1699 | marko | 2007-08-10 19:53:19 +0300 (Fri, 10 Aug 2007) | 5 lines -# r2667 -# r2667 branches/zip: Add changes that accidentally omitted from r1698: -# r2667 -# r2667 innodb-index.test, innodb-index.result: Add a test for creating -# r2667 a PRIMARY KEY on a column that contains a NULL value. -# r2667 ------------------------------------------------------------------------ -# r2667 -# r2667 but in BZR-r2667: -# r2667 http://bazaar.launchpad.net/~mysql/mysql-server/mysql-5.1/revision/davi%40mysql.com-20080617141221-8yre8ys9j4uw3xx5?start_revid=joerg%40mysql.com-20080630105418-7qoe5ehomgrcdb89 -# r2667 MySQL changed the behavior to do full table copy when creating PRIMARY INDEX -# r2667 on a non-NULL column instead of calling ::add_index() which would fail (and -# r2667 this is what we were testing here). Before r2667 the code execution path was -# r2667 like this (when adding PRIMARY INDEX on a non-NULL column with ALTER TABLE): -# r2667 -# r2667 mysql_alter_table() -# r2667 compare_tables() // would return ALTER_TABLE_INDEX_CHANGED -# r2667 ::add_index() // would fail with "primary index cannot contain NULL" -# r2667 -# r2667 after r2667 the code execution path is the following: -# r2667 -# r2667 mysql_alter_table() -# r2667 compare_tables() // returns ALTER_TABLE_DATA_CHANGED -# r2667 full copy is done, without calling ::add_index() -# r2667 -# r2667 To enable, remove "# r2667: " below. -# r2667 -# r2667: insert into t1 values (null,null,null,'null'); -insert into t1 -select a,left(repeat(d,100*a),65535),repeat(d,20*a),d from t2,t3; -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; -# r2667: --error ER_PRIMARY_CANT_HAVE_NULL -# r2667: alter table t1 add primary key (a), add key (b(20)); -# r2667: 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; -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; -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; - -set global innodb_file_per_table=on; -set global innodb_file_format='Barracuda'; -# Test creating a table that could lead to undo log overflow. -# In the undo log, we write a 768-byte prefix (REC_MAX_INDEX_COL_LEN) -# of each externally stored column that appears as a column prefix in an index. -# For this test case, it would suffice to write 1 byte, though. -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; -create index t1a on t1 (a(767)); -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)); -create index t1f on t1 (f(767)); -create index t1g on t1 (g(767)); -create index t1h on t1 (h(767)); -create index t1i on t1 (i(767)); -create index t1j on t1 (j(767)); -create index t1k on t1 (k(767)); -create index t1l on t1 (l(767)); -create index t1m on t1 (m(767)); -create index t1n on t1 (n(767)); -create index t1o on t1 (o(767)); -create index t1p on t1 (p(767)); -create index t1q on t1 (q(767)); -create index t1r on t1 (r(767)); -create index t1s on t1 (s(767)); -create index t1t on t1 (t(767)); ---error 139 -create index t1u on t1 (u(767)); ---error 139 -create index t1ut on t1 (u(767), t(767)); -create index t1st on t1 (s(767), t(767)); -show create table t1; ---error 139 -create index t1u on t1 (u(767)); -alter table t1 row_format=compact; -create index t1u on t1 (u(767)); - -drop table t1; - -# Bug#12547647 UPDATE LOGGING COULD EXCEED LOG PAGE SIZE -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 infinite undo log allocation. ---error ER_UNDO_RECORD_TOO_BIG -UPDATE bug12547647 SET c = REPEAT('b',16928); -DROP TABLE bug12547647; - eval set global innodb_file_per_table=$per_table; eval set global innodb_file_format=$format; eval set global innodb_file_format_max=$format; @@ -546,7 +345,7 @@ eval set global innodb_file_format_max=$format; # constraint modifications (Issue #70, Bug #38786) # SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; -SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; +SET FOREIGN_KEY_CHECKS=0; CREATE TABLE t1( c1 BIGINT(12) NOT NULL, @@ -589,8 +388,10 @@ CREATE TABLE t2( PRIMARY KEY (c1,c2,c3) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +SET FOREIGN_KEY_CHECKS=0; ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3) REFERENCES t1(c1); +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SHOW CREATE TABLE t2; @@ -620,26 +421,59 @@ CREATE TABLE t2( PRIMARY KEY (c1) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ---replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/ +SET FOREIGN_KEY_CHECKS=0; +--enable_info + +# mysqltest first does replace_regex, then replace_result +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLD_DATADIR ./ master-data/ '' --error ER_CANT_CREATE_TABLE ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca + FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1), ALGORITHM=COPY; +--error ER_FK_NO_INDEX_PARENT +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1); ---replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/ +# mysqltest first does replace_regex, then replace_result +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLD_DATADIR ./ master-data/ '' --error ER_CANT_CREATE_TABLE ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca + FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2), ALGORITHM=COPY; +--error ER_FK_NO_INDEX_PARENT +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2); ---replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/ + +--error ER_FK_INCORRECT_OPTION +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca + FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1), ALGORITHM=INPLACE; + +# mysqltest first does replace_regex, then replace_result +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLD_DATADIR ./ master-data/ '' --error ER_CANT_CREATE_TABLE ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca - FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1); + FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1), ALGORITHM=COPY; + ALTER TABLE t1 MODIFY COLUMN c2 BIGINT(12) NOT NULL; ---replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/ +# mysqltest first does replace_regex, then replace_result +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLD_DATADIR ./ master-data/ '' --error ER_CANT_CREATE_TABLE ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca + FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2), ALGORITHM=COPY; +--error ER_FK_NO_INDEX_PARENT +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2); ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1); + +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; + SHOW CREATE TABLE t1; SHOW CREATE TABLE t2; CREATE INDEX i_t2_c2_c1 ON t2(c2, c1); @@ -648,40 +482,84 @@ CREATE INDEX i_t2_c3_c1_c2 ON t2(c3, c1, c2); SHOW CREATE TABLE t2; CREATE INDEX i_t2_c3_c2 ON t2(c3, c2); SHOW CREATE TABLE t2; +--disable_info DROP TABLE t2; DROP TABLE t1; -# 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 CREATE INDEX t1a ON t1(a); causes a lock wait timeout -# start disabled45225_2 -#connect (a,localhost,root,,); -#connect (b,localhost,root,,); -#connection a; -#CREATE TABLE t1 (a INT, b CHAR(1)) ENGINE=InnoDB; -#INSERT INTO t1 VALUES (3,'a'),(3,'b'),(1,'c'),(0,'d'),(1,'e'); -#connection b; -#BEGIN; -#SELECT * FROM t1; -#connection a; -#CREATE INDEX t1a ON t1(a); -#connection b; -#SELECT * FROM t1; -#--error ER_TABLE_DEF_CHANGED -#SELECT * FROM t1 FORCE INDEX(t1a) ORDER BY a; -#SELECT * FROM t1; -#COMMIT; -#SELECT * FROM t1 FORCE INDEX(t1a) ORDER BY a; -#connection default; -#disconnect a; -#disconnect b; -# -#DROP TABLE t1; -# end disabled45225_2 -#this delay is needed because 45225_2 is disabled, to allow the purge to run -SELECT SLEEP(10); -DROP TABLE t1_purge, t2_purge, t3_purge, t4_purge; -DROP TABLE t12637786; -DROP TABLE t12963823; +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +CREATE TABLE t1 (a INT, b CHAR(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (3,'a'),(3,'b'),(1,'c'),(0,'d'),(1,'e'); +CREATE TABLE t2 (a INT, b CHAR(1)) ENGINE=InnoDB; +CREATE TABLE t2i (a INT, b CHAR(1) NOT NULL) ENGINE=InnoDB; +CREATE TABLE t2c (a INT, b CHAR(1) NOT NULL) ENGINE=InnoDB; +INSERT INTO t2 SELECT * FROM t1; +INSERT INTO t2i SELECT * FROM t1; +INSERT INTO t2c SELECT * FROM t1; +connection b; +BEGIN; +# This acquires a MDL lock on t1 until commit. +SELECT * FROM t1; +connection a; +# This times out before of the MDL lock held by connection b. +SET lock_wait_timeout=1; +--error ER_LOCK_WAIT_TIMEOUT +CREATE INDEX t1a ON t1(a); +--enable_info +CREATE INDEX t2a ON t2(a); +--disable_info +set @old_sql_mode = @@sql_mode; +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +# And adding a PRIMARY KEY will also add NOT NULL implicitly! +set @@sql_mode = 'STRICT_TRANS_TABLES'; +--enable_info +ALTER TABLE t2i ADD PRIMARY KEY(a,b), ADD INDEX t2a(a), ALGORITHM=INPLACE; +--disable_info +set @@sql_mode = @old_sql_mode; +--enable_info +ALTER TABLE t2c ADD PRIMARY KEY(a,b), ADD INDEX t2a(a), ALGORITHM=COPY; +--disable_info +connection b; +# t2i and t2c are too new for this transaction, because they were rebuilt +--error ER_TABLE_DEF_CHANGED +SELECT * FROM t2i; +--error ER_TABLE_DEF_CHANGED +SELECT * FROM t2i FORCE INDEX(t2a) ORDER BY a; +--error ER_TABLE_DEF_CHANGED +SELECT * FROM t2c; +--error ER_TABLE_DEF_CHANGED +SELECT * FROM t2c FORCE INDEX(t2a) ORDER BY a; +# In t2, only the new index t2a is too new for this transaction. +SELECT * FROM t2; +--error ER_TABLE_DEF_CHANGED +SELECT * FROM t2 FORCE INDEX(t2a) ORDER BY a; +SELECT * FROM t2; +COMMIT; +# For a new transaction, all of t2, t2i, t2c are accessible. +SELECT * FROM t2; +SELECT * FROM t2 FORCE INDEX(t2a) ORDER BY a; +SELECT * FROM t2i; +SELECT * FROM t2i FORCE INDEX(t2a) ORDER BY a; +SELECT * FROM t2c; +SELECT * FROM t2c FORCE INDEX(t2a) ORDER BY a; +connection default; +disconnect a; +disconnect b; + +--error ER_DUP_KEYNAME +alter table t2 add index t2a(b); +alter table t2 drop index t2a, add index t2a(b); +show create table t2; +show create table t2i; +show create table t2c; + +--disable_info + +DROP TABLE t1,t2,t2c,t2i; + +--disable_query_log +eval SET GLOBAL innodb_file_format=$innodb_file_format_orig; +eval SET GLOBAL innodb_file_format_max=$innodb_file_format_max_orig; +--enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb-mdev-7408.opt b/mysql-test/suite/innodb/t/innodb-mdev-7408.opt new file mode 100644 index 00000000000..1c256483e10 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-mdev-7408.opt @@ -0,0 +1,2 @@ +--innodb_ft_default_stopword + diff --git a/mysql-test/suite/innodb/t/innodb-mdev-7408.test b/mysql-test/suite/innodb/t/innodb-mdev-7408.test new file mode 100644 index 00000000000..d1cd1879bb1 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-mdev-7408.test @@ -0,0 +1,16 @@ +--source include/have_innodb.inc + +select @@global.innodb_ft_server_stopword_table; +CREATE TABLE `stop_it-IT` ENGINE = InnoDB SELECT * FROM information_schema.INNODB_FT_DEFAULT_STOPWORD; +--error 1231 +SET @@global.innodb_ft_server_stopword_table = 'test/stop_it-IT'; +--error 0,1231 +SET @@global.innodb_ft_server_stopword_table = 'test/stop_it@002dIT'; +drop table `stop_it-IT`; + +CREATE TABLE stop_it ENGINE = InnoDB SELECT * FROM information_schema.INNODB_FT_DEFAULT_STOPWORD; +SET @@global.innodb_ft_server_stopword_table = 'test/stop_it'; + +SET @@global.innodb_ft_server_stopword_table = NULL; + +drop table stop_it; diff --git a/mysql-test/suite/innodb/t/innodb-mdev7046.test b/mysql-test/suite/innodb/t/innodb-mdev7046.test new file mode 100644 index 00000000000..b4085228e02 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-mdev7046.test @@ -0,0 +1,50 @@ +--source include/have_innodb.inc +--source include/have_partition.inc +# Test causes OS error printout +--source include/not_windows.inc + +--disable_query_log +--disable_result_log +--disable_warnings + + +# Ignore OS errors +call mtr.add_suppression("InnoDB: File ./test/t1*"); +call mtr.add_suppression("InnoDB: Error number*"); +call mtr.add_suppression("InnoDB: File ./test/t1#p#p1#sp#p1sp0.ibd: 'rename' returned OS error*"); + +# MDEV-7046: MySQL#74480 - Failing assertion: os_file_status(newpath, &exists, &type) +# after Operating system error number 36 in a file operation + +USE test; +create table t1(f1 INT,f2 INT,f3 CHAR (10),primary key(f1,f2)) partition by range(f1) subpartition by hash(f2) subpartitions 2 (partition p1 values less than (0),partition p2 values less than (2),partition p3 values less than (2147483647)); +--replace_regex /'.*t2_new.*'/'t2_new'/ +--error 7 +RENAME TABLE t1 TO `t2_new..............................................end`; +alter table t1 engine=innodb; +--replace_regex /'.*t2_new.*'/'t2_new'/ +--error 1025 +RENAME TABLE t1 TO `t2_new..............................................end`; +--replace_regex /'.*t2_new.*'/'t2_new'/ +show warnings; +drop table t1; + +DROP DATABASE test;CREATE DATABASE test;USE test; +SET @@session.storage_engine=MYISAM; +--error 0,1,1103 +CREATE TABLE t1(id INT,purchased DATE)PARTITION BY RANGE(YEAR(purchased)) SUBPARTITION BY HASH(TO_DAYS(purchased)) SUBPARTITIONS 2 (PARTITION p0 VALUES LESS THAN MAXVALUE (SUBPARTITION sp0 DATA DIRECTORY='/tmp/not-existing' INDEX DIRECTORY='/tmp/not-existing',SUBPARTITION sp1)); +drop table if exists t1; +CREATE TABLE t1(id INT,purchased DATE)PARTITION BY RANGE(YEAR(purchased)) SUBPARTITION BY HASH(TO_DAYS(purchased)) SUBPARTITIONS 2 (PARTITION p0 VALUES LESS THAN MAXVALUE (SUBPARTITION sp0,SUBPARTITION sp1)); +ALTER TABLE t1 ENGINE=InnoDB; + +drop table t1; + +let $datadir=`select @@datadir`; +--remove_file $datadir/test/db.opt + +--enable_query_log +--enable_result_log +--enable_warnings + +# make sure that we have at least some ouput to avoid mtr warning +--echo 1 diff --git a/mysql-test/suite/innodb/t/innodb-stats-initialize-failure.test b/mysql-test/suite/innodb/t/innodb-stats-initialize-failure.test new file mode 100644 index 00000000000..e480f0caf07 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-stats-initialize-failure.test @@ -0,0 +1,39 @@ +# MDEV-6424: Mariadb server crashes with assertion failure in file ha_innodb.cc +--source include/have_innodb.inc + +# DEBUG_SYNC must be compiled in. +--source include/have_debug_sync.inc + +call mtr.add_suppression("InnoDB: Warning: Index.*"); +# This caused crash earlier +set DEBUG_DBUG='+d,ib_ha_innodb_stat_not_initialized'; +create table t1(a int not null primary key, b int, c int, key(b), key(c)) engine=innodb; + +delimiter //; +create procedure innodb_insert_proc (repeat_count int) +begin + declare current_num int; + set current_num = 0; + while current_num < repeat_count do + insert into t1 values(current_num, current_num, current_num); + set current_num = current_num + 1; + end while; +end// +delimiter ;// +commit; + +set autocommit=0; +call innodb_insert_proc(10000); +commit; +set autocommit=1; + +select count(1) from t1; +select count(1) from t1 where a between 5 and 100; +select count(1) from t1 where b between 5 and 256; +select count(1) from t1 where c between 7 and 787; + +set DEBUG_DBUG=NULL; + +drop procedure innodb_insert_proc; +drop table t1; + diff --git a/mysql-test/suite/innodb/t/innodb-stats-modified-counter.opt b/mysql-test/suite/innodb/t/innodb-stats-modified-counter.opt new file mode 100644 index 00000000000..3e5b41c6db9 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-stats-modified-counter.opt @@ -0,0 +1 @@ +--loose-innodb-sys-tablestats diff --git a/mysql-test/suite/innodb/t/innodb-stats-modified-counter.test b/mysql-test/suite/innodb/t/innodb-stats-modified-counter.test new file mode 100644 index 00000000000..b3e45002768 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-stats-modified-counter.test @@ -0,0 +1,28 @@ +-- source include/have_innodb.inc + +# +# MDEV-8297: information_schema.innodb_sys_tablestats.modified_counter doesn't change on UPDATE +# + +set global innodb_stats_auto_recalc=off; + +CREATE TABLE t1 (i int) ENGINE=InnoDB; + +SELECT NAME, STATS_INITIALIZED, NUM_ROWS, MODIFIED_COUNTER FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS WHERE NAME = 'test/t1'; + +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); + +SELECT NAME, STATS_INITIALIZED, NUM_ROWS, MODIFIED_COUNTER FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS WHERE NAME = 'test/t1'; + +DELETE FROM t1 WHERE i = 1; + +SELECT NAME, STATS_INITIALIZED, NUM_ROWS, MODIFIED_COUNTER FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS WHERE NAME = 'test/t1'; + +UPDATE t1 SET i = 4 WHERE i = 2; + +SELECT NAME, STATS_INITIALIZED, NUM_ROWS, MODIFIED_COUNTER FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS WHERE NAME = 'test/t1'; + +DROP TABLE t1; + +set global innodb_stats_auto_recalc=default; diff --git a/mysql-test/suite/innodb/t/innodb-virtual-columns.test b/mysql-test/suite/innodb/t/innodb-virtual-columns.test new file mode 100644 index 00000000000..368c6fc8cb1 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-virtual-columns.test @@ -0,0 +1,302 @@ +--source include/have_innodb.inc + +# +# MDEV-7367: Updating a virtual column corrupts table which crashes server +# MySQL table columns contains virtual columns but InnoDB table +# definition does not. +# +CREATE TABLE IF NOT EXISTS gso_grad_supr ( + term char(4) NOT NULL DEFAULT '', + uw_id int(8) UNSIGNED NOT NULL DEFAULT 0, + plan varchar(10) NOT NULL DEFAULT '', + wdraw_rsn varchar(4) NOT NULL DEFAULT '', + admit_term char(4) NOT NULL DEFAULT '', + CONSTRAINT gso_grad_supr_pky PRIMARY KEY (uw_id, term) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO `gso_grad_supr` VALUES ('1031',2,'CSM','','1009'); +INSERT INTO `gso_grad_supr` VALUES ('1035',2,'CSM','ACAD','1009'); + +CREATE TABLE IF NOT EXISTS grad_degree ( + student_id int(8) UNSIGNED NOT NULL, + plan varchar(10) NOT NULL, + admit_term char(4) NOT NULL, + wdraw_rsn varchar(4) NOT NULL DEFAULT '', + ofis_deg_status varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed' + ELSE 'Not Completed' + END) VIRTUAL, + deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data', + deg_as_of_term char(4) NOT NULL COMMENT 'In most cases also end term', + CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE INDEX grad_degree_wdraw_rsn_ndx ON grad_degree (wdraw_rsn); +CREATE INDEX grad_degree_as_of_term_ndx ON grad_degree (deg_as_of_term); + +INSERT IGNORE grad_degree ( + student_id, + plan, + admit_term, + wdraw_rsn, + deg_start_term, + deg_as_of_term +) +SELECT + ggs.uw_id AS c_student_id, + ggs.plan, + ggs.admit_term, + ggs.wdraw_rsn, + IF( (SELECT COUNT(*) FROM grad_degree AS gd WHERE gd.student_id = ggs.uw_id AND gd.admit_term = ggs.admit_term) > 0, ggs.term, ggs.admit_term ) AS c_deg_start_term, + ggs.term AS c_as_of_term +FROM gso_grad_supr AS ggs +LEFT OUTER JOIN + grad_degree AS gd + ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term ) +WHERE + ggs.term = 1031 AND + gd.student_id IS NULL +; + +UPDATE grad_degree AS gd +INNER JOIN + gso_grad_supr AS ggs + ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term ) +SET + gd.wdraw_rsn = ggs.wdraw_rsn, + gd.deg_as_of_term = 1035 +WHERE + gd.wdraw_rsn NOT IN ('DCMP', 'TRDC') AND + ggs.term = 1035 +; + +drop table grad_degree; + +# +# Test with more virtual columns so that MySQL table has +# more columns than InnoDB and index definition is out +# of number of actual InnoDB columns. +# +CREATE TABLE IF NOT EXISTS grad_degree ( + student_id int(8) UNSIGNED NOT NULL, + plan varchar(10) NOT NULL, + admit_term char(4) NOT NULL, + wdraw_rsn varchar(4) NOT NULL DEFAULT '', + ofis_deg_status varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed' + ELSE 'Not Completed' + END) VIRTUAL, + ofis_deg_status2 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress2' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed2' + ELSE 'Not Completed2' + END) VIRTUAL, + ofis_deg_status3 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress3' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed3' + ELSE 'Not Completed3' + END) VIRTUAL, + ofis_deg_status4 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress4' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed4' + ELSE 'Not Completed4' + END) VIRTUAL, + ofis_deg_status5 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress5' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed5' + ELSE 'Not Completed5' + END) VIRTUAL, + ofis_deg_status6 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress6' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed6' + ELSE 'Not Completed6' + END) VIRTUAL, + ofis_deg_status7 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress7' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed7' + ELSE 'Not Completed7' + END) VIRTUAL, + ofis_deg_status8 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress8' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed8' + ELSE 'Not Completed8' + END) VIRTUAL, + deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data', + deg_as_of_term char(4) NOT NULL COMMENT 'In most cases also end term', + CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE INDEX grad_degree_wdraw_rsn_ndx ON grad_degree (wdraw_rsn); +CREATE INDEX grad_degree_as_of_term_ndx ON grad_degree (deg_as_of_term); + +INSERT IGNORE grad_degree ( + student_id, + plan, + admit_term, + wdraw_rsn, + deg_start_term, + deg_as_of_term +) +SELECT + ggs.uw_id AS c_student_id, + ggs.plan, + ggs.admit_term, + ggs.wdraw_rsn, + IF( (SELECT COUNT(*) FROM grad_degree AS gd WHERE gd.student_id = ggs.uw_id AND gd.admit_term = ggs.admit_term) > 0, ggs.term, ggs.admit_term ) AS c_deg_start_term, + ggs.term AS c_as_of_term +FROM gso_grad_supr AS ggs +LEFT OUTER JOIN + grad_degree AS gd + ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term ) +WHERE + ggs.term = 1031 AND + gd.student_id IS NULL +; + +UPDATE grad_degree AS gd +INNER JOIN + gso_grad_supr AS ggs + ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term ) +SET + gd.wdraw_rsn = ggs.wdraw_rsn, + gd.deg_as_of_term = 1035 +WHERE + gd.wdraw_rsn NOT IN ('DCMP', 'TRDC') AND + ggs.term = 1035 +; + +# +# Verify that indexes can be dropped +# +ALTER TABLE grad_degree DROP INDEX grad_degree_wdraw_rsn_ndx; + +# +# Verify that we can drop columns +# +ALTER TABLE grad_degree DROP COLUMN deg_start_term; + +SHOW CREATE TABLE grad_degree; + +DROP TABLE grad_degree; + +# +# Verify after dropping virtual columns +# +CREATE TABLE IF NOT EXISTS grad_degree ( + student_id int(8) UNSIGNED NOT NULL, + plan varchar(10) NOT NULL, + admit_term char(4) NOT NULL, + wdraw_rsn varchar(4) NOT NULL DEFAULT '', + ofis_deg_status varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed' + ELSE 'Not Completed' + END) VIRTUAL, + ofis_deg_status2 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress2' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed2' + ELSE 'Not Completed2' + END) VIRTUAL, + ofis_deg_status3 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress3' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed3' + ELSE 'Not Completed3' + END) VIRTUAL, + ofis_deg_status4 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress4' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed4' + ELSE 'Not Completed4' + END) VIRTUAL, + ofis_deg_status5 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress5' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed5' + ELSE 'Not Completed5' + END) VIRTUAL, + ofis_deg_status6 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress6' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed6' + ELSE 'Not Completed6' + END) VIRTUAL, + ofis_deg_status7 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress7' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed7' + ELSE 'Not Completed7' + END) VIRTUAL, + ofis_deg_status8 varchar(15) AS ( + CASE + WHEN wdraw_rsn = '' THEN 'In progress8' + WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed8' + ELSE 'Not Completed8' + END) VIRTUAL, + deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data', + deg_as_of_term char(4) NOT NULL COMMENT 'In most cases also end term', + CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE INDEX grad_degree_wdraw_rsn_ndx ON grad_degree (wdraw_rsn); + +ALTER TABLE grad_degree DROP COLUMN ofis_deg_status2, DROP COLUMN ofis_deg_status3, +DROP COLUMN ofis_deg_status4, DROP COLUMN ofis_deg_status5, DROP COLUMN ofis_deg_status6, +DROP COLUMN ofis_deg_status7, DROP COLUMN ofis_deg_status8; + +CREATE INDEX grad_degree_as_of_term_ndx ON grad_degree (deg_as_of_term); + +INSERT IGNORE grad_degree ( + student_id, + plan, + admit_term, + wdraw_rsn, + deg_start_term, + deg_as_of_term +) +SELECT + ggs.uw_id AS c_student_id, + ggs.plan, + ggs.admit_term, + ggs.wdraw_rsn, + IF( (SELECT COUNT(*) FROM grad_degree AS gd WHERE gd.student_id = ggs.uw_id AND gd.admit_term = ggs.admit_term) > 0, ggs.term, ggs.admit_term ) AS c_deg_start_term, + ggs.term AS c_as_of_term +FROM gso_grad_supr AS ggs +LEFT OUTER JOIN + grad_degree AS gd + ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term ) +WHERE + ggs.term = 1031 AND + gd.student_id IS NULL +; + +UPDATE grad_degree AS gd +INNER JOIN + gso_grad_supr AS ggs + ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term ) +SET + gd.wdraw_rsn = ggs.wdraw_rsn, + gd.deg_as_of_term = 1035 +WHERE + gd.wdraw_rsn NOT IN ('DCMP', 'TRDC') AND + ggs.term = 1035 +; + +select * from grad_degree; +select * from gso_grad_supr; + +drop table grad_degree; +drop table gso_grad_supr; diff --git a/mysql-test/suite/innodb/t/innodb-wl5522-1.test b/mysql-test/suite/innodb/t/innodb-wl5522-1.test new file mode 100644 index 00000000000..b1db34976a9 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-wl5522-1.test @@ -0,0 +1,952 @@ +# Not supported in embedded +--source include/not_embedded.inc + +-- source include/have_innodb.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +let MYSQLD_DATADIR =`SELECT @@datadir`; +let $innodb_file_per_table = `SELECT @@innodb_file_per_table`; +let $innodb_file_format = `SELECT @@innodb_file_format`; + +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +SET GLOBAL innodb_file_format = `Barracuda`; +SELECT @@innodb_file_format; + +let $MYSQLD_DATADIR = `SELECT @@datadir`; + +# Following testcases are created from JET cases (where import +# export instance are differnt server ) +# Here test will be run on same import and export instance. + +DROP DATABASE IF EXISTS testdb_wl5522; +CREATE DATABASE testdb_wl5522; + +# case 1 +CREATE TABLE testdb_wl5522.t1 (c1 INT ) ENGINE = Innodb; +INSERT INTO testdb_wl5522.t1 VALUES (1),(123),(331); +SELECT c1 FROM testdb_wl5522.t1; +FLUSH TABLES testdb_wl5522.t1 FOR EXPORT; +SELECT * FROM testdb_wl5522.t1 ORDER BY c1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1; +CREATE TABLE testdb_wl5522.t1 (c1 INT ) ENGINE = Innodb; +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; +SELECT * FROM testdb_wl5522.t1 ORDER BY c1; +DROP TABLE testdb_wl5522.t1; + +# case 2 +CREATE TABLE testdb_wl5522.t1 ( +col1 BIT(1), +col2 BOOLEAN, +col3 TINYINT, +col4 SMALLINT, +col5 MEDIUMINT, +col6 INT, +col7 BIGINT, +col8 FLOAT (14,3) , +col9 DOUBLE (14,3), +col10 VARCHAR(20), +col11 TEXT , +col12 ENUM('a','b','c'), +col13 TEXT, +col14 CHAR(20) , +col15 VARBINARY (400) , +col16 BINARY(40), +col17 BLOB (400) , +col18 INT NOT NULL PRIMARY KEY, +col19 DATE , +col20 DATETIME , +col21 TIMESTAMP , +col22 TIME , +col23 YEAR ) ENGINE = Innodb; + +CREATE INDEX idx1 ON testdb_wl5522.t1(col18); +CREATE INDEX prefix_idx ON testdb_wl5522.t1(col14 (10)); +CREATE UNIQUE INDEX idx2 ON testdb_wl5522.t1(col12); +CREATE UNIQUE INDEX idx3 ON testdb_wl5522.t1(col8); +INSERT INTO testdb_wl5522.t1 VALUES +(1,1,-128,32767,-8388608,2147483647,-9223372036854775808, 92233720368.222, +-92233720368.222,'aaa', + 'aaaaaaaaaa','b','bbbbb','ccccc', +REPEAT('d',40),REPEAT('d',40),REPEAT('d',40),1,'1000-01-01', +'3000-12-31 23:59:59.99','1990-01-01 00:00:01.00', +'01:59:59.00','1901'); +INSERT INTO testdb_wl5522.t1 VALUES +(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, +NULL,NULL,NULL,3,NULL,NULL,NULL,NULL,NULL); +--error 1048 +INSERT INTO testdb_wl5522.t1 VALUES (NULL,NULL,NULL,NULL,NULL,NULL,NULL, +NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +--error 1062 +INSERT INTO testdb_wl5522.t1 VALUES (NULL,NULL,NULL,NULL,NULL,NULL,NULL, +NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,NULL,NULL,NULL,NULL,NULL); + +FLUSH TABLES testdb_wl5522.t1 WITH READ LOCK; +SELECT COUNT(*) FROM testdb_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1; + +CREATE TABLE testdb_wl5522.t1 ( +col1 BIT(1), +col2 BOOLEAN, +col3 TINYINT, +col4 SMALLINT, +col5 MEDIUMINT, +col6 INT, +col7 BIGINT, +col8 FLOAT (14,3) , +col9 DOUBLE (14,3), +col10 VARCHAR(20), +col11 TEXT, +col12 ENUM('a','b','c'), +col13 TEXT, +col14 CHAR(20) , +col15 VARBINARY (400) , +col16 BINARY(40), +col17 BLOB (400) , +col18 INT NOT NULL PRIMARY KEY, +col19 DATE , +col20 DATETIME , +col21 TIMESTAMP , +col22 TIME , +col23 YEAR ) ENGINE = Innodb; + +CREATE INDEX idx1 ON testdb_wl5522.t1(col18); +CREATE INDEX prefix_idx ON testdb_wl5522.t1(col14 (10)); +CREATE UNIQUE INDEX idx2 ON testdb_wl5522.t1(col12); +CREATE UNIQUE INDEX idx3 ON testdb_wl5522.t1(col8); + +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; +CHECK TABLE testdb_wl5522.t1; + +SELECT COUNT(*) FROM testdb_wl5522.t1; + +DROP TABLE testdb_wl5522.t1; + + +# case 3 - with blob objects + +SET GLOBAL innodb_file_format='Barracuda'; + +CREATE TABLE testdb_wl5522.t1 ( +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 testdb_wl5522.t1 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) , +col_3_text = REPEAT("a", 4000) , +col_4_blob = REPEAT("o", 4000) , +col_5_text = REPEAT("a", 4000) , +col_6_varchar = REPEAT("a", 4000) , +col_7_binary = REPEAT("a", 255) +FROM testdb_wl5522.t1; +FLUSH TABLES testdb_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1; + +CREATE TABLE testdb_wl5522.t1 ( +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; + +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; + +SELECT col_1_varbinary = REPEAT("a", 4000) , +col_2_varchar = REPEAT("o", 4000) , +col_3_text = REPEAT("a", 4000) , +col_4_blob = REPEAT("o", 4000) , +col_5_text = REPEAT("a", 4000) , +col_6_varchar = REPEAT("a", 4000) , +col_7_binary = REPEAT("a", 255) +FROM testdb_wl5522.t1; + +DROP TABLE testdb_wl5522.t1; + +# case 4 - trasportable tablesace with autoincrement +CREATE TABLE testdb_wl5522.t1 ( +col_1_int INT AUTO_INCREMENT, +col_2_varchar VARCHAR (20), +PRIMARY KEY (col_1_int)) ENGINE = Innodb; + +INSERT INTO testdb_wl5522.t1 VALUES (1,'a1'),(2,'a2'),(3,'a3'); +INSERT INTO testdb_wl5522.t1 (col_2_varchar) VALUES ('a4'),('a5'),('a6'); + +SELECT * FROM testdb_wl5522.t1 ORDER BY col_1_int; +FLUSH TABLES testdb_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1; + +CREATE TABLE testdb_wl5522.t1 ( +col_1_int INT AUTO_INCREMENT, +col_2_varchar VARCHAR (20), +PRIMARY KEY (col_1_int)) ENGINE = Innodb; +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; +SELECT * FROM testdb_wl5522.t1 ORDER BY col_1_int; + +# error on inserting duplicate value +--error 1062 +INSERT INTO testdb_wl5522.t1 VALUES (1,'a1'); +# insert new values +INSERT INTO testdb_wl5522.t1(col_2_varchar) VALUES ('a101'),('a102'),('a103'); +SELECT * FROM testdb_wl5522.t1 ORDER BY col_1_int; +# check table can be altered +ALTER TABLE testdb_wl5522.t1 MODIFY col_1_int BIGINT; +SELECT * FROM testdb_wl5522.t1 ORDER BY col_1_int; + +DROP TABLE testdb_wl5522.t1; + +# case 5 - check with primary and foreign key +CREATE TABLE testdb_wl5522.t1 ( +col_1_int INT,col_2_varchar VARCHAR (20), +PRIMARY KEY (col_2_varchar)) ENGINE = Innodb; + +CREATE TABLE testdb_wl5522.t1_fk ( +col_1_int INT,col_2_varchar VARCHAR (20), +PRIMARY KEY (col_1_int), +FOREIGN KEY (col_2_varchar) REFERENCES testdb_wl5522.t1(col_2_varchar) +) ENGINE = Innodb; + + +INSERT INTO testdb_wl5522.t1 VALUES (1,'a1'),(2,'a2'),(3,'a3'),(4,'a4'),(5,'a5'); +INSERT INTO testdb_wl5522.t1_fk VALUES (1,'a1'),(2,'a2'),(3,'a3'); + +SELECT * FROM testdb_wl5522.t1; +SELECT * FROM testdb_wl5522.t1_fk; +FLUSH TABLES testdb_wl5522.t1,testdb_wl5522.t1_fk FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +ib_backup_tablespaces("testdb_wl5522", "t1_fk"); +EOF + +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1_fk,testdb_wl5522.t1; + +CREATE TABLE testdb_wl5522.t1 ( +col_1_int INT,col_2_varchar VARCHAR (20), +PRIMARY KEY (col_2_varchar)) ENGINE = Innodb; + +CREATE TABLE testdb_wl5522.t1_fk ( +col_1_int INT,col_2_varchar VARCHAR (20), +PRIMARY KEY (col_1_int), +FOREIGN KEY (col_2_varchar) REFERENCES testdb_wl5522.t1(col_2_varchar) +) ENGINE = Innodb; + +# Alter table discrad table is not allowed with foreign_key_checks = 1 +SET foreign_key_checks = 0; +ALTER TABLE testdb_wl5522.t1_fk DISCARD TABLESPACE; +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; +SET foreign_key_checks = 1; + + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_discard_tablespaces("testdb_wl5522", "t1_fk"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1_fk"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; +ALTER TABLE testdb_wl5522.t1_fk IMPORT TABLESPACE; +SELECT * FROM testdb_wl5522.t1; +SELECT * FROM testdb_wl5522.t1_fk; + +# Enter Invalid value: PK-FK relationship violation +--error 1452 +INSERT INTO testdb_wl5522.t1_fk VALUES (100,'a100'); + +SET AUTOCOMMIT = 0; +INSERT INTO testdb_wl5522.t1_fk VALUES (4,'a4'),(5,'a5'); +ROLLBACK; +SELECT * FROM testdb_wl5522.t1_fk; + +DROP TABLE testdb_wl5522.t1_fk,testdb_wl5522.t1; +SET AUTOCOMMIT = 1; + + +# case 6 - transporatbale tablespace with transactions +CREATE TABLE testdb_wl5522.t1 ( +col_1_int int,col_2_varchar VARCHAR (20), +PRIMARY KEY (col_2_varchar)) ENGINE = Innodb; +SET AUTOCOMMIT = 0; +INSERT INTO testdb_wl5522.t1 VALUES (1,'a1'),(2,'a2'); +SELECT * FROM testdb_wl5522.t1; +COMMIT; +INSERT INTO testdb_wl5522.t1 VALUES (3,'a3'),(4,'a4'); +ROLLBACK; +INSERT INTO testdb_wl5522.t1 VALUES (5,'a5'),(6,'a6'); +COMMIT; +SELECT * FROM testdb_wl5522.t1 ORDER BY col_1_int; +FLUSH TABLES testdb_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1; +CREATE TABLE testdb_wl5522.t1 ( +col_1_int int,col_2_varchar VARCHAR (20), +PRIMARY KEY (col_2_varchar)) ENGINE = Innodb; +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; +SET AUTOCOMMIT = 0; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; + + +INSERT INTO testdb_wl5522.t1 VALUES (7,'a7'),(8,'a8'); +COMMIT; +INSERT INTO testdb_wl5522.t1 VALUES (9,'a9'),(10,'a10'); +ROLLBACK; +INSERT INTO testdb_wl5522.t1 VALUES (11,'a11'),(12,'a12'); +COMMIT; +SELECT * FROM testdb_wl5522.t1 ORDER BY col_1_int; +SET AUTOCOMMIT = 1; + +DROP TABLE testdb_wl5522.t1; + +#case 7 - transpotable tablespace with transaction(earlier failed with jet) + +CREATE TABLE testdb_wl5522.t1 ( i int ) ENGINE = Innodb; +INSERT INTO testdb_wl5522.t1 VALUES (100),(200),(300); +SELECT * FROM testdb_wl5522.t1 ORDER BY i; +FLUSH TABLES testdb_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1; +CREATE TABLE testdb_wl5522.t1 ( i int ) ENGINE = Innodb; +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; +SELECT * FROM testdb_wl5522.t1 ORDER BY i; +SET AUTOCOMMIT = 0; +INSERT INTO testdb_wl5522.t1 VALUES (101),(102),(103); +COMMIT; +SELECT * FROM testdb_wl5522.t1 ORDER BY i; +SET AUTOCOMMIT = 1; +DROP TABLE testdb_wl5522.t1; + + +# case 8 - negative cases +CREATE TABLE testdb_wl5522.t1 ( i int ) ENGINE = Innodb; +INSERT INTO testdb_wl5522.t1 VALUES (100),(200),(300); +SELECT * FROM testdb_wl5522.t1 ORDER BY i; +FLUSH TABLES testdb_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +# try if we can flush again +FLUSH TABLES testdb_wl5522.t1 FOR EXPORT; +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1; + +# create table with incorrect schema +CREATE TABLE testdb_wl5522.t1 ( i bigint) ENGINE = Innodb; +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +# error as mismatch in column data type +--error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; + +# explicilty delet idb file before creating table with correct schema +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("testdb_wl5522", "t1"); +EOF + +DROP TABLE testdb_wl5522.t1; + +CREATE TABLE testdb_wl5522.t1 ( i int ) ENGINE = Innodb; +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +# Import should succeed +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; +# Try to import twice +--error 1813 +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; +SELECT * FROM testdb_wl5522.t1 ORDER BY i; + +SET AUTOCOMMIT = 0; +INSERT INTO testdb_wl5522.t1 VALUES (101),(102),(103); +COMMIT; +SELECT * FROM testdb_wl5522.t1 ORDER BY i; +DROP TABLE testdb_wl5522.t1; +CREATE TABLE testdb_wl5522.t1 (i int) ENGINE = Innodb; +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; +# do not delete ibt file and try to import +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF +#--error 1000 +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; +DROP TABLE testdb_wl5522.t1; +SET AUTOCOMMIT = 1; + + +# case 9 - empty table import +CREATE TABLE testdb_wl5522.t1 (c1 INT ) ENGINE = Innodb; +SET AUTOCOMMIT = 0; +INSERT INTO testdb_wl5522.t1 VALUES (1),(123),(331); +SELECT c1 FROM testdb_wl5522.t1; +ROLLBACK; +FLUSH TABLES testdb_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1; +CREATE TABLE testdb_wl5522.t1 (c1 INT ) ENGINE = Innodb; +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; +SELECT * FROM testdb_wl5522.t1 ORDER BY c1; +DROP TABLE testdb_wl5522.t1; +SET AUTOCOMMIT = 1; + +# case 10 - tt with prefix index + +CREATE TABLE testdb_wl5522.t1 (col_1 CHAR (255) , +col_2 VARCHAR (255), col_3 VARCHAR (255), +col_4 VARCHAR (255),col_5 VARCHAR (255), +col_6 text (255), col_7 text (255), +col_8 text (255),col_9 text (255), +col_10 BLOB (255),col_11 BLOB (255), +col_12 BLOB (255), col_13 BLOB (255), +col_14 BLOB (255) , col_15 int ) ENGINE = innodb; + +CREATE INDEX prefix_idx ON testdb_wl5522.t1( +col_1 (50),col_2 (50),col_3 (50), +col_4 (50),col_5 (50),col_6 (50), +col_7 (50),col_8 (50),col_9 (50), +col_10 (50),col_11 (50),col_12 (50), +col_13(50)); + +INSERT INTO testdb_wl5522.t1 VALUES ( +REPEAT("col1_00001",10),REPEAT("col2_00001",10),REPEAT("col3_00001",10), +REPEAT("col4_00001",10),REPEAT("col5_00001",10),REPEAT("col6_00001",10), +REPEAT("col7_00001",10),REPEAT("col8_00001",10),REPEAT("col9_00001",10), +REPEAT("col10_00001",10),REPEAT("col11_00001",10),REPEAT("col12_00001",10), +REPEAT("col13_00001",10),REPEAT("col14_00001",10),1); + +SELECT +col_1 = REPEAT("col1_00001",10), +col_2 = REPEAT("col2_00001",10), +col_3 = REPEAT("col3_00001",10), +col_4 = REPEAT("col4_00001",10), +col_5 = REPEAT("col5_00001",10), +col_6 = REPEAT("col6_00001",10), +col_7 = REPEAT("col7_00001",10), +col_8 = REPEAT("col8_00001",10), +col_9 = REPEAT("col9_00001",10), +col_10 = REPEAT("col10_00001",10), +col_11 = REPEAT("col11_00001",10), +col_12 = REPEAT("col12_00001",10), +col_13 = REPEAT("col13_00001",10), +col_14 = REPEAT("col14_00001",10), +col_15 +FROM testdb_wl5522.t1; + +FLUSH TABLES testdb_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1; + +CREATE TABLE testdb_wl5522.t1 (col_1 CHAR (255) , +col_2 VARCHAR (255), col_3 VARCHAR (255), +col_4 VARCHAR (255),col_5 VARCHAR (255), +col_6 text (255), col_7 text (255), +col_8 text (255),col_9 text (255), +col_10 BLOB (255),col_11 BLOB (255), +col_12 BLOB (255), col_13 BLOB (255), +col_14 BLOB (255) , col_15 int ) ENGINE = innodb; + +CREATE INDEX prefix_idx ON testdb_wl5522.t1( +col_1 (50),col_2 (50),col_3 (50), +col_4 (50),col_5 (50),col_6 (50), +col_7 (50),col_8 (50),col_9 (50), +col_10 (50),col_11 (50),col_12 (50), +col_13(50)); + + +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; + + +SELECT +col_1 = REPEAT("col1_00001",10), +col_2 = REPEAT("col2_00001",10), +col_3 = REPEAT("col3_00001",10), +col_4 = REPEAT("col4_00001",10), +col_5 = REPEAT("col5_00001",10), +col_6 = REPEAT("col6_00001",10), +col_7 = REPEAT("col7_00001",10), +col_8 = REPEAT("col8_00001",10), +col_9 = REPEAT("col9_00001",10), +col_10 = REPEAT("col10_00001",10), +col_11 = REPEAT("col11_00001",10), +col_12 = REPEAT("col12_00001",10), +col_13 = REPEAT("col13_00001",10), +col_14 = REPEAT("col14_00001",10), +col_15 +FROM testdb_wl5522.t1; + +DROP TABLE testdb_wl5522.t1; + + +# case 11 - tt with secondary index + +CREATE TABLE testdb_wl5522.t1 (col_1 CHAR (255) , +col_2 VARCHAR (255), col_3 VARCHAR (255), +col_4 VARCHAR (255),col_5 VARCHAR (255), +col_6 text (255), col_7 text (255), +col_8 text (255),col_9 text (255), +col_10 BLOB (255),col_11 BLOB (255), +col_12 BLOB (255), col_13 BLOB (255), +col_14 BLOB (255) , col_15 int ) ENGINE = innodb; + +CREATE INDEX idx1 ON testdb_wl5522.t1(col_1); +CREATE INDEX idx2 ON testdb_wl5522.t1(col_2); +CREATE INDEX idx3 ON testdb_wl5522.t1(col_3); +CREATE INDEX idx4 ON testdb_wl5522.t1(col_4); +CREATE INDEX idx5 ON testdb_wl5522.t1(col_5); +CREATE INDEX idx6 ON testdb_wl5522.t1(col_6(255)); +CREATE INDEX idx7 ON testdb_wl5522.t1(col_7(255)); +CREATE INDEX idx8 ON testdb_wl5522.t1(col_8(255)); +CREATE INDEX idx9 ON testdb_wl5522.t1(col_9(255)); +CREATE INDEX idx10 ON testdb_wl5522.t1(col_10(255)); +CREATE INDEX idx11 ON testdb_wl5522.t1(col_11(255)); +CREATE INDEX idx12 ON testdb_wl5522.t1(col_12(255)); +CREATE INDEX idx13 ON testdb_wl5522.t1(col_13(255)); +CREATE INDEX idx14 ON testdb_wl5522.t1(col_14(255)); + +INSERT INTO testdb_wl5522.t1 VALUES ( +REPEAT("col1_00001",10),REPEAT("col2_00001",10),REPEAT("col3_00001",10), +REPEAT("col4_00001",10),REPEAT("col5_00001",10),REPEAT("col6_00001",10), +REPEAT("col7_00001",10),REPEAT("col8_00001",10),REPEAT("col9_00001",10), +REPEAT("col10_00001",10),REPEAT("col11_00001",10),REPEAT("col12_00001",10), +REPEAT("col13_00001",10),REPEAT("col14_00001",10),1); + +SELECT +col_1 = REPEAT("col1_00001",10), +col_2 = REPEAT("col2_00001",10), +col_3 = REPEAT("col3_00001",10), +col_4 = REPEAT("col4_00001",10), +col_5 = REPEAT("col5_00001",10), +col_6 = REPEAT("col6_00001",10), +col_7 = REPEAT("col7_00001",10), +col_8 = REPEAT("col8_00001",10), +col_9 = REPEAT("col9_00001",10), +col_10 = REPEAT("col10_00001",10), +col_11 = REPEAT("col11_00001",10), +col_12 = REPEAT("col12_00001",10), +col_13 = REPEAT("col13_00001",10), +col_14 = REPEAT("col14_00001",10), +col_15 +FROM testdb_wl5522.t1; + +FLUSH TABLES testdb_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE testdb_wl5522.t1; + +CREATE TABLE testdb_wl5522.t1 (col_1 CHAR (255) , +col_2 VARCHAR (255), col_3 VARCHAR (255), +col_4 VARCHAR (255),col_5 VARCHAR (255), +col_6 text (255), col_7 text (255), +col_8 text (255),col_9 text (255), +col_10 BLOB (255),col_11 BLOB (255), +col_12 BLOB (255), col_13 BLOB (255), +col_14 BLOB (255) , col_15 int ) ENGINE = innodb; + +CREATE INDEX idx1 ON testdb_wl5522.t1(col_1); +CREATE INDEX idx2 ON testdb_wl5522.t1(col_2); +CREATE INDEX idx3 ON testdb_wl5522.t1(col_3); +CREATE INDEX idx4 ON testdb_wl5522.t1(col_4); +CREATE INDEX idx5 ON testdb_wl5522.t1(col_5); +CREATE INDEX idx6 ON testdb_wl5522.t1(col_6(255)); +CREATE INDEX idx7 ON testdb_wl5522.t1(col_7(255)); +CREATE INDEX idx8 ON testdb_wl5522.t1(col_8(255)); +CREATE INDEX idx9 ON testdb_wl5522.t1(col_9(255)); +CREATE INDEX idx10 ON testdb_wl5522.t1(col_10(255)); +CREATE INDEX idx11 ON testdb_wl5522.t1(col_11(255)); +CREATE INDEX idx12 ON testdb_wl5522.t1(col_12(255)); +CREATE INDEX idx13 ON testdb_wl5522.t1(col_13(255)); +CREATE INDEX idx14 ON testdb_wl5522.t1(col_14(255)); + +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; + +SELECT +col_1 = REPEAT("col1_00001",10), +col_2 = REPEAT("col2_00001",10), +col_3 = REPEAT("col3_00001",10), +col_4 = REPEAT("col4_00001",10), +col_5 = REPEAT("col5_00001",10), +col_6 = REPEAT("col6_00001",10), +col_7 = REPEAT("col7_00001",10), +col_8 = REPEAT("col8_00001",10), +col_9 = REPEAT("col9_00001",10), +col_10 = REPEAT("col10_00001",10), +col_11 = REPEAT("col11_00001",10), +col_12 = REPEAT("col12_00001",10), +col_13 = REPEAT("col13_00001",10), +col_14 = REPEAT("col14_00001",10), +col_15 +FROM testdb_wl5522.t1; + +# perform transaction on impoted table +SET AUTOCOMMIT = 0; +INSERT INTO testdb_wl5522.t1(col_15) VALUES (15000),(16000); +SELECT col_15 FROM testdb_wl5522.t1 WHERE col_15 > 11000; +ROLLBACK; +SELECT col_15 FROM testdb_wl5522.t1 WHERE col_15 > 11000; +INSERT INTO testdb_wl5522.t1(col_15) VALUES (15000),(16000); +COMMIT; +SELECT col_15 FROM testdb_wl5522.t1 WHERE col_15 > 11000; +# dml +ALTER TABLE testdb_wl5522.t1 DROP INDEX idx1; +ALTER TABLE testdb_wl5522.t1 DROP INDEX idx6; +ALTER TABLE testdb_wl5522.t1 DROP INDEX idx10; + +SELECT +col_1 = REPEAT("col1_00001",10), +col_2 = REPEAT("col2_00001",10), +col_3 = REPEAT("col3_00001",10), +col_4 = REPEAT("col4_00001",10), +col_5 = REPEAT("col5_00001",10), +col_6 = REPEAT("col6_00001",10), +col_7 = REPEAT("col7_00001",10), +col_8 = REPEAT("col8_00001",10), +col_9 = REPEAT("col9_00001",10), +col_10 = REPEAT("col10_00001",10), +col_11 = REPEAT("col11_00001",10), +col_12 = REPEAT("col12_00001",10), +col_13 = REPEAT("col13_00001",10), +col_14 = REPEAT("col14_00001",10), +col_15 +FROM testdb_wl5522.t1; + +ALTER TABLE testdb_wl5522.t1 ADD INDEX idx1 (col_1); +ALTER TABLE testdb_wl5522.t1 ADD INDEX idx6 (col_1(255)); +ALTER TABLE testdb_wl5522.t1 ADD INDEX idx10 (col_10(255)); + + +SELECT +col_1 = REPEAT("col1_00001",10), +col_2 = REPEAT("col2_00001",10), +col_3 = REPEAT("col3_00001",10), +col_4 = REPEAT("col4_00001",10), +col_5 = REPEAT("col5_00001",10), +col_6 = REPEAT("col6_00001",10), +col_7 = REPEAT("col7_00001",10), +col_8 = REPEAT("col8_00001",10), +col_9 = REPEAT("col9_00001",10), +col_10 = REPEAT("col10_00001",10), +col_11 = REPEAT("col11_00001",10), +col_12 = REPEAT("col12_00001",10), +col_13 = REPEAT("col13_00001",10), +col_14 = REPEAT("col14_00001",10), +col_15 +FROM testdb_wl5522.t1; + +DROP TABLE testdb_wl5522.t1; +SET AUTOCOMMIT = 1; + +# case 12 - tt with trigger / view + +CREATE TABLE testdb_wl5522.t1(col1 bit(1) , +col2 boolean,col3 tinyint , col4 smallint , +col5 mediumint ,col6 int , col7 bigint , +col8 float (14,3) ,col9 double (14,3), +col10 VARCHAR(20) CHARACTER SET utf8 , +col11 TEXT CHARACTER SET binary , +col12 ENUM('a','b','c') CHARACTER SET binary, +col13 TEXT CHARACTER SET latin1 COLLATE latin1_general_cs , +col14 CHAR(20) , col15 VARBINARY (400), +col16 BINARY(40), col17 BLOB (400), +col18 int not null primary key, +col19 DATE ,col20 DATETIME , col21 TIMESTAMP , +col22 TIME , col23 YEAR ) ENGINE = Innodb; + +# table for trigger action +CREATE TABLE testdb_wl5522.trigger_table ( i int ) ENGINE = Innodb; +# define trigger +CREATE TRIGGER testdb_wl5522.tri AFTER INSERT ON testdb_wl5522.t1 +FOR EACH ROW INSERT INTO testdb_wl5522.trigger_table VALUES(NEW.col18); +# define view +CREATE OR REPLACE VIEW testdb_wl5522.VW1 AS SELECT * FROM testdb_wl5522.t1; + +CREATE INDEX idx1 ON testdb_wl5522.t1(col18); +CREATE INDEX prefix_idx ON testdb_wl5522.t1(col14 (10)); +CREATE UNIQUE INDEX idx2 ON testdb_wl5522.t1(col12); +CREATE UNIQUE INDEX idx3 ON testdb_wl5522.t1(col8); + + +INSERT INTO testdb_wl5522.t1 VALUES ( +1,1,-128,32767,-8388608,2147483647,-9223372036854775808,92233720368.222, +-92233720368.222,'aaa','aaaaaaaaaa','b','bbbbb','ccccc',REPEAT('d',40), +REPEAT('d',40),REPEAT('d',40),1,'1000-01-01','3000-12-31 23:59:59.99', +'1990-01-01 00:00:01.00','01:59:59.00','1901'); + +INSERT INTO testdb_wl5522.t1 VALUES ( +NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, +NULL,NULL,3,NULL,NULL,NULL,NULL,NULL); + + +--error 1048 +INSERT INTO testdb_wl5522.t1 VALUES ( +NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, +NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); + +--error 1062 +INSERT INTO testdb_wl5522.t1 VALUES ( +NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, +NULL,NULL,1,NULL,NULL,NULL,NULL,NULL); + +SELECT COUNT(*) FROM testdb_wl5522.t1; +SELECT * FROM testdb_wl5522.trigger_table; +SELECT COUNT(*) FROM testdb_wl5522.VW1; +FLUSH TABLES testdb_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("testdb_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +# trigger is also dropped when table is dropped +DROP TABLE testdb_wl5522.t1; + +CREATE TABLE testdb_wl5522.t1(col1 bit(1) , +col2 boolean,col3 tinyint , col4 smallint , +col5 mediumint ,col6 int , col7 bigint , +col8 float (14,3) ,col9 double (14,3), +col10 VARCHAR(20) CHARACTER SET utf8 , +col11 TEXT CHARACTER SET binary , +col12 ENUM('a','b','c') CHARACTER SET binary, +col13 TEXT CHARACTER SET latin1 COLLATE latin1_general_cs , +col14 CHAR(20) , col15 VARBINARY (400), +col16 BINARY(40), col17 BLOB (400), +col18 int not null primary key, +col19 DATE ,col20 DATETIME , col21 TIMESTAMP , +col22 TIME , col23 YEAR ) ENGINE = Innodb; + +CREATE INDEX idx1 ON testdb_wl5522.t1(col18); +CREATE INDEX prefix_idx ON testdb_wl5522.t1(col14 (10)); +CREATE UNIQUE INDEX idx2 ON testdb_wl5522.t1(col12); +CREATE UNIQUE INDEX idx3 ON testdb_wl5522.t1(col8); + + +ALTER TABLE testdb_wl5522.t1 DISCARD TABLESPACE; + + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("testdb_wl5522", "t1"); +ib_restore_tablespaces("testdb_wl5522", "t1"); +EOF + +ALTER TABLE testdb_wl5522.t1 IMPORT TABLESPACE; + +SELECT COUNT(*) FROM testdb_wl5522.t1; +SELECT * FROM testdb_wl5522.trigger_table; +SELECT COUNT(*) FROM testdb_wl5522.VW1; + +# trigger table is not updated as trigger got dropped +INSERT INTO testdb_wl5522.t1(col18) VALUES (5); +# validate data in table not updated +SELECT * FROM testdb_wl5522.trigger_table; + +UPDATE testdb_wl5522.t1 SET col18=10 WHERE col18=1; + +# view shows updated data +SELECT COUNT(*) FROM testdb_wl5522.VW1; + +SELECT COUNT(*) FROM testdb_wl5522.t1 WHERE col18=10; +ALTER TABLE testdb_wl5522.t1 ADD COLUMN col24 varbinary(40) default null; +INSERT INTO testdb_wl5522.t1(col18,col24) VALUES (6,REPEAT('a',10)); +SELECT col24,col18 FROM testdb_wl5522.t1 WHERE col18 in (6,1,10) ORDER BY col18; +ALTER TABLE testdb_wl5522.t1 DROP INDEX prefix_idx; +SELECT col18,col14 FROM testdb_wl5522.t1 WHERE col14 like '_ccc%'; +ALTER TABLE testdb_wl5522.t1 ADD INDEX prefix_idx (col24(10)); +SELECT col18,col24 FROM testdb_wl5522.t1 WHERE col24 like '_a_a%'; + +DROP TABLE testdb_wl5522.t1; + +DROP DATABASE testdb_wl5522; + +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 +--remove_file $MYSQLTEST_VARDIR/tmp/t1_fk.cfg +--remove_file $MYSQLTEST_VARDIR/tmp/t1_fk.ibd + +eval SET GLOBAL INNODB_FILE_FORMAT=$innodb_file_format; +eval SET GLOBAL INNODB_FILE_PER_TABLE=$innodb_file_per_table; diff --git a/mysql-test/suite/innodb/t/innodb-wl5522-debug-zip.test b/mysql-test/suite/innodb/t/innodb-wl5522-debug-zip.test new file mode 100644 index 00000000000..37b630ad47b --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-wl5522-debug-zip.test @@ -0,0 +1,759 @@ +# Not supported in embedded +--source include/not_embedded.inc + +# This test case needs to crash the server. Needs a debug server. +--source include/have_debug.inc + +# Don't test this under valgrind, memory leaks will occur. +--source include/not_valgrind.inc + +# Avoid CrashReporter popup on Mac +--source include/not_crashrep.inc + +-- source include/have_innodb.inc + +# compressed table in tests are with sizes KEY_BLOCK_SIZE 1,2,4,8,16 +# Table creatation fails if KEY_BLOCK_SIZE > innodb-page-size,so +# allow test to run only when innodb-page-size=16 +--source include/have_innodb_16k.inc + +# Test intentionally crashes the server, corrupted pages possible +call mtr.add_suppression("InnoDB: Page for tablespace .* "); +call mtr.add_suppression("InnoSB: Warning: database page corruption or a failed .*"); +FLUSH TABLES; + +let MYSQLD_DATADIR =`SELECT @@datadir`; +let $innodb_file_per_table = `SELECT @@innodb_file_per_table`; +let $innodb_file_format = `SELECT @@innodb_file_format`; +let $innodb_strict_mode_orig=`select @@session.innodb_strict_mode`; +let $pathfix=/: '.*test_wl5522.*t1.ibd'/: 'test_wl5522_t1.ibd'/; + +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +SET GLOBAL innodb_file_format = `Barracuda`; +SELECT @@innodb_file_format; + +SET SESSION innodb_strict_mode=1; +SELECT @@SESSION.innodb_strict_mode; + + + +DROP DATABASE IF EXISTS test_wl5522; +CREATE DATABASE test_wl5522; + +# Create the table that we will use for crash recovery (during IMPORT) +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb +ROW_FORMAT=COMPRESSED; +INSERT INTO test_wl5522.t1 VALUES (1), (2), (3), (4); + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test_wl5522", "t1"); +EOF +UNLOCK TABLES; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb +ROW_FORMAT=COMPRESSED; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("test_wl5522", "t1"); +EOF + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +##### Before commit crash +SET SESSION debug_dbug="+d,ib_import_before_commit_crash"; + +--error ER_TABLESPACE_DISCARDED +SELECT * FROM test_wl5522.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 test_wl5522.t1 IMPORT TABLESPACE; + +--enable_reconnect +--source include/wait_until_connected_again.inc +--disable_reconnect + +SET SESSION debug_dbug="-d,ib_import_before_commit_crash"; +#### 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 test_wl5522.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 test_wl5522.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}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "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 + +SET SESSION debug_dbug="-d,ib_import_before_checkpoint_crash"; +#### Before checkpoint crash + +# After the above test the results are non-deterministic, recreate the table +# and do a proper import. + +DROP TABLE test_wl5522.t1; + +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +SET GLOBAL innodb_file_format = `Barracuda`; +SELECT @@innodb_file_format; + +SET SESSION innodb_strict_mode=1; +SELECT @@SESSION.innodb_strict_mode; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb +ROW_FORMAT=COMPRESSED; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; +CHECK TABLE test_wl5522.t1; + +SELECT COUNT(*) FROM test_wl5522.t1; + +INSERT INTO test_wl5522.t1 VALUES(400), (500), (600); + +SELECT * FROM test_wl5522.t1; + +DROP TABLE test_wl5522.t1; + +# Test handling of internal failure error +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb +ROW_FORMAT=COMPRESSED; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +# Test failure after reset of space id and LSN in the tablespace +SET SESSION debug_dbug="+d,ib_import_internal_error"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_INTERNAL_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_internal_error"; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +DROP TABLE test_wl5522.t1; + + +# Test failure after reset of space id and LSN in the tablespace +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb +ROW_FORMAT=COMPRESSED; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "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"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_INTERNAL_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="-d,ib_import_reset_space_and_lsn_failure"; + +# Test failure after attempting a tablespace open +SET SESSION debug_dbug="+d,ib_import_open_tablespace_failure"; + +--replace_regex /'.*[\/\\]/'/ +--error ER_GET_ERRMSG +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_open_tablespace_failure"; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "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 test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_check_bitmap_failure"; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "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 test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_cluster_root_adjust_failure"; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +# Test failure after importing the cluster index +SET SESSION debug_dbug="+d,ib_import_cluster_failure"; + +--error ER_NOT_KEYFILE +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_cluster_failure"; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "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 test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_sec_root_adjust_failure"; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +# Test failure after importing the cluster index +SET SESSION debug_dbug="+d,ib_import_set_max_rowid_failure"; + +--error ER_NOT_KEYFILE +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_set_max_rowid_failure"; + +# Left over from the failed IMPORT +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +DROP TABLE test_wl5522.t1; + +--disable_query_log +# Enable metrics for the counters we are going to use +set global innodb_monitor_enable = purge_stop_count; +set global innodb_monitor_enable = purge_resume_count; +set global innodb_monitor_enable = ibuf_merges; +set global innodb_monitor_enable = ibuf_merges_insert; +--enable_query_log + +# +# Create a large table with delete marked records, disable purge during +# the update so that we can test the IMPORT purge code. +# +CREATE TABLE test_wl5522.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 KEY_BLOCK_SIZE=8; + +# Stop purge so that it doesn't remove the delete marked entries. +SET GLOBAL INNODB_PURGE_STOP_NOW=ON; + +# Disable change buffer merge from the master thread, additionally +# enable aggressive flushing so that more changes are buffered. +SET GLOBAL innodb_disable_background_merge=ON; +SET GLOBAL innodb_monitor_reset = ibuf_merges; +SET GLOBAL innodb_monitor_reset = ibuf_merges_insert; + +INSERT INTO test_wl5522.t1(c2, c3, c4) VALUES + (1, REPEAT('a', 2048), REPEAT('a', 2048)), + (2, REPEAT('b', 2048), REPEAT('b', 2048)), + (3, REPEAT('c', 2048), REPEAT('c', 2048)), + (4, REPEAT('d', 2048), REPEAT('d', 2048)); + +INSERT INTO test_wl5522.t1(c2, c3, c4) SELECT c2, c3, c4 FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1(c2, c3, c4) SELECT c2, c3, c4 FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1(c2, c3, c4) SELECT c2, c3, c4 FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1(c2, c3, c4) SELECT c2, c3, c4 FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1(c2, c3, c4) SELECT c2, c3, c4 FROM test_wl5522.t1; + +DELETE FROM test_wl5522.t1 WHERE c2 = 1; + +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c3 = REPEAT("c2", 1024); +UPDATE test_wl5522.t1 SET c4 = REPEAT("c4", 1024); + +SHOW CREATE TABLE test_wl5522.t1; + +SELECT c1, c2 FROM test_wl5522.t1; +SELECT COUNT(*) FROM test_wl5522.t1; +SELECT SUM(c2) FROM test_wl5522.t1; + +SELECT name + FROM information_schema.innodb_metrics + WHERE name = 'ibuf_merges_insert' AND count = 0; + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +SELECT name + FROM information_schema.innodb_metrics + WHERE name = 'ibuf_merges' AND count > 0; + +SELECT name + FROM information_schema.innodb_metrics + WHERE name = 'ibuf_merges_inserts' AND count > 0; + +SET GLOBAL innodb_disable_background_merge=OFF; + +# Enable normal operation +SET GLOBAL INNODB_PURGE_RUN_NOW=ON; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.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 KEY_BLOCK_SIZE=8; + +SELECT c1, c2 FROM test_wl5522.t1; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; +CHECK TABLE test_wl5522.t1; + +SELECT c1,c2 FROM test_wl5522.t1; +SELECT COUNT(*) FROM test_wl5522.t1; +SELECT SUM(c2) FROM test_wl5522.t1; + +SHOW CREATE TABLE test_wl5522.t1; + +DROP TABLE test_wl5522.t1; + +#### +# Create a table and save the tablespace and .cfg file, we need to create +# a Btree that has several levels +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +INSERT INTO test_wl5522.t1 VALUES + (100, REPEAT('Karanbir', 899), REPEAT('Ajeeth', 1200)); + +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +SELECT COUNT(*) FROM test_wl5522.t1; +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_trigger_corruption_1"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_INTERNAL_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_trigger_corruption_1"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +# + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,buf_page_is_corrupt_failure"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +# Following alter is not failing +#--error ER_INTERNAL_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,buf_page_is_corrupt_failure"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_trigger_corruption_2"; + +--replace_regex $pathfix + +--error ER_INNODB_INDEX_CORRUPT +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_trigger_corruption_2"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_trigger_corruption_3"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_NOT_KEYFILE +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_trigger_corruption_3"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +SET SESSION debug_dbug="+d,ib_import_create_index_failure_1"; + +ALTER TABLE test_wl5522.t1 ADD INDEX idx(c1); + +SET SESSION debug_dbug="-d,ib_import_create_index_failure_1"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +# + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,fil_space_create_failure"; + +--replace_regex /'.*[\/\\]/'/ +--error ER_GET_ERRMSG +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,fil_space_create_failure"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +# + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,dict_tf_to_fsp_flags_failure"; + +--replace_regex /'.*[\/\\]/'/ +--error ER_GET_ERRMSG +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,dict_tf_to_fsp_flags_failure"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +# + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,fsp_flags_is_valid_failure"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_INTERNAL_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,fsp_flags_is_valid_failure"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + + +DROP DATABASE test_wl5522; + +set global innodb_monitor_disable = all; +set global innodb_monitor_reset_all = all; + +-- disable_warnings +set global innodb_monitor_enable = default; +set global innodb_monitor_disable = default; +set global innodb_monitor_reset = default; +set global innodb_monitor_reset_all = default; +-- enable_warnings + +--disable_query_log +call mtr.add_suppression("'Resource temporarily unavailable'"); +call mtr.add_suppression("Monitor ibuf_merges is already enabled"); +call mtr.add_suppression("Monitor ibuf_merges_insert is already enabled"); +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("Error in page .* of index \"GEN_CLUST_INDEX\" of table \"test_wl5522\".\"t1\""); +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("Failed to find tablespace for table '\"test_wl5522\".\"t1\"' in the cache"); +call mtr.add_suppression("Could not find a valid tablespace file for 'test_wl5522.*t1'"); +--enable_query_log + +#cleanup +--remove_file $MYSQLTEST_VARDIR/tmp/t1.cfg +--remove_file $MYSQLTEST_VARDIR/tmp/t1.ibd + +eval SET GLOBAL INNODB_FILE_PER_TABLE=$innodb_file_per_table; +eval SET GLOBAL INNODB_FILE_FORMAT=$innodb_file_format; +eval SET SESSION innodb_strict_mode=$innodb_strict_mode_orig; + diff --git a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test new file mode 100644 index 00000000000..9c0c11fadab --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test @@ -0,0 +1,1494 @@ +# Not supported in embedded +--source include/not_embedded.inc + +# Adding big test option for this test. +--source include/big_test.inc + +# This test case needs to crash the server. Needs a debug server. +--source include/have_debug.inc + +# Don't test this under valgrind, memory leaks will occur. +--source include/not_valgrind.inc + +# Avoid CrashReporter popup on Mac +--source include/not_crashrep.inc + +-- source include/have_innodb.inc + +let MYSQLD_DATADIR =`SELECT @@datadir`; +let $innodb_file_per_table = `SELECT @@innodb_file_per_table`; +let $pathfix=/: '.*test_wl5522.*t1.ibd'/: 'test_wl5522\\t1.ibd'/; +let $strerrfix=/ (\(.+\))//; + +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +DROP DATABASE IF EXISTS test_wl5522; +CREATE DATABASE test_wl5522; + +##### Before DISCARD commit crash +SET SESSION debug_dbug="+d,ib_discard_before_commit_crash"; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = InnoDB; +INSERT INTO test_wl5522.t1 VALUES(1),(2),(3); + +# 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 test_wl5522.t1 DISCARD TABLESPACE; + +--enable_reconnect +--source include/wait_until_connected_again.inc +--disable_reconnect + +SET SESSION debug_dbug="-d,ib_discard_before_commit_crash"; +DROP TABLE test_wl5522.t1; +#### Before DISCARD commit crash + +##### After DISCARD commit crash +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +SET SESSION debug_dbug="+d,ib_discard_after_commit_crash"; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = InnoDB; +INSERT INTO test_wl5522.t1 VALUES(1),(2),(3); + +# 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 test_wl5522.t1 DISCARD TABLESPACE; + +--enable_reconnect +--source include/wait_until_connected_again.inc +--disable_reconnect + +SET SESSION debug_dbug="-d,ib_discard_after_commit_crash"; +DROP TABLE test_wl5522.t1; +#### After DISCARD commit crash + +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +# Create the table that we will use for crash recovery (during IMPORT) +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1), (2), (3), (4); + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test_wl5522", "t1"); +EOF +UNLOCK TABLES; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +##### Before commit crash +SET SESSION debug_dbug="+d,ib_import_before_commit_crash"; + +--error ER_TABLESPACE_DISCARDED +SELECT * FROM test_wl5522.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 test_wl5522.t1 IMPORT TABLESPACE; + +--enable_reconnect +--source include/wait_until_connected_again.inc +--disable_reconnect + +SET SESSION debug_dbug="-d,ib_import_before_commit_crash"; +#### 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 test_wl5522.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 test_wl5522.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}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "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 + +SET SESSION debug_dbug="-d,ib_import_before_checkpoint_crash"; +#### Before checkpoint crash + +# After the above test the results are non-deterministic, recreate the table +# and do a proper import. + +DROP TABLE test_wl5522.t1; + +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; +CHECK TABLE test_wl5522.t1; + +SELECT COUNT(*) FROM test_wl5522.t1; + +INSERT INTO test_wl5522.t1 VALUES(400), (500), (600); + +SELECT * FROM test_wl5522.t1; + +DROP TABLE test_wl5522.t1; + +# Test IO Write error(s), flush tables doesn't return an error message +# so we have to make do with the error/warning pushed by the server +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +SET SESSION debug_dbug="+d,ib_export_io_write_failure_1"; + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +UNLOCK TABLES; + +SET SESSION debug_dbug="-d,ib_export_io_write_failure_1"; + +DROP TABLE test_wl5522.t1; + + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +SET SESSION debug_dbug="+d,ib_export_io_write_failure_2"; + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +UNLOCK TABLES; + +SET SESSION debug_dbug="-d,ib_export_io_write_failure_2"; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +SET SESSION debug_dbug="+d,ib_export_io_write_failure_3"; + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +UNLOCK TABLES; + +SET SESSION debug_dbug="-d,ib_export_io_write_failure_3"; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +SET SESSION debug_dbug="+d,ib_export_io_write_failure_4"; + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +UNLOCK TABLES; + +SET SESSION debug_dbug="-d,ib_export_io_write_failure_4"; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +SET SESSION debug_dbug="+d,ib_export_io_write_failure_5"; + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +UNLOCK TABLES; + +SET SESSION debug_dbug="-d,ib_export_io_write_failure_5"; + +DROP TABLE test_wl5522.t1; + + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +SET SESSION debug_dbug="+d,ib_export_io_write_failure_6"; + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +UNLOCK TABLES; + +SET SESSION debug_dbug="-d,ib_export_io_write_failure_6"; + +DROP TABLE test_wl5522.t1; + + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +SET SESSION debug_dbug="+d,ib_export_io_write_failure_7"; + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +UNLOCK TABLES; + +SET SESSION debug_dbug="-d,ib_export_io_write_failure_7"; + +DROP TABLE test_wl5522.t1; + + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +SET SESSION debug_dbug="+d,ib_export_io_write_failure_8"; + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +UNLOCK TABLES; + +SET SESSION debug_dbug="-d,ib_export_io_write_failure_8"; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +SET SESSION debug_dbug="+d,ib_export_io_write_failure_9"; + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +UNLOCK TABLES; + +SET SESSION debug_dbug="-d,ib_export_io_write_failure_9"; + +DROP TABLE test_wl5522.t1; + + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +SET SESSION debug_dbug="+d,ib_export_io_write_failure_10"; + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +UNLOCK TABLES; + +SET SESSION debug_dbug="-d,ib_export_io_write_failure_10"; + +DROP TABLE test_wl5522.t1; + + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +SET SESSION debug_dbug="+d,ib_export_io_write_failure_11"; + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +UNLOCK TABLES; + +SET SESSION debug_dbug="-d,ib_export_io_write_failure_11"; + +DROP TABLE test_wl5522.t1; + + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +SET SESSION debug_dbug="+d,ib_export_io_write_failure_12"; + +--replace_regex /, .*\).*t1.cfg/, Bad file descriptor) t1.cfg/ + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +UNLOCK TABLES; + +SET SESSION debug_dbug="-d,ib_export_io_write_failure_12"; + +DROP TABLE test_wl5522.t1; + +# Create a table and save the tablespace and .cfg file +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (100), (200), (300); +SELECT COUNT(*) FROM test_wl5522.t1; +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE test_wl5522.t1; + +# Test IO Read error(s) +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +SET SESSION debug_dbug="+d,ib_import_io_read_error_1"; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_cfg_files("test_wl5522", "t1"); +EOF + +--replace_regex $strerrfix + +--error ER_IO_READ_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_io_read_error_1"; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +SET SESSION debug_dbug="+d,ib_import_io_read_error_2"; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_cfg_files("test_wl5522", "t1"); +EOF + +--replace_regex $strerrfix + +--error ER_IO_READ_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_io_read_error_2"; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +SET SESSION debug_dbug="+d,ib_import_io_read_error_3"; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_cfg_files("test_wl5522", "t1"); +EOF + +--replace_regex $strerrfix + +--error ER_IO_READ_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_io_read_error_3"; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +SET SESSION debug_dbug="+d,ib_import_io_read_error_4"; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_cfg_files("test_wl5522", "t1"); +EOF + +--replace_regex $strerrfix + +--error ER_IO_READ_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_io_read_error_4"; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +SET SESSION debug_dbug="+d,ib_import_io_read_error_5"; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_cfg_files("test_wl5522", "t1"); +EOF + +--replace_regex $strerrfix + +--error ER_IO_READ_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_io_read_error_5"; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +SET SESSION debug_dbug="+d,ib_import_io_read_error_6"; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_cfg_files("test_wl5522", "t1"); +EOF + +--replace_regex $strerrfix + +--error ER_IO_READ_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_io_read_error_6"; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +SET SESSION debug_dbug="+d,ib_import_io_read_error_7"; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_cfg_files("test_wl5522", "t1"); +EOF + +--replace_regex $strerrfix + +--error ER_IO_READ_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_io_read_error_7"; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +SET SESSION debug_dbug="+d,ib_import_io_read_error_8"; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_cfg_files("test_wl5522", "t1"); +EOF + +--replace_regex $strerrfix + +--error ER_IO_READ_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_io_read_error_8"; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +SET SESSION debug_dbug="+d,ib_import_io_read_error_9"; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_cfg_files("test_wl5522", "t1"); +EOF + +--replace_regex $strerrfix + +--error ER_IO_READ_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_io_read_error_9"; + +DROP TABLE test_wl5522.t1; + +# Test string read failure +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +SET SESSION debug_dbug="+d,ib_import_string_read_error"; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_cfg_files("test_wl5522", "t1"); +EOF + +--replace_regex $strerrfix + +--error ER_IO_READ_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_string_read_error"; + +DROP TABLE test_wl5522.t1; + +# Test OOM error during import + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_OOM_1"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_OUT_OF_RESOURCES +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_OOM_1"; + +DROP TABLE test_wl5522.t1; + + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_OOM_2"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_OUT_OF_RESOURCES +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_OOM_2"; + +DROP TABLE test_wl5522.t1; + + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_OOM_4"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_OUT_OF_RESOURCES +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_OOM_4"; + +DROP TABLE test_wl5522.t1; + + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_OOM_5"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_OUT_OF_RESOURCES +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_OOM_5"; + +DROP TABLE test_wl5522.t1; + + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_OOM_6"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_OUT_OF_RESOURCES +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_OOM_6"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_OOM_7"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_OUT_OF_RESOURCES +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_OOM_7"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_OOM_8"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_OUT_OF_RESOURCES +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_OOM_8"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_OOM_9"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_OUT_OF_RESOURCES +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_OOM_9"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; +INSERT INTO test_wl5522.t1 VALUES (1); + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_OOM_10"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_OUT_OF_RESOURCES +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_OOM_10"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +#### +# Test handling of internal failure error +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +# Test failure after reset of space id and LSN in the tablespace +SET SESSION debug_dbug="+d,ib_import_internal_error"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_INTERNAL_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_internal_error"; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +DROP TABLE test_wl5522.t1; + + +# Test failure after reset of space id and LSN in the tablespace +CREATE TABLE test_wl5522.t1 (c1 INT) ENGINE = Innodb; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "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"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_INTERNAL_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="-d,ib_import_reset_space_and_lsn_failure"; + +# Test failure after attempting a tablespace open +SET SESSION debug_dbug="+d,ib_import_open_tablespace_failure"; + +--replace_regex /file: '.*t1.ibd'/'t1.ibd'/ + +--error ER_GET_ERRMSG +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_open_tablespace_failure"; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "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 test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_check_bitmap_failure"; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "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 test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_cluster_root_adjust_failure"; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +# Test failure after importing the cluster index +SET SESSION debug_dbug="+d,ib_import_cluster_failure"; + +--error ER_NOT_KEYFILE +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_cluster_failure"; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "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 test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_sec_root_adjust_failure"; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +# Test failure after importing the cluster index +SET SESSION debug_dbug="+d,ib_import_set_max_rowid_failure"; + +--error ER_NOT_KEYFILE +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_set_max_rowid_failure"; + +# Left over from the failed IMPORT +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +DROP TABLE test_wl5522.t1; + +--disable_query_log +# Enable metrics for the counters we are going to use +set global innodb_monitor_enable = purge_stop_count; +set global innodb_monitor_enable = purge_resume_count; +set global innodb_monitor_enable = ibuf_merges; +set global innodb_monitor_enable = ibuf_merges_insert; +--enable_query_log + +# +# Create a large table with delete marked records, disable purge during +# the update so that we can test the IMPORT purge code. +# +CREATE TABLE test_wl5522.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; + +# Stop purge so that it doesn't remove the delete marked entries. +SET GLOBAL INNODB_PURGE_STOP_NOW=ON; + +# Disable change buffer merge from the master thread, additionally +# enable aggressive flushing so that more changes are buffered. +SET GLOBAL innodb_disable_background_merge=ON; +SET GLOBAL innodb_monitor_reset = ibuf_merges; +SET GLOBAL innodb_monitor_reset = ibuf_merges_insert; + +INSERT INTO test_wl5522.t1(c2, c3, c4) VALUES + (1, REPEAT('a', 2048), REPEAT('a', 2048)), + (2, REPEAT('b', 2048), REPEAT('b', 2048)), + (3, REPEAT('c', 2048), REPEAT('c', 2048)), + (4, REPEAT('d', 2048), REPEAT('d', 2048)); + +INSERT INTO test_wl5522.t1(c2, c3, c4) SELECT c2, c3, c4 FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1(c2, c3, c4) SELECT c2, c3, c4 FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1(c2, c3, c4) SELECT c2, c3, c4 FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1(c2, c3, c4) SELECT c2, c3, c4 FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1(c2, c3, c4) SELECT c2, c3, c4 FROM test_wl5522.t1; + +DELETE FROM test_wl5522.t1 WHERE c2 = 1; + +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c2 = c2 + c1; +UPDATE test_wl5522.t1 SET c3 = REPEAT("c2", 1024); +UPDATE test_wl5522.t1 SET c4 = REPEAT("c4", 1024); + +SHOW CREATE TABLE test_wl5522.t1; + +SELECT c1, c2 FROM test_wl5522.t1; +SELECT COUNT(*) FROM test_wl5522.t1; +SELECT SUM(c2) FROM test_wl5522.t1; + +SELECT name + FROM information_schema.innodb_metrics + WHERE name = 'ibuf_merges_insert' AND count = 0; + +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +SELECT name + FROM information_schema.innodb_metrics + WHERE name = 'ibuf_merges' AND count > 0; + +SELECT name + FROM information_schema.innodb_metrics + WHERE name = 'ibuf_merges_inserts' AND count > 0; + +SET GLOBAL innodb_disable_background_merge=OFF; + +# Enable normal operation +SET GLOBAL INNODB_PURGE_RUN_NOW=ON; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.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; + +SELECT c1, c2 FROM test_wl5522.t1; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; +CHECK TABLE test_wl5522.t1; + +SELECT c1,c2 FROM test_wl5522.t1; +SELECT COUNT(*) FROM test_wl5522.t1; +SELECT SUM(c2) FROM test_wl5522.t1; + +SHOW CREATE TABLE test_wl5522.t1; + +DROP TABLE test_wl5522.t1; + +#### +# Create a table and save the tablespace and .cfg file, we need to create +# a Btree that has several levels +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb; + +INSERT INTO test_wl5522.t1 VALUES + (100, REPEAT('Karanbir', 899), REPEAT('Ajeeth', 1200)); + +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +INSERT INTO test_wl5522.t1 SELECT * FROM test_wl5522.t1; +SELECT COUNT(*) FROM test_wl5522.t1; +FLUSH TABLES test_wl5522.t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test_wl5522", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE test_wl5522.t1; + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_trigger_corruption_1"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_INTERNAL_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_trigger_corruption_1"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +# + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,buf_page_is_corrupt_failure"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_INTERNAL_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,buf_page_is_corrupt_failure"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +# +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_trigger_corruption_2"; + +--replace_regex $pathfix + +--error ER_INNODB_INDEX_CORRUPT +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_trigger_corruption_2"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF +# + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,ib_import_trigger_corruption_3"; + +--replace_regex $pathfix + +--error ER_NOT_KEYFILE +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,ib_import_trigger_corruption_3"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +SET SESSION debug_dbug="+d,ib_import_create_index_failure_1"; + +ALTER TABLE test_wl5522.t1 ADD INDEX idx(c1); + +SET SESSION debug_dbug="-d,ib_import_create_index_failure_1"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +# + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,fil_space_create_failure"; + +--replace_regex $pathfix + +--error ER_GET_ERRMSG +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,fil_space_create_failure"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +# + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,dict_tf_to_fsp_flags_failure"; + +--replace_regex $pathfix + +--error ER_GET_ERRMSG +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,dict_tf_to_fsp_flags_failure"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + +# + +CREATE TABLE test_wl5522.t1 (c1 INT, c2 VARCHAR(1024), c3 BLOB) ENGINE = Innodb; + +ALTER TABLE test_wl5522.t1 DISCARD TABLESPACE; + +--error ER_TABLESPACE_DISCARDED +SELECT COUNT(*) FROM test_wl5522.t1; + +# Restore files +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespaces("test_wl5522", "t1"); +EOF + +SET SESSION debug_dbug="+d,fsp_flags_is_valid_failure"; + +--replace_regex /'.*t1.cfg'/'t1.cfg'/ + +--error ER_INTERNAL_ERROR +ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE; + +SET SESSION debug_dbug="-d,fsp_flags_is_valid_failure"; + +DROP TABLE test_wl5522.t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test_wl5522", "t1"); +EOF + + +DROP DATABASE test_wl5522; + +set global innodb_monitor_disable = all; +set global innodb_monitor_reset_all = all; + +-- disable_warnings +set global innodb_monitor_enable = default; +set global innodb_monitor_disable = default; +set global innodb_monitor_reset = default; +set global innodb_monitor_reset_all = default; +-- enable_warnings + +--disable_query_log +call mtr.add_suppression("InnoDB: The log sequence numbers [0-9]+ and [0-9]+ in ibdata files do not match the log sequence number [0-9]+ in the ib_logfiles!"); +call mtr.add_suppression("'Resource temporarily unavailable'"); +call mtr.add_suppression("Monitor ibuf_merges is already enabled"); +call mtr.add_suppression("Monitor ibuf_merges_insert is already enabled"); +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("Error in page .* of index \"GEN_CLUST_INDEX\" of table \"test_wl5522\".\"t1\""); +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("Failed to find tablespace for table '\"test_wl5522\".\"t1\"' in the cache"); +call mtr.add_suppression("Could not find a valid tablespace file for 'test_wl5522.*t1'"); +call mtr.add_suppression("while reading index meta-data, expected to read 44 bytes but read only 0 bytes"); +--enable_query_log + +#cleanup +--remove_file $MYSQLTEST_VARDIR/tmp/t1.cfg +--remove_file $MYSQLTEST_VARDIR/tmp/t1.ibd + +eval SET GLOBAL INNODB_FILE_PER_TABLE=$innodb_file_per_table; + diff --git a/mysql-test/suite/innodb/t/innodb-wl5522-zip.test b/mysql-test/suite/innodb/t/innodb-wl5522-zip.test new file mode 100644 index 00000000000..d139e0b700d --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-wl5522-zip.test @@ -0,0 +1,544 @@ +# Not supported in embedded +--source include/not_embedded.inc + +-- source include/have_innodb.inc +# compressed table in tests are with sizes KEY_BLOCK_SIZE 1,2,4,8,16 +# Table creatation fails if KEY_BLOCK_SIZE > innodb-page-size,so +# allow test to run only when innodb-page-size=16 +--source include/have_innodb_16k.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +let $innodb_file_per_table = `SELECT @@innodb_file_per_table`; +let $innodb_file_format = `SELECT @@innodb_file_format`; +let $innodb_strict_mode_orig=`select @@session.innodb_strict_mode`; + +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +SET GLOBAL innodb_file_format = `Barracuda`; +SELECT @@innodb_file_format; + +SET SESSION innodb_strict_mode=1; +SELECT @@SESSION.innodb_strict_mode; + +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 ; + +insert into t1 (b, c) values ('Apa', 'Filler........'), +('Banan', 'Filler........'), ('Cavalry', '..asdasdfaeraf'), +('Devotion', 'asdfuihknaskdf'), ('Evolution', 'lsjndofiabsoibeg'); + +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +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; +--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 + +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +SET GLOBAL innodb_file_format = `Barracuda`; +SELECT @@innodb_file_format; + +# restore session variable +SET SESSION innodb_strict_mode=1; +SELECT @@SESSION.innodb_strict_mode; + +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(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +--list_files $MYSQLD_DATADIR/test + +FLUSH TABLES t1 FOR EXPORT; +SELECT COUNT(*) FROM t1; +perl; +do "$ENV{MTR_SUITE_DIR}/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}/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(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +--list_files $MYSQLD_DATADIR/test +FLUSH TABLES t1 FOR EXPORT; +SELECT COUNT(*) FROM t1; +perl; +do "$ENV{MTR_SUITE_DIR}/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 +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +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}/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 KEY_BLOCK_SIZE=8; + +INSERT INTO t1(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +FLUSH TABLES t1 FOR EXPORT; +SELECT COUNT(*) FROM t1 WHERE c2 = 1; +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF +--list_files $MYSQLD_DATADIR/test +UNLOCK TABLES; + +# Move the LSN forward +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX(c2)) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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. +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; + +INSERT INTO t1(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +FLUSH TABLES t1 FOR EXPORT; +SELECT COUNT(*) FROM t1 WHERE c2 = 1; +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF +UNLOCK TABLES; + +# Move the LSN forward +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX x(c2)) ENGINE=InnoDB + ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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}/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}/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(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +SELECT COUNT(*) FROM t1; + +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(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +FLUSH TABLES t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/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}/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}/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}/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}/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}/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}/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=4; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +# This should fail because is KEY_BLOCK_SIZE=4 +# but KEY_BLOCK_SIZE=8 is 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}/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}/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}/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 + +eval SET GLOBAL INNODB_FILE_FORMAT=$innodb_file_format; +eval SET GLOBAL INNODB_FILE_PER_TABLE=$innodb_file_per_table; +eval SET SESSION innodb_strict_mode=$innodb_strict_mode_orig; diff --git a/mysql-test/suite/innodb/t/innodb-wl5522.test b/mysql-test/suite/innodb/t/innodb-wl5522.test new file mode 100644 index 00000000000..c9e7748cb47 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-wl5522.test @@ -0,0 +1,884 @@ +# Not supported in embedded +--source include/not_embedded.inc + +-- source include/have_innodb.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +let $innodb_file_per_table = `SELECT @@innodb_file_per_table`; +let $innodb_file_format = `SELECT @@innodb_file_format`; + +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +SET GLOBAL innodb_file_format = `Barracuda`; +SELECT @@innodb_file_format; + +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; + +insert into t1 (b, c) values ('Apa', 'Filler........'), +('Banan', 'Filler........'), ('Cavalry', '..asdasdfaeraf'), +('Devotion', 'asdfuihknaskdf'), ('Evolution', 'lsjndofiabsoibeg'); + +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a; +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; +--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 + +SET GLOBAL innodb_file_per_table = 1; +SELECT @@innodb_file_per_table; + +SET GLOBAL innodb_file_format = `Barracuda`; +SELECT @@innodb_file_format; + +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; + +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; + +INSERT INTO t1(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +--list_files $MYSQLD_DATADIR/test + +FLUSH TABLES t1 FOR EXPORT; +SELECT COUNT(*) FROM t1; +perl; +do "$ENV{MTR_SUITE_DIR}/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; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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; + +INSERT INTO t1(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +--list_files $MYSQLD_DATADIR/test +FLUSH TABLES t1 FOR EXPORT; +SELECT COUNT(*) FROM t1; +perl; +do "$ENV{MTR_SUITE_DIR}/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 +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT) ENGINE=InnoDB; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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; + +INSERT INTO t1(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +FLUSH TABLES t1 FOR EXPORT; +SELECT COUNT(*) FROM t1 WHERE c2 = 1; +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF +--list_files $MYSQLD_DATADIR/test +UNLOCK TABLES; + +# Move the LSN forward +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX(c2)) ENGINE=InnoDB; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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. +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB; + +INSERT INTO t1(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +FLUSH TABLES t1 FOR EXPORT; +SELECT COUNT(*) FROM t1 WHERE c2 = 1; +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF +UNLOCK TABLES; + +# Move the LSN forward +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX x(c2)) ENGINE=InnoDB; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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}/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}/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(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +SELECT COUNT(*) FROM t1; + +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; + +INSERT INTO t1(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +FLUSH TABLES t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/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; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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}/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; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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}/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; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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}/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; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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}/include/innodb-util.pl"; +ib_cleanup("test", "t1"); +EOF + +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +DROP TABLE t1; + +# +# Row format tests [EXPORT REDUNDANT - IMPORT COMPACT & DYNAMIC] +# +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; + +INSERT INTO t1(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +FLUSH TABLES t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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}/include/innodb-util.pl"; +ib_cleanup("test", "t1"); +EOF + +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPACT; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +--error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE t1 IMPORT TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +--error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE t1 IMPORT TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/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=REDUNDANT; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +ALTER TABLE t1 IMPORT TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_cleanup("test", "t1"); +EOF + +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +DROP TABLE t1; + +# +# Row format tests [EXPORT COMPACT - IMPORT REDUNDANT & DYNAMIC] +# +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPACT; + +INSERT INTO t1(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +FLUSH TABLES t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPACT; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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}/include/innodb-util.pl"; +ib_cleanup("test", "t1"); +EOF + +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +--error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE t1 IMPORT TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +--error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE t1 IMPORT TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/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=COMPACT; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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}/include/innodb-util.pl"; +ib_cleanup("test", "t1"); +EOF + +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +DROP TABLE t1; + +# +# Row format tests [EXPORT DYNAMIC- IMPORT REDUNDANT & DYNAMIC] +# +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + +INSERT INTO t1(c2) VALUES(1); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; + +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +FLUSH TABLES t1 FOR EXPORT; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespaces("test", "t1"); +EOF + +UNLOCK TABLES; + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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}/include/innodb-util.pl"; +ib_cleanup("test", "t1"); +EOF + +SHOW CREATE TABLE t1; +SELECT * FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPACT; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +--error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE t1 IMPORT TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_unlink_tablespace("test", "t1"); +EOF + +DROP TABLE t1; + +CREATE TABLE t1( + c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_discard_tablespaces("test", "t1"); +ib_restore_tablespaces("test", "t1"); +EOF + +--error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE t1 IMPORT TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/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=DYNAMIC; + +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t1; + +perl; +do "$ENV{MTR_SUITE_DIR}/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}/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 + +eval SET GLOBAL INNODB_FILE_FORMAT=$innodb_file_format; +eval SET GLOBAL INNODB_FILE_PER_TABLE=$innodb_file_per_table; diff --git a/mysql-test/suite/innodb/t/innodb-xa.test b/mysql-test/suite/innodb/t/innodb-xa.test new file mode 100644 index 00000000000..d94cd75aa14 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-xa.test @@ -0,0 +1,17 @@ +--source include/have_innodb.inc + +--disable_abort_on_error +xa rollback 'xid2'; +drop table if exists t1; +create table t1(a int)engine=innodb; +rollback; +xa start 'xid2'; +insert into `t1` values (1); +savepoint `sv1`; +xa end 'xid2'; +start transaction; +xa prepare 'xid2'; +release savepoint `sv1`; +xa commit 'xid2'; +drop table t1; + diff --git a/mysql-test/suite/innodb/t/innodb.test b/mysql-test/suite/innodb/t/innodb.test index c36dc1c5f95..b519c48b23d 100644 --- a/mysql-test/suite/innodb/t/innodb.test +++ b/mysql-test/suite/innodb/t/innodb.test @@ -14,10 +14,11 @@ ####################################################################### -- source include/have_innodb.inc + let $MYSQLD_DATADIR= `select @@datadir`; + let collation=utf8_unicode_ci; --source include/have_collation.inc - set optimizer_switch = 'mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; # Save the original values of some variables in order to be able to @@ -439,21 +440,11 @@ INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca select count(*) from t1 where sca_code = 'PD'; select count(*) from t1 where sca_code <= 'PD'; select count(*) from t1 where sca_pic is null; -# this should be fixed by MySQL (see Bug #51451) -# now that http://bugs.mysql.com/49838 is fixed the following ALTER does -# copy the table instead of failing -# --error ER_WRONG_NAME_FOR_INDEX alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic); -alter table t1 drop index sca_pic; -alter table t1 add index sca_pic (cat_code, sca_pic); select count(*) from t1 where sca_code='PD' and sca_pic is null; select count(*) from t1 where cat_code='E'; -# this should be fixed by MySQL (see Bug #51451) ---error ER_WRONG_NAME_FOR_INDEX alter table t1 drop index sca_pic, add index (sca_pic, cat_code); -alter table t1 drop index sca_pic; -alter table t1 add index (sca_pic, cat_code); select count(*) from t1 where sca_code='PD' and sca_pic is null; select count(*) from t1 where sca_pic >= 'n'; select sca_pic from t1 where sca_pic is null; @@ -1058,7 +1049,7 @@ CREATE TABLE t2 ( INSERT INTO t1 VALUES ('old', 'somevalu'), ('other', 'anyvalue'); INSERT INTO t2 VALUES (10, 'old'), (20, 'other'); --- error ER_FOREIGN_DUPLICATE_KEY +--error ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO UPDATE t1 SET c1 = 'other' WHERE c1 = 'old'; DROP TABLE t2,t1; @@ -1248,16 +1239,6 @@ select distinct concat(a, b) from t1; drop table t1; # -# BUG#7709 test case - Boolean fulltext query against unsupported -# engines does not fail -# - -CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; ---error 1214 -SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); -DROP TABLE t1; - -# # check null values #1 # @@ -1939,7 +1920,7 @@ INSERT INTO t1 VALUES ('other', 'anyvalue'); INSERT INTO t2 VALUES ('old'); INSERT INTO t2 VALUES ('other'); ---error ER_FOREIGN_DUPLICATE_KEY +--error ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; DROP TABLE t2; @@ -2317,12 +2298,12 @@ CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL; -# mysqltest first does replace_regex, then replace_result ---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ -# Embedded server doesn't chdir to data directory ---replace_result $MYSQLD_DATADIR ./ master-data/ '' ---error 1025 +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +set @old_sql_mode = @@sql_mode; +set @@sql_mode = 'STRICT_TRANS_TABLES'; +--error ER_FK_COLUMN_NOT_NULL ALTER TABLE t2 MODIFY a INT NOT NULL; +set @@sql_mode = @old_sql_mode; DELETE FROM t1; DROP TABLE t2,t1; diff --git a/mysql-test/suite/innodb/t/innodb_blob_unrecoverable_crash.test b/mysql-test/suite/innodb/t/innodb_blob_unrecoverable_crash.test new file mode 100644 index 00000000000..dc6d2f6f65c --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_blob_unrecoverable_crash.test @@ -0,0 +1,41 @@ +--source include/not_embedded.inc +--source include/not_crashrep.inc +--source include/have_innodb.inc + +SET GLOBAL max_allowed_packet = 100*1024*1024; + +--disable_query_log +call mtr.add_suppression("InnoDB: The total blob data length"); +FLUSH TABLES; +--enable_query_log + +--echo # Connection big_packets: +connect(big_packets,localhost,root,,); +connection big_packets; + +CREATE TABLE t1 (a BIGINT PRIMARY KEY, b LONGBLOB) ENGINE=InnoDB; + +# Insert a few rows (it doesn't really matter how many). These transactions +# are committed once they are acked, so they should not be lost. +INSERT INTO t1 (a, b) VALUES (1, '1'); +INSERT INTO t1 (a, b) VALUES (2, '2'); +INSERT INTO t1 (a, b) VALUES (3, '3'); +INSERT INTO t1 (a, b) VALUES (4, '4'); +INSERT INTO t1 (a, b) VALUES (5, '5'); + +# The BLOB insert will fail, and should disappear. However all data committed +# up to this point should not be lost. +start transaction; +--replace_regex /\(> [0-9]*\)/(> ####)/ +--error ER_TOO_BIG_ROWSIZE +INSERT INTO t1 (a, b) VALUES (6, REPEAT('a', 20*1024*1024)); + +connection default; +--source include/kill_and_restart_mysqld.inc +disconnect big_packets; + +# We should see (1,2,3,4,5) here. +SELECT a FROM t1; + +# Clean up. +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb_bug11766634.test b/mysql-test/suite/innodb/t/innodb_bug11766634.test deleted file mode 100644 index f360c4b1ce1..00000000000 --- a/mysql-test/suite/innodb/t/innodb_bug11766634.test +++ /dev/null @@ -1,59 +0,0 @@ -# Bug 11766634 59783: InnoDB data grows unexpectedly when inserting, -# truncating, inserting the same set of rows. -# -# Scenario: -# create table t1. Insert $recs records. check size of ibdata1. -# drop table t1. create table t1. Insert the same set of $recs -# records. The size of ibdata1 must not increase. -# - --- source include/not_embedded.inc --- source include/have_innodb.inc - -create table t1 (f1 char(255)) engine innodb; -let $MYSQLD_DATADIR=`select @@datadir`; -let IBDATA1=$MYSQLD_DATADIR/ibdata1; - -let $recs = 36262; - ---disable_query_log -let $c = $recs; -start transaction; -while ($c) -{ - insert into t1 values ('Hello World'); - dec $c; -} -commit work; ---enable_query_log - -perl; -my $filesize = -s $ENV{'IBDATA1'}; -my $filename = $ENV{MYSQL_TMP_DIR} . '/innodb_bug11766634.txt'; -open F, '>', $filename or die "open(>$filename): $!"; -print F $filesize; -EOF - -drop table t1; -create table t1 (f1 char(255)) engine innodb; - ---disable_query_log -let $c = $recs; -start transaction; -while ($c) -{ - insert into t1 values ('Hello World'); - dec $c; -} -commit work; ---enable_query_log - -perl; -my $filesize = -s $ENV{'IBDATA1'}; -my $filename = $ENV{MYSQL_TMP_DIR} . '/innodb_bug11766634.txt'; -$_=do $filename; -print $_ == $filesize, "\n"; -EOF - -drop table t1; - diff --git a/mysql-test/suite/innodb/t/innodb_bug12400341.test b/mysql-test/suite/innodb/t/innodb_bug12400341.test index 68daad46145..165e19b7cbc 100644 --- a/mysql-test/suite/innodb/t/innodb_bug12400341.test +++ b/mysql-test/suite/innodb/t/innodb_bug12400341.test @@ -13,13 +13,19 @@ if (`select count(*)=0 from information_schema.global_variables where variable_n # undo slots of the previous test might exist still --source include/not_windows.inc -call mtr.add_suppression("InnoDB: Warning: cannot find a free slot for an undo log. Do you have too"); +# Previous undo slots cause unnecessary failures +--source include/not_windows.inc + +call mtr.add_suppression("InnoDB: Warning: cannot find a free slot for an undo log. Do you have too*"); --disable_query_log set @old_innodb_trx_rseg_n_slots_debug = @@innodb_trx_rseg_n_slots_debug; set global innodb_trx_rseg_n_slots_debug = 32; --enable_query_log +set @old_innodb_undo_logs = @@innodb_undo_logs; +set global innodb_undo_logs=1; + show variables like "max_connections"; show variables like "innodb_thread_concurrency"; show variables like "innodb_file_per_table"; @@ -104,6 +110,8 @@ while ($c) # drop database mysqltest; +set global innodb_undo_logs = @old_innodb_undo_logs; + --disable_query_log set global innodb_trx_rseg_n_slots_debug = @old_innodb_trx_rseg_n_slots_debug; --enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb_bug12661768.test b/mysql-test/suite/innodb/t/innodb_bug12661768.test index 01549a7e9e9..b1ba1b44917 100644 --- a/mysql-test/suite/innodb/t/innodb_bug12661768.test +++ b/mysql-test/suite/innodb/t/innodb_bug12661768.test @@ -44,7 +44,7 @@ SET SESSION foreign_key_checks=1; -- enable_result_log --- error ER_FOREIGN_DUPLICATE_KEY +-- error ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO eval UPDATE IGNORE `$t1_name` SET a = 3; eval DROP TABLE `$t2_name`, `$t1_name`; diff --git a/mysql-test/suite/innodb/t/innodb_bug12902967.test b/mysql-test/suite/innodb/t/innodb_bug12902967.test index 1183c4ceff6..8e1b8199524 100644 --- a/mysql-test/suite/innodb/t/innodb_bug12902967.test +++ b/mysql-test/suite/innodb/t/innodb_bug12902967.test @@ -24,7 +24,7 @@ alter table t1 add constraint c1 foreign key (f1) references t1(f1); perl; $file = $ENV{error_log}; open (FILE, '<', $file) or die "can't open(< $file): $!\n"; -print ((grep { /^InnoDB:/ and not /aio/i } <FILE>)[-2..-1]); +print ((grep { /^InnoDB:/ and not /aio/i and not /io_setup\(\) attempt [0-9]+ failed/ } <FILE>)[-2..-1]); EOF drop table t1; diff --git a/mysql-test/suite/innodb/t/innodb_bug13510739.test b/mysql-test/suite/innodb/t/innodb_bug13510739.test index f10bcd8e272..d2193996d68 100644 --- a/mysql-test/suite/innodb/t/innodb_bug13510739.test +++ b/mysql-test/suite/innodb/t/innodb_bug13510739.test @@ -2,6 +2,10 @@ # Bug#13510739 63775: SERVER CRASH ON HANDLER READ NEXT AFTER DELETE RECORD. # +if (`select plugin_auth_version < "5.6.15" from information_schema.plugins where plugin_name='innodb'`) +{ + --skip Not fixed in InnoDB before 5.6.15 +} -- source include/have_innodb.inc CREATE TABLE bug13510739 (c INTEGER NOT NULL, PRIMARY KEY (c)) ENGINE=INNODB; diff --git a/mysql-test/suite/innodb/t/innodb_bug13635833.test b/mysql-test/suite/innodb/t/innodb_bug13635833.test deleted file mode 100644 index 47185b9d526..00000000000 --- a/mysql-test/suite/innodb/t/innodb_bug13635833.test +++ /dev/null @@ -1,64 +0,0 @@ ---source include/have_innodb.inc ---source include/have_debug_sync.inc ---source include/not_embedded.inc - -SET DEBUG_SYNC='reset'; - -# Save the initial number of concurrent sessions ---source include/count_sessions.inc - -create table t1 (f1 integer, key k1 (f1)) engine=innodb; -create table t2 (f1 int, f2 int, key(f1), key(f2)) engine=innodb; -create table t3 (f2 int, key(f2)) engine=innodb; - -insert into t1 values (10); -insert into t2 values (10, 20); -insert into t3 values (20); - -alter table t2 add constraint c1 foreign key (f1) - references t1(f1) on update cascade; - -show create table t1; -show create table t2; -show create table t3; - -SET DEBUG_SYNC='innodb_rename_table_ready SIGNAL update_can_proceed - WAIT_FOR dict_unfreeze'; - ---send -alter table t2 add constraint z1 foreign key (f2) - references t3(f2) on update cascade; - -connect (thr2,localhost,root,,); -connection thr2; - -SET DEBUG_SYNC='innodb_row_update_for_mysql_begin - WAIT_FOR update_can_proceed'; -SET DEBUG_SYNC='innodb_dml_cascade_dict_unfreeze SIGNAL dict_unfreeze - WAIT_FOR foreign_free_cache'; - ---send -update ignore t1 set f1 = 20; - -connection default; ---replace_regex /'[^']*test\/#sql2-[0-9a-f-]*'/'#sql2-temporary'/ ---error ER_ERROR_ON_RENAME -reap; - -SET DEBUG_SYNC='now SIGNAL foreign_free_cache'; - -connection thr2; -reap; -disconnect thr2; ---source include/wait_until_disconnected.inc - -connection default; - -drop table t2; -drop table t1; -drop table t3; - -# Wait till we reached the initial number of concurrent sessions ---source include/wait_until_count_sessions.inc - -SET DEBUG_SYNC='reset'; diff --git a/mysql-test/suite/innodb/t/innodb_bug14676111-master.opt b/mysql-test/suite/innodb/t/innodb_bug14676111-master.opt deleted file mode 100644 index e16b9b0b895..00000000000 --- a/mysql-test/suite/innodb/t/innodb_bug14676111-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-innodb-purge-threads=0 diff --git a/mysql-test/suite/innodb/t/innodb_bug14676111.opt b/mysql-test/suite/innodb/t/innodb_bug14676111.opt new file mode 100644 index 00000000000..77945d1e4bb --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug14676111.opt @@ -0,0 +1 @@ +--innodb-sys-tablestats=1
\ No newline at end of file diff --git a/mysql-test/suite/innodb/t/innodb_bug14676111.test b/mysql-test/suite/innodb/t/innodb_bug14676111.test index 41862b8105e..02ef5e5e7f0 100644 --- a/mysql-test/suite/innodb/t/innodb_bug14676111.test +++ b/mysql-test/suite/innodb/t/innodb_bug14676111.test @@ -3,11 +3,6 @@ -- source include/have_innodb.inc -- source include/have_debug.inc -# Note that this test needs to be able to manipulate how/when purge is done -# using @@innodb_limit_optimistic_insert_debug. This does not work with -# background purge threads, so we disabled them in the -master.opt (they are -# off by default in normal 5.5 innodb but on by default in xtradb) - if (`select count(*)=0 from information_schema.global_variables where variable_name = 'INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG'`) { --skip Test requires InnoDB built with UNIV_DEBUG definition. @@ -15,16 +10,12 @@ if (`select count(*)=0 from information_schema.global_variables where variable_n --disable_query_log set @old_innodb_limit_optimistic_insert_debug = @@innodb_limit_optimistic_insert_debug; +set @old_innodb_undo_logs = @@innodb_undo_logs; +# Limit undo segments for stable progress of purge. +set global innodb_undo_logs = 1; --enable_query_log ---disable_warnings -drop table if exists t1; ---enable_warnings - -CREATE TABLE t1 (a int not null primary key) engine=InnoDB; -let $wait_condition= - SELECT VARIABLE_VALUE < 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS - WHERE VARIABLE_NAME = 'INNODB_PURGE_TRX_ID_AGE'; +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=0; # # make 4 leveled straight tree @@ -55,10 +46,12 @@ insert into t1 values (2); #(1, 2) (3) (4) (5) analyze table t1; -select DATA_LENGTH / 16384 from information_schema.TABLES where TABLE_SCHEMA = 'test' and TABLE_NAME = 't1'; +select CLUST_INDEX_SIZE from information_schema.INNODB_SYS_TABLESTATS where NAME = 'test/t1'; delete from t1 where a=4; ---source include/wait_condition.inc +set global innodb_purge_stop_now=ON; +set global innodb_purge_run_now=ON; +--source include/wait_innodb_all_purged.inc #deleting 1 record of 2 records don't cause merge artificially. #current tree form # (1, 5) @@ -67,10 +60,12 @@ delete from t1 where a=4; #(1, 2) (3) (5) analyze table t1; -select DATA_LENGTH / 16384 from information_schema.TABLES where TABLE_SCHEMA = 'test' and TABLE_NAME = 't1'; +select CLUST_INDEX_SIZE from information_schema.INNODB_SYS_TABLESTATS where NAME = 'test/t1'; delete from t1 where a=5; ---source include/wait_condition.inc +set global innodb_purge_stop_now=ON; +set global innodb_purge_run_now=ON; +--source include/wait_innodb_all_purged.inc #deleting 1 record of 2 records don't cause merge artificially. #current tree form # (1) @@ -79,16 +74,18 @@ delete from t1 where a=5; #(1, 2) (3) <- merged next analyze table t1; -select DATA_LENGTH / 16384 from information_schema.TABLES where TABLE_SCHEMA = 'test' and TABLE_NAME = 't1'; +select CLUST_INDEX_SIZE from information_schema.INNODB_SYS_TABLESTATS where NAME = 'test/t1'; # # cause merge at level 0 # #disable the artificial limitation of records in a page -set global innodb_limit_optimistic_insert_debug = 10000; +set global innodb_limit_optimistic_insert_debug = 0; delete from t1 where a=2; ---source include/wait_condition.inc +set global innodb_purge_stop_now=ON; +set global innodb_purge_run_now=ON; +--source include/wait_innodb_all_purged.inc #merge page occurs. and lift up occurs. #current tree form # (1) @@ -96,7 +93,7 @@ delete from t1 where a=2; # (1, 3) analyze table t1; -select DATA_LENGTH / 16384 from information_schema.TABLES where TABLE_SCHEMA = 'test' and TABLE_NAME = 't1'; +select CLUST_INDEX_SIZE from information_schema.INNODB_SYS_TABLESTATS where NAME = 'test/t1'; insert into t1 values (2); #current tree form @@ -105,13 +102,15 @@ insert into t1 values (2); # (1, 2, 3) delete from t1 where a=2; ---source include/wait_condition.inc +set global innodb_purge_stop_now=ON; +set global innodb_purge_run_now=ON; +--source include/wait_innodb_all_purged.inc #current tree form # (1) # (1, 3) analyze table t1; -select DATA_LENGTH / 16384 from information_schema.TABLES where TABLE_SCHEMA = 'test' and TABLE_NAME = 't1'; +select CLUST_INDEX_SIZE from information_schema.INNODB_SYS_TABLESTATS where NAME = 'test/t1'; insert into t1 values (2); #current tree form @@ -119,15 +118,18 @@ insert into t1 values (2); # (1, 2, 3) <- lift up this level next, because the father is root delete from t1 where a=2; ---source include/wait_condition.inc +set global innodb_purge_stop_now=ON; +set global innodb_purge_run_now=ON; +--source include/wait_innodb_all_purged.inc #current tree form # (1, 3) analyze table t1; -select DATA_LENGTH / 16384 from information_schema.TABLES where TABLE_SCHEMA = 'test' and TABLE_NAME = 't1'; +select CLUST_INDEX_SIZE from information_schema.INNODB_SYS_TABLESTATS where NAME = 'test/t1'; drop table t1; --disable_query_log set global innodb_limit_optimistic_insert_debug = @old_innodb_limit_optimistic_insert_debug; +set global innodb_undo_logs = @old_innodb_undo_logs; --enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb_bug21704.test b/mysql-test/suite/innodb/t/innodb_bug21704.test index 67d76587819..82e7c81d0e4 100644 --- a/mysql-test/suite/innodb/t/innodb_bug21704.test +++ b/mysql-test/suite/innodb/t/innodb_bug21704.test @@ -1,4 +1,5 @@ ---source include/have_innodb.inc +-- source include/have_innodb.inc + --echo # --echo # Bug#21704: Renaming column does not update FK definition. --echo # @@ -8,12 +9,6 @@ --echo # foreign key (either in the referencing or referenced table). --echo ---disable_warnings -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS t2; -DROP TABLE IF EXISTS t3; ---enable_warnings - CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT ENGINE=INNODB; CREATE TABLE t2 (a INT PRIMARY KEY, b INT, @@ -32,64 +27,50 @@ INSERT INTO t3 VALUES (1,1,1),(2,2,2),(3,3,3); --echo # Test renaming the column in the referenced table. --echo -# mysqltest first does replace_regex, then replace_result ---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ -# Embedded server doesn't chdir to data directory ---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' ---error ER_ERROR_ON_RENAME -ALTER TABLE t1 CHANGE a c INT; +--enable_info +ALTER TABLE t1 CHANGE a e INT; --echo # Ensure that online column rename works. ---enable_info ALTER TABLE t1 CHANGE b c INT; ---disable_info --echo --echo # Test renaming the column in the referencing table --echo -# mysqltest first does replace_regex, then replace_result ---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ -# Embedded server doesn't chdir to data directory ---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' ---error ER_ERROR_ON_RENAME -ALTER TABLE t2 CHANGE a c INT; +ALTER TABLE t2 CHANGE a z INT; --echo # Ensure that online column rename works. ---enable_info ALTER TABLE t2 CHANGE b c INT; ---disable_info --echo --echo # Test with self-referential constraints --echo -# mysqltest first does replace_regex, then replace_result ---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ -# Embedded server doesn't chdir to data directory ---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' ---error ER_ERROR_ON_RENAME -ALTER TABLE t3 CHANGE a d INT; +ALTER TABLE t3 CHANGE a f INT; -# mysqltest first does replace_regex, then replace_result ---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ -# Embedded server doesn't chdir to data directory ---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' ---error ER_ERROR_ON_RENAME -ALTER TABLE t3 CHANGE b d INT; +ALTER TABLE t3 CHANGE b g INT; --echo # Ensure that online column rename works. ---enable_info ALTER TABLE t3 CHANGE c d INT; ---disable_info --echo --echo # Cleanup. --echo +--disable_info +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; +SHOW CREATE TABLE t3; + +SELECT f.*, c.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS c +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FOREIGN f +ON c.ID=f.ID +WHERE FOR_NAME LIKE 'test/t%'; + DROP TABLE t3; DROP TABLE t2; DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb_bug34053.test b/mysql-test/suite/innodb/t/innodb_bug34053.test index b935e45c06d..56c26acb632 100644 --- a/mysql-test/suite/innodb/t/innodb_bug34053.test +++ b/mysql-test/suite/innodb/t/innodb_bug34053.test @@ -21,8 +21,11 @@ FLUSH PRIVILEGES; -- connection con1 -- error ER_SPECIFIC_ACCESS_DENIED_ERROR CREATE TABLE innodb_monitor (a INT) ENGINE=INNODB; --- error ER_SPECIFIC_ACCESS_DENIED_ERROR +# this should only fail with UNIV_MEM_DEBUG CREATE TABLE innodb_mem_validate (a INT) ENGINE=INNODB; +DROP TABLE innodb_mem_validate; +CREATE TABLE innodb_sql (a INT) ENGINE=INNODB; +DROP TABLE innodb_sql; CREATE TABLE innodb_monitorx (a INT) ENGINE=INNODB; DROP TABLE innodb_monitorx; CREATE TABLE innodb_monito (a INT) ENGINE=INNODB; @@ -39,12 +42,10 @@ CREATE TABLE innodb_mem_validate (a INT) ENGINE=INNODB; -- connection con1 -- error ER_SPECIFIC_ACCESS_DENIED_ERROR DROP TABLE innodb_monitor; --- error ER_SPECIFIC_ACCESS_DENIED_ERROR DROP TABLE innodb_mem_validate; -- connection default DROP TABLE innodb_monitor; -DROP TABLE innodb_mem_validate; DROP USER 'shane'@'localhost'; -- disconnect con1 diff --git a/mysql-test/suite/innodb/t/innodb_bug34300.test b/mysql-test/suite/innodb/t/innodb_bug34300.test index 11682ad7828..13c708b48d6 100644 --- a/mysql-test/suite/innodb/t/innodb_bug34300.test +++ b/mysql-test/suite/innodb/t/innodb_bug34300.test @@ -1,31 +1,37 @@ ---source include/have_innodb.inc # # Bug#34300 Tinyblob & tinytext fields currupted after export/import and alter in 5.1 # http://bugs.mysql.com/34300 # +-- source include/have_innodb.inc + +if (`select plugin_auth_version <= "5.6.22-MariaDB-72.0" from information_schema.plugins where plugin_name='innodb'`) +{ + --skip Not fixed in XtraDB as of 5.6.22-MariaDB-72.0 or earlier +} + -- disable_query_log -- disable_result_log -call mtr.add_suppression("InnoDB: Warning: a long semaphore wait:"); -call mtr.add_suppression("the age of the last checkpoint is"); +call mtr.add_suppression("InnoDB: The total blob data length"); # set packet size and reconnect let $max_packet=`select @@global.max_allowed_packet`; SET @@global.max_allowed_packet=16777216; --connect (newconn, localhost, root,,) -DROP TABLE IF EXISTS bug34300; +--enable_result_log + CREATE TABLE bug34300 ( f4 TINYTEXT, f6 MEDIUMTEXT, f8 TINYBLOB ) ENGINE=InnoDB; +--replace_regex /\(> [0-9]*\)/(> ####)/ +--error ER_TOO_BIG_ROWSIZE INSERT INTO bug34300 VALUES ('xxx', repeat('a', 8459264), 'zzz'); --- enable_result_log - SELECT f4, f8 FROM bug34300; ALTER TABLE bug34300 ADD COLUMN (f10 INT); diff --git a/mysql-test/suite/innodb/t/innodb_bug47167.test b/mysql-test/suite/innodb/t/innodb_bug47167.test index 505c21547b2..88adfc753a9 100644 --- a/mysql-test/suite/innodb/t/innodb_bug47167.test +++ b/mysql-test/suite/innodb/t/innodb_bug47167.test @@ -44,3 +44,8 @@ set global innodb_file_format_max = on; --error ER_WRONG_VALUE_FOR_VAR set global innodb_file_format_max = off; --enable_warnings + +# Put the saved value back to 'innodb_file_format_max' +--disable_query_log +set global innodb_file_format_max = @old_innodb_file_format_max; +--enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb_bug53592.test b/mysql-test/suite/innodb/t/innodb_bug53592.test index 2f901d7eb99..6c0f5a8422d 100644 --- a/mysql-test/suite/innodb/t/innodb_bug53592.test +++ b/mysql-test/suite/innodb/t/innodb_bug53592.test @@ -1,8 +1,8 @@ ---source include/have_innodb.inc # Testcase for Bug #53592 - "crash replacing duplicates into # table after fast alter table added unique key". The fix is to make # sure index number lookup should go through "index translation table". +--source include/have_innodb.inc # Use FIC for index creation set old_alter_table=0; @@ -75,7 +75,7 @@ INSERT INTO bug53592_1 VALUES (3, 4); INSERT INTO bug53592_2 VALUES (1); INSERT INTO bug53592_2 VALUES (3); ---error ER_FOREIGN_DUPLICATE_KEY +--error ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO UPDATE bug53592_1 SET col1 = 3 WHERE col2 = 2; drop table bug53592_2; diff --git a/mysql-test/suite/innodb/t/innodb_bug54044.test b/mysql-test/suite/innodb/t/innodb_bug54044.test index e79e34b8e59..61a09375ae1 100644 --- a/mysql-test/suite/innodb/t/innodb_bug54044.test +++ b/mysql-test/suite/innodb/t/innodb_bug54044.test @@ -1,7 +1,7 @@ ---source include/have_innodb.inc # This is the test for bug #54044. Special handle MYSQL_TYPE_NULL type # during create table, so it will not trigger assertion failure. +--source include/have_innodb.inc # This 'create table' operation no longer uses the NULL datatype. @@ -16,3 +16,13 @@ CREATE TABLE tmp ENGINE = INNODB AS SELECT COALESCE(NULL, NULL, NULL), GREATEST(NULL, NULL), NULL; SHOW CREATE TABLE tmp; DROP TABLE tmp; + +# These 'create table' operations should fail because of +# using NULL datatype + +CREATE TABLE t1 (a VARCHAR(3)) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('foo'),('bar'); +FLUSH TABLES; +--error 1005 +CREATE TEMPORARY TABLE tmp ENGINE=InnoDB AS SELECT VALUES(a) FROM t1; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb_bug56947.test b/mysql-test/suite/innodb/t/innodb_bug56947.test index b6feb239314..7883cafe291 100644 --- a/mysql-test/suite/innodb/t/innodb_bug56947.test +++ b/mysql-test/suite/innodb/t/innodb_bug56947.test @@ -1,15 +1,18 @@ ---source include/have_innodb.inc # # Bug #56947 valgrind reports a memory leak in innodb-plugin.innodb-index # -SET @old_innodb_file_per_table=@@innodb_file_per_table; -# avoid a message about filed *.ibd file creation in the error log +-- source include/have_innodb.inc +-- source include/have_debug.inc + SET GLOBAL innodb_file_per_table=0; create table bug56947(a int not null) engine = innodb; -CREATE TABLE `bug56947#1`(a int) ENGINE=InnoDB; ---error 156 + +SET DEBUG_DBUG='+d,ib_rebuild_cannot_rename'; +--replace_regex /"[^"]*"/"xxx"/ +--error ER_GET_ERRNO alter table bug56947 add unique index (a); -drop table `bug56947#1`; +SET DEBUG_DBUG='-d,ib_rebuild_cannot_rename'; +check table bug56947; + drop table bug56947; ---disable_query_log -SET GLOBAL innodb_file_per_table=@old_innodb_file_per_table; +SET @@global.innodb_file_per_table=DEFAULT; diff --git a/mysql-test/suite/innodb/t/innodb_bug57904.test b/mysql-test/suite/innodb/t/innodb_bug57904.test index 48dc5254b26..97e7ec93d87 100644 --- a/mysql-test/suite/innodb/t/innodb_bug57904.test +++ b/mysql-test/suite/innodb/t/innodb_bug57904.test @@ -18,7 +18,8 @@ CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT, REFERENCES customer(id) ) ENGINE=INNODB; -query_vertical SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS; +query_vertical SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS +WHERE table_name = 'product_order'; DROP TABLE product_order; DROP TABLE product; diff --git a/mysql-test/suite/innodb/t/innodb_bug59641.test b/mysql-test/suite/innodb/t/innodb_bug59641.test index a8d35cd1029..7fa32d2ec35 100644 --- a/mysql-test/suite/innodb/t/innodb_bug59641.test +++ b/mysql-test/suite/innodb/t/innodb_bug59641.test @@ -2,11 +2,11 @@ # Bug #59641 Prepared XA transaction causes shutdown hang after a crash -- source include/not_embedded.inc -# The server would issue this warning on restart. -call mtr.add_suppression("Found 3 prepared XA transactions"); -# Close tables used by other tests (to not get crashed myisam tables) -flush tables; +--disable_query_log +call mtr.add_suppression("Found 3 prepared XA transactions"); +FLUSH TABLES; +--enable_query_log CREATE TABLE t(a INT PRIMARY KEY, b INT)ENGINE=InnoDB; INSERT INTO t VALUES(2,2),(4,4),(8,8),(16,16),(32,32); @@ -17,7 +17,6 @@ XA END '123'; XA PREPARE '123'; CONNECT (con1,localhost,root,,); -CONNECTION con1; XA START '456'; INSERT INTO t VALUES(3,47),(5,67); @@ -26,7 +25,6 @@ XA END '456'; XA PREPARE '456'; CONNECT (con2,localhost,root,,); -CONNECTION con2; XA START '789'; UPDATE t SET b=4*a WHERE a=32; @@ -34,30 +32,13 @@ XA END '789'; XA PREPARE '789'; CONNECT (con3,localhost,root,,); -CONNECTION con3; -# Kill the server without sending a shutdown command --- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- shutdown_server 0 --- source include/wait_until_disconnected.inc - -# Restart the server. --- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- enable_reconnect --- source include/wait_until_connected_again.inc +--source include/kill_and_restart_mysqld.inc SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SELECT * FROM t; COMMIT; -# Shut down the server. This would hang because of the bug. --- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- shutdown_server --- source include/wait_until_disconnected.inc - -# Restart the server. --- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- enable_reconnect --- source include/wait_until_connected_again.inc +--source include/restart_mysqld.inc SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SELECT * FROM t; diff --git a/mysql-test/suite/innodb/t/innodb_bug60049.test b/mysql-test/suite/innodb/t/innodb_bug60049.test index 19c7fad484d..6760d1a1f02 100644 --- a/mysql-test/suite/innodb/t/innodb_bug60049.test +++ b/mysql-test/suite/innodb/t/innodb_bug60049.test @@ -1,16 +1,22 @@ ---source include/have_innodb.inc # Bug #60049 Verify that purge leaves no garbage in unique secondary indexes # This test requires a fresh server start-up and a slow shutdown. # This was a suspected bug (not a bug). -- source include/not_embedded.inc +-- source include/have_innodb.inc +-- source include/have_innodb_16k.inc -# -# This test will not work if we don't do full shutdown of innodb -# -set @@global.innodb_fast_shutdown=0; +call mtr.add_suppression('InnoDB: Error: Table "mysql"."innodb_(table|index)_stats" not found'); +call mtr.add_suppression('InnoDB: Error: Fetch of persistent statistics requested'); -CREATE TABLE t(a INT)ENGINE=InnoDB; +-- disable_query_log +let $create1 = query_get_value(SHOW CREATE TABLE mysql.innodb_table_stats, Create Table, 1); +let $create2 = query_get_value(SHOW CREATE TABLE mysql.innodb_index_stats, Create Table, 1); +DROP TABLE mysql.innodb_index_stats; +DROP TABLE mysql.innodb_table_stats; +-- enable_query_log + +CREATE TABLE t(a INT)ENGINE=InnoDB STATS_PERSISTENT=0; RENAME TABLE t TO u; DROP TABLE u; SELECT @@innodb_fast_shutdown; @@ -42,3 +48,8 @@ EOF -- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -- enable_reconnect -- source include/wait_until_connected_again.inc + +-- disable_query_log +USE mysql; +eval $create1; +eval $create2; diff --git a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test index f67e2e7e047..ee04e8d66fc 100644 --- a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test +++ b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test @@ -2,12 +2,13 @@ # Test for persistent corrupt bit for corrupted index and table # -- source include/have_innodb.inc +#-- source include/have_innodb_16k.inc -- source include/not_embedded.inc # This test needs debug server -- source include/have_debug.inc -- disable_query_log -call mtr.add_suppression("Flagged corruption of idx.*in CHECK TABLE"); +call mtr.add_suppression("Flagged corruption of idx.*in"); set names utf8; @@ -38,7 +39,7 @@ select count(*) from corrupt_bit_test_ā; # This will flag all secondary indexes corrupted SET SESSION debug_dbug="+d,dict_set_index_corrupted"; check table corrupt_bit_test_ā; -SET SESSION debug_dbug="-d,dict_set_index_corrupted"; +SET SESSION debug_dbug=""; # Cannot create new indexes while corrupted indexes exist --error ER_INDEX_CORRUPT diff --git a/mysql-test/suite/innodb/t/innodb_ctype_ldml-master.opt b/mysql-test/suite/innodb/t/innodb_ctype_ldml-master.opt new file mode 100644 index 00000000000..cddf744de98 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_ctype_ldml-master.opt @@ -0,0 +1,3 @@ +--character-sets-dir=$MYSQL_TEST_DIR/std_data/ +--default-storage-engine=InnoDB + diff --git a/mysql-test/suite/innodb/t/innodb_ctype_ldml.test b/mysql-test/suite/innodb/t/innodb_ctype_ldml.test new file mode 100644 index 00000000000..011271e4e22 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_ctype_ldml.test @@ -0,0 +1,369 @@ +--source include/have_innodb.inc +--source include/have_ucs2.inc +--source include/have_utf8mb4.inc +--source include/have_utf16.inc +--source include/have_utf32.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# Index.xml has some intentional errors in collation definitions. +# They are reported to the server error log. Let's suppress them. +--disable_query_log +call mtr.add_suppression("Syntax error at '\\[strength tertiary\\]'"); +call mtr.add_suppression("Can't reset before a primary ignorable character U\\+A48C"); +--enable_query_log + +--echo In the following tests we change the order of letter "b" +--echo making it equal to letter "a", and check that it works +--echo with all Unicode character sets +set names utf8; + +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +show variables like 'character_sets_dir%'; + +show collation like 'utf8_phone_ci'; +CREATE TABLE t1 ( + name VARCHAR(64), + phone VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_phone_ci +); +INSERT INTO t1 VALUES ('Svoj','+7 912 800 80 02'); +INSERT INTO t1 VALUES ('Hf','+7 (912) 800 80 04'); +INSERT INTO t1 VALUES ('Bar','+7-912-800-80-01'); +INSERT INTO t1 VALUES ('Ramil','(7912) 800 80 03'); +INSERT INTO t1 VALUES ('Sanja','+380 (912) 8008005'); +SELECT * FROM t1 ORDER BY phone; +SELECT * FROM t1 WHERE phone='+7(912)800-80-01'; +SELECT * FROM t1 WHERE phone='79128008001'; +SELECT * FROM t1 WHERE phone='7 9 1 2 8 0 0 8 0 0 1'; +DROP TABLE t1; + +show collation like 'utf8_test_ci'; +create table t1 (c1 char(1) character set utf8 collate utf8_test_ci); +insert into t1 values ('a'); +select * from t1 where c1='b'; +drop table t1; + +show collation like 'ucs2_test_ci'; +create table t1 (c1 char(1) character set ucs2 collate ucs2_test_ci); +insert into t1 values ('a'); +select * from t1 where c1='b'; +drop table t1; + +show collation like 'utf8mb4_test_ci'; +create table t1 (c1 char(1) character set utf8mb4 collate utf8mb4_test_ci); +insert into t1 values ('a'); +select * from t1 where c1='b'; +drop table t1; + +show collation like 'utf16_test_ci'; +create table t1 (c1 char(1) character set utf16 collate utf16_test_ci); +insert into t1 values ('a'); +select * from t1 where c1='b'; +drop table t1; + +show collation like 'utf32_test_ci'; +create table t1 (c1 char(1) character set utf32 collate utf32_test_ci); +insert into t1 values ('a'); +select * from t1 where c1='b'; +drop table t1; + +### +### TODO: activate this when utf8_unicode_520_ci is merged +### +### make sure utf8_test_ci is Unicode-5.0.0 +##SELECT hex(weight_string(_utf8mb4'a' collate utf8mb4_test_ci)); +##SELECT hex(weight_string(convert(_utf32 0x10002 using utf8mb4) collate utf8mb4_test_ci)); +##SELECT hex(@a:=convert(_utf32 0x10400 using utf8mb4) collate utf8mb4_test_ci), hex(lower(@a)); +##SELECT hex(@a:=convert(_utf32 0x10428 using utf8mb4) collate utf8mb4_test_ci), hex(upper(@a)); +##SELECT hex(@a:=convert(_utf32 0x2C00 using utf8mb4) collate utf8mb4_test_ci), hex(lower(@a)); +##SELECT hex(@a:=convert(_utf32 0x2C30 using utf8mb4) collate utf8mb4_test_ci), hex(upper(@a)); + +### check that it works with supplementary characters +##SELECT hex(weight_string(convert(_utf32 0x61 using utf8mb4) collate utf8mb4_test_ci)); +##SELECT hex(weight_string(convert(_utf32 0x62 using utf8mb4) collate utf8mb4_test_ci)); +##SELECT hex(weight_string(convert(_utf32 0x10062 using utf8mb4) collate utf8mb4_test_ci)); +##SELECT hex(weight_string(convert(_utf32 0x10400 using utf8mb4) collate utf8mb4_test_ci)); +##SELECT hex(weight_string(convert(_utf32 0x100400 using utf8mb4) collate utf8mb4_test_ci)); + +### check contractions with non-ascii characters +##SELECT hex(weight_string(_utf8mb4 0x64 collate utf8mb4_test_ci)); +##SELECT hex(weight_string(convert(_ucs2 0x0064017e using utf8mb4) collate utf8mb4_test_ci)); +##SELECT hex(weight_string(convert(_ucs2 0x0044017e using utf8mb4) collate utf8mb4_test_ci)); +##SELECT hex(weight_string(convert(_ucs2 0x0044017d using utf8mb4) collate utf8mb4_test_ci)); + + +--echo # +--echo # Bug#45645 Mysql server close all connection and restart using lower function +--echo # +CREATE TABLE t1 (a VARCHAR(10)) CHARACTER SET utf8 COLLATE utf8_test_ci; +INSERT INTO t1 (a) VALUES ('hello!'); +SELECT * FROM t1 WHERE LOWER(a)=LOWER('N'); +DROP TABLE t1; + +--echo # +--echo # Bug#51976 LDML collations issue (cyrillic example) +--echo # +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_test_ci); +INSERT INTO t1 (a) VALUES ('Hello'); +SELECT a, UPPER(a), LOWER(a) FROM t1; +DROP TABLE t1; + +--echo # +--echo # Bug#43827 Server closes connections and restarts +--echo # +# Crash happened with a user-defined utf8 collation, +# on attempt to insert a string longer than the column can store. +CREATE TABLE t1 (c1 VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_test_ci); +INSERT INTO t1 SELECT REPEAT('a',11); +DROP TABLE t1; + +# +# Vietnamese experimental collation +# +--echo Vietnamese experimental collation + +show collation like 'ucs2_vn_ci'; +create table t1 (c1 char(1) character set ucs2 collate ucs2_vn_ci); +insert into t1 values (0x0061),(0x0041),(0x00E0),(0x00C0),(0x1EA3),(0x1EA2), + (0x00E3),(0x00C3),(0x00E1),(0x00C1),(0x1EA1),(0x1EA0); +insert into t1 values (0x0103),(0x0102),(0x1EB1),(0x1EB0),(0x1EB3),(0x1EB2), + (0x1EB5),(0x1EB4),(0x1EAF),(0x1EAE),(0x1EB7),(0x1EB6); +insert into t1 values (0x00E2),(0x00C2),(0x1EA7),(0x1EA6),(0x1EA9),(0x1EA8), + (0x1EAB),(0x1EAA),(0x1EA5),(0x1EA4),(0x1EAD),(0x1EAC); +insert into t1 values ('b'),('B'),('c'),('C'); +insert into t1 values ('d'),('D'),(0x0111),(0x0110); +insert into t1 values (0x0065),(0x0045),(0x00E8),(0x00C8),(0x1EBB),(0x1EBA), + (0x1EBD),(0x1EBC),(0x00E9),(0x00C9),(0x1EB9),(0x1EB8); +insert into t1 values (0x00EA),(0x00CA),(0x1EC1),(0x1EC0),(0x1EC3),(0x1EC2), + (0x1EC5),(0x1EC4),(0x1EBF),(0x1EBE),(0x1EC7),(0x1EC6); +insert into t1 values ('g'),('G'),('h'),('H'); +insert into t1 values (0x0069),(0x0049),(0x00EC),(0x00CC),(0x1EC9),(0x1EC8), + (0x0129),(0x0128),(0x00ED),(0x00CD),(0x1ECB),(0x1ECA); +insert into t1 values ('k'),('K'),('l'),('L'),('m'),('M'); +insert into t1 values (0x006F),(0x004F),(0x00F2),(0x00D2),(0x1ECF),(0x1ECE), + (0x00F5),(0x00D5),(0x00F3),(0x00D3),(0x1ECD),(0x1ECC); +insert into t1 values (0x00F4),(0x00D4),(0x1ED3),(0x1ED2),(0x1ED5),(0x1ED4), + (0x1ED7),(0x1ED6),(0x1ED1),(0x1ED0),(0x1ED9),(0x1ED8); +insert into t1 values (0x01A1),(0x01A0),(0x1EDD),(0x1EDC),(0x1EDF),(0x1EDE), + (0x1EE1),(0x1EE0),(0x1EDB),(0x1EDA),(0x1EE3),(0x1EE2); +insert into t1 values ('p'),('P'),('q'),('Q'),('r'),('R'),('s'),('S'),('t'),('T'); +insert into t1 values (0x0075),(0x0055),(0x00F9),(0x00D9),(0x1EE7),(0x1EE6), + (0x0169),(0x0168),(0x00FA),(0x00DA),(0x1EE5),(0x1EE4); +insert into t1 values (0x01B0),(0x01AF),(0x1EEB),(0x1EEA),(0x1EED),(0x1EEC), + (0x1EEF),(0x1EEE),(0x1EE9),(0x1EE8),(0x1EF1),(0x1EF0); +insert into t1 values ('v'),('V'),('x'),('X'); +insert into t1 values (0x0079),(0x0059),(0x1EF3),(0x1EF2),(0x1EF7),(0x1EF6), + (0x1EF9),(0x1EF8),(0x00FD),(0x00DD),(0x1EF5),(0x1EF4); +select hex(c1) as h, c1 from t1 order by c1, h; +select group_concat(hex(c1) order by hex(c1)) from t1 group by c1; +select group_concat(c1 order by hex(c1) SEPARATOR '') from t1 group by c1; +drop table t1; + +--echo Bug#46448 trailing spaces are not ignored when user collation maps space != 0x20 +set names latin1; +show collation like 'latin1_test'; +select "foo" = "foo " collate latin1_test; + +-- echo The following tests check that two-byte collation IDs work +# The file ../std-data/Index.xml has a number of collations with high IDs. + +# Test that the "ID" column in I_S and SHOW queries can handle two bytes +select * from information_schema.collations where id>256 and is_compiled<>'Yes' order by id; +show collation like '%test%'; + +# Test that two-byte collation ID is correctly transfered to the client side. +show collation like 'ucs2_vn_ci'; +create table t1 (c1 char(1) character set ucs2 collate ucs2_vn_ci); + +show create table t1; + +insert into t1 values (0x0061); +--enable_metadata +set @@character_set_results=NULL; +select * from t1; +--disable_metadata +drop table t1; + +# +# Check maximum collation ID (2047 as of MySQL-6.0.9) +# +CREATE TABLE t1 (s1 char(10) character set utf8 collate utf8_maxuserid_ci); +INSERT INTO t1 VALUES ('a'),('b'); +SELECT * FROM t1 WHERE s1='a' ORDER BY BINARY s1; +DROP TABLE t1; + + +# +# Bug#47756 Setting 2byte collation ID with 'set names' crashes the server +# +SET NAMES utf8 COLLATE utf8_phone_ci; +SHOW COLLATION LIKE 'utf8_phone_ci'; +SET NAMES utf8; + +# make sure utf8mb4_test_400_ci is Unicode-4.0.0 based +SELECT hex(weight_string(_utf8mb4'a' collate utf8mb4_test_400_ci)); +SELECT hex(weight_string(convert(_utf32 0x10002 using utf8mb4) collate utf8mb4_test_400_ci)); +SELECT hex(@a:=convert(_utf32 0x10400 using utf8mb4) collate utf8mb4_test_400_ci), hex(lower(@a)); +SELECT hex(@a:=convert(_utf32 0x10428 using utf8mb4) collate utf8mb4_test_400_ci), hex(upper(@a)); +SELECT hex(@a:=convert(_utf32 0x2C00 using utf8mb4) collate utf8mb4_test_400_ci), hex(lower(@a)); +SELECT hex(@a:=convert(_utf32 0x2C30 using utf8mb4) collate utf8mb4_test_400_ci), hex(upper(@a)); + +--echo # +--echo # WL#5624 Collation customization improvements +--echo # +SET NAMES utf8 COLLATE utf8_5624_1; +CREATE TABLE t1 AS SELECT REPEAT(' ', 16) AS a LIMIT 0; +# Part 1,2,3: long contractions and expansions +# Part 7: Quarternary difference +INSERT INTO t1 VALUES ('012345'),('001234'),('000123'),('000012'),('000001'); +INSERT INTO t1 VALUES ('12345'),('01234'),('00123'),('00012'),('00001'); +INSERT INTO t1 VALUES ('1234'),('0123'),('0012'),('0001'); +INSERT INTO t1 VALUES ('123'),('012'),('001'); +INSERT INTO t1 VALUES ('12'),('01'); +INSERT INTO t1 VALUES ('1'),('9'); +INSERT INTO t1 VALUES ('ГАИ'),('ГИБДД'); +# Part 4: reset before +# Part 6: characters rather than escape sequences +INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e'); +INSERT INTO t1 VALUES ('cz'),('Ċ'),('ċ'); +INSERT INTO t1 VALUES ('f'),('fz'),('g'),('Ġ'),('ġ'); +INSERT INTO t1 VALUES ('h'),('hz'),('GĦ'),('Għ'),('gĦ'),('għ'); +INSERT INTO t1 VALUES ('i'),('iz'),('Ħ'),('ħ'); +INSERT INTO t1 VALUES ('y'),('yz'),('z'),('Ż'),('ż'); +INSERT INTO t1 VALUES ('ā'),('Ā'),('á'),('Á'),('à'),('À'); +INSERT INTO t1 VALUES ('ē'),('é'),('ě'),('ê'),('Ē'),('É'),('Ě'),('Ê'); +# Part 8: Abbreviated shift syntax +INSERT INTO t1 VALUES ('a'),('~'),('!'),('@'),('#'),('$'),('%'),('^'); +INSERT INTO t1 VALUES ('('),(')'),('-'),('+'),('|'),('='),(':'),(';'); +INSERT INTO t1 VALUES ('"'),('\''),('?'); +# Part 9: Normal expansion syntax +INSERT INTO t1 VALUES ('ch'),('k'),('cs'),('ccs'),('cscs'); +# Part 10: Previous context +INSERT INTO t1 VALUES ('aa-'),('ab-'),('ac-'),('ad-'),('ae-'),('af-'),('az-'); +# Part 12: Logical reset positions +INSERT INTO t1 VALUES ('lp-fni'),('lp-lni'); +INSERT INTO t1 VALUES ('lp-fpi'),('lp-lpi'); +INSERT INTO t1 VALUES ('lp-fsi'),('lp-lsi'); +INSERT INTO t1 VALUES ('lp-fti'),('lp-lti'); +INSERT INTO t1 VALUES ('lp-ft'),('lp-lt'); +INSERT INTO t1 VALUES ('lp-fv'),('lp-lv'); +# Logical positions with reset before +INSERT INTO t1 VALUES ('lb-fni'),('lb-lni'); +INSERT INTO t1 VALUES ('lb-fv'),('lb-lv'); +# Part 5: Long tailoring +INSERT INTO t1 VALUES (_ucs2 0x3106),(_ucs2 0x3110), (_ucs2 0x3111), (_ucs2 0x3112); +INSERT INTO t1 VALUES (_ucs2 0x32A3), (_ucs2 0x3231); +INSERT INTO t1 VALUES (_ucs2 0x84D9), (_ucs2 0x98F5), (_ucs2 0x7CF3), (_ucs2 0x5497); +SELECT a, HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a, LENGTH(a), BINARY a; +--echo # +--echo # WL#5624, the same test with UCS2 +--echo # +ALTER TABLE t1 CONVERT TO CHARACTER SET ucs2 COLLATE ucs2_5624_1; +SELECT a, HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a, LENGTH(a), BINARY(a); +DROP TABLE t1; + +--echo # +--echo # WL#5624, unsupported features +--echo # +# Part 13: More verbosity +--error ER_UNKNOWN_COLLATION +SET NAMES utf8 COLLATE utf8_5624_2; +SHOW WARNINGS; + +--echo # +--echo # WL#5624, reset before primary ignorable +--echo # +--error ER_UNKNOWN_COLLATION +SET NAMES utf8 COLLATE utf8_5624_3; +SHOW WARNINGS; + +--echo # +--echo # WL#5624, \u without hex digits is equal to {'\\', 'u'} +--echo # +SET NAMES utf8 COLLATE utf8_5624_4; +CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS a LIMIT 0; +INSERT INTO t1 VALUES ('\\'),('u'),('x'),('X'); +SELECT a, HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a, LENGTH(a), BINARY(a); +DROP TABLE t1; + +--echo # +--echo # WL#5624, testing Bengali collations +--echo # +SET NAMES utf8, collation_connection=utf8_bengali_standard_ci; +CREATE TABLE t1 AS SELECT REPEAT (' ', 10) AS a LIMIT 0; +INSERT INTO t1 VALUES (_ucs2 0x09FA), (_ucs2 0x09F8), (_ucs2 0x09F9), (_ucs2 0x09F2); +INSERT INTO t1 VALUES (_ucs2 0x09DC), (_ucs2 0x09A109BC); +INSERT INTO t1 VALUES (_ucs2 0x09A2), (_ucs2 0x09DD), (_ucs2 0x09A209BC); +INSERT INTO t1 VALUES (_ucs2 0x09A3); +SELECT HEX(WEIGHT_STRING(a)), HEX(CONVERT(a USING ucs2)), HEX(a) +FROM t1 ORDER BY a, BINARY a; +DROP TABLE t1; + +SET NAMES utf8, collation_connection=utf8_bengali_traditional_ci; +CREATE TABLE t1 AS SELECT REPEAT (' ', 10) AS a LIMIT 0; +INSERT INTO t1 VALUES +(_ucs2 0x0985),(_ucs2 0x0986),(_ucs2 0x0987),(_ucs2 0x0988), +(_ucs2 0x0989),(_ucs2 0x098A),(_ucs2 0x098B),(_ucs2 0x09E0), +(_ucs2 0x098C),(_ucs2 0x09E1),(_ucs2 0x098F),(_ucs2 0x0990), +(_ucs2 0x0993); + +INSERT INTO t1 VALUES +(_ucs2 0x0994),(_ucs2 0x0982),(_ucs2 0x0983),(_ucs2 0x0981), +(_ucs2 0x099509CD), (_ucs2 0x099609CD), (_ucs2 0x099709CD), (_ucs2 0x099809CD), +(_ucs2 0x099909CD), (_ucs2 0x099A09CD), (_ucs2 0x099B09CD), (_ucs2 0x099C09CD), +(_ucs2 0x099D09CD), (_ucs2 0x099E09CD), (_ucs2 0x099F09CD), (_ucs2 0x09A009CD), +(_ucs2 0x09A109CD), (_ucs2 0x09A209CD), (_ucs2 0x09A309CD), +(_ucs2 0x09CE), (_ucs2 0x09A409CD200D), (_ucs2 0x09A409CD), +(_ucs2 0x09A509CD),(_ucs2 0x09A609CD), +(_ucs2 0x09A709CD), (_ucs2 0x09A809CD), (_ucs2 0x09AA09CD), (_ucs2 0x09AB09CD), +(_ucs2 0x09AC09CD), (_ucs2 0x09AD09CD), (_ucs2 0x09AE09CD), (_ucs2 0x09AF09CD), +(_ucs2 0x09B009CD), (_ucs2 0x09F009CD), (_ucs2 0x09B209CD), (_ucs2 0x09F109CD), +(_ucs2 0x09B609CD), (_ucs2 0x09B709CD), (_ucs2 0x09B809CD), (_ucs2 0x09B909CD); + +INSERT INTO t1 VALUES + (_ucs2 0x099509CD0985),(_ucs2 0x0995), + (_ucs2 0x099509CD0986),(_ucs2 0x099509BE), + (_ucs2 0x099509CD0987),(_ucs2 0x099509BF), + (_ucs2 0x099509CD0988),(_ucs2 0x099509C0), + (_ucs2 0x099509CD0989),(_ucs2 0x099509C1), + (_ucs2 0x099509CD098A),(_ucs2 0x099509C2), + (_ucs2 0x099509CD098B),(_ucs2 0x099509C3), + (_ucs2 0x099509CD09E0),(_ucs2 0x099509C4), + (_ucs2 0x099509CD098C),(_ucs2 0x099509E2), + (_ucs2 0x099509CD09E1),(_ucs2 0x099509E3), + (_ucs2 0x099509CD098F),(_ucs2 0x099509C7), + (_ucs2 0x099509CD0990),(_ucs2 0x099509C8), + (_ucs2 0x099509CD0993),(_ucs2 0x099509CB), + (_ucs2 0x099509CD0994),(_ucs2 0x099509CC); + +SELECT HEX(WEIGHT_STRING(a)), HEX(CONVERT(a USING ucs2)), HEX(a) +FROM t1 ORDER BY a, BINARY(a); +SELECT HEX(WEIGHT_STRING(a)) as wa, +GROUP_CONCAT(HEX(CONVERT(a USING ucs2)) ORDER BY LENGTH(a), BINARY a) +FROM t1 GROUP BY a ORDER BY a; +DROP TABLE t1; + +--echo # +--echo # WL#5624, shift after, using expansion +--echo # +SET NAMES utf8 COLLATE utf8_5624_5; +CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS a LIMIT 0; +INSERT INTO t1 VALUES ('0'),('1'),('0z'),(_ucs2 0x0030FF9D); +INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e'),('f'),('g'),('h'),('i'); +INSERT INTO t1 VALUES ('j'),('k'),('l'),('m'),('n'),('o'),('p'),('q'),('r'); +INSERT INTO t1 VALUES ('s'),('t'),('u'),('v'),('w'),('x'),('y'),('z'); +INSERT INTO t1 VALUES ('aa'),('aaa'); +INSERT INTO t1 VALUES ('A'),('B'),('C'),('D'),('E'),('F'),('G'),('H'),('I'); +INSERT INTO t1 VALUES ('J'),('K'),('L'),('M'),('N'),('O'),('P'),('Q'),('R'); +INSERT INTO t1 VALUES ('S'),('T'),('U'),('V'),('W'),('X'),('Y'),('Z'); +INSERT INTO t1 VALUES ('AA'),('AAA'); + +SELECT a, HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a, LENGTH(a), BINARY(a); +DROP TABLE t1; + + +--echo # +--echo # End of WL#5624 +--echo # diff --git a/mysql-test/suite/innodb/t/innodb_file_format.test b/mysql-test/suite/innodb/t/innodb_file_format.test index 941edb728dd..2c99167ce6e 100644 --- a/mysql-test/suite/innodb/t/innodb_file_format.test +++ b/mysql-test/suite/innodb/t/innodb_file_format.test @@ -1,7 +1,8 @@ ---source include/have_innodb.inc ---source include/restart_and_reinit.inc +-- source include/restart_and_reinit.inc +-- source include/have_innodb.inc let $innodb_file_format_orig=`select @@innodb_file_format`; +let $innodb_file_format_max_orig=`select @@innodb_file_format_max`; select @@innodb_file_format; select @@innodb_file_format_check; @@ -37,4 +38,7 @@ set global innodb_file_format_max=antelope; --error ER_INCORRECT_GLOBAL_LOCAL_VAR set global innodb_file_format_check=off; +--disable_query_log eval SET GLOBAL innodb_file_format=$innodb_file_format_orig; +eval SET GLOBAL innodb_file_format_max=$innodb_file_format_max_orig; +--enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb_information_schema_buffer.opt b/mysql-test/suite/innodb/t/innodb_information_schema_buffer.opt new file mode 100644 index 00000000000..9e43eb47f97 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_information_schema_buffer.opt @@ -0,0 +1,3 @@ +--loose-innodb-buffer-pool-stats +--loose-innodb-buffer-page +--loose-innodb-buffer-page-lru diff --git a/mysql-test/suite/innodb/t/innodb_information_schema_buffer.test b/mysql-test/suite/innodb/t/innodb_information_schema_buffer.test index 751a2bd6b5e..6858b898649 100644 --- a/mysql-test/suite/innodb/t/innodb_information_schema_buffer.test +++ b/mysql-test/suite/innodb/t/innodb_information_schema_buffer.test @@ -25,7 +25,7 @@ INSERT INTO infoschema_buffer_test VALUES(9); # right away SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE -WHERE TABLE_NAME like "%infoschema_buffer_test" +WHERE TABLE_NAME like "%infoschema_buffer_test%" and PAGE_STATE="file_page" and PAGE_TYPE="index"; # The NUMBER_RECORDS and DATA_SIZE should check with each insertion @@ -33,14 +33,14 @@ INSERT INTO infoschema_buffer_test VALUES(19); SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE -WHERE TABLE_NAME like "%infoschema_buffer_test" +WHERE TABLE_NAME like "%infoschema_buffer_test%" and PAGE_STATE="file_page" and PAGE_TYPE="index"; CREATE INDEX idx ON infoschema_buffer_test(col1); SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE -WHERE TABLE_NAME like "%infoschema_buffer_test" +WHERE TABLE_NAME like "%infoschema_buffer_test%" and PAGE_STATE="file_page" and INDEX_NAME = "idx" and PAGE_TYPE="index"; @@ -49,7 +49,7 @@ DROP TABLE infoschema_buffer_test; SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE -WHERE TABLE_NAME like "%infoschema_buffer_test"; +WHERE TABLE_NAME like "%infoschema_buffer_test%"; # Do one more test #--replace_regex /'*[0-9]*'/'NUM'/ @@ -64,13 +64,9 @@ ENGINE=INNODB; SELECT count(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE -WHERE TABLE_NAME like "%infoschema_child" and PAGE_STATE="file_page" +WHERE TABLE_NAME like "%infoschema_child%" and PAGE_STATE="file_page" and PAGE_TYPE="index"; DROP TABLE infoschema_child; DROP TABLE infoschema_parent; -show create table information_schema.innodb_buffer_page; -show create table information_schema.innodb_buffer_page_lru; -show create table information_schema.innodb_buffer_pool_stats; - diff --git a/mysql-test/suite/innodb/t/innodb_monitor.test b/mysql-test/suite/innodb/t/innodb_monitor.test new file mode 100644 index 00000000000..864e0cae862 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_monitor.test @@ -0,0 +1,387 @@ +# This is the test for Metrics Monitor Table feature. +# Test the metrics monitor system's control system +# and counter accuracy. + +--source include/have_innodb.inc + +set global innodb_monitor_disable = All; + +# Test turn on/off the monitor counter with "all" option +# By default, they will be off +select name, status from information_schema.innodb_metrics; + +# Turn on all monitor counters +set global innodb_monitor_enable = all; + +# status should all change to "enabled" +select name from information_schema.innodb_metrics where status!='enabled'; + +# Test wrong argument to the global configure option +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_monitor_enable = aaa; + +# We require a valid monitor counter/module name. There is no default +# counter name or module. A warning will be printed asking user to +# specify a valid counter name. +#--disable_warnings +#set global innodb_monitor_enable = default; +#--enable_warnings + +# Turn off all monitor counters, option name should be case +# insensitive +set global innodb_monitor_disable = All; + +# status should all change to "disabled" +select name from information_schema.innodb_metrics where status!='disabled'; + +# Reset all counter values +set global innodb_monitor_reset_all = all; + +# count should all change to 0 +select name from information_schema.innodb_metrics where count!=0; + +# Test wildcard match, turn on all counters contain string "lock" +set global innodb_monitor_enable = "%lock%"; + +# All lock related counter should be enabled +select name from information_schema.innodb_metrics +where status != IF(name like "%lock%", 'enabled', 'disabled'); + +# Disable them +set global innodb_monitor_disable = "%lock%"; + +# All lock related counter should be disabled +select name, status from information_schema.innodb_metrics +where name like "%lock%"; + +# No match for "%lock*" +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_monitor_enable = "%lock*"; + +# All counters will be turned on with wildcard match string with all "%" +set global innodb_monitor_enable="%%%%%%%%%%%%%%%%%%%%%%%%%%%"; + +select name from information_schema.innodb_metrics where status!='enabled'; + +# Turn off all counters +set global innodb_monitor_disable="%%%%%"; + +select name from information_schema.innodb_metrics where status!='disabled'; + +# One more round testing. All counters will be turned on with +# single wildcard character "%" +set global innodb_monitor_enable="%"; + +select name from information_schema.innodb_metrics where status!='enabled'; + +# Turn off all the counters with "%_%" +set global innodb_monitor_disable="%_%"; + +select name from information_schema.innodb_metrics where status!='disabled'; + +# Turn on all counters start with "log" +set global innodb_monitor_enable="log%%%%"; + +select name from information_schema.innodb_metrics +where status != IF(name like "log%", 'enabled', 'disabled'); + +# Turn on counters "os_data_fsync" with wildcard match "os_%a_fs_ncs", "_" +# is single character wildcard match word +set global innodb_monitor_enable="os_%a_fs_ncs"; + +# Turn on counters whose name contains "os" and "pending" with +# wildcard match "os%pending%" +set global innodb_monitor_enable="os%pending%"; + +select name, status from information_schema.innodb_metrics +where name like "os%"; + +# Empty string is an invalid option +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_monitor_enable=""; + +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_monitor_enable="_"; + +# Reset counters only in "module_metadata" module +set global innodb_monitor_disable = module_metadata; + +set global innodb_monitor_reset_all = module_metadata; + +# Only turn on "table_open" counter +set global innodb_monitor_enable = metadata_table_handles_opened; + +# Create a new table to test "metadata_table_handles_opened" counter +create table monitor_test(col int) engine = innodb; + +# This will open the monitor_test table +select * from monitor_test; + +# "metadata_table_handles_opened" should increment by 1 +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; + +# Reset the counter value while counter is still on (started) +# This will reset value "count_reset" but not +# "count" +set global innodb_monitor_reset = metadata_table_handles_opened; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; + +# re-create table again to increment "metadata_table_handles_opened" again +drop table monitor_test; + +# Create a new table to test "metadata_table_handles_opened" counter +create table monitor_test(col int) engine = innodb; + +select * from monitor_test; + +# "metadata_table_handles_opened" should increment +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; + +# Cannot reset all monitor value while the counter is on +set global innodb_monitor_reset_all = metadata_table_handles_opened; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; + +# Turn off the counter "metadata_table_handles_opened" +set global innodb_monitor_disable = metadata_table_handles_opened; + +# Reset the counter value while counter is off (disabled) +set global innodb_monitor_reset = metadata_table_handles_opened; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; + +# re-create table again. Since monitor is off, "metadata_table_handles_opened" +# should not be incremented +drop table monitor_test; + +# Create a new table to test "metadata_table_handles_opened" counter +create table monitor_test(col int) engine = innodb; + +# "metadata_table_handles_opened" should increment +select * from monitor_test; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; + +# Reset all the counters, include those counter *_since_start +set global innodb_monitor_reset_all = metadata_table_handles_opened; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; + +# Turn on "table_open" counter again +set global innodb_monitor_enable = metadata_table_handles_opened; + +# Test metadata_table_handles_opened again to see if it is working correctly +# after above round of turning on/off/reset +drop table monitor_test; + +# Create a new table to test "metadata_table_handles_opened" counter +create table monitor_test(col int) engine = innodb stats_persistent=0; + +select * from monitor_test; + +# "metadata_table_handles_opened" should increment +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; + +# Test counter "metadata_table_handles_closed", +# create index will close the old handle +set global innodb_monitor_enable = metadata_table_handles_closed; + +create index idx on monitor_test(col); + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_closed"; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; + +# Reset counters only in "module_metadata" module +set global innodb_monitor_disable = module_metadata; + +set global innodb_monitor_reset = module_metadata; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; + +set global innodb_monitor_reset_all = module_metadata; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; + +# Test Transaction Module +set global innodb_monitor_enable = module_trx; + +begin; +insert into monitor_test values(9); +commit; + +begin; +insert into monitor_test values(9); +rollback; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "trx_rollbacks" or name like "trx_active_transactions"; + +set global innodb_monitor_disable = module_trx; + +# Test DML Module +set global innodb_monitor_enable = module_dml; + +insert into monitor_test values(9); + +update monitor_test set col = 10 where col = 9; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; + +delete from monitor_test; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status + from information_schema.innodb_metrics + where name like "dml%"; + +# test reset counter while the counter is on +set global innodb_monitor_reset = module_dml; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; + +# insert/delete some rows after the reset +insert into monitor_test values(9); +insert into monitor_test values(1); + +delete from monitor_test; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; + +# We do not allow reset_all while the counter is on, nothing +# should be reset here +set global innodb_monitor_reset_all = module_dml; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; + +# Turn off the counter +set global innodb_monitor_disable = module_dml; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; + +# Reset all counter values +set global innodb_monitor_reset_all = module_dml; + +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; + +# Open individual counter "dml_inserts" +set global innodb_monitor_enable = dml_inserts; + +insert into monitor_test values(9); +insert into monitor_test values(1); + +delete from monitor_test; + +# Only counter "dml_inserts" should be updated +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; + +set global innodb_monitor_disable = module_dml; + +drop table monitor_test; + +set global innodb_monitor_enable = file_num_open_files; + +# Counters are unpredictable when innodb-file-per-table is on +--replace_column 2 # 3 # 4 # 5 # 6 # 7 # +select name, max_count, min_count, count, + max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "file_num_open_files"; + +set global innodb_monitor_disable = file_num_open_files; + +# Test ICP module counters +set global innodb_monitor_enable = "icp%"; + +create table monitor_test(a char(3), b int, c char(2), +primary key (a(1), c(1)), key(b)) engine = innodb; + +insert into monitor_test values("13", 2, "aa"); + +select a from monitor_test where b < 1 for update; + +# should have icp_attempts = 1 and icp_out_of_range = 1 +select name, count from information_schema.innodb_metrics +where name like "icp%"; + +# should have icp_attempts = 2 and icp_match = 1 +select a from monitor_test where b < 3 for update; + +select name, count from information_schema.innodb_metrics +where name like "icp%"; + +drop table monitor_test; + +set global innodb_monitor_disable = all; +set global innodb_monitor_reset_all = all; + +# Test for bug #13966091 +select 1 from `information_schema`.`INNODB_METRICS` +where case (1) when (1) then (AVG_COUNT_RESET) else (1) end; + +-- disable_warnings +set global innodb_monitor_enable = default; +set global innodb_monitor_disable = default; +set global innodb_monitor_reset = default; +set global innodb_monitor_reset_all = default; +-- enable_warnings diff --git a/mysql-test/suite/innodb/t/innodb_mysql.test b/mysql-test/suite/innodb/t/innodb_mysql.test index 3ae5be3aa30..7c2ae98f001 100644 --- a/mysql-test/suite/innodb/t/innodb_mysql.test +++ b/mysql-test/suite/innodb/t/innodb_mysql.test @@ -5,11 +5,12 @@ # main testing code t/innodb_mysql.test -> include/mix1.inc # -# Slow test, don't run during staging part --- source include/not_staging.inc --- source include/have_innodb.inc --- source include/have_query_cache.inc +#Want to skip this test from daily Valgrind execution. +--source include/no_valgrind_without_big.inc +# Adding big test option for this test. +--source include/big_test.inc +-- source include/have_innodb.inc let $engine_type= InnoDB; let $other_engine_type= MEMORY; # InnoDB does support FOREIGN KEYFOREIGN KEYs @@ -21,21 +22,21 @@ set session innodb_support_xa=default; --disable_warnings drop table if exists t1, t2, t3; --enable_warnings -# -# BUG#35850: Performance regression in 5.1.23/5.1.24 -# +--echo # +--echo # BUG#35850: Performance regression in 5.1.23/5.1.24 +--echo # create table t1(a int); insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t2 (a int, b int, pk int, key(a,b), primary key(pk)) engine=innodb; insert into t2 select @a:=A.a+10*(B.a + 10*C.a),@a, @a from t1 A, t1 B, t1 C; ---echo this must use key 'a', not PRIMARY: +--echo # this must use key 'a', not PRIMARY: --replace_column 9 # explain select a from t2 where a=b; drop table t1, t2; -# -# Bug #40360: Binlog related errors with binlog off -# +--echo # +--echo # Bug #40360: Binlog related errors with binlog off +--echo # # This bug is triggered when the binlog format is STATEMENT and the # binary log is turned off. In this case, no error should be shown for # the statement since there are no replication issues. @@ -47,9 +48,9 @@ CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; INSERT INTO t1 VALUES(1); DROP TABLE t1; -# -# Bug#37284 Crash in Field_string::type() -# +--echo # +--echo # Bug#37284 Crash in Field_string::type() +--echo # --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings @@ -58,10 +59,10 @@ CREATE INDEX i1 on t1 (a(3)); SELECT * FROM t1 WHERE a = 'abcde'; DROP TABLE t1; -# -# Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of -# requested column -# +--echo # +--echo # Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of +--echo # requested column +--echo # CREATE TABLE foo (a int, b int, c char(10), PRIMARY KEY (c(3)), @@ -85,6 +86,12 @@ INSERT INTO foo VALUES INSERT INTO bar SELECT * FROM foo; INSERT INTO foo2 SELECT * FROM foo; +-- disable_result_log +ANALYZE TABLE bar; +ANALYZE TABLE foo; +ANALYZE TABLE foo2; +-- enable_result_log + --query_vertical EXPLAIN SELECT c FROM bar WHERE b>2; --query_vertical EXPLAIN SELECT c FROM foo WHERE b>2; --query_vertical EXPLAIN SELECT c FROM foo2 WHERE b>2; @@ -96,9 +103,9 @@ INSERT INTO foo2 SELECT * FROM foo; DROP TABLE foo, bar, foo2; -# -# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table -# +--echo # +--echo # Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table +--echo # --disable_warnings DROP TABLE IF EXISTS t1,t3,t2; @@ -137,9 +144,9 @@ DEALLOCATE PREPARE stmt3; DROP TABLE t1,t3,t2; DROP FUNCTION f1; -# -# Bug#37016: TRUNCATE TABLE removes some rows but not all -# +--echo # +--echo # Bug#37016: TRUNCATE TABLE removes some rows but not all +--echo # --disable_warnings DROP TABLE IF EXISTS t1,t2; @@ -337,9 +344,9 @@ DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; -# -# Bug#43580: Issue with Innodb on multi-table update -# +--echo # +--echo # Bug#43580: Issue with Innodb on multi-table update +--echo # CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE = INNODB; CREATE TABLE t2 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; @@ -460,8 +467,14 @@ INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log EXPLAIN SELECT * FROM t1 WHERE b=1 AND c=1 ORDER BY a; EXPLAIN SELECT * FROM t1 FORCE INDEX(i2) WHERE b=1 and c=1 ORDER BY a; +# With 4k pages, the 'rows' column in the output below is either 120 or 138, +# not 128 as it is with 8k and 16k. Bug#12602606 +--replace_result 128 {checked} 120 {checked} 138 {checked} EXPLAIN SELECT * FROM t1 FORCE INDEX(PRIMARY) WHERE b=1 AND c=1 ORDER BY a; DROP TABLE t1; @@ -505,11 +518,7 @@ INSERT INTO t2 VALUES (),(); CREATE OR REPLACE VIEW v1 AS SELECT 1 FROM t2 WHERE b =(SELECT a FROM t1 LIMIT 1); ---disable_query_log ---disable_result_log CONNECT (con1, localhost, root,,); ---enable_query_log ---enable_result_log CONNECTION default; DELIMITER |; @@ -546,7 +555,7 @@ DROP TABLE t1,t2; --echo # Bug #49324: more valgrind errors in test_if_skip_sort_order --echo # CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ; ---echo #should not cause valgrind warnings +--echo # should not cause valgrind warnings SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a; DROP TABLE t1; @@ -558,6 +567,10 @@ create table t1(f1 int not null primary key, f2 int) engine=innodb; create table t2(f1 int not null, key (f1)) engine=innodb; insert into t1 values (1,1),(2,2),(3,3); insert into t2 values (1),(2),(3); +-- disable_result_log +analyze table t1; +analyze table t2; +-- enable_result_log explain select t1.* from t1 left join t2 using(f1) group by t1.f1; drop table t1,t2; --echo # @@ -576,6 +589,8 @@ INSERT INTO t1 VALUES (1,1,1,1,1,1), (2,2,2,2,2,2), (3,3,3,3,3,3), (7,7,7,7,7,7), (8,8,8,8,8,8), (9,9,9,9,9,9), (11,11,11,11,11,11); +ANALYZE TABLE t1; + --query_vertical EXPLAIN SELECT COUNT(*) FROM t1 DROP TABLE t1; @@ -594,36 +609,6 @@ ALTER TABLE t1 DROP INDEX k, ADD UNIQUE INDEX k (a,b); DROP TABLE t1; ---echo # ---echo # Bug #53334: wrong result for outer join with impossible ON condition ---echo # (see the same test case for MyISAM in join.test) ---echo # - -create table t1 (id int primary key); -create table t2 (id int); - -insert into t1 values (75); -insert into t1 values (79); -insert into t1 values (78); -insert into t1 values (77); -replace into t1 values (76); -replace into t1 values (76); -insert into t1 values (104); -insert into t1 values (103); -insert into t1 values (102); -insert into t1 values (101); -insert into t1 values (105); -insert into t1 values (106); -insert into t1 values (107); - -insert into t2 values (107),(75),(1000); - -select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 - where t2.id=75 and t1.id is null; -explain select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 - where t2.id=75 and t1.id is null; - -drop table t1,t2; --echo # --echo # Bug #47453: InnoDB incorrectly changes TIMESTAMP columns when @@ -635,7 +620,7 @@ CREATE TABLE t2 (a INT, b INT, c TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) ENGINE=InnoDB; ---echo set up our data elements +--echo # set up our data elements INSERT INTO t1 (d) VALUES (1); INSERT INTO t2 (a,b) VALUES (1,1); SELECT SECOND(c) INTO @bug47453 FROM t2; @@ -648,7 +633,7 @@ SELECT SLEEP(1); UPDATE t1 JOIN t2 ON d=a SET b=1 WHERE a=1; ---echo #should be 0 +--echo # should be 0 SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a; DROP TABLE t1, t2; @@ -728,6 +713,13 @@ CREATE TABLE t1 ( LOAD DATA INFILE '../../std_data/intersect-bug50389.tsv' INTO TABLE t1; +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log + +set @tmp_innodb_mysql= @@optimizer_switch; +set optimizer_switch='extended_keys=off'; + SELECT * FROM t1 WHERE f1 IN (3305028,3353871,3772880,3346860,4228206,3336022, 3470988,3305175,3329875,3817277,3856380,3796193, @@ -739,6 +731,7 @@ EXPLAIN SELECT * FROM t1 WHERE f1 IN 3470988,3305175,3329875,3817277,3856380,3796193, 3784744,4180925,4559596,3963734,3856391,4494153) AND f5 = 'abcdefghijklmnopwrst' AND f2 = 1221457 AND f4 = 0 ; +set optimizer_switch=@tmp_innodb_mysql; DROP TABLE t1; @@ -754,7 +747,7 @@ CREATE TABLE t1 ( PRIMARY KEY (f1), UNIQUE KEY (f2, f3), KEY (f4) -) ENGINE=InnoDB; +) ENGINE=InnoDB STATS_PERSISTENT=0; INSERT INTO t1 VALUES (1,1,991,1), (2,1,992,1), (3,1,993,1), (4,1,994,1), (5,1,995,1), @@ -786,64 +779,11 @@ UNLOCK TABLES; DROP TABLE t1; --echo # ---echo # Bug#55826: create table .. select crashes with when KILL_BAD_DATA ---echo # is returned ---echo # -CREATE TABLE t1(a INT) ENGINE=innodb; -INSERT INTO t1 VALUES (0); -SET SQL_MODE='STRICT_ALL_TABLES'; ---error ER_TRUNCATED_WRONG_VALUE -CREATE TABLE t2 - SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`; -DROP TABLE t1; -SET SQL_MODE=DEFAULT; - - - ---echo # ---echo # Bug#55580: segfault in read_view_sees_trx_id ---echo # -CREATE TABLE t1 (a INT) ENGINE=Innodb; -CREATE TABLE t2 (a INT) ENGINE=Innodb; -INSERT INTO t1 VALUES (1),(2); -INSERT INTO t2 VALUES (1),(2); - -connect (con1,localhost,root,,test); -connect (con2,localhost,root,,test); - -connection con1; -START TRANSACTION; -SELECT * FROM t2 LOCK IN SHARE MODE; - -connection con2; -START TRANSACTION; -SELECT * FROM t1 LOCK IN SHARE MODE; - -connection con1; -let $conn_id= `SELECT CONNECTION_ID()`; ---send SELECT * FROM t1 FOR UPDATE - -connection con2; -let $wait_timeout= 2; -let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST -WHERE ID=$conn_id AND STATE='Sending data'; ---source include/wait_condition.inc ---echo # should not crash ---error ER_LOCK_DEADLOCK -SELECT * FROM t1 GROUP BY (SELECT a FROM t2 LIMIT 1 FOR UPDATE) + t1.a; - -connection default; -disconnect con1; -disconnect con2; - -DROP TABLE t1,t2; - ---echo # --echo # Bug#55656: mysqldump can be slower after bug #39653 fix --echo # CREATE TABLE t1 (a INT , b INT, c INT, d INT, - KEY (b), PRIMARY KEY (a,b)) ENGINE=INNODB; + KEY (b), PRIMARY KEY (a,b)) ENGINE=INNODB STATS_PERSISTENT=0; INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3); --query_vertical EXPLAIN SELECT COUNT(*) FROM t1 @@ -862,63 +802,6 @@ CREATE INDEX b ON t1(a,b,c,d); DROP TABLE t1; --echo # ---echo # Bug#56862 Execution of a query that uses index merge returns a wrong result ---echo # - -CREATE TABLE t1 ( - pk int NOT NULL AUTO_INCREMENT PRIMARY KEY, - a int, - b int, - INDEX idx(a)) -ENGINE=INNODB; - -INSERT INTO t1(a,b) VALUES - (11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500), - (3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800), - (6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700), - (13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000); -INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1; -INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1; -INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1 VALUES (1000000, 0, 0); - -SET SESSION sort_buffer_size = 1024*36; - -EXPLAIN -SELECT COUNT(*) FROM - (SELECT * FROM t1 FORCE INDEX (idx,PRIMARY) - WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; - -SELECT COUNT(*) FROM - (SELECT * FROM t1 FORCE INDEX (idx,PRIMARY) - WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; - -SET SESSION sort_buffer_size = DEFAULT; - -DROP TABLE t1; - ---echo # ---echo # ALTER TABLE IGNORE didn't ignore duplicates for unique add index ---echo # - -create table t1 (a int primary key, b int) engine = innodb; -insert into t1 values (1,1),(2,1); -alter ignore table t1 add unique `main` (b); -select * from t1; -drop table t1; - ---echo End of 5.1 tests ---echo # - ---echo # --echo # Bug#55826: create table .. select crashes with when KILL_BAD_DATA --echo # is returned --echo # @@ -933,49 +816,8 @@ DROP TABLE t1; SET SQL_MODE=DEFAULT; --echo # ---echo # Bug#56862 Execution of a query that uses index merge returns a wrong result +--echo # Bug#56862 Moved to innodb_16k.test --echo # - -CREATE TABLE t1 ( - pk int NOT NULL AUTO_INCREMENT PRIMARY KEY, - a int, - b int, - INDEX idx(a)) -ENGINE=INNODB; - -INSERT INTO t1(a,b) VALUES - (11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500), - (3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800), - (6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700), - (13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000); -INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1; -INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1; -INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1 VALUES (1000000, 0, 0); - -SET SESSION sort_buffer_size = 1024*36; - -EXPLAIN -SELECT COUNT(*) FROM - (SELECT * FROM t1 FORCE INDEX (idx,PRIMARY) - WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; - -SELECT COUNT(*) FROM - (SELECT * FROM t1 FORCE INDEX (idx,PRIMARY) - WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; - -SET SESSION sort_buffer_size = DEFAULT; - -DROP TABLE t1; - --echo # --echo # Test for bug #39932 "create table fails if column for FK is in different --echo # case than in corr index". @@ -984,122 +826,15 @@ DROP TABLE t1; drop tables if exists t1, t2; --enable_warnings create table t1 (pk int primary key) engine=InnoDB; ---echo # Even although the below statement uses uppercased field names in ---echo # foreign key definition it still should be able to find explicitly ---echo # created supporting index. So it should succeed and should not ---echo # create any additional supporting indexes. +# Even although the below statement uses uppercased field names in +# foreign key definition it still should be able to find explicitly +# created supporting index. So it should succeed and should not +# create any additional supporting indexes. create table t2 (fk int, key x (fk), constraint x foreign key (FK) references t1 (PK)) engine=InnoDB; show create table t2; drop table t2, t1; ---echo # ---echo # Bug #663818: wrong result when BNLH is used ---echo # - -CREATE TABLE t1(pk int NOT NULL PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t1 VALUES - (1), (2), (11), (12), (13), (14), - (15), (16), (17), (18), (19); -CREATE TABLE t2(pk int NOT NULL PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t2 VALUES - (1), (10), (11), (12), (13), (14), - (15), (16), (17), (18), (19), (20), (21); - -SET SESSION join_buffer_size=10000; - -SET SESSION join_cache_level=3; -EXPLAIN -SELECT t1.pk FROM t1,t2 - WHERE t1.pk = t2.pk AND t2.pk <> 8; -SELECT t1.pk FROM t1,t2 - WHERE t1.pk = t2.pk AND t2.pk <> 8; - -SET SESSION join_cache_level=1; -EXPLAIN -SELECT t1.pk FROM t1,t2 - WHERE t1.pk = t2.pk AND t2.pk <> 8; -SELECT t1.pk FROM t1,t2 - WHERE t1.pk = t2.pk AND t2.pk <> 8; - -DROP TABLE t1,t2; - -SET SESSION join_cache_level=DEFAULT; -SET SESSION join_buffer_size=DEFAULT; - ---echo # ---echo # Bug#668644: HAVING + ORDER BY ---echo # - -CREATE TABLE t1 ( - pk int NOT NULL PRIMARY KEY, i int DEFAULT NULL, - INDEX idx (i) -) ENGINE=INNODB; -INSERT INTO t1 VALUES - (6,-1636630528),(2,-1097924608),(1,6),(3,6),(4,1148715008),(5,1541734400); - -CREATE TABLE t2 ( - i int DEFAULT NULL, - pk int NOT NULL PRIMARY KEY, - INDEX idx (i) -) ENGINE= INNODB; -INSERT INTO t2 VALUES - (-1993998336,20),(-1036582912,1),(-733413376,5),(-538247168,16), - (-514260992,4),(-249561088,9),(1,2),(1,6),(2,10),(2,19),(4,17), - (5,14),(5,15),(6,8),(7,13),(8,18),(9,11),(9,12),(257425408,7), - (576061440,3); - -EXPLAIN -SELECT t1 .i AS f FROM t1, t2 - WHERE t2.i = t1.pk AND t1.pk BETWEEN 0 AND 224 - HAVING f > 7 - ORDER BY f; -SELECT t1 .i AS f FROM t1, t2 - WHERE t2.i = t1.pk AND t1.pk BETWEEN 0 AND 224 - HAVING f > 7 - ORDER BY f; - -DROP TABLE t1, t2; - ---echo # ---echo # Test for bug #56619 - Assertion failed during ---echo # ALTER TABLE RENAME, DISABLE KEYS ---echo # - ---disable_warnings -DROP TABLE IF EXISTS t1, t2; ---enable_warnings -CREATE TABLE t1 (a INT, INDEX(a)) engine=innodb; ---disable_warnings -ALTER TABLE t1 RENAME TO t2, DISABLE KEYS; -DROP TABLE IF EXISTS t1, t2; ---enable_warnings - ---echo # ---echo # Bug#702322: HAVING with two ANDed predicates + ORDER BY ---echo # - -CREATE TABLE t1 (pk int PRIMARY KEY, a int, KEY (a)) ENGINE=InnoDB; -CREATE TABLE t2 (a int, KEY (a)) ENGINE=InnoDB; - -INSERT INTO t1 VALUES - (18,0),(9,10),(8,11),(2,15),(7,19),(1,20); - -SET SESSION join_cache_level = 0; - -# vanilla InnoDB doesn't do ICP ---replace_result "Using where" "Using index condition" -EXPLAIN -SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.pk = t2.a - WHERE t1.pk >= 6 HAVING t1.a<> 0 AND t1.a <> 11 - ORDER BY t1.a; -SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.pk = t2.a - WHERE t1.pk >= 6 HAVING t1.a<> 0 AND t1.a <> 11 - ORDER BY t1.a; - -DROP TABLE t1,t2; - ---echo End of 5.3 tests --echo # --echo # Test for bug #11762012 - "54553: INNODB ASSERTS IN HA_INNOBASE:: @@ -1120,7 +855,41 @@ UPDATE t1 SET c = 5; UNLOCK TABLES; DROP TEMPORARY TABLE t1; ---echo End of 5.1 tests +--echo # End of 5.1 tests + + +--echo # +--echo # Bug#49604 "6.0 processing compound WHERE clause incorrectly +--echo # with Innodb - extra rows" +--echo # + +CREATE TABLE t1 ( + c1 INT NOT NULL, + c2 INT, + PRIMARY KEY (c1), + KEY k1 (c2) +) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (12,1); +INSERT INTO t1 VALUES (15,1); +INSERT INTO t1 VALUES (16,1); +INSERT INTO t1 VALUES (22,1); +INSERT INTO t1 VALUES (20,2); + +CREATE TABLE t2 ( + c1 INT NOT NULL, + c2 INT, + PRIMARY KEY (c1) +) ENGINE=InnoDB; + +INSERT INTO t2 VALUES (1,2); +INSERT INTO t2 VALUES (2,9); + +SELECT STRAIGHT_JOIN t2.c2, t1.c2, t2.c1 +FROM t1 JOIN t2 ON t1.c2 = t2.c1 +WHERE t2.c1 IN (2, 1, 6) OR t2.c1 NOT IN (1); + +DROP TABLE t1, t2; --echo # @@ -1160,12 +929,64 @@ connection default; COMMIT; DROP TABLE t1; DROP FUNCTION f1; +--echo # +--echo # Bug#42744: Crash when using a join buffer to join a table with a blob +--echo # column and an additional column used for duplicate elimination. +--echo # + +CREATE TABLE t1 (a tinyblob) ENGINE=InnoDB; +CREATE TABLE t2 (a int PRIMARY KEY, b tinyblob) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('1'), (NULL); +INSERT INTO t2 VALUES (1, '1'); + +EXPLAIN +SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); + +SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); + +DROP TABLE t1,t2; + +--echo # +--echo # Bug#48093: 6.0 Server not processing equivalent IN clauses properly +--echo # with Innodb tables +--echo # + +CREATE TABLE t1 ( + i int(11) DEFAULT NULL, + v1 varchar(1) DEFAULT NULL, + v2 varchar(20) DEFAULT NULL, + KEY i (i), + KEY v (v1,i) +) ENGINE=innodb; + +INSERT INTO t1 VALUES (1,'f','no'); +INSERT INTO t1 VALUES (2,'u','yes-u'); +INSERT INTO t1 VALUES (2,'h','yes-h'); +INSERT INTO t1 VALUES (3,'d','no'); + +--echo +SELECT v2 +FROM t1 +WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2; + +--echo +--echo # Should not use index_merge +EXPLAIN +SELECT v2 +FROM t1 +WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2; + +DROP TABLE t1; --echo # --echo # Bug#54606 innodb fast alter table + pack_keys=0 --echo # prevents adding new indexes --echo # +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + CREATE TABLE t1 (a INT, b CHAR(9), c INT, key(b)) ENGINE=InnoDB PACK_KEYS=0; @@ -1174,4 +995,38 @@ CREATE INDEX c on t1 (c); DROP TABLE t1; ---echo End of 5.1 tests + +--echo # +--echo # Additional coverage for refactoring which is made as part +--echo # of fix for Bug#27480 "Extend CREATE TEMPORARY TABLES privilege +--echo # to allow temp table operations". +--echo # +--echo # Check that OPTIMIZE table works for temporary InnoDB tables. +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TEMPORARY TABLE t1 (a INT) ENGINE=InnoDB; +OPTIMIZE TABLE t1; +DROP TABLE t1; + + +--echo # +--echo # Bug#11762345 54927: DROPPING AND ADDING AN INDEX IN ONE +--echo # COMMAND CAN FAIL IN INNODB PLUGIN 1.0 +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (id int, a int, b int, PRIMARY KEY (id), + INDEX a (a)) ENGINE=innodb; + +ALTER TABLE t1 DROP INDEX a, ADD INDEX a (b, a); +# This used to fail +ALTER TABLE t1 DROP INDEX a, ADD INDEX (a, b); + +DROP TABLE t1; + + +--echo End of 6.0 tests diff --git a/mysql-test/suite/innodb/t/innodb_simulate_comp_failures.test b/mysql-test/suite/innodb/t/innodb_simulate_comp_failures.test index a940a926f85..cf22935fad6 100644 --- a/mysql-test/suite/innodb/t/innodb_simulate_comp_failures.test +++ b/mysql-test/suite/innodb/t/innodb_simulate_comp_failures.test @@ -1,8 +1,8 @@ --source include/big_test.inc # test takes too long with valgrind --source include/not_valgrind.inc ---let $num_inserts = 100000 ---let $num_ops = 30000 +--let $num_inserts = 1500 +--let $num_ops = 3500 --source suite/innodb/include/innodb_simulate_comp_failures.inc # clean exit --exit diff --git a/mysql-test/suite/innodb/t/innodb_stats.test b/mysql-test/suite/innodb/t/innodb_stats.test new file mode 100644 index 00000000000..b9f71f8fa6f --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_stats.test @@ -0,0 +1,61 @@ +# +# Test the persistent stats feature +# + +-- source include/have_innodb.inc + +-- disable_warnings +-- disable_query_log + +DROP TABLE IF EXISTS test_innodb_stats; + +CREATE TABLE test_innodb_stats ( + a INT, + KEY a_key (a) +) ENGINE=INNODB STATS_PERSISTENT=1; + +-- enable_warnings +-- enable_query_log + +# test empty table +-- let $insert = SELECT 'dummy INSERT, the table should be empty' +-- source suite/innodb/include/innodb_stats.inc + +# test table with 1 row +-- let $insert = INSERT INTO test_innodb_stats (a) VALUES (1) +-- source suite/innodb/include/innodb_stats.inc + +# test table with 2 eq rows +-- let $insert = INSERT INTO test_innodb_stats (a) VALUES (1), (1) +-- source suite/innodb/include/innodb_stats.inc + +# test table with 3 eq rows +-- let $insert = INSERT INTO test_innodb_stats (a) VALUES (1), (1), (1) +-- source suite/innodb/include/innodb_stats.inc + +# test table with 10 eq rows +-- let $insert = INSERT INTO test_innodb_stats (a) VALUES (1), (1), (1), (1), (1), (1), (1), (1), (1), (1) +-- source suite/innodb/include/innodb_stats.inc + +# test table with 2 diff rows +-- let $insert = INSERT INTO test_innodb_stats (a) VALUES (1), (2) +-- source suite/innodb/include/innodb_stats.inc + +# test table with 2 diff rows, 3 rows in total +-- let $insert = INSERT INTO test_innodb_stats (a) VALUES (1), (1), (2) +-- source suite/innodb/include/innodb_stats.inc + +# test table with 3 diff rows +-- let $insert = INSERT INTO test_innodb_stats (a) VALUES (1), (2), (3) +-- source suite/innodb/include/innodb_stats.inc + +# test table with 3 diff rows, 5 rows in total +-- let $insert = INSERT INTO test_innodb_stats (a) VALUES (1), (1), (2), (3), (3) +-- source suite/innodb/include/innodb_stats.inc + +# test table with 5 diff rows, 10 rows in total +-- let $insert = INSERT INTO test_innodb_stats (a) VALUES (1), (2), (3), (4), (5), (1), (2), (3), (4), (5) +-- source suite/innodb/include/innodb_stats.inc + +-- disable_query_log +DROP TABLE test_innodb_stats; diff --git a/mysql-test/suite/innodb/t/innodb_stats_create_on_corrupted.test b/mysql-test/suite/innodb/t/innodb_stats_create_on_corrupted.test new file mode 100644 index 00000000000..de6026a23aa --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_stats_create_on_corrupted.test @@ -0,0 +1,48 @@ +# +# Test creating a persistent stats table on nonexistent or corrupted +# persistent storage +# + +-- source include/have_innodb.inc +# Various sizes printed in this test depend on the page size and the +# functionality tested here is not related to the page size, so we only +# test with 16k page size. +-- source include/have_innodb_16k.inc + +call mtr.add_suppression("InnoDB: Error: Table \"mysql\".\"innodb_index_stats\" not found"); +call mtr.add_suppression("InnoDB: Error: Fetch of persistent statistics requested for table"); + +-- vertical_results + +# corrupt the persistent storage +ALTER TABLE mysql.innodb_index_stats RENAME TO mysql.innodb_index_stats_; + +CREATE TABLE test_ps_create_on_corrupted +(a INT, PRIMARY KEY (a)) +ENGINE=INNODB STATS_PERSISTENT=1; + +# check the stats (should have been generated using the old transient stats +# method) +SELECT seq_in_index, column_name, cardinality +FROM information_schema.statistics WHERE table_name = 'test_ps_create_on_corrupted' +ORDER BY index_name, seq_in_index; + +SELECT table_rows, avg_row_length, max_data_length, index_length +FROM information_schema.tables WHERE table_name = 'test_ps_create_on_corrupted'; + +# restore the persistent storage +ALTER TABLE mysql.innodb_index_stats_ RENAME TO mysql.innodb_index_stats; + +--source include/restart_mysqld.inc + +-- vertical_results + +# check again +SELECT seq_in_index, column_name, cardinality +FROM information_schema.statistics WHERE table_name = 'test_ps_create_on_corrupted' +ORDER BY index_name, seq_in_index; + +SELECT table_rows, avg_row_length, max_data_length, index_length +FROM information_schema.tables WHERE table_name = 'test_ps_create_on_corrupted'; + +DROP TABLE test_ps_create_on_corrupted; diff --git a/mysql-test/suite/innodb/t/innodb_stats_create_table.test b/mysql-test/suite/innodb/t/innodb_stats_create_table.test new file mode 100644 index 00000000000..e7ae09bd19d --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_stats_create_table.test @@ -0,0 +1,66 @@ +# +# Test CREATE TABLE ... STATS_PERSISTENT=0|1|default +# + +-- source include/have_innodb.inc + +set @save_innodb_stats_persistent= @@innodb_stats_persistent; + +set global innodb_stats_persistent=default; + +-- vertical_results + +# confirm that nothing is present before the test +SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE +database_name = 'test' AND +table_name = 'test_ps_create_table'; + +## + +CREATE TABLE test_ps_create_table (a INT, PRIMARY KEY (a)) +ENGINE=INNODB STATS_PERSISTENT=0; + +# nothing should be present +SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE +database_name = 'test' AND +table_name = 'test_ps_create_table'; + +DROP TABLE test_ps_create_table; + +## + +CREATE TABLE test_ps_create_table (a INT, PRIMARY KEY (a)) +ENGINE=INNODB; + +# 1 row should be present if the default of --innodb-stats-persistent is 1 +SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE +database_name = 'test' AND +table_name = 'test_ps_create_table'; + +DROP TABLE test_ps_create_table; + +## + +CREATE TABLE test_ps_create_table (a INT, PRIMARY KEY (a)) +ENGINE=INNODB STATS_PERSISTENT=default; + +# 1 row should be present if the default of --innodb-stats-persistent is 1 +SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE +database_name = 'test' AND +table_name = 'test_ps_create_table'; + +DROP TABLE test_ps_create_table; + +## + +CREATE TABLE test_ps_create_table (a INT, PRIMARY KEY (a)) +ENGINE=INNODB STATS_PERSISTENT=1; + +# 1 row should be present +SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE +database_name = 'test' AND +table_name = 'test_ps_create_table'; + +DROP TABLE test_ps_create_table; + +set global innodb_stats_persistent= @save_innodb_stats_persistent; diff --git a/mysql-test/suite/innodb/t/innodb_stats_drop_locked.test b/mysql-test/suite/innodb/t/innodb_stats_drop_locked.test new file mode 100644 index 00000000000..26367b8e6ae --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_stats_drop_locked.test @@ -0,0 +1,61 @@ +# +# Test the persistent stats feature when DROPping a table or an +# index when the corresponding rows in the stats tables are locked +# + +-- source include/have_innodb.inc + +-- disable_warnings +-- disable_query_log + +DROP TABLE IF EXISTS innodb_stats_drop_locked; + +CREATE TABLE innodb_stats_drop_locked (c INT, KEY c_key (c)) +ENGINE=INNODB STATS_PERSISTENT=1; + +ANALYZE TABLE innodb_stats_drop_locked; + +-- enable_warnings +-- enable_query_log + +SET autocommit=0; + +SELECT table_name FROM mysql.innodb_table_stats +WHERE table_name='innodb_stats_drop_locked' +FOR UPDATE; + +SELECT table_name FROM mysql.innodb_index_stats +WHERE table_name='innodb_stats_drop_locked' +FOR UPDATE; + +-- connect (con1,localhost,root,,) + +-- connection con1 + +ALTER TABLE innodb_stats_drop_locked DROP INDEX c_key; + +# the index should be gone +SHOW CREATE TABLE innodb_stats_drop_locked; + +DROP TABLE innodb_stats_drop_locked; + +# the table should be gone +SHOW TABLES; + +-- connection default + +-- disconnect con1 + +COMMIT; + +# the stats should be there + +SELECT table_name FROM mysql.innodb_table_stats +WHERE table_name='innodb_stats_drop_locked'; + +SELECT table_name FROM mysql.innodb_index_stats +WHERE table_name='innodb_stats_drop_locked'; + +--disable_query_log +call mtr.add_suppression("Unable to delete statistics for table test.innodb_stats_drop_locked: Lock wait timeout. They can be deleted later using DELETE FROM mysql.innodb_index_stats WHERE database_name"); +--enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb_stats_fetch.test b/mysql-test/suite/innodb/t/innodb_stats_fetch.test new file mode 100644 index 00000000000..8544509ccad --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_stats_fetch.test @@ -0,0 +1,79 @@ +# +# Test fetching from stats tables after manual update (ie FLUSH TABLE +# can be used to forcibly (re)fetch the stats from disk) +# + +-- source include/have_innodb.inc +# Various sizes printed in this test depend on the page size and the +# functionality tested here is not related to the page size, so we only +# test with 16k page size. +-- source include/have_innodb_16k.inc + +-- vertical_results + +CREATE TABLE test_ps_fetch +(a INT, b INT, c INT, d INT, PRIMARY KEY (a, b), INDEX idx (c, d)) +ENGINE=INNODB STATS_PERSISTENT=1; + +ANALYZE TABLE test_ps_fetch; + +SELECT n_rows, clustered_index_size, sum_of_other_index_sizes +FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_fetch'; + +SELECT index_name, stat_name, stat_value, sample_size, stat_description +FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_fetch' +ORDER BY index_name, stat_name; + +SELECT index_name, seq_in_index, column_name, cardinality +FROM information_schema.statistics WHERE table_name = 'test_ps_fetch' +ORDER BY index_name, seq_in_index; + +SELECT +table_rows, avg_row_length, max_data_length, index_length +FROM information_schema.tables WHERE table_name = 'test_ps_fetch'; + +UPDATE mysql.innodb_table_stats SET +n_rows = 1000, +clustered_index_size = 5 +WHERE +table_name = 'test_ps_fetch'; + +UPDATE mysql.innodb_index_stats SET +stat_value = 20 +WHERE +table_name = 'test_ps_fetch' AND +index_name = 'PRIMARY' AND +stat_name = 'n_diff_pfx01'; + +UPDATE mysql.innodb_index_stats SET +stat_value = 90 +WHERE +table_name = 'test_ps_fetch' AND +index_name = 'PRIMARY' AND +stat_name = 'n_diff_pfx02'; + +UPDATE mysql.innodb_index_stats SET +stat_value = 3 +WHERE +table_name = 'test_ps_fetch' AND +index_name = 'idx' AND +stat_name = 'n_diff_pfx01'; + +UPDATE mysql.innodb_index_stats SET +stat_value = 11 +WHERE +table_name = 'test_ps_fetch' AND +index_name = 'idx' AND +stat_name = 'n_diff_pfx02'; + +FLUSH TABLE test_ps_fetch; + +SELECT seq_in_index, column_name, cardinality +FROM information_schema.statistics WHERE table_name = 'test_ps_fetch' +ORDER BY index_name, seq_in_index; + +SELECT +table_rows, avg_row_length, max_data_length, index_length +FROM information_schema.tables WHERE table_name = 'test_ps_fetch'; + +DROP TABLE test_ps_fetch; diff --git a/mysql-test/suite/innodb/t/innodb_stats_fetch_corrupted.test b/mysql-test/suite/innodb/t/innodb_stats_fetch_corrupted.test new file mode 100644 index 00000000000..4a3f7527c09 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_stats_fetch_corrupted.test @@ -0,0 +1,45 @@ +# +# Test fetching from stats tables that are corrupted +# + +-- source include/have_innodb.inc +# Various sizes printed in this test depend on the page size and the +# functionality tested here is not related to the page size, so we only +# test with 16k page size. +-- source include/have_innodb_16k.inc + +call mtr.add_suppression("InnoDB: Error: Table \"mysql\".\"innodb_index_stats\" not found"); +call mtr.add_suppression("InnoDB: Error: Fetch of persistent statistics requested for table"); + +-- vertical_results + +CREATE TABLE test_ps_fetch_corrupted +(a INT, PRIMARY KEY (a)) +ENGINE=INNODB STATS_PERSISTENT=1; + +# write stats to mysql.innodb_table_stats +ANALYZE TABLE test_ps_fetch_corrupted; + +# check that indeed stats were written by ANALYZE above +SELECT n_rows, clustered_index_size, sum_of_other_index_sizes +FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_fetch_corrupted'; + +# corrupt the persistent storage +ALTER TABLE mysql.innodb_index_stats RENAME TO mysql.innodb_index_stats_; + +# reopen the table, this will attept to read from the persistent storage +FLUSH TABLE test_ps_fetch_corrupted; + +# check the stats (should have been generated using the old transient stats +# method) +SELECT seq_in_index, column_name, cardinality +FROM information_schema.statistics WHERE table_name = 'test_ps_fetch_corrupted' +ORDER BY index_name, seq_in_index; + +SELECT table_rows, avg_row_length, max_data_length, index_length +FROM information_schema.tables WHERE table_name = 'test_ps_fetch_corrupted'; + +# restore the persistent storage +ALTER TABLE mysql.innodb_index_stats_ RENAME TO mysql.innodb_index_stats; + +DROP TABLE test_ps_fetch_corrupted; diff --git a/mysql-test/suite/innodb/t/innodb_stats_fetch_nonexistent.test b/mysql-test/suite/innodb/t/innodb_stats_fetch_nonexistent.test new file mode 100644 index 00000000000..dbafb33965c --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_stats_fetch_nonexistent.test @@ -0,0 +1,38 @@ +# +# Test fetching from stats tables while there are no stats +# + +-- source include/have_innodb.inc + +call mtr.add_suppression("InnoDB: Error: Fetch of persistent statistics requested for table*"); + +-- vertical_results + +CREATE TABLE test_ps_fetch_nonexistent +(a INT, PRIMARY KEY (a)) +ENGINE=INNODB STATS_PERSISTENT=1; + +# write stats to mysql.innodb_table_stats +ANALYZE TABLE test_ps_fetch_nonexistent; + +# check that indeed stats were written by ANALYZE above +SELECT COUNT(*) +FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_fetch_nonexistent'; + +# delete the stats +DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_fetch_nonexistent'; +DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_fetch_nonexistent'; + +# reopen the table, this will attept to read the stats +FLUSH TABLE test_ps_fetch_nonexistent; + +# check the stats (should have been generated using the old transient stats +# method) +SELECT seq_in_index, column_name, cardinality +FROM information_schema.statistics WHERE table_name = 'test_ps_fetch_nonexistent' +ORDER BY index_name, seq_in_index; + +SELECT table_rows, avg_row_length, max_data_length, index_length +FROM information_schema.tables WHERE table_name = 'test_ps_fetch_nonexistent'; + +DROP TABLE test_ps_fetch_nonexistent; diff --git a/mysql-test/suite/innodb/t/innodb_stats_rename_table.test b/mysql-test/suite/innodb/t/innodb_stats_rename_table.test new file mode 100644 index 00000000000..5c1fe0f2089 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_stats_rename_table.test @@ -0,0 +1,42 @@ +# +# Test that RENAME TABLE renames the entries in +# mysql.innodb_table_stats and mysql.innodb_index_stats +# + +-- source include/have_innodb.inc + +-- vertical_results + +# confirm that nothing is present before the test +SELECT table_name, n_rows +FROM mysql.innodb_table_stats +WHERE table_name IN ('stats_rename_old', 'stats_rename_new'); + +SELECT table_name, index_name, stat_name, stat_value +FROM mysql.innodb_index_stats +WHERE table_name IN ('stats_rename_old', 'stats_rename_new'); + +CREATE TABLE stats_rename_old (a INT, PRIMARY KEY (a)) +ENGINE=INNODB STATS_PERSISTENT=1; + +# confirm that CREATE inserted a zeroed entries +SELECT table_name, n_rows +FROM mysql.innodb_table_stats +WHERE table_name IN ('stats_rename_old', 'stats_rename_new'); + +SELECT table_name, index_name, stat_name, stat_value +FROM mysql.innodb_index_stats +WHERE table_name IN ('stats_rename_old', 'stats_rename_new'); + +RENAME TABLE stats_rename_old TO stats_rename_new; + +# confirm that rows were updated correspondingly +SELECT table_name, n_rows +FROM mysql.innodb_table_stats +WHERE table_name IN ('stats_rename_old', 'stats_rename_new'); + +SELECT table_name, index_name, stat_name, stat_value +FROM mysql.innodb_index_stats +WHERE table_name IN ('stats_rename_old', 'stats_rename_new'); + +DROP TABLE stats_rename_new; diff --git a/mysql-test/suite/innodb/t/innodb_stats_rename_table_if_exists.test b/mysql-test/suite/innodb/t/innodb_stats_rename_table_if_exists.test new file mode 100644 index 00000000000..e5b5d1814c0 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_stats_rename_table_if_exists.test @@ -0,0 +1,58 @@ +# +# Test what happens during RENAME TABLE if there are already rows in the stats +# tables for the new table. This cannot happen normally, one have to insert +# manually like what we do here. +# +# The RENAME should succeed and existent rows should be overwritten. +# + +-- source include/have_innodb.inc + +-- vertical_results + +CREATE TABLE stats_rename1 (a INT, PRIMARY KEY (a)) +ENGINE=INNODB STATS_PERSISTENT=1; + +INSERT INTO mysql.innodb_table_stats +SELECT +database_name, +'stats_rename2' AS table_name, +last_update, +123 AS n_rows, +clustered_index_size, +sum_of_other_index_sizes +FROM mysql.innodb_table_stats +WHERE table_name = 'stats_rename1'; + +INSERT INTO mysql.innodb_index_stats +SELECT +database_name, +'stats_rename2' AS table_name, +index_name, +last_update, +stat_name, +567 AS stat_value, +sample_size, +stat_description +FROM mysql.innodb_index_stats +WHERE table_name = 'stats_rename1'; + +SELECT table_name, n_rows +FROM mysql.innodb_table_stats +WHERE table_name IN ('stats_rename1', 'stats_rename2'); + +SELECT table_name, index_name, stat_name, stat_value +FROM mysql.innodb_index_stats +WHERE table_name IN ('stats_rename1', 'stats_rename2'); + +RENAME TABLE stats_rename1 TO stats_rename2; + +SELECT table_name, n_rows +FROM mysql.innodb_table_stats +WHERE table_name IN ('stats_rename1', 'stats_rename2'); + +SELECT table_name, index_name, stat_name, stat_value +FROM mysql.innodb_index_stats +WHERE table_name IN ('stats_rename1', 'stats_rename2'); + +DROP TABLE stats_rename2; diff --git a/mysql-test/suite/innodb/t/log_file_size.test b/mysql-test/suite/innodb/t/log_file_size.test new file mode 100644 index 00000000000..ae63ee6e133 --- /dev/null +++ b/mysql-test/suite/innodb/t/log_file_size.test @@ -0,0 +1,222 @@ +# Test resizing the InnoDB redo log. + +--source include/have_innodb.inc + +# Embedded server does not support crashing +--source include/not_embedded.inc +# Avoid CrashReporter popup on Mac +--source include/not_crashrep.inc +# DBUG_EXECUTE_IF is needed +--source include/have_debug.inc + +if (`SELECT @@innodb_log_file_size = 1048576`) { + --skip Test requires innodb_log_file_size>1M. +} + +--disable_query_log +call mtr.add_suppression("InnoDB: Resizing redo log"); +call mtr.add_suppression("InnoDB: Starting to delete and rewrite log files"); +call mtr.add_suppression("InnoDB: New log files created"); +# This message is output by 10.0 and 10.1, not by 10.2 +call mtr.add_suppression("InnoDB: The log sequence number in the ibdata files is higher than the log sequence number in the ib_logfiles"); +call mtr.add_suppression("InnoDB: The log sequence numbers [0-9]+ and [0-9]+ in ibdata files do not match the log sequence number [0-9]+ in the ib_logfiles"); +call mtr.add_suppression("syntax error in innodb_log_group_home_dir"); +call mtr.add_suppression("Plugin 'InnoDB' init function returned error"); +call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed"); +call mtr.add_suppression("InnoDB: Plugin initialization aborted"); +call mtr.add_suppression("InnoDB: innodb_read_only prevents crash recovery"); +call mtr.add_suppression("InnoDB: Are you sure you are using the right ib_logfiles"); +call mtr.add_suppression("InnoDB: Cannot create log files in read-only mode"); +call mtr.add_suppression("InnoDB: Only one log file found"); +call mtr.add_suppression("InnoDB: Log file .*ib_logfile[01].* size"); +call mtr.add_suppression("InnoDB: Unable to open .*ib_logfile0. to check native AIO read support"); +# InnoDB shutdown after refused startup is not clean in 10.0 or 10.1! +call mtr.add_suppression("mysqld got signal 11"); +call mtr.add_suppression("Attempting backtrace"); +FLUSH TABLES; +--enable_query_log + +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +BEGIN; +INSERT INTO t1 VALUES (42); + +let $restart_parameters = --innodb-log-file-size=6M; +--source include/kill_and_restart_mysqld.inc + +SELECT * FROM t1; + +INSERT INTO t1 VALUES (42); +BEGIN; +DELETE FROM t1; + +let $restart_parameters = --innodb-log-files-in-group=3 --innodb-log-file-size=5M; +--source include/kill_and_restart_mysqld.inc + +SELECT * FROM t1; + +INSERT INTO t1 VALUES (123); + +let MYSQLD_DATADIR= `select @@datadir`; +let SEARCH_RANGE= -50000; +let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; + +BEGIN; +DELETE FROM t1; + +--source include/kill_mysqld.inc + +--let $restart_parameters= --innodb-log-group-home-dir=foo\;bar +--source include/start_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; +let SEARCH_PATTERN= syntax error in innodb_log_group_home_dir; +--source include/search_pattern_in_file.inc + +--let $restart_parameters= --debug=d,innodb_log_abort_1 +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; +let SEARCH_PATTERN= InnoDB: Starting an apply batch of log records; +--source include/search_pattern_in_file.inc + +--let $restart_parameters= --debug=d,innodb_log_abort_3 +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; +let SEARCH_PATTERN= InnoDB: Starting an apply batch of log records; +--source include/search_pattern_in_file.inc + +--let $restart_parameters= --innodb-read-only +--source include/restart_mysqld.inc + +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; +let SEARCH_PATTERN= InnoDB: innodb_read_only prevents crash recovery; +--source include/search_pattern_in_file.inc + +--let $restart_parameters= --debug=d,innodb_log_abort_4 +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; +let SEARCH_PATTERN= InnoDB: Starting an apply batch of log records; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN= InnoDB: Resizing redo log from 3\*[0-9]+ to 2\*[0-9]+ pages; +--source include/search_pattern_in_file.inc + +--let $restart_parameters= --debug=d,innodb_log_abort_5 +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; +let SEARCH_PATTERN= InnoDB: Starting an apply batch of log records; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN= InnoDB: Resizing redo log from 3\*[0-9]+ to 2\*[0-9]+ pages; +--source include/search_pattern_in_file.inc + +--let $restart_parameters= --innodb-read-only +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; +let SEARCH_PATTERN= InnoDB: innodb_read_only prevents crash recovery; +--source include/search_pattern_in_file.inc + +--let $restart_parameters= --debug=d,innodb_log_abort_6 +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; + +let SEARCH_PATTERN= InnoDB: Starting an apply batch of log records; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN= InnoDB: Resizing redo log from 3\*[0-9]+ to 2\*[0-9]+ pages; +--source include/search_pattern_in_file.inc + +--let $restart_parameters= --debug=d,innodb_log_abort_7 +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; + +# this aborts right after deleting all log files + +--let $restart_parameters= --innodb-read-only +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; + +let SEARCH_PATTERN= InnoDB: Cannot create log files in read-only mode; +--source include/search_pattern_in_file.inc + +--let $restart_parameters= --debug=d,innodb_log_abort_8 +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; + +let SEARCH_PATTERN= InnoDB: Setting log file .*ib_logfile[0-9]+ size to; +--source include/search_pattern_in_file.inc + +--let $restart_parameters= --debug=d,innodb_log_abort_9 +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; + +let SEARCH_PATTERN= InnoDB: Setting log file .*ib_logfile[0-9]+ size to; +--source include/search_pattern_in_file.inc +--source include/shutdown_mysqld.inc + +# We should have perfectly synced files here. +# Rename the log files, and trigger an error in recovery. +--move_file $MYSQLD_DATADIR/ib_logfile101 $MYSQLD_DATADIR/ib_logfile0 +--move_file $MYSQLD_DATADIR/ib_logfile1 $MYSQLD_DATADIR/ib_logfile1_hidden + +--let $restart_parameters= +--source include/start_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; + +let SEARCH_PATTERN= InnoDB: Only one log file found; +--source include/search_pattern_in_file.inc +--move_file $MYSQLD_DATADIR/ib_logfile0 $MYSQLD_DATADIR/ib_logfile101 + +perl; +die unless open(FILE, ">$ENV{MYSQLD_DATADIR}/ib_logfile0"); +print FILE "garbage"; +close(FILE); +EOF + +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; +let SEARCH_PATTERN= InnoDB: Log file .*ib_logfile0 size 7 is not a multiple of innodb_page_size; +--source include/search_pattern_in_file.inc +--remove_file $MYSQLD_DATADIR/ib_logfile0 +--move_file $MYSQLD_DATADIR/ib_logfile101 $MYSQLD_DATADIR/ib_logfile0 + +perl; +die unless open(FILE, ">$ENV{MYSQLD_DATADIR}/ib_logfile1"); +print FILE "junkfill" x 131072; +close(FILE); +EOF + +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; + +let SEARCH_PATTERN= InnoDB: Log file .*ib_logfile1 is of different size 1048576 bytes than other log files; +--source include/search_pattern_in_file.inc +--remove_file $MYSQLD_DATADIR/ib_logfile1 +--move_file $MYSQLD_DATADIR/ib_logfile0 $MYSQLD_DATADIR/ib_logfile101 +--move_file $MYSQLD_DATADIR/ib_logfile1_hidden $MYSQLD_DATADIR/ib_logfile1 + +--let $restart_parameters= --debug=d,innodb_log_abort_10 +--source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE +SELECT * FROM t1; + +let SEARCH_PATTERN= InnoDB: Setting log file .*ib_logfile[0-9]+ size to; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN= InnoDB: Renaming log file .*ib_logfile101 to .*ib_logfile0; +--source include/search_pattern_in_file.inc + +--let $restart_parameters= +--source include/restart_mysqld.inc + +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/read_only_recovery.test b/mysql-test/suite/innodb/t/read_only_recovery.test new file mode 100644 index 00000000000..f41081e5a94 --- /dev/null +++ b/mysql-test/suite/innodb/t/read_only_recovery.test @@ -0,0 +1,36 @@ +--source include/have_innodb.inc +# need to restart server +--source include/not_embedded.inc + +--connect(con1, localhost, root) +CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB; +BEGIN; +# Generate insert_undo log. +INSERT INTO t VALUES(1),(2); +# Generate update_undo log. +DELETE FROM t WHERE a=2; +--connection default +--echo # Normal MariaDB shutdown would roll back the above transaction. +--echo # We want the transaction to remain open, so we will kill the server +--echo # after ensuring that any non-transactional files are clean. +FLUSH TABLES; +--echo # Ensure that the above incomplete transaction becomes durable. +SET GLOBAL innodb_flush_log_at_trx_commit=1; +BEGIN; +INSERT INTO t VALUES(0); +ROLLBACK; +--let $restart_parameters= --innodb-force-recovery=3 +--source include/kill_and_restart_mysqld.inc +--disconnect con1 +SELECT * FROM t; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t; +--let $restart_parameters= --innodb-read-only +--source include/restart_mysqld.inc +SELECT * FROM t; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t; +--let $restart_parameters= +--source include/restart_mysqld.inc +SELECT * FROM t; +DROP TABLE t; diff --git a/mysql-test/suite/innodb/t/row_lock.test b/mysql-test/suite/innodb/t/row_lock.test index 76ac4fec23f..d9f9a7289c4 100644 --- a/mysql-test/suite/innodb/t/row_lock.test +++ b/mysql-test/suite/innodb/t/row_lock.test @@ -5,7 +5,6 @@ # --source include/have_innodb.inc ---source include/have_debug_sync.inc CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB; INSERT INTO t1 VALUES (1,1),(2,2); @@ -23,17 +22,17 @@ UPDATE t1 SET a = 0 WHERE a = ( SELECT e FROM t3 ); --connect (con12,localhost,root,,test) -SET DEBUG_SYNC='srv_suspend_mysql_thread_enter SIGNAL waiting'; - --send UPDATE t4 SET d = 1 WHERE d in ( SELECT a FROM t1 ) ORDER BY c LIMIT 6; --connection con11 # Wait for con12 to start waiting for con11 - -SET DEBUG_SYNC='now WAIT_FOR waiting'; -SET DEBUG_SYNC='RESET'; +let $wait_condition= + select count(*) = 1 from information_schema.innodb_trx + where trx_state = "lock wait" and + trx_query like "%SELECT a FROM t1%"; +--source include/wait_condition.inc UPDATE t4 SET d = 9; diff --git a/mysql-test/suite/innodb/t/snapshot.test b/mysql-test/suite/innodb/t/snapshot.test new file mode 100644 index 00000000000..8e3dc76fe54 --- /dev/null +++ b/mysql-test/suite/innodb/t/snapshot.test @@ -0,0 +1,18 @@ + +--source include/have_log_bin.inc +--source include/have_binlog_format_row.inc +--source include/have_innodb.inc + +START TRANSACTION WITH CONSISTENT SNAPSHOT; + +--connect (con1,localhost,root,,test) +CREATE TABLE IF NOT EXISTS t1 (pk INT PRIMARY KEY, i INT, KEY(i)) ENGINE=InnoDB; + +--connection default +--error 1412 +UPDATE t1 SET i = 0; +--error 1412 +UPDATE t1 SET pk = 0; +commit; + +drop table t1; diff --git a/mysql-test/suite/innodb/t/system_tables.test b/mysql-test/suite/innodb/t/system_tables.test new file mode 100644 index 00000000000..90cb8c59fbd --- /dev/null +++ b/mysql-test/suite/innodb/t/system_tables.test @@ -0,0 +1,12 @@ +--source include/have_innodb.inc + +# +# MDEV-10775 System table in InnoDB format allowed in MariaDB could lead to crash +# +alter table mysql.time_zone_name engine=InnoDB; +create table envois3 (starttime datetime) engine=InnoDB; +insert envois3 values ('2008-08-11 22:43:00'); +--source include/restart_mysqld.inc +select convert_tz(starttime,'UTC','Europe/Moscow') starttime from envois3; +drop table envois3; +alter table mysql.time_zone_name engine=MyISAM; diff --git a/mysql-test/suite/innodb/t/table_index_statistics.test b/mysql-test/suite/innodb/t/table_index_statistics.test new file mode 100644 index 00000000000..af6f1946486 --- /dev/null +++ b/mysql-test/suite/innodb/t/table_index_statistics.test @@ -0,0 +1,8 @@ +--source include/have_innodb.inc + +SET @default_storage_engine_old = @@session.default_storage_engine; +SET SESSION default_storage_engine = INNODB; + +--source extra/table_index_statistics.inc + +SET SESSION default_storage_engine = @default_storage_engine_old; diff --git a/mysql-test/suite/innodb/t/tmpdir.test b/mysql-test/suite/innodb/t/tmpdir.test new file mode 100644 index 00000000000..abe455adda5 --- /dev/null +++ b/mysql-test/suite/innodb/t/tmpdir.test @@ -0,0 +1,68 @@ +--source include/have_innodb.inc +--source include/count_sessions.inc + +if (`select plugin_auth_version <= "5.6.28-MariaDB-76.1" from information_schema.plugins where plugin_name='innodb'`) +{ + --skip Not fixed in XtraDB as of 5.6.28-MariaDB-76.1 or earlier +} + +--echo # +--echo # Bug #19183565 CREATE DYNAMIC INNODB_TMPDIR VARIABLE TO CONTROL +--echo # WHERE INNODB WRITES TEMP FILES +--echo # + +--echo # If innodb_tmpdir is NULL or "", temporary file will be created in +--echo # server configuration variable location(--tmpdir) + +create table t1(a int primary key)engine=innodb; +show session variables like 'innodb_tmpdir'; +alter table t1 add column b int not null; +set global innodb_tmpdir=NULL; +--echo # Connection con1 +connect (con1,localhost,root); +show session variables like 'innodb_tmpdir'; +alter table t1 add key(b); +connection default; +disconnect con1; +drop table t1; + +--echo # innodb_tmpdir with invalid path. + +create table t1(a int primary key)engine=innodb; +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_tmpdir='wrong_value'; +show warnings; +drop table t1; + + +--echo # innodb_tmpdir with mysql data directory path. + +let $MYSQLD_DATADIR= `select @@datadir`; +create table t1(a text, b text, fulltext(a,b))engine=innodb; +insert into t1 values('test1', 'test2'); +insert into t1 values('text1', 'text2'); +--replace_result $MYSQLD_DATADIR MYSQL_DATADIR +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_tmpdir = @@global.datadir; +--replace_regex /.*mysqld.1/DATADIR/ +show warnings; +drop table t1; + +--echo # innodb_tmpdir with valid location. +let $MYSQL_TMP_DIR= `select @@tmpdir`; +create table t1(a text, b text, fulltext(a,b))engine=innodb; +insert into t1 values('test1', 'test2'); +insert into t1 values('text1', 'text2'); +set @tmpdir = @@global.tmpdir; +set global innodb_tmpdir = @tmpdir; +show session variables like 'innodb_tmpdir'; +--echo # Connection con3 +connect (con3,localhost,root); +# Following alter using innodb_tmpdir as a path to create temporary files +alter table t1 add fulltext(b); +disconnect con3; +connection default; +set global innodb_tmpdir=NULL; +drop table t1; + +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/suite/innodb/t/xa_recovery.test b/mysql-test/suite/innodb/t/xa_recovery.test index aec606de77e..f5c2b655545 100644 --- a/mysql-test/suite/innodb/t/xa_recovery.test +++ b/mysql-test/suite/innodb/t/xa_recovery.test @@ -1,7 +1,3 @@ -if (`select plugin_auth_version <= "5.5.43-MariaDB-37.2" from information_schema.plugins where plugin_name='innodb'`) -{ - --skip Not fixed in XtraDB as of 5.5.43-MariaDB-37.2 or earlier -} --source include/have_innodb.inc # Embedded server does not support restarting. --source include/not_embedded.inc @@ -9,6 +5,7 @@ if (`select plugin_auth_version <= "5.5.43-MariaDB-37.2" from information_schema # MDEV-8841 - close tables opened by previous tests, # so they don't get marked crashed when the server gets crashed --disable_query_log +call mtr.add_suppression("Found 1 prepared XA transactions"); FLUSH TABLES; --enable_query_log @@ -18,17 +15,7 @@ connect (con1,localhost,root); XA START 'x'; UPDATE t1 set a=2; XA END 'x'; XA PREPARE 'x'; connection default; -call mtr.add_suppression("Found 1 prepared XA transactions"); - -# Kill and restart the server. --- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- shutdown_server 0 --- source include/wait_until_disconnected.inc - --- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- enable_reconnect --- source include/wait_until_connected_again.inc --- disable_reconnect +--source include/kill_and_restart_mysqld.inc disconnect con1; connect (con1,localhost,root); |