summaryrefslogtreecommitdiff
path: root/mysql-test/suite/innodb
diff options
context:
space:
mode:
authorDaniel Black <danielgb@au.ibm.com>2018-02-25 15:25:54 +1100
committerGitHub <noreply@github.com>2018-02-25 15:25:54 +1100
commit0805a9565f09a36104a420d9e229e44b1eea8879 (patch)
tree5c5dbf942479c2b7349f1b4505768ddf5a2f8b8d /mysql-test/suite/innodb
parent3188131b15c26509e4df3c4b15972d07a20be8bd (diff)
parent8936b175106a3fdfc560e9d33aa58a6372084c5f (diff)
downloadmariadb-git-0805a9565f09a36104a420d9e229e44b1eea8879.tar.gz
Merge branch '10.3' into 10.2-MDEV-10814-dont-dump-query-cache
Diffstat (limited to 'mysql-test/suite/innodb')
-rw-r--r--mysql-test/suite/innodb/include/innodb_bulk_create_index.inc185
-rw-r--r--mysql-test/suite/innodb/include/innodb_bulk_create_index_debug.inc221
-rw-r--r--mysql-test/suite/innodb/r/alter_copy.result213
-rw-r--r--mysql-test/suite/innodb/r/alter_crash.result23
-rw-r--r--mysql-test/suite/innodb/r/ddl_purge.result25
-rw-r--r--mysql-test/suite/innodb/r/deadlock_detect.result6
-rw-r--r--mysql-test/suite/innodb/r/drop_table_background.result15
-rw-r--r--mysql-test/suite/innodb/r/foreign_key.result43
-rw-r--r--mysql-test/suite/innodb/r/innodb-autoinc.result18
-rw-r--r--mysql-test/suite/innodb/r/innodb-fk-warnings.result18
-rw-r--r--mysql-test/suite/innodb/r/innodb-fk.result4
-rw-r--r--mysql-test/suite/innodb/r/innodb-fkcheck.result4
-rw-r--r--mysql-test/suite/innodb/r/innodb-index-debug.result31
-rw-r--r--mysql-test/suite/innodb/r/innodb-index-online-fk.result6
-rw-r--r--mysql-test/suite/innodb/r/innodb-index-online.result25
-rw-r--r--mysql-test/suite/innodb/r/innodb-lru-force-no-free-page.result10
-rw-r--r--mysql-test/suite/innodb/r/innodb-on-duplicate-update.result60
-rw-r--r--mysql-test/suite/innodb/r/innodb-replace-debug.result14
-rw-r--r--mysql-test/suite/innodb/r/innodb-table-online.result4
-rw-r--r--mysql-test/suite/innodb/r/innodb-wl5522-debug.result18
-rw-r--r--mysql-test/suite/innodb/r/innodb.result157
-rw-r--r--mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result34
-rw-r--r--mysql-test/suite/innodb/r/innodb_buffer_pool_resize_with_chunks.result26
-rw-r--r--mysql-test/suite/innodb/r/innodb_bulk_create_index.result1037
-rw-r--r--mysql-test/suite/innodb/r/innodb_bulk_create_index_debug.result485
-rw-r--r--mysql-test/suite/innodb/r/innodb_bulk_create_index_flush.result54
-rw-r--r--mysql-test/suite/innodb/r/innodb_bulk_create_index_replication.result222
-rw-r--r--mysql-test/suite/innodb/r/innodb_bulk_create_index_small.result139
-rw-r--r--mysql-test/suite/innodb/r/innodb_corrupt_bit.result9
-rw-r--r--mysql-test/suite/innodb/r/innodb_max_recordsize_32k.result34
-rw-r--r--mysql-test/suite/innodb/r/innodb_max_recordsize_64k.result34
-rw-r--r--mysql-test/suite/innodb/r/innodb_mysql.result6
-rw-r--r--mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result2
-rw-r--r--mysql-test/suite/innodb/r/instant_alter,4k.rdiff52
-rw-r--r--mysql-test/suite/innodb/r/instant_alter,8k.rdiff54
-rw-r--r--mysql-test/suite/innodb/r/instant_alter.resultbin119287 -> 120413 bytes
-rw-r--r--mysql-test/suite/innodb/r/instant_alter_crash.result1
-rw-r--r--mysql-test/suite/innodb/r/instant_alter_debug.result2
-rw-r--r--mysql-test/suite/innodb/r/instant_alter_rollback.result1
-rw-r--r--mysql-test/suite/innodb/r/lock_deleted.result57
-rw-r--r--mysql-test/suite/innodb/r/log_corruption.result38
-rw-r--r--mysql-test/suite/innodb/r/mvcc.result32
-rw-r--r--mysql-test/suite/innodb/r/purge_secondary.result148
-rw-r--r--mysql-test/suite/innodb/r/read_only_recover_committed.result47
-rw-r--r--mysql-test/suite/innodb/r/read_only_recovery.result1
-rw-r--r--mysql-test/suite/innodb/r/recovery_shutdown.result66
-rw-r--r--mysql-test/suite/innodb/r/rename_table_debug.result12
-rw-r--r--mysql-test/suite/innodb/r/restart.result29
-rw-r--r--mysql-test/suite/innodb/r/row_format_redundant.result2
-rw-r--r--mysql-test/suite/innodb/r/table_flags.result13
-rw-r--r--mysql-test/suite/innodb/r/truncate_inject.result114
-rw-r--r--mysql-test/suite/innodb/r/truncate_restart.result12
-rw-r--r--mysql-test/suite/innodb/r/update-cascade.result290
-rw-r--r--mysql-test/suite/innodb/r/update_time.result53
-rw-r--r--mysql-test/suite/innodb/r/update_time_wl6658.result228
-rw-r--r--mysql-test/suite/innodb/t/alter_copy.test91
-rw-r--r--mysql-test/suite/innodb/t/alter_crash.test96
-rw-r--r--mysql-test/suite/innodb/t/ddl_purge.test36
-rw-r--r--mysql-test/suite/innodb/t/deadlock_detect.test14
-rw-r--r--mysql-test/suite/innodb/t/drop_table_background.test14
-rw-r--r--mysql-test/suite/innodb/t/foreign_key.test40
-rw-r--r--mysql-test/suite/innodb/t/ibuf_not_empty.test2
-rw-r--r--mysql-test/suite/innodb/t/innodb-alter-tempfile.test14
-rw-r--r--mysql-test/suite/innodb/t/innodb-autoinc.test17
-rw-r--r--mysql-test/suite/innodb/t/innodb-index-debug.test39
-rw-r--r--mysql-test/suite/innodb/t/innodb-index-online.test27
-rw-r--r--mysql-test/suite/innodb/t/innodb-lru-force-no-free-page.test24
-rw-r--r--mysql-test/suite/innodb/t/innodb-master.opt2
-rw-r--r--mysql-test/suite/innodb/t/innodb-on-duplicate-update.test63
-rw-r--r--mysql-test/suite/innodb/t/innodb-replace-debug.test16
-rw-r--r--mysql-test/suite/innodb/t/innodb.test160
-rw-r--r--mysql-test/suite/innodb/t/innodb_buffer_pool_resize.opt2
-rw-r--r--mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test74
-rw-r--r--mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.opt3
-rw-r--r--mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.test63
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug14147491.test10
-rw-r--r--mysql-test/suite/innodb/t/innodb_bulk_create_index.test46
-rw-r--r--mysql-test/suite/innodb/t/innodb_bulk_create_index_debug.test23
-rw-r--r--mysql-test/suite/innodb/t/innodb_bulk_create_index_flush.test75
-rw-r--r--mysql-test/suite/innodb/t/innodb_bulk_create_index_replication.test182
-rw-r--r--mysql-test/suite/innodb/t/innodb_bulk_create_index_small.test148
-rw-r--r--mysql-test/suite/innodb/t/innodb_corrupt_bit.test5
-rw-r--r--mysql-test/suite/innodb/t/innodb_default_row_format.combinations4
-rw-r--r--mysql-test/suite/innodb/t/innodb_default_row_format.inc2
-rw-r--r--mysql-test/suite/innodb/t/innodb_force_recovery.test1
-rw-r--r--mysql-test/suite/innodb/t/innodb_max_recordsize_32k.opt3
-rw-r--r--mysql-test/suite/innodb/t/innodb_max_recordsize_32k.test37
-rw-r--r--mysql-test/suite/innodb/t/innodb_max_recordsize_64k.opt3
-rw-r--r--mysql-test/suite/innodb/t/innodb_max_recordsize_64k.test37
-rw-r--r--mysql-test/suite/innodb/t/instant_alter.test58
-rw-r--r--mysql-test/suite/innodb/t/instant_alter_crash.test2
-rw-r--r--mysql-test/suite/innodb/t/instant_alter_rollback.test3
-rw-r--r--mysql-test/suite/innodb/t/lock_deleted.test72
-rw-r--r--mysql-test/suite/innodb/t/log_corruption.test99
-rw-r--r--mysql-test/suite/innodb/t/log_file_name.test1
-rw-r--r--mysql-test/suite/innodb/t/log_file_size.test3
-rw-r--r--mysql-test/suite/innodb/t/mvcc.test52
-rw-r--r--mysql-test/suite/innodb/t/purge_secondary.opt1
-rw-r--r--mysql-test/suite/innodb/t/purge_secondary.test131
-rw-r--r--mysql-test/suite/innodb/t/read_only_recover_committed.test67
-rw-r--r--mysql-test/suite/innodb/t/read_only_recovery.test3
-rw-r--r--mysql-test/suite/innodb/t/recovery_shutdown.test64
-rw-r--r--mysql-test/suite/innodb/t/rename_table_debug.test21
-rw-r--r--mysql-test/suite/innodb/t/restart.test80
-rw-r--r--mysql-test/suite/innodb/t/row_format_redundant.test6
-rw-r--r--mysql-test/suite/innodb/t/table_definition_cache_debug.opt2
-rw-r--r--mysql-test/suite/innodb/t/table_flags.test5
-rw-r--r--mysql-test/suite/innodb/t/truncate_inject.test97
-rw-r--r--mysql-test/suite/innodb/t/truncate_restart.test16
-rw-r--r--mysql-test/suite/innodb/t/update-cascade.test221
-rw-r--r--mysql-test/suite/innodb/t/update_time-master.opt1
-rw-r--r--mysql-test/suite/innodb/t/update_time.test79
-rw-r--r--mysql-test/suite/innodb/t/update_time_wl6658.test232
113 files changed, 6625 insertions, 498 deletions
diff --git a/mysql-test/suite/innodb/include/innodb_bulk_create_index.inc b/mysql-test/suite/innodb/include/innodb_bulk_create_index.inc
new file mode 100644
index 00000000000..3c10517933f
--- /dev/null
+++ b/mysql-test/suite/innodb/include/innodb_bulk_create_index.inc
@@ -0,0 +1,185 @@
+#
+# wl#7277: InnoDB: Bulk Load for Create Index
+#
+
+# Create Insert Procedure
+DELIMITER |;
+CREATE PROCEDURE populate_t1(load_even INT)
+BEGIN
+ DECLARE i int DEFAULT 1;
+
+ START TRANSACTION;
+ WHILE (i <= 10000) DO
+ IF i%2 = 0 AND load_even = 1 THEN
+ INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+ END IF;
+ IF i%2 != 0 AND load_even != 1 THEN
+ INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+ END IF;
+ SET i = i + 1;
+ END WHILE;
+ COMMIT;
+END|
+DELIMITER ;|
+
+SELECT @@innodb_fill_factor;
+
+if ($row_format != 'COMPRESSED')
+{
+ eval CREATE TABLE t1(
+ class INT,
+ id INT,
+ title VARCHAR(100)
+ ) ENGINE=InnoDB ROW_FORMAT=$row_format;
+}
+
+if ($row_format == 'COMPRESSED')
+{
+ SET GLOBAL innodb_file_per_table=1;
+
+ eval CREATE TABLE t1(
+ class INT,
+ id INT,
+ title VARCHAR(100)
+ ) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4;
+}
+
+-- disable_query_log
+# Load half records
+CALL populate_t1(1);
+-- enable_query_log
+
+SELECT COUNT(*) FROM t1;
+
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+
+CREATE INDEX idx_title ON t1(title);
+
+/* Check table. */
+CHECK TABLE t1;
+
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE id = 10;
+SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE id = 5000;
+SELECT * FROM t1 WHERE title = 'a5000';
+
+SELECT * FROM t1 WHERE id = 10000;
+SELECT * FROM t1 WHERE title = 'a10000';
+
+SELECT * FROM t1 WHERE id = 10010;
+SELECT * FROM t1 WHERE title = 'a10010';
+
+/*Insert/Update/Delete. */
+DELETE FROM t1 WHERE id < 4010 AND id > 3990;
+INSERT INTO t1 VALUES(4000, 4000, 'b4000');
+UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990;
+
+SELECT * FROM t1 WHERE id = 3000;
+SELECT * FROM t1 WHERE title = 'a3000';
+SELECT * FROM t1 WHERE title = 'b3000';
+
+SELECT * FROM t1 WHERE id = 4000;
+SELECT * FROM t1 WHERE title = 'a4000';
+SELECT * FROM t1 WHERE title = 'b4000';
+
+SELECT * FROM t1 WHERE id = 4001;
+SELECT * FROM t1 WHERE title = 'a4001';
+
+-- disable_query_log
+# Load half records (follow up load)
+CALL populate_t1(0);
+-- enable_query_log
+SELECT COUNT(*) FROM t1;
+
+
+/* Add column. */
+ALTER TABLE t1 ADD COLUMN content TEXT;
+
+CHECK TABLE t1;
+
+SELECT * FROM t1 WHERE id = 10;
+SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE id = 5000;
+SELECT * FROM t1 WHERE title = 'a5000';
+
+SELECT * FROM t1 WHERE id = 10000;
+SELECT * FROM t1 WHERE title = 'a10000';
+
+SELECT * FROM t1 WHERE id = 10010;
+SELECT * FROM t1 WHERE title = 'a10010';
+
+/* Drop column. */
+ALTER TABLE t1 DROP COLUMN content;
+
+CHECK TABLE t1;
+
+SELECT * FROM t1 WHERE id = 10;
+SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE id = 5000;
+SELECT * FROM t1 WHERE title = 'a5000';
+
+SELECT * FROM t1 WHERE id = 10000;
+SELECT * FROM t1 WHERE title = 'a10000';
+
+SELECT * FROM t1 WHERE id = 10010;
+SELECT * FROM t1 WHERE title = 'a10010';
+
+DROP TABLE t1;
+
+# Test Blob
+if ($row_format != 'COMPRESSED') {
+ eval CREATE TABLE t1(
+ a INT PRIMARY KEY,
+ b TEXT,
+ c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format;
+}
+
+if ($row_format == 'COMPRESSED') {
+ eval CREATE TABLE t1(
+ a INT PRIMARY KEY,
+ b BLOB,
+ c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4;
+}
+
+let $cnt= 5000;
+-- disable_query_log
+WHILE ($cnt>=4950)
+{
+EVAL INSERT INTO t1 VALUES
+ ($cnt, REPEAT(CONCAT('a', $cnt),2000), CONCAT('a', $cnt));
+dec $cnt;
+}
+-- enable_query_log
+ALTER TABLE t1 ADD INDEX `idx` (a,b(5));
+
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%';
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+DELETE FROM t1 WHERE a=4975 AND b like 'b4975%';
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+
+ALTER TABLE t1 DROP COLUMN c;
+
+CHECK TABLE t1;
+
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+
+DROP TABLE t1;
+
+# Restore global variables
+if ($row_format == 'COMPRESSED')
+{
+ SET GLOBAL innodb_file_per_table=default;
+}
+
+DROP PROCEDURE populate_t1;
diff --git a/mysql-test/suite/innodb/include/innodb_bulk_create_index_debug.inc b/mysql-test/suite/innodb/include/innodb_bulk_create_index_debug.inc
new file mode 100644
index 00000000000..48de3a1962d
--- /dev/null
+++ b/mysql-test/suite/innodb/include/innodb_bulk_create_index_debug.inc
@@ -0,0 +1,221 @@
+#
+# wl#7277: InnoDB: Bulk Load for Create Index
+#
+
+# 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
+
+# Create Insert Procedure
+DELIMITER |;
+CREATE PROCEDURE populate_t1()
+BEGIN
+ DECLARE i int DEFAULT 1;
+
+ START TRANSACTION;
+ WHILE (i <= 10000) DO
+ INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+ SET i = i + 1;
+ END WHILE;
+ COMMIT;
+END|
+DELIMITER ;|
+
+# Test scenarios:
+# 1. Test restart;
+# 2. Test crash recovery.
+
+# Test Restart
+if ($row_format != 'COMPRESSED')
+{
+ eval CREATE TABLE t1(
+ class INT,
+ id INT,
+ title VARCHAR(100)
+ ) ENGINE=InnoDB ROW_FORMAT=$row_format;
+}
+
+if ($row_format == 'COMPRESSED')
+{
+ SET GLOBAL innodb_file_per_table=1;
+
+ eval CREATE TABLE t1(
+ class INT,
+ id INT,
+ title VARCHAR(100)
+ ) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4;
+}
+
+-- disable_query_log
+CALL populate_t1();
+-- enable_query_log
+
+SELECT COUNT(*) FROM t1;
+
+CREATE INDEX idx_title ON t1(title);
+
+--source include/restart_mysqld.inc
+
+CHECK TABLE t1;
+
+SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE title = 'a5000';
+
+SELECT * FROM t1 WHERE title = 'a10000';
+
+SELECT * FROM t1 WHERE title = 'a10010';
+
+DROP TABLE t1;
+
+-- echo # Test Blob
+
+if ($row_format != 'COMPRESSED') {
+ eval CREATE TABLE t1(
+ a INT PRIMARY KEY,
+ b TEXT,
+ c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format;
+}
+
+if ($row_format == 'COMPRESSED') {
+ SET GLOBAL innodb_file_per_table=1;
+
+ eval CREATE TABLE t1(
+ a INT PRIMARY KEY,
+ b TEXT,
+ c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4;
+}
+
+INSERT INTO t1 VALUES
+ (1, REPEAT('a',10000), 'a'),
+ (2, REPEAT('b',20000), 'b'),
+ (3, REPEAT('c',40000), 'c'),
+ (4, REPEAT('d',60000), 'd');
+
+SELECT CHAR_LENGTH(b) FROM t1;
+
+ALTER TABLE t1 DROP COLUMN c;
+
+--source include/restart_mysqld.inc
+
+CHECK TABLE t1;
+
+SELECT CHAR_LENGTH(b) FROM t1;
+
+DROP TABLE t1;
+
+# Test Crash Recovery
+
+if ($row_format != 'COMPRESSED')
+{
+ eval CREATE TABLE t1(
+ class INT,
+ id INT,
+ title VARCHAR(100)
+ ) ENGINE=InnoDB ROW_FORMAT=$row_format;
+}
+
+if ($row_format == 'COMPRESSED')
+{
+ SET GLOBAL innodb_file_per_table=1;
+
+ eval CREATE TABLE t1(
+ class INT,
+ id INT,
+ title VARCHAR(100)
+ ) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4;
+}
+
+-- disable_query_log
+CALL populate_t1();
+-- enable_query_log
+
+SET debug_dbug='+d,crash_commit_before';
+
+# Write file to make mysql-test-run.pl start up the server again
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+--error 2013
+CREATE INDEX idx_title ON t1(title);
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+SELECT COUNT(*) FROM t1;
+
+CHECK TABLE t1;
+
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE title = 'a5000';
+
+SELECT * FROM t1 WHERE title = 'a10000';
+
+SELECT * FROM t1 WHERE title = 'a10010';
+
+DROP TABLE t1;
+
+-- echo # Test Blob
+
+if ($row_format != 'COMPRESSED') {
+ eval CREATE TABLE t1(
+ a INT PRIMARY KEY,
+ b TEXT,
+ c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format;
+}
+
+if ($row_format == 'COMPRESSED') {
+ SET GLOBAL innodb_file_per_table=1;
+
+ eval CREATE TABLE t1(
+ a INT PRIMARY KEY,
+ b TEXT,
+ c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4;
+}
+
+INSERT INTO t1 VALUES
+ (1, REPEAT('a',10000), 'a'),
+ (2, REPEAT('b',20000), 'b'),
+ (3, REPEAT('c',40000), 'c'),
+ (4, REPEAT('d',60000), 'd');
+
+SELECT CHAR_LENGTH(b) FROM t1;
+
+SET debug_dbug='+d,crash_commit_before';
+
+# Write file to make mysql-test-run.pl start up the server again
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+--error 2013
+ALTER TABLE t1 DROP COLUMN c;
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+CHECK TABLE t1;
+
+SELECT CHAR_LENGTH(b) FROM t1;
+
+DROP TABLE t1;
+
+# Restore global variables
+if ($row_format == 'COMPRESSED')
+{
+ SET GLOBAL innodb_file_per_table=default;
+}
+
+DROP PROCEDURE populate_t1;
diff --git a/mysql-test/suite/innodb/r/alter_copy.result b/mysql-test/suite/innodb/r/alter_copy.result
new file mode 100644
index 00000000000..286c5152ded
--- /dev/null
+++ b/mysql-test/suite/innodb/r/alter_copy.result
@@ -0,0 +1,213 @@
+#
+# MDEV-11415 AVOID INTERMEDIATE COMMIT WHILE DOING
+# ALTER TABLE...ALGORITHM=COPY
+#
+CREATE TABLE t(a SERIAL, b INT, c INT, d INT) ENGINE=InnoDB;
+CREATE TABLE t1(a INT, b TEXT, c TEXT,
+FULLTEXT(b), FULLTEXT(c(3)), FULLTEXT(b,c)) ENGINE=InnoDB;
+BEGIN;
+COMMIT;
+SELECT COUNT(*) FROM t;
+COUNT(*)
+999
+UPDATE t SET b=a%7, c=a%11, d=a%13;
+INSERT INTO t1 VALUES(1, 'This is a first b column', 'This is a first c column');
+INSERT INTO t1 VALUES(2, 'This is a second b column', 'This is a second c column');
+INSERT INTO t1(a) VALUES(3);
+INSERT INTO t1 VALUES(4, 'This is a third b column', 'This is a third c column');
+DELETE FROM t1 WHERE a = 2;
+SELECT * FROM t1 WHERE MATCH(b) AGAINST ('first');
+a b c
+1 This is a first b column This is a first c column
+SELECT * FROM t1 WHERE MATCH(c) AGAINST ('first');
+a b c
+1 This is a first b column This is a first c column
+SELECT * FROM t1 WHERE MATCH(b,c) AGAINST ('column');
+a b c
+1 This is a first b column This is a first c column
+4 This is a third b column This is a third c column
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` text DEFAULT NULL,
+ `c` text DEFAULT NULL,
+ FULLTEXT KEY `b` (`b`),
+ FULLTEXT KEY `c` (`c`),
+ FULLTEXT KEY `b_2` (`b`,`c`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 FORCE, ALGORITHM=COPY;
+SET DEBUG_DBUG='+d,crash_commit_before';
+ALTER TABLE t ADD INDEX(b,c,d,a),ADD INDEX(b,c,a,d),ADD INDEX(b,a,c,d),ADD INDEX(b,a,d,c),
+ADD INDEX(b,d,a,c),ADD INDEX(b,d,c,a),ADD INDEX(a,b,c,d),ADD INDEX(a,b,d,c),
+ADD INDEX(a,c,b,d),ADD INDEX(a,c,d,b),ADD INDEX(a,d,b,c),ADD INDEX(a,d,c,b),
+ADD INDEX(c,a,b,d),ADD INDEX(c,a,d,b),ADD INDEX(c,b,a,d),ADD INDEX(c,b,d,a),
+ADD INDEX(c,d,a,b),ADD INDEX(c,d,b,a),ADD INDEX(d,a,b,c),ADD INDEX(d,a,c,b),
+ADD INDEX(d,b,a,c),ADD INDEX(d,b,c,a),ADD INDEX(d,c,a,b),ADD INDEX(d,c,b,a),
+ADD INDEX(a,b,c), ADD INDEX(a,c,b), ADD INDEX(a,c,d), ADD INDEX(a,d,c),
+ADD INDEX(a,b,d), ADD INDEX(a,d,b), ADD INDEX(b,c,d), ADD INDEX(b,d,c),
+ALGORITHM=COPY;
+ERROR HY000: Lost connection to MySQL server during query
+#sql-temporary.frm
+#sql-temporary.ibd
+FTS_INDEX_1.ibd
+FTS_INDEX_2.ibd
+FTS_INDEX_3.ibd
+FTS_INDEX_4.ibd
+FTS_INDEX_5.ibd
+FTS_INDEX_6.ibd
+FTS_INDEX_1.ibd
+FTS_INDEX_2.ibd
+FTS_INDEX_3.ibd
+FTS_INDEX_4.ibd
+FTS_INDEX_5.ibd
+FTS_INDEX_6.ibd
+FTS_INDEX_1.ibd
+FTS_INDEX_2.ibd
+FTS_INDEX_3.ibd
+FTS_INDEX_4.ibd
+FTS_INDEX_5.ibd
+FTS_INDEX_6.ibd
+FTSBEING_DELETED.ibd
+FTSBEING_DELETED_CACHE.ibd
+FTSCONFIG.ibd
+FTSDELETED.ibd
+FTSDELETED_CACHE.ibd
+t.frm
+t.ibd
+t1.frm
+t1.ibd
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `d` int(11) DEFAULT NULL,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=1000 DEFAULT CHARSET=latin1
+SELECT COUNT(*) FROM t;
+COUNT(*)
+999
+CHECK TABLE t;
+Table Op Msg_type Msg_text
+test.t check status OK
+SELECT * FROM t1 WHERE MATCH(b) AGAINST ('first');
+a b c
+1 This is a first b column This is a first c column
+SELECT * FROM t1 WHERE MATCH(c) AGAINST ('first');
+a b c
+1 This is a first b column This is a first c column
+SELECT * FROM t1 WHERE MATCH(b,c) AGAINST ('column');
+a b c
+1 This is a first b column This is a first c column
+4 This is a third b column This is a third c column
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` text DEFAULT NULL,
+ `c` text DEFAULT NULL,
+ FULLTEXT KEY `b` (`b`),
+ FULLTEXT KEY `c` (`c`),
+ FULLTEXT KEY `b_2` (`b`,`c`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+#sql-temporary.frm
+#sql-temporary.ibd
+FTS_INDEX_1.ibd
+FTS_INDEX_2.ibd
+FTS_INDEX_3.ibd
+FTS_INDEX_4.ibd
+FTS_INDEX_5.ibd
+FTS_INDEX_6.ibd
+FTS_INDEX_1.ibd
+FTS_INDEX_2.ibd
+FTS_INDEX_3.ibd
+FTS_INDEX_4.ibd
+FTS_INDEX_5.ibd
+FTS_INDEX_6.ibd
+FTS_INDEX_1.ibd
+FTS_INDEX_2.ibd
+FTS_INDEX_3.ibd
+FTS_INDEX_4.ibd
+FTS_INDEX_5.ibd
+FTS_INDEX_6.ibd
+FTSBEING_DELETED.ibd
+FTSBEING_DELETED_CACHE.ibd
+FTSCONFIG.ibd
+FTSDELETED.ibd
+FTSDELETED_CACHE.ibd
+t.frm
+t.ibd
+t1.frm
+t1.ibd
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `d` int(11) DEFAULT NULL,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=1000 DEFAULT CHARSET=latin1
+SELECT COUNT(*) FROM t;
+COUNT(*)
+999
+CHECK TABLE t;
+Table Op Msg_type Msg_text
+test.t check status OK
+SELECT * FROM t1 WHERE MATCH(b) AGAINST ('first');
+a b c
+1 This is a first b column This is a first c column
+SELECT * FROM t1 WHERE MATCH(c) AGAINST ('first');
+a b c
+1 This is a first b column This is a first c column
+SELECT * FROM t1 WHERE MATCH(b,c) AGAINST ('column');
+a b c
+1 This is a first b column This is a first c column
+4 This is a third b column This is a third c column
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` text DEFAULT NULL,
+ `c` text DEFAULT NULL,
+ FULLTEXT KEY `b` (`b`),
+ FULLTEXT KEY `c` (`c`),
+ FULLTEXT KEY `b_2` (`b`,`c`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+#sql-temporary.frm
+FTS_INDEX_1.ibd
+FTS_INDEX_2.ibd
+FTS_INDEX_3.ibd
+FTS_INDEX_4.ibd
+FTS_INDEX_5.ibd
+FTS_INDEX_6.ibd
+FTS_INDEX_1.ibd
+FTS_INDEX_2.ibd
+FTS_INDEX_3.ibd
+FTS_INDEX_4.ibd
+FTS_INDEX_5.ibd
+FTS_INDEX_6.ibd
+FTS_INDEX_1.ibd
+FTS_INDEX_2.ibd
+FTS_INDEX_3.ibd
+FTS_INDEX_4.ibd
+FTS_INDEX_5.ibd
+FTS_INDEX_6.ibd
+FTSBEING_DELETED.ibd
+FTSBEING_DELETED_CACHE.ibd
+FTSCONFIG.ibd
+FTSDELETED.ibd
+FTSDELETED_CACHE.ibd
+t.frm
+t.ibd
+t1.frm
+t1.ibd
+DROP TABLE t1,t;
diff --git a/mysql-test/suite/innodb/r/alter_crash.result b/mysql-test/suite/innodb/r/alter_crash.result
index 8de02cc5fbd..5bf25cf8592 100644
--- a/mysql-test/suite/innodb/r/alter_crash.result
+++ b/mysql-test/suite/innodb/r/alter_crash.result
@@ -44,10 +44,9 @@ SET DEBUG_DBUG='+d,innodb_alter_commit_crash_after_commit';
ALTER TABLE t1 ADD PRIMARY KEY (f2, f1);
ERROR HY000: Lost connection to MySQL server during query
# Restart mysqld after the crash and reconnect.
-# Manual *.frm recovery begin.
-# Manual recovery end
-FLUSH TABLES;
-# Drop the orphaned original table.
+SELECT * FROM information_schema.innodb_sys_tables
+WHERE table_id = ID;
+TABLE_ID NAME FLAG N_COLS SPACE ROW_FORMAT ZIP_PAGE_SIZE SPACE_TYPE
# Files in datadir after manual recovery.
t1.frm
t1.ibd
@@ -83,12 +82,9 @@ SET DEBUG_DBUG='+d,innodb_alter_commit_crash_before_commit';
ALTER TABLE t2 ADD PRIMARY KEY (f2, f1);
ERROR HY000: Lost connection to MySQL server during query
# Startup the server after the crash
-# Read and remember the temporary table name
-# Manual *.frm recovery begin. The dictionary was not updated
-# and the files were not renamed. The rebuilt table
-# was left behind on purpose, to faciliate data recovery.
-# Manual recovery end
-# Drop the orphaned rebuilt table.
+SELECT * FROM information_schema.innodb_sys_tables
+WHERE name LIKE 'test/#sql-%';
+TABLE_ID NAME FLAG N_COLS SPACE ROW_FORMAT ZIP_PAGE_SIZE SPACE_TYPE
SHOW TABLES;
Tables_in_test
t2
@@ -123,10 +119,9 @@ SET DEBUG_DBUG='+d,innodb_alter_commit_crash_after_commit';
ALTER TABLE t1 ADD INDEX (b), CHANGE c d int, ALGORITHM=INPLACE;
ERROR HY000: Lost connection to MySQL server during query
# Restart mysqld after the crash and reconnect.
-# Manual *.frm recovery begin.
-# Manual recovery end
-FLUSH TABLES;
-# Drop the orphaned original table.
+SELECT * FROM information_schema.innodb_sys_tables
+WHERE table_id = ID;
+TABLE_ID NAME FLAG N_COLS SPACE ROW_FORMAT ZIP_PAGE_SIZE SPACE_TYPE
# Files in datadir after manual recovery.
t1.frm
t1.ibd
diff --git a/mysql-test/suite/innodb/r/ddl_purge.result b/mysql-test/suite/innodb/r/ddl_purge.result
new file mode 100644
index 00000000000..45f4c99e97b
--- /dev/null
+++ b/mysql-test/suite/innodb/r/ddl_purge.result
@@ -0,0 +1,25 @@
+CREATE TABLE t0 (pk INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t1 (pk INT PRIMARY KEY, b INT) ENGINE=InnoDB;
+connect con1,localhost,root,,test;
+BEGIN;
+INSERT INTO t0 SET pk=1;
+connect con2,localhost,root,,test;
+BEGIN;
+INSERT INTO t0 SET pk=2;
+connection default;
+SET DEBUG_SYNC='alter_table_inplace_after_lock_downgrade SIGNAL prepared WAIT_FOR logged';
+ALTER TABLE t1 FORCE;
+connection con1;
+SET DEBUG_SYNC='now WAIT_FOR prepared';
+INSERT INTO t1 SET pk=1;
+COMMIT;
+disconnect con1;
+connection con2;
+UPDATE t1 SET b=1;
+DELETE FROM t1;
+ROLLBACK;
+SET DEBUG_SYNC='now SIGNAL logged';
+disconnect con2;
+connection default;
+SET DEBUG_SYNC='RESET';
+DROP TABLE t0,t1;
diff --git a/mysql-test/suite/innodb/r/deadlock_detect.result b/mysql-test/suite/innodb/r/deadlock_detect.result
index c3e3794ed21..4e14eff34b2 100644
--- a/mysql-test/suite/innodb/r/deadlock_detect.result
+++ b/mysql-test/suite/innodb/r/deadlock_detect.result
@@ -8,21 +8,15 @@ PRIMARY KEY(id)
INSERT INTO t1 VALUES(1), (2), (3);
BEGIN;
SELECT * FROM t1 WHERE id = 1 FOR UPDATE;
-id
-1
connect con1,localhost,root,,;
BEGIN;
SELECT * FROM t1 WHERE id = 2 FOR UPDATE;
-id
-2
SELECT * FROM t1 WHERE id = 1 FOR UPDATE;
connection default;
SELECT * FROM t1 WHERE id = 2 FOR UPDATE;
connection con1;
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ROLLBACK;
connection default;
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ROLLBACK;
DROP TABLE t1;
disconnect con1;
diff --git a/mysql-test/suite/innodb/r/drop_table_background.result b/mysql-test/suite/innodb/r/drop_table_background.result
index a6f5672ba7f..e74bcd5e780 100644
--- a/mysql-test/suite/innodb/r/drop_table_background.result
+++ b/mysql-test/suite/innodb/r/drop_table_background.result
@@ -3,7 +3,22 @@ KEY(c1), KEY(c2), KEY(c2,c1),
KEY(c3), KEY(c3,c1), KEY(c3,c2), KEY(c3,c2,c1),
KEY(c4), KEY(c4,c1), KEY(c4,c2), KEY(c4,c2,c1),
KEY(c4,c3), KEY(c4,c3,c1), KEY(c4,c3,c2), KEY(c4,c3,c2,c1)) ENGINE=InnoDB;
+CREATE TABLE `#mysql50##sql-ib-foo`(a SERIAL) ENGINE=InnoDB;
+INSERT INTO t (c1) VALUES (1),(2),(1);
SET DEBUG_DBUG='+d,row_drop_table_add_to_background';
+CREATE TABLE target (PRIMARY KEY(c1)) ENGINE=InnoDB SELECT * FROM t;
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+SELECT * from target;
+ERROR 42S02: Table 'test.target' doesn't exist
DROP TABLE t;
CREATE TABLE t (a INT) ENGINE=InnoDB;
DROP TABLE t;
+DROP TABLE target;
+ERROR 42S02: Unknown table 'test.target'
+CREATE TABLE target (a INT) ENGINE=InnoDB;
+DROP TABLE target;
+SELECT * FROM `#mysql50##sql-ib-foo`;
+ERROR 42S02: Table 'test.#mysql50##sql-ib-foo' doesn't exist in engine
+DROP TABLE `#mysql50##sql-ib-foo`;
+Warnings:
+Warning 1932 Table 'test.#mysql50##sql-ib-foo' doesn't exist in engine
diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/innodb/r/foreign_key.result
index da0e16b86ac..e569fc7dba7 100644
--- a/mysql-test/suite/innodb/r/foreign_key.result
+++ b/mysql-test/suite/innodb/r/foreign_key.result
@@ -263,3 +263,46 @@ SELECT * FROM t2;
id ref_id f
2 2 20
DROP TABLE t2, t1;
+#
+# MDEV-15199 Referential integrity broken in ON DELETE CASCADE
+#
+CREATE TABLE member (id int AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO member VALUES (1);
+CREATE TABLE address (
+id int AUTO_INCREMENT PRIMARY KEY,
+member_id int NOT NULL,
+KEY address_FI_1 (member_id),
+CONSTRAINT address_FK_1 FOREIGN KEY (member_id) REFERENCES member (id)
+ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB;
+INSERT INTO address VALUES (2,1);
+CREATE TABLE payment_method (
+id int AUTO_INCREMENT PRIMARY KEY,
+member_id int NOT NULL,
+cardholder_address_id int DEFAULT NULL,
+KEY payment_method_FI_1 (member_id),
+KEY payment_method_FI_2 (cardholder_address_id),
+CONSTRAINT payment_method_FK_1 FOREIGN KEY (member_id) REFERENCES member (id) ON DELETE CASCADE ON UPDATE CASCADE,
+CONSTRAINT payment_method_FK_2 FOREIGN KEY (cardholder_address_id) REFERENCES address (id) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB;
+INSERT INTO payment_method VALUES (3,1,2);
+BEGIN;
+UPDATE member SET id=42;
+SELECT * FROM member;
+id
+42
+SELECT * FROM address;
+id member_id
+2 42
+SELECT * FROM payment_method;
+id member_id cardholder_address_id
+3 42 2
+DELETE FROM member;
+COMMIT;
+SELECT * FROM member;
+id
+SELECT * FROM address;
+id member_id
+SELECT * FROM payment_method;
+id member_id cardholder_address_id
+DROP TABLE payment_method,address,member;
diff --git a/mysql-test/suite/innodb/r/innodb-autoinc.result b/mysql-test/suite/innodb/r/innodb-autoinc.result
index e276303557e..ee1adc07661 100644
--- a/mysql-test/suite/innodb/r/innodb-autoinc.result
+++ b/mysql-test/suite/innodb/r/innodb-autoinc.result
@@ -1351,3 +1351,21 @@ t CREATE TABLE `t` (
KEY `i` (`i`)
) ENGINE=InnoDB AUTO_INCREMENT=401 DEFAULT CHARSET=latin1
DROP TABLE t;
+#
+# MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())
+#
+SET sql_mode=STRICT_ALL_TABLES;
+CREATE TABLE t1 (
+c1 DOUBLE NOT NULL PRIMARY KEY AUTO_INCREMENT
+) ENGINE=InnoDB AUTO_INCREMENT=10000000000000000000;
+INSERT INTO t1 VALUES ();
+SELECT * FROM t1;
+c1
+1e19
+DROP TABLE t1;
+CREATE TABLE t1 (a DOUBLE PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (-1);
+SELECT * FROM t1;
+a
+-1
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/innodb-fk-warnings.result b/mysql-test/suite/innodb/r/innodb-fk-warnings.result
index 792cae85b55..fc3f45f3d0a 100644
--- a/mysql-test/suite/innodb/r/innodb-fk-warnings.result
+++ b/mysql-test/suite/innodb/r/innodb-fk-warnings.result
@@ -27,7 +27,7 @@ show warnings;
Level Code Message
Warning 150 Create table '`test`.`t2`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near ' foreign key a (a) references t1(a)) engine=innodb'.
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `t2`
drop table t1;
create table t1(a int not null primary key, b int) engine=innodb;
create table t2(a int, b int, constraint a foreign key a (a) references t1(a),
@@ -36,7 +36,7 @@ ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint
show warnings;
Level Code Message
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `t2`
create table t2(a int, b int, constraint a foreign key a (a) references t1(a)) engine=innodb;
alter table t2 add constraint b foreign key (b) references t2(b);
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
@@ -44,7 +44,7 @@ show warnings;
Level Code Message
Warning 150 Alter table '`test`.`t2`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near ' foreign key (b) references t2(b)'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
drop table t2, t1;
create table t1 (f1 integer primary key) engine=innodb;
alter table t1 add constraint c1 foreign key (f1) references t11(f1);
@@ -53,7 +53,7 @@ show warnings;
Level Code Message
Warning 150 Alter table `test`.`t1` with foreign key constraint failed. Referenced table `test`.`t11` not found in the data dictionary near ' foreign key (f1) references t11(f1)'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
drop table t1;
create temporary table t1(a int not null primary key, b int, key(b)) engine=innodb;
create temporary table t2(a int, foreign key(a) references t1(a)) engine=innodb;
@@ -76,14 +76,14 @@ show warnings;
Level Code Message
Warning 150 Create table `mysqld.1`.`t2` with foreign key constraint failed. Referenced table `mysqld.1`.`t1` not found in the data dictionary near 'foreign key(a) references t1(a)) engine=innodb'.
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `t2`
alter table t1 add foreign key(b) references t1(a);
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
show warnings;
Level Code Message
Warning 150 Alter table `mysqld.1`.`t1` with foreign key constraint failed. Referenced table `mysqld.1`.`t1` not found in the data dictionary near 'foreign key(b) references t1(a)'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
drop table t1;
create table t1(a int not null primary key, b int, key(b)) engine=innodb;
alter table t1 add foreign key(a,b) references t1(a);
@@ -106,14 +106,14 @@ show warnings;
Level Code Message
Warning 150 Alter table `test`.`t1` with foreign key constraint failed. You have defined a SET NULL condition but column 'f1' is defined as NOT NULL in ' foreign key (f1) references t1(f1) on update set null' near ' on update set null'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
create table t2(a int not null, foreign key(a) references t1(f1) on delete set null) engine=innodb;
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
show warnings;
Level Code Message
Warning 150 Create table `test`.`t2` with foreign key constraint failed. You have defined a SET NULL condition but column 'a' is defined as NOT NULL in 'foreign key(a) references t1(f1) on delete set null) engine=innodb' near ' on delete set null) engine=innodb'.
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `t2`
drop table t1;
create table t1 (id int not null primary key, f1 int, f2 int, key(f1)) engine=innodb;
create table t2(a char(20), key(a), foreign key(a) references t1(f1)) engine=innodb;
@@ -122,5 +122,5 @@ show warnings;
Level Code Message
Warning 150 Create table `test`.`t2` with foreign key constraint failed. Field type or character set for column 'a' does not mach referenced column 'f1' near 'foreign key(a) references t1(f1)) engine=innodb'.
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `t2`
drop table t1;
diff --git a/mysql-test/suite/innodb/r/innodb-fk.result b/mysql-test/suite/innodb/r/innodb-fk.result
index 2eb19764769..4efa0214999 100644
--- a/mysql-test/suite/innodb/r/innodb-fk.result
+++ b/mysql-test/suite/innodb/r/innodb-fk.result
@@ -53,7 +53,7 @@ Level Code Message
Warning 150 Create table `test`.`t2` with foreign key constraint failed. Referenced table `test`.`t3` not found in the data dictionary near ' FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE CASCADE
) ENGINE=InnoDB'.
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `t2`
CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
f2 int(11) NOT NULL,
@@ -67,7 +67,7 @@ show warnings;
Level Code Message
Warning 150 Alter table `test`.`t2` with foreign key constraint failed. Referenced table `test`.`t3` not found in the data dictionary near ' FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE CASCADE'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
drop table t2;
drop table t1;
CREATE DATABASE kg_test1;
diff --git a/mysql-test/suite/innodb/r/innodb-fkcheck.result b/mysql-test/suite/innodb/r/innodb-fkcheck.result
index c6beabb0f50..efa227e4035 100644
--- a/mysql-test/suite/innodb/r/innodb-fkcheck.result
+++ b/mysql-test/suite/innodb/r/innodb-fkcheck.result
@@ -37,7 +37,7 @@ ERROR HY000: Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint
show warnings;
Level Code Message
Error 1005 Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `b`
DROP TABLE IF EXISTS d;
Warnings:
Note 1051 Unknown table 'bug_fk.d'
@@ -76,7 +76,7 @@ ERROR HY000: Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint
show warnings;
Level Code Message
Error 1005 Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `b`
set foreign_key_checks=0;
drop table c;
drop table d;
diff --git a/mysql-test/suite/innodb/r/innodb-index-debug.result b/mysql-test/suite/innodb/r/innodb-index-debug.result
index beab075f3c8..5d161e5e6ca 100644
--- a/mysql-test/suite/innodb/r/innodb-index-debug.result
+++ b/mysql-test/suite/innodb/r/innodb-index-debug.result
@@ -95,7 +95,7 @@ SET DEBUG_SYNC= 'now SIGNAL flushed';
SET DEBUG_DBUG = @saved_debug_dbug;
connection con1;
/*con1 reap*/ ALTER TABLE t1 ADD COLUMN k4 int;
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SELECT COUNT(k1),k2,k3 FROM t1 GROUP BY k2,k3;
COUNT(k1) k2 k3
480 aaa bbb
@@ -112,6 +112,35 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB AUTO_INCREMENT=1023 DEFAULT CHARSET=latin1
drop table t1;
drop table t480;
+#
+# MDEV-12827 Assertion failure when reporting duplicate key error
+# in online table rebuild
+#
+CREATE TABLE t1 (j INT UNIQUE, i INT UNIQUE) ENGINE=InnoDB;
+connect con1,localhost,root,,test;
+SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL built WAIT_FOR log';
+ALTER TABLE t1 DROP j, FORCE;
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR built';
+INSERT INTO t1 (i) VALUES (0),(0);
+ERROR 23000: Duplicate entry '0' for key 'i'
+SET DEBUG_SYNC='now SIGNAL log';
+connection con1;
+ERROR 23000: Duplicate entry '0' for key 'i'
+SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL built2 WAIT_FOR log2';
+ALTER TABLE t1 DROP j, FORCE;
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR built2';
+INSERT INTO t1 (i) VALUES (0),(1);
+UPDATE t1 SET i=0;
+ERROR 23000: Duplicate entry '0' for key 'i'
+SET DEBUG_SYNC='now SIGNAL log2';
+connection con1;
+ERROR 23000: Duplicate entry '0' for key 'i'
+disconnect con1;
+connection default;
+SET DEBUG_SYNC='RESET';
+DROP TABLE t1;
SET DEBUG_SYNC='RESET';
#
# BUG#21612714 ALTER TABLE SORTING SKIPPED WHEN CHANGE PK AND DROP
diff --git a/mysql-test/suite/innodb/r/innodb-index-online-fk.result b/mysql-test/suite/innodb/r/innodb-index-online-fk.result
index 359ce4a717c..47fc8e8b840 100644
--- a/mysql-test/suite/innodb/r/innodb-index-online-fk.result
+++ b/mysql-test/suite/innodb/r/innodb-index-online-fk.result
@@ -86,6 +86,7 @@ child CREATE TABLE `child` (
DELETE FROM parent where a = 1;
SELECT * FROM child;
a1 a2
+1 NULL
2 3
10 20
SET foreign_key_checks = 0;
@@ -126,6 +127,7 @@ SYS_TABLESPACES
SYS_VIRTUAL
mysql/innodb_index_stats
mysql/innodb_table_stats
+mysql/transaction_registry
test/child
test/parent
INSERT INTO child VALUES(5,4);
@@ -317,6 +319,7 @@ SYS_TABLESPACES
SYS_VIRTUAL
mysql/innodb_index_stats
mysql/innodb_table_stats
+mysql/transaction_registry
test/child
test/parent
ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT,
@@ -342,6 +345,7 @@ SYS_TABLESPACES
SYS_VIRTUAL
mysql/innodb_index_stats
mysql/innodb_table_stats
+mysql/transaction_registry
test/child
test/parent
SHOW CREATE TABLE child;
@@ -378,6 +382,7 @@ SYS_TABLESPACES
SYS_VIRTUAL
mysql/innodb_index_stats
mysql/innodb_table_stats
+mysql/transaction_registry
test/child
test/parent
SHOW CREATE TABLE child;
@@ -414,6 +419,7 @@ SYS_TABLESPACES
SYS_VIRTUAL
mysql/innodb_index_stats
mysql/innodb_table_stats
+mysql/transaction_registry
test/child
test/parent
SHOW CREATE TABLE child;
diff --git a/mysql-test/suite/innodb/r/innodb-index-online.result b/mysql-test/suite/innodb/r/innodb-index-online.result
index 5427f13043d..c646645ba7a 100644
--- a/mysql-test/suite/innodb/r/innodb-index-online.result
+++ b/mysql-test/suite/innodb/r/innodb-index-online.result
@@ -37,11 +37,11 @@ connection con1;
SET @saved_debug_dbug = @@SESSION.debug_dbug;
SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter';
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET DEBUG_DBUG = @saved_debug_dbug;
SET DEBUG_DBUG = '+d,innodb_OOM_inplace_alter';
CREATE UNIQUE INDEX c2 ON t1(c2);
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET DEBUG_DBUG = @saved_debug_dbug;
CREATE UNIQUE INDEX c2 ON t1(c2);
DROP INDEX c2 ON t1;
@@ -470,8 +470,6 @@ ddl_online_create_index 0
ddl_pending_alter_table 0
ddl_sort_file_alter_table 0
ddl_log_file_alter_table 2
-connection con1;
-disconnect con1;
connection default;
SHOW CREATE TABLE t1;
Table Create Table
@@ -498,6 +496,25 @@ ERROR 42000: Duplicate key name 'c2h'
SET DEBUG_SYNC = 'RESET';
SET GLOBAL innodb_monitor_disable = module_ddl;
DROP TABLE t1;
+#
+# MDEV-13205 assertion !dict_index_is_online_ddl(index) upon ALTER TABLE
+#
+CREATE TABLE t1 (c VARCHAR(64)) ENGINE=InnoDB;
+SET DEBUG_SYNC = 'row_log_apply_before SIGNAL t1u_created WAIT_FOR dup_done';
+ALTER TABLE t1 ADD UNIQUE(c);
+connection con1;
+SET DEBUG_SYNC = 'now WAIT_FOR t1u_created';
+BEGIN;
+INSERT INTO t1 VALUES('bar'),('bar');
+SET DEBUG_SYNC = 'now SIGNAL dup_done';
+connection default;
+ERROR 23000: Duplicate entry 'bar' for key 'c'
+SET DEBUG_SYNC = 'RESET';
+disconnect con1;
+CREATE TABLE t2 (c VARCHAR(64)) ENGINE=InnoDB;
+ALTER TABLE t2 ADD FOREIGN KEY (c) REFERENCES t1 (c);
+ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
+DROP TABLE t2,t1;
SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig;
SET GLOBAL innodb_monitor_enable = default;
SET GLOBAL innodb_monitor_disable = default;
diff --git a/mysql-test/suite/innodb/r/innodb-lru-force-no-free-page.result b/mysql-test/suite/innodb/r/innodb-lru-force-no-free-page.result
new file mode 100644
index 00000000000..09e53b59d9d
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-lru-force-no-free-page.result
@@ -0,0 +1,10 @@
+call mtr.add_suppression("InnoDB: Difficult to find free blocks in the buffer pool");
+SET @saved_debug = @@SESSION.debug_dbug;
+SET SESSION debug_dbug="+d,ib_lru_force_no_free_page";
+CREATE TABLE t1 (j LONGBLOB) ENGINE = InnoDB;
+BEGIN;
+INSERT INTO t1 VALUES (repeat('abcdefghijklmnopqrstuvwxyz',200));
+COMMIT;
+SET debug_dbug = @saved_debug;
+DROP TABLE t1;
+FOUND 1 /InnoDB: Difficult to find free blocks / in mysqld.1.err
diff --git a/mysql-test/suite/innodb/r/innodb-on-duplicate-update.result b/mysql-test/suite/innodb/r/innodb-on-duplicate-update.result
new file mode 100644
index 00000000000..474ebf33bbd
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-on-duplicate-update.result
@@ -0,0 +1,60 @@
+set sql_mode='';
+set innodb_strict_mode=0;
+CREATE TABLE `v` (
+`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+INSERT v values (1);
+CREATE TABLE `vp` (
+`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+`v_id` int(10) unsigned NOT NULL,
+`p_id` int(10) unsigned NOT NULL,
+`ppp` varchar(255) NOT NULL,
+PRIMARY KEY (`id`),
+UNIQUE KEY `IDX_vp_uniq` (`v_id`,`p_id`),
+KEY `FK_vp_v` (`v_id`),
+CONSTRAINT `FK_vp_v` FOREIGN KEY (`v_id`) REFERENCES `v` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+INSERT vp VALUES (12, 1, 100, 'text12');
+INSERT INTO `vp` (`id`,`ppp`) VALUES (12, 'test12-2') ON DUPLICATE KEY UPDATE `ppp` = VALUES(`ppp`);
+Warnings:
+Warning 1364 Field 'v_id' doesn't have a default value
+Warning 1364 Field 'p_id' doesn't have a default value
+SELECT * FROM vp;
+id v_id p_id ppp
+12 1 100 test12-2
+DROP TABLE vp, v;
+CREATE TABLE t1 (i int PRIMARY KEY) ENGINE=InnoDB;
+INSERT into t1 values (1);
+CREATE TABLE t2 (
+i int not null primary key,
+vi int not null,
+m int,
+UNIQUE KEY (vi),
+CONSTRAINT `cc` FOREIGN KEY (vi) REFERENCES t1 (i) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB;
+INSERT into t2 VALUES (1, 1, 100);
+INSERT INTO t2 (i,m) VALUES (1, 2) ON DUPLICATE KEY UPDATE m=3;
+Warnings:
+Warning 1364 Field 'vi' doesn't have a default value
+SELECT * FROM t2;
+i vi m
+1 1 3
+DROP TABLE t2,t1;
+CREATE TABLE t1 (i int PRIMARY KEY) ENGINE=InnoDB;
+INSERT into t1 values (1);
+CREATE TABLE t2 (
+i int not null primary key,
+vi int not null,
+m int,
+KEY (vi),
+CONSTRAINT `cc` FOREIGN KEY (vi) REFERENCES t1 (i) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB;
+INSERT into t2 VALUES (1, 1, 100);
+INSERT INTO t2 (i,m) VALUES (1, 2) ON DUPLICATE KEY UPDATE m=3;
+Warnings:
+Warning 1364 Field 'vi' doesn't have a default value
+SELECT * FROM t2;
+i vi m
+1 1 3
+DROP TABLE t2, t1;
diff --git a/mysql-test/suite/innodb/r/innodb-replace-debug.result b/mysql-test/suite/innodb/r/innodb-replace-debug.result
new file mode 100644
index 00000000000..989fb055cbc
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-replace-debug.result
@@ -0,0 +1,14 @@
+#
+# Bug#17604730 ASSERTION: *CURSOR->INDEX->NAME == TEMP_INDEX_PREFIX
+#
+create table t1 (f1 int primary key, f2 int, f3 int, unique key k1(f2),
+key k2(f3)) engine=innodb;
+insert into t1 values (14, 24, 34);
+set @old_dbug= @@session.debug_dbug;
+set debug_dbug = '+d,row_ins_sec_index_entry_timeout';
+replace into t1 values (14, 25, 34);
+select * from t1;
+f1 f2 f3
+14 25 34
+drop table t1;
+set debug_dbug = @old_dbug;
diff --git a/mysql-test/suite/innodb/r/innodb-table-online.result b/mysql-test/suite/innodb/r/innodb-table-online.result
index 09ec3bbc252..3ac00436e07 100644
--- a/mysql-test/suite/innodb/r/innodb-table-online.result
+++ b/mysql-test/suite/innodb/r/innodb-table-online.result
@@ -42,7 +42,7 @@ connection con1;
SET @saved_debug_dbug = @@SESSION.debug_dbug;
SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter';
ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE;
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET SESSION DEBUG = @saved_debug_dbug;
Warnings:
Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
@@ -50,7 +50,7 @@ SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter';
Warnings:
Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE;
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET SESSION DEBUG = @saved_debug_dbug;
Warnings:
Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
diff --git a/mysql-test/suite/innodb/r/innodb-wl5522-debug.result b/mysql-test/suite/innodb/r/innodb-wl5522-debug.result
index 99e9c49eee9..ec3856c20b8 100644
--- a/mysql-test/suite/innodb/r/innodb-wl5522-debug.result
+++ b/mysql-test/suite/innodb/r/innodb-wl5522-debug.result
@@ -323,7 +323,7 @@ ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug="+d,ib_import_OOM_1";
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE test_wl5522.t1;
unlink: t1.ibd
@@ -336,7 +336,7 @@ ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug="+d,ib_import_OOM_2";
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE test_wl5522.t1;
unlink: t1.ibd
@@ -349,7 +349,7 @@ ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug="+d,ib_import_OOM_4";
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE test_wl5522.t1;
unlink: t1.ibd
@@ -362,7 +362,7 @@ ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug="+d,ib_import_OOM_5";
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE test_wl5522.t1;
unlink: t1.ibd
@@ -375,7 +375,7 @@ ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug="+d,ib_import_OOM_6";
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE test_wl5522.t1;
unlink: t1.ibd
@@ -388,7 +388,7 @@ ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug="+d,ib_import_OOM_7";
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE test_wl5522.t1;
unlink: t1.ibd
@@ -401,7 +401,7 @@ ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug="+d,ib_import_OOM_8";
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE test_wl5522.t1;
unlink: t1.ibd
@@ -414,7 +414,7 @@ ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug="+d,ib_import_OOM_9";
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE test_wl5522.t1;
unlink: t1.ibd
@@ -427,7 +427,7 @@ ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug="+d,ib_import_OOM_10";
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
-ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+ERROR HY000: Out of memory.
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE test_wl5522.t1;
unlink: t1.ibd
diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result
index edac0d0ab69..aafd31ae6f1 100644
--- a/mysql-test/suite/innodb/r/innodb.result
+++ b/mysql-test/suite/innodb/r/innodb.result
@@ -1,3 +1,5 @@
+create temporary table t (a char(1) character set filename) engine=innodb;
+drop temporary table t;
set optimizer_switch = 'mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
drop table if exists t1,t2,t3,t4;
drop database if exists mysqltest;
@@ -1318,80 +1320,17 @@ INSERT INTO t2 VALUES (10, 'old'), (20, 'other');
UPDATE t1 SET c1 = 'other' WHERE c1 = 'old';
ERROR 23000: Foreign key constraint for table 't1', record 'other-somevalu' would lead to a duplicate entry in table 't2', key 'c1'
DROP TABLE t2,t1;
-call mtr.add_suppression("Cannot delete/update rows with cascading foreign key constraints that exceed max depth of 255. Please drop excessive foreign constraints and try again");
+call mtr.add_suppression("Cannot delete/update rows with cascading foreign key constraints that exceed max depth of 15\\. Please drop excessive foreign constraints and try again");
create table t1(
id int primary key,
pid int,
index(pid),
foreign key(pid) references t1(id) on delete cascade) engine=innodb;
-insert into t1 values
-( 0, 0), ( 1, 0), ( 2, 1), ( 3, 2),
-( 4, 3), ( 5, 4), ( 6, 5), ( 7, 6),
-( 8, 7), ( 9, 8), ( 10, 9), ( 11, 10),
-( 12, 11), ( 13, 12), ( 14, 13), ( 15, 14),
-( 16, 15), ( 17, 16), ( 18, 17), ( 19, 18),
-( 20, 19), ( 21, 20), ( 22, 21), ( 23, 22),
-( 24, 23), ( 25, 24), ( 26, 25), ( 27, 26),
-( 28, 27), ( 29, 28), ( 30, 29), ( 31, 30),
-( 32, 31), ( 33, 32), ( 34, 33), ( 35, 34),
-( 36, 35), ( 37, 36), ( 38, 37), ( 39, 38),
-( 40, 39), ( 41, 40), ( 42, 41), ( 43, 42),
-( 44, 43), ( 45, 44), ( 46, 45), ( 47, 46),
-( 48, 47), ( 49, 48), ( 50, 49), ( 51, 50),
-( 52, 51), ( 53, 52), ( 54, 53), ( 55, 54),
-( 56, 55), ( 57, 56), ( 58, 57), ( 59, 58),
-( 60, 59), ( 61, 60), ( 62, 61), ( 63, 62),
-( 64, 63), ( 65, 64), ( 66, 65), ( 67, 66),
-( 68, 67), ( 69, 68), ( 70, 69), ( 71, 70),
-( 72, 71), ( 73, 72), ( 74, 73), ( 75, 74),
-( 76, 75), ( 77, 76), ( 78, 77), ( 79, 78),
-( 80, 79), ( 81, 80), ( 82, 81), ( 83, 82),
-( 84, 83), ( 85, 84), ( 86, 85), ( 87, 86),
-( 88, 87), ( 89, 88), ( 90, 89), ( 91, 90),
-( 92, 91), ( 93, 92), ( 94, 93), ( 95, 94),
-( 96, 95), ( 97, 96), ( 98, 97), ( 99, 98),
-(100, 99), (101, 100), (102, 101), (103, 102),
-(104, 103), (105, 104), (106, 105), (107, 106),
-(108, 107), (109, 108), (110, 109), (111, 110),
-(112, 111), (113, 112), (114, 113), (115, 114),
-(116, 115), (117, 116), (118, 117), (119, 118),
-(120, 119), (121, 120), (122, 121), (123, 122),
-(124, 123), (125, 124), (126, 125), (127, 126),
-(128, 127), (129, 128), (130, 129), (131, 130),
-(132, 131), (133, 132), (134, 133), (135, 134),
-(136, 135), (137, 136), (138, 137), (139, 138),
-(140, 139), (141, 140), (142, 141), (143, 142),
-(144, 143), (145, 144), (146, 145), (147, 146),
-(148, 147), (149, 148), (150, 149), (151, 150),
-(152, 151), (153, 152), (154, 153), (155, 154),
-(156, 155), (157, 156), (158, 157), (159, 158),
-(160, 159), (161, 160), (162, 161), (163, 162),
-(164, 163), (165, 164), (166, 165), (167, 166),
-(168, 167), (169, 168), (170, 169), (171, 170),
-(172, 171), (173, 172), (174, 173), (175, 174),
-(176, 175), (177, 176), (178, 177), (179, 178),
-(180, 179), (181, 180), (182, 181), (183, 182),
-(184, 183), (185, 184), (186, 185), (187, 186),
-(188, 187), (189, 188), (190, 189), (191, 190),
-(192, 191), (193, 192), (194, 193), (195, 194),
-(196, 195), (197, 196), (198, 197), (199, 198),
-(200, 199), (201, 200), (202, 201), (203, 202),
-(204, 203), (205, 204), (206, 205), (207, 206),
-(208, 207), (209, 208), (210, 209), (211, 210),
-(212, 211), (213, 212), (214, 213), (215, 214),
-(216, 215), (217, 216), (218, 217), (219, 218),
-(220, 219), (221, 220), (222, 221), (223, 222),
-(224, 223), (225, 224), (226, 225), (227, 226),
-(228, 227), (229, 228), (230, 229), (231, 230),
-(232, 231), (233, 232), (234, 233), (235, 234),
-(236, 235), (237, 236), (238, 237), (239, 238),
-(240, 239), (241, 240), (242, 241), (243, 242),
-(244, 243), (245, 244), (246, 245), (247, 246),
-(248, 247), (249, 248), (250, 249), (251, 250),
-(252, 251), (253, 252), (254, 253), (255, 254);
+insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
+(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
delete from t1 where id=0;
Got one of the listed errors
-delete from t1 where id=255;
+delete from t1 where id=15;
delete from t1 where id=0;
drop table t1;
CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB;
@@ -1756,10 +1695,10 @@ variable_value
16384
SELECT variable_value - @innodb_rows_deleted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_deleted';
variable_value - @innodb_rows_deleted_orig
-311
+71
SELECT variable_value - @innodb_rows_inserted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_inserted';
variable_value - @innodb_rows_inserted_orig
-1204
+964
SELECT variable_value - @innodb_rows_updated_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_updated';
variable_value - @innodb_rows_updated_orig
866
@@ -3299,3 +3238,83 @@ show status like "handler_read_key";
Variable_name Value
Handler_read_key 0
drop table t1;
+CREATE TABLE t1 (c1 INT) ENGINE=InnoDB;
+CREATE TEMPORARY TABLE t2 (c1 INT) ENGINE=InnoDB;
+START TRANSACTION READ ONLY;
+INSERT INTO t2 VALUES(0);
+INSERT INTO t1 VALUES(0);
+ERROR 25006: Cannot execute statement in a READ ONLY transaction
+ROLLBACK;
+SELECT * FROM t1;
+c1
+SELECT * FROM t2;
+c1
+START TRANSACTION READ ONLY;
+INSERT INTO t1 VALUES(0);
+ERROR 25006: Cannot execute statement in a READ ONLY transaction
+INSERT INTO t2 VALUES(1);
+COMMIT;
+SET TRANSACTION READ ONLY;
+START TRANSACTION;
+INSERT INTO t2 VALUES(3);
+INSERT INTO t1 VALUES(0);
+ERROR 25006: Cannot execute statement in a READ ONLY transaction
+COMMIT;
+SELECT * FROM t1;
+c1
+SELECT * FROM t2;
+c1
+1
+3
+DROP TABLE t2;
+CREATE TEMPORARY TABLE t2 (
+c1 INT AUTO_INCREMENT PRIMARY KEY,
+c2 INT, INDEX idx(c2)) ENGINE=InnoDB;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TEMPORARY TABLE `t2` (
+ `c1` int(11) NOT NULL AUTO_INCREMENT,
+ `c2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`c1`),
+ KEY `idx` (`c2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+START TRANSACTION READ ONLY;
+INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3);
+INSERT INTO t1 VALUES(0);
+ERROR 25006: Cannot execute statement in a READ ONLY transaction
+ROLLBACK;
+SELECT * FROM t1;
+c1
+SELECT * FROM t2;
+c1 c2
+START TRANSACTION READ ONLY;
+INSERT INTO t1 VALUES(0);
+ERROR 25006: Cannot execute statement in a READ ONLY transaction
+INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3);
+COMMIT;
+SET TRANSACTION READ ONLY;
+START TRANSACTION;
+INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3);
+INSERT INTO t1 VALUES(0);
+ERROR 25006: Cannot execute statement in a READ ONLY transaction
+COMMIT;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TEMPORARY TABLE `t2` (
+ `c1` int(11) NOT NULL AUTO_INCREMENT,
+ `c2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`c1`),
+ KEY `idx` (`c2`)
+) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+c1
+SELECT * FROM t2;
+c1 c2
+4 1
+7 1
+5 2
+8 2
+6 3
+9 3
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result b/mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result
new file mode 100644
index 00000000000..667d31a0b69
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result
@@ -0,0 +1,34 @@
+set global innodb_adaptive_hash_index=ON;
+select @@innodb_buffer_pool_size;
+@@innodb_buffer_pool_size
+8388608
+set global innodb_buffer_pool_size = 10485760;
+Warnings:
+Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '10485760'
+select @@innodb_buffer_pool_size;
+@@innodb_buffer_pool_size
+16777216
+create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
+create or replace view view0 as select 1 union all select 1;
+set @`v_id` := 0;
+set @`v_val` := 0;
+replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17;
+set global innodb_buffer_pool_size = 7340032;
+Warnings:
+Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '7340032'
+select @@innodb_buffer_pool_size;
+@@innodb_buffer_pool_size
+8388608
+select count(val) from t1;
+count(val)
+262144
+set global innodb_adaptive_hash_index=OFF;
+set global innodb_buffer_pool_size = 25165824;
+select @@innodb_buffer_pool_size;
+@@innodb_buffer_pool_size
+25165824
+select count(val) from t1;
+count(val)
+262144
+drop table t1;
+drop view view0;
diff --git a/mysql-test/suite/innodb/r/innodb_buffer_pool_resize_with_chunks.result b/mysql-test/suite/innodb/r/innodb_buffer_pool_resize_with_chunks.result
new file mode 100644
index 00000000000..4bf244c9588
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_buffer_pool_resize_with_chunks.result
@@ -0,0 +1,26 @@
+select @@innodb_buffer_pool_chunk_size;
+@@innodb_buffer_pool_chunk_size
+2097152
+create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
+create or replace view view0 as select 1 union all select 1;
+set @`v_id` := 0;
+set @`v_val` := 0;
+replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17;
+set global innodb_buffer_pool_size = 7340032;
+Warnings:
+Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '7340032'
+select count(val) from t1;
+count(val)
+262144
+set global innodb_buffer_pool_size = 16777216;
+select count(val) from t1;
+count(val)
+262144
+drop table t1;
+drop view view0;
+set global innodb_buffer_pool_size = 1048576;
+Warnings:
+Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '1048576'
+select @@innodb_buffer_pool_size;
+@@innodb_buffer_pool_size
+6291456
diff --git a/mysql-test/suite/innodb/r/innodb_bulk_create_index.result b/mysql-test/suite/innodb/r/innodb_bulk_create_index.result
new file mode 100644
index 00000000000..ec7ce044cb7
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_bulk_create_index.result
@@ -0,0 +1,1037 @@
+CREATE PROCEDURE populate_t1(load_even INT)
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 10000) DO
+IF i%2 = 0 AND load_even = 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+IF i%2 != 0 AND load_even != 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+SELECT @@innodb_fill_factor;
+@@innodb_fill_factor
+100
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+5000
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+CREATE INDEX idx_title ON t1(title);
+/* Check table. */
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_id idx_id 5 const 1
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 5000;
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE id = 10000;
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE id = 10010;
+class id title
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+/*Insert/Update/Delete. */
+DELETE FROM t1 WHERE id < 4010 AND id > 3990;
+INSERT INTO t1 VALUES(4000, 4000, 'b4000');
+UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990;
+SELECT * FROM t1 WHERE id = 3000;
+class id title
+3000 3000 b3000
+SELECT * FROM t1 WHERE title = 'a3000';
+class id title
+SELECT * FROM t1 WHERE title = 'b3000';
+class id title
+3000 3000 b3000
+SELECT * FROM t1 WHERE id = 4000;
+class id title
+4000 4000 b4000
+SELECT * FROM t1 WHERE title = 'a4000';
+class id title
+SELECT * FROM t1 WHERE title = 'b4000';
+class id title
+4000 4000 b4000
+SELECT * FROM t1 WHERE id = 4001;
+class id title
+SELECT * FROM t1 WHERE title = 'a4001';
+class id title
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9992
+/* Add column. */
+ALTER TABLE t1 ADD COLUMN content TEXT;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE id = 10;
+class id title content
+10 10 a10 NULL
+SELECT * FROM t1 WHERE title = 'a10';
+class id title content
+10 10 a10 NULL
+SELECT * FROM t1 WHERE id = 5000;
+class id title content
+5000 5000 a5000 NULL
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title content
+5000 5000 a5000 NULL
+SELECT * FROM t1 WHERE id = 10000;
+class id title content
+10000 10000 a10000 NULL
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title content
+10000 10000 a10000 NULL
+SELECT * FROM t1 WHERE id = 10010;
+class id title content
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title content
+/* Drop column. */
+ALTER TABLE t1 DROP COLUMN content;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 5000;
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE id = 10000;
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE id = 10010;
+class id title
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+ALTER TABLE t1 ADD INDEX `idx` (a,b(5));
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+10000
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+b=REPEAT(CONCAT('a',4975),2000)
+1
+UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%';
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+b=REPEAT(CONCAT('a',4975),2000)
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+b=REPEAT(CONCAT('b',4975),2000)
+1
+DELETE FROM t1 WHERE a=4975 AND b like 'b4975%';
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+b=REPEAT(CONCAT('b',4975),2000)
+ALTER TABLE t1 DROP COLUMN c;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+DROP TABLE t1;
+DROP PROCEDURE populate_t1;
+CREATE PROCEDURE populate_t1(load_even INT)
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 10000) DO
+IF i%2 = 0 AND load_even = 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+IF i%2 != 0 AND load_even != 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+SELECT @@innodb_fill_factor;
+@@innodb_fill_factor
+100
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+5000
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+CREATE INDEX idx_title ON t1(title);
+/* Check table. */
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_id idx_id 5 const 1
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 5000;
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE id = 10000;
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE id = 10010;
+class id title
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+/*Insert/Update/Delete. */
+DELETE FROM t1 WHERE id < 4010 AND id > 3990;
+INSERT INTO t1 VALUES(4000, 4000, 'b4000');
+UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990;
+SELECT * FROM t1 WHERE id = 3000;
+class id title
+3000 3000 b3000
+SELECT * FROM t1 WHERE title = 'a3000';
+class id title
+SELECT * FROM t1 WHERE title = 'b3000';
+class id title
+3000 3000 b3000
+SELECT * FROM t1 WHERE id = 4000;
+class id title
+4000 4000 b4000
+SELECT * FROM t1 WHERE title = 'a4000';
+class id title
+SELECT * FROM t1 WHERE title = 'b4000';
+class id title
+4000 4000 b4000
+SELECT * FROM t1 WHERE id = 4001;
+class id title
+SELECT * FROM t1 WHERE title = 'a4001';
+class id title
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9992
+/* Add column. */
+ALTER TABLE t1 ADD COLUMN content TEXT;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE id = 10;
+class id title content
+10 10 a10 NULL
+SELECT * FROM t1 WHERE title = 'a10';
+class id title content
+10 10 a10 NULL
+SELECT * FROM t1 WHERE id = 5000;
+class id title content
+5000 5000 a5000 NULL
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title content
+5000 5000 a5000 NULL
+SELECT * FROM t1 WHERE id = 10000;
+class id title content
+10000 10000 a10000 NULL
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title content
+10000 10000 a10000 NULL
+SELECT * FROM t1 WHERE id = 10010;
+class id title content
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title content
+/* Drop column. */
+ALTER TABLE t1 DROP COLUMN content;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 5000;
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE id = 10000;
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE id = 10010;
+class id title
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+ALTER TABLE t1 ADD INDEX `idx` (a,b(5));
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+10000
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+b=REPEAT(CONCAT('a',4975),2000)
+1
+UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%';
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+b=REPEAT(CONCAT('a',4975),2000)
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+b=REPEAT(CONCAT('b',4975),2000)
+1
+DELETE FROM t1 WHERE a=4975 AND b like 'b4975%';
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+b=REPEAT(CONCAT('b',4975),2000)
+ALTER TABLE t1 DROP COLUMN c;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+DROP TABLE t1;
+DROP PROCEDURE populate_t1;
+CREATE PROCEDURE populate_t1(load_even INT)
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 10000) DO
+IF i%2 = 0 AND load_even = 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+IF i%2 != 0 AND load_even != 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+SELECT @@innodb_fill_factor;
+@@innodb_fill_factor
+100
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+5000
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+CREATE INDEX idx_title ON t1(title);
+/* Check table. */
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_id idx_id 5 const 1
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 5000;
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE id = 10000;
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE id = 10010;
+class id title
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+/*Insert/Update/Delete. */
+DELETE FROM t1 WHERE id < 4010 AND id > 3990;
+INSERT INTO t1 VALUES(4000, 4000, 'b4000');
+UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990;
+SELECT * FROM t1 WHERE id = 3000;
+class id title
+3000 3000 b3000
+SELECT * FROM t1 WHERE title = 'a3000';
+class id title
+SELECT * FROM t1 WHERE title = 'b3000';
+class id title
+3000 3000 b3000
+SELECT * FROM t1 WHERE id = 4000;
+class id title
+4000 4000 b4000
+SELECT * FROM t1 WHERE title = 'a4000';
+class id title
+SELECT * FROM t1 WHERE title = 'b4000';
+class id title
+4000 4000 b4000
+SELECT * FROM t1 WHERE id = 4001;
+class id title
+SELECT * FROM t1 WHERE title = 'a4001';
+class id title
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9992
+/* Add column. */
+ALTER TABLE t1 ADD COLUMN content TEXT;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE id = 10;
+class id title content
+10 10 a10 NULL
+SELECT * FROM t1 WHERE title = 'a10';
+class id title content
+10 10 a10 NULL
+SELECT * FROM t1 WHERE id = 5000;
+class id title content
+5000 5000 a5000 NULL
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title content
+5000 5000 a5000 NULL
+SELECT * FROM t1 WHERE id = 10000;
+class id title content
+10000 10000 a10000 NULL
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title content
+10000 10000 a10000 NULL
+SELECT * FROM t1 WHERE id = 10010;
+class id title content
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title content
+/* Drop column. */
+ALTER TABLE t1 DROP COLUMN content;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 5000;
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE id = 10000;
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE id = 10010;
+class id title
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+ALTER TABLE t1 ADD INDEX `idx` (a,b(5));
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+10000
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+b=REPEAT(CONCAT('a',4975),2000)
+1
+UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%';
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+b=REPEAT(CONCAT('a',4975),2000)
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+b=REPEAT(CONCAT('b',4975),2000)
+1
+DELETE FROM t1 WHERE a=4975 AND b like 'b4975%';
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+b=REPEAT(CONCAT('b',4975),2000)
+ALTER TABLE t1 DROP COLUMN c;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+DROP TABLE t1;
+DROP PROCEDURE populate_t1;
+CREATE PROCEDURE populate_t1(load_even INT)
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 10000) DO
+IF i%2 = 0 AND load_even = 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+IF i%2 != 0 AND load_even != 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+SELECT @@innodb_fill_factor;
+@@innodb_fill_factor
+100
+SET GLOBAL innodb_file_per_table=1;
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+5000
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+CREATE INDEX idx_title ON t1(title);
+/* Check table. */
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_id idx_id 5 const 1
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 5000;
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE id = 10000;
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE id = 10010;
+class id title
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+/*Insert/Update/Delete. */
+DELETE FROM t1 WHERE id < 4010 AND id > 3990;
+INSERT INTO t1 VALUES(4000, 4000, 'b4000');
+UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990;
+SELECT * FROM t1 WHERE id = 3000;
+class id title
+3000 3000 b3000
+SELECT * FROM t1 WHERE title = 'a3000';
+class id title
+SELECT * FROM t1 WHERE title = 'b3000';
+class id title
+3000 3000 b3000
+SELECT * FROM t1 WHERE id = 4000;
+class id title
+4000 4000 b4000
+SELECT * FROM t1 WHERE title = 'a4000';
+class id title
+SELECT * FROM t1 WHERE title = 'b4000';
+class id title
+4000 4000 b4000
+SELECT * FROM t1 WHERE id = 4001;
+class id title
+SELECT * FROM t1 WHERE title = 'a4001';
+class id title
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9992
+/* Add column. */
+ALTER TABLE t1 ADD COLUMN content TEXT;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE id = 10;
+class id title content
+10 10 a10 NULL
+SELECT * FROM t1 WHERE title = 'a10';
+class id title content
+10 10 a10 NULL
+SELECT * FROM t1 WHERE id = 5000;
+class id title content
+5000 5000 a5000 NULL
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title content
+5000 5000 a5000 NULL
+SELECT * FROM t1 WHERE id = 10000;
+class id title content
+10000 10000 a10000 NULL
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title content
+10000 10000 a10000 NULL
+SELECT * FROM t1 WHERE id = 10010;
+class id title content
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title content
+/* Drop column. */
+ALTER TABLE t1 DROP COLUMN content;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 5000;
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE id = 10000;
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE id = 10010;
+class id title
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b BLOB,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+ALTER TABLE t1 ADD INDEX `idx` (a,b(5));
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+10000
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+b=REPEAT(CONCAT('a',4975),2000)
+1
+UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%';
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+b=REPEAT(CONCAT('a',4975),2000)
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+b=REPEAT(CONCAT('b',4975),2000)
+1
+DELETE FROM t1 WHERE a=4975 AND b like 'b4975%';
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+b=REPEAT(CONCAT('b',4975),2000)
+ALTER TABLE t1 DROP COLUMN c;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+DROP TABLE t1;
+SET GLOBAL innodb_file_per_table=default;
+DROP PROCEDURE populate_t1;
+SET GLOBAL innodb_fill_factor=10;
+CREATE PROCEDURE populate_t1(load_even INT)
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 10000) DO
+IF i%2 = 0 AND load_even = 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+IF i%2 != 0 AND load_even != 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+SELECT @@innodb_fill_factor;
+@@innodb_fill_factor
+10
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+5000
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+CREATE INDEX idx_title ON t1(title);
+/* Check table. */
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_id idx_id 5 const 1
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 5000;
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE id = 10000;
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE id = 10010;
+class id title
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+/*Insert/Update/Delete. */
+DELETE FROM t1 WHERE id < 4010 AND id > 3990;
+INSERT INTO t1 VALUES(4000, 4000, 'b4000');
+UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990;
+SELECT * FROM t1 WHERE id = 3000;
+class id title
+3000 3000 b3000
+SELECT * FROM t1 WHERE title = 'a3000';
+class id title
+SELECT * FROM t1 WHERE title = 'b3000';
+class id title
+3000 3000 b3000
+SELECT * FROM t1 WHERE id = 4000;
+class id title
+4000 4000 b4000
+SELECT * FROM t1 WHERE title = 'a4000';
+class id title
+SELECT * FROM t1 WHERE title = 'b4000';
+class id title
+4000 4000 b4000
+SELECT * FROM t1 WHERE id = 4001;
+class id title
+SELECT * FROM t1 WHERE title = 'a4001';
+class id title
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9992
+/* Add column. */
+ALTER TABLE t1 ADD COLUMN content TEXT;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE id = 10;
+class id title content
+10 10 a10 NULL
+SELECT * FROM t1 WHERE title = 'a10';
+class id title content
+10 10 a10 NULL
+SELECT * FROM t1 WHERE id = 5000;
+class id title content
+5000 5000 a5000 NULL
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title content
+5000 5000 a5000 NULL
+SELECT * FROM t1 WHERE id = 10000;
+class id title content
+10000 10000 a10000 NULL
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title content
+10000 10000 a10000 NULL
+SELECT * FROM t1 WHERE id = 10010;
+class id title content
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title content
+/* Drop column. */
+ALTER TABLE t1 DROP COLUMN content;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 5000;
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE id = 10000;
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE id = 10010;
+class id title
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+ALTER TABLE t1 ADD INDEX `idx` (a,b(5));
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+10000
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+b=REPEAT(CONCAT('a',4975),2000)
+1
+UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%';
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+b=REPEAT(CONCAT('a',4975),2000)
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+b=REPEAT(CONCAT('b',4975),2000)
+1
+DELETE FROM t1 WHERE a=4975 AND b like 'b4975%';
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+b=REPEAT(CONCAT('b',4975),2000)
+ALTER TABLE t1 DROP COLUMN c;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+DROP TABLE t1;
+DROP PROCEDURE populate_t1;
+SET GLOBAL innodb_fill_factor=50;
+CREATE PROCEDURE populate_t1(load_even INT)
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 10000) DO
+IF i%2 = 0 AND load_even = 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+IF i%2 != 0 AND load_even != 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+SELECT @@innodb_fill_factor;
+@@innodb_fill_factor
+50
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+5000
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+CREATE INDEX idx_title ON t1(title);
+/* Check table. */
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_id idx_id 5 const 1
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 5000;
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE id = 10000;
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE id = 10010;
+class id title
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+/*Insert/Update/Delete. */
+DELETE FROM t1 WHERE id < 4010 AND id > 3990;
+INSERT INTO t1 VALUES(4000, 4000, 'b4000');
+UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990;
+SELECT * FROM t1 WHERE id = 3000;
+class id title
+3000 3000 b3000
+SELECT * FROM t1 WHERE title = 'a3000';
+class id title
+SELECT * FROM t1 WHERE title = 'b3000';
+class id title
+3000 3000 b3000
+SELECT * FROM t1 WHERE id = 4000;
+class id title
+4000 4000 b4000
+SELECT * FROM t1 WHERE title = 'a4000';
+class id title
+SELECT * FROM t1 WHERE title = 'b4000';
+class id title
+4000 4000 b4000
+SELECT * FROM t1 WHERE id = 4001;
+class id title
+SELECT * FROM t1 WHERE title = 'a4001';
+class id title
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9992
+/* Add column. */
+ALTER TABLE t1 ADD COLUMN content TEXT;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE id = 10;
+class id title content
+10 10 a10 NULL
+SELECT * FROM t1 WHERE title = 'a10';
+class id title content
+10 10 a10 NULL
+SELECT * FROM t1 WHERE id = 5000;
+class id title content
+5000 5000 a5000 NULL
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title content
+5000 5000 a5000 NULL
+SELECT * FROM t1 WHERE id = 10000;
+class id title content
+10000 10000 a10000 NULL
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title content
+10000 10000 a10000 NULL
+SELECT * FROM t1 WHERE id = 10010;
+class id title content
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title content
+/* Drop column. */
+ALTER TABLE t1 DROP COLUMN content;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 5000;
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE id = 10000;
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE id = 10010;
+class id title
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+ALTER TABLE t1 ADD INDEX `idx` (a,b(5));
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+10000
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+b=REPEAT(CONCAT('a',4975),2000)
+1
+UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%';
+SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%';
+b=REPEAT(CONCAT('a',4975),2000)
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+b=REPEAT(CONCAT('b',4975),2000)
+1
+DELETE FROM t1 WHERE a=4975 AND b like 'b4975%';
+SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%';
+b=REPEAT(CONCAT('b',4975),2000)
+ALTER TABLE t1 DROP COLUMN c;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+DROP TABLE t1;
+DROP PROCEDURE populate_t1;
+SET GLOBAL innodb_fill_factor=default;
diff --git a/mysql-test/suite/innodb/r/innodb_bulk_create_index_debug.result b/mysql-test/suite/innodb/r/innodb_bulk_create_index_debug.result
new file mode 100644
index 00000000000..cd5a3c340da
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_bulk_create_index_debug.result
@@ -0,0 +1,485 @@
+CREATE PROCEDURE populate_t1()
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 10000) DO
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10000
+CREATE INDEX idx_title ON t1(title);
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+# Test Blob
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+INSERT INTO t1 VALUES
+(1, REPEAT('a',10000), 'a'),
+(2, REPEAT('b',20000), 'b'),
+(3, REPEAT('c',40000), 'c'),
+(4, REPEAT('d',60000), 'd');
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+ALTER TABLE t1 DROP COLUMN c;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+DROP TABLE t1;
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+SET debug_dbug='+d,crash_commit_before';
+CREATE INDEX idx_title ON t1(title);
+ERROR HY000: Lost connection to MySQL server during query
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10000
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+# Test Blob
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+INSERT INTO t1 VALUES
+(1, REPEAT('a',10000), 'a'),
+(2, REPEAT('b',20000), 'b'),
+(3, REPEAT('c',40000), 'c'),
+(4, REPEAT('d',60000), 'd');
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+SET debug_dbug='+d,crash_commit_before';
+ALTER TABLE t1 DROP COLUMN c;
+ERROR HY000: Lost connection to MySQL server during query
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+DROP TABLE t1;
+DROP PROCEDURE populate_t1;
+CREATE PROCEDURE populate_t1()
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 10000) DO
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10000
+CREATE INDEX idx_title ON t1(title);
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+# Test Blob
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+INSERT INTO t1 VALUES
+(1, REPEAT('a',10000), 'a'),
+(2, REPEAT('b',20000), 'b'),
+(3, REPEAT('c',40000), 'c'),
+(4, REPEAT('d',60000), 'd');
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+ALTER TABLE t1 DROP COLUMN c;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+DROP TABLE t1;
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+SET debug_dbug='+d,crash_commit_before';
+CREATE INDEX idx_title ON t1(title);
+ERROR HY000: Lost connection to MySQL server during query
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10000
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+# Test Blob
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+INSERT INTO t1 VALUES
+(1, REPEAT('a',10000), 'a'),
+(2, REPEAT('b',20000), 'b'),
+(3, REPEAT('c',40000), 'c'),
+(4, REPEAT('d',60000), 'd');
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+SET debug_dbug='+d,crash_commit_before';
+ALTER TABLE t1 DROP COLUMN c;
+ERROR HY000: Lost connection to MySQL server during query
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+DROP TABLE t1;
+DROP PROCEDURE populate_t1;
+CREATE PROCEDURE populate_t1()
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 10000) DO
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10000
+CREATE INDEX idx_title ON t1(title);
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+# Test Blob
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 VALUES
+(1, REPEAT('a',10000), 'a'),
+(2, REPEAT('b',20000), 'b'),
+(3, REPEAT('c',40000), 'c'),
+(4, REPEAT('d',60000), 'd');
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+ALTER TABLE t1 DROP COLUMN c;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+DROP TABLE t1;
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+SET debug_dbug='+d,crash_commit_before';
+CREATE INDEX idx_title ON t1(title);
+ERROR HY000: Lost connection to MySQL server during query
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10000
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+# Test Blob
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 VALUES
+(1, REPEAT('a',10000), 'a'),
+(2, REPEAT('b',20000), 'b'),
+(3, REPEAT('c',40000), 'c'),
+(4, REPEAT('d',60000), 'd');
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+SET debug_dbug='+d,crash_commit_before';
+ALTER TABLE t1 DROP COLUMN c;
+ERROR HY000: Lost connection to MySQL server during query
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+DROP TABLE t1;
+DROP PROCEDURE populate_t1;
+CREATE PROCEDURE populate_t1()
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 10000) DO
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+SET GLOBAL innodb_file_per_table=1;
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10000
+CREATE INDEX idx_title ON t1(title);
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+# Test Blob
+SET GLOBAL innodb_file_per_table=1;
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+INSERT INTO t1 VALUES
+(1, REPEAT('a',10000), 'a'),
+(2, REPEAT('b',20000), 'b'),
+(3, REPEAT('c',40000), 'c'),
+(4, REPEAT('d',60000), 'd');
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+ALTER TABLE t1 DROP COLUMN c;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+DROP TABLE t1;
+SET GLOBAL innodb_file_per_table=1;
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+SET debug_dbug='+d,crash_commit_before';
+CREATE INDEX idx_title ON t1(title);
+ERROR HY000: Lost connection to MySQL server during query
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10000
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a5000';
+class id title
+5000 5000 a5000
+SELECT * FROM t1 WHERE title = 'a10000';
+class id title
+10000 10000 a10000
+SELECT * FROM t1 WHERE title = 'a10010';
+class id title
+DROP TABLE t1;
+# Test Blob
+SET GLOBAL innodb_file_per_table=1;
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+INSERT INTO t1 VALUES
+(1, REPEAT('a',10000), 'a'),
+(2, REPEAT('b',20000), 'b'),
+(3, REPEAT('c',40000), 'c'),
+(4, REPEAT('d',60000), 'd');
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+SET debug_dbug='+d,crash_commit_before';
+ALTER TABLE t1 DROP COLUMN c;
+ERROR HY000: Lost connection to MySQL server during query
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1;
+CHAR_LENGTH(b)
+10000
+20000
+40000
+60000
+DROP TABLE t1;
+SET GLOBAL innodb_file_per_table=default;
+DROP PROCEDURE populate_t1;
diff --git a/mysql-test/suite/innodb/r/innodb_bulk_create_index_flush.result b/mysql-test/suite/innodb/r/innodb_bulk_create_index_flush.result
new file mode 100644
index 00000000000..d2b812642f6
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_bulk_create_index_flush.result
@@ -0,0 +1,54 @@
+CREATE PROCEDURE populate_t1()
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 10000) DO
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10000
+SET @saved_dbug= @@SESSION.debug_dbug;
+SET debug_dbug='+d,ib_index_build_fail_before_flush';
+CREATE INDEX idx_id ON t1(id);
+ERROR 70100: Query execution was interrupted
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+CREATE INDEX idx_title ON t1(title);
+ERROR 70100: Query execution was interrupted
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+CREATE FULLTEXT INDEX fidx_title ON t1(title);
+ERROR 70100: Query execution was interrupted
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+ALTER TABLE t1 ADD COLUMN content TEXT, FORCE;
+ERROR 70100: Query execution was interrupted
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SET debug_dbug= @saved_dbug;
+INSERT INTO t1 VALUES(10001, 10001, 'a10000');
+ALTER TABLE t1 ADD UNIQUE INDEX idx_title(title);
+ERROR 23000: Duplicate entry 'a10000' for key 'idx_title'
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+ALTER TABLE t1 ADD UNIQUE INDEX idx_id(id), ADD UNIQUE INDEX idx_title(title);
+ERROR 23000: Duplicate entry 'a10000' for key 'idx_title'
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1;
+DROP PROCEDURE populate_t1;
diff --git a/mysql-test/suite/innodb/r/innodb_bulk_create_index_replication.result b/mysql-test/suite/innodb/r/innodb_bulk_create_index_replication.result
new file mode 100644
index 00000000000..ae050170b4f
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_bulk_create_index_replication.result
@@ -0,0 +1,222 @@
+include/master-slave.inc
+[connection master]
+connection master;
+CREATE PROCEDURE populate_t1(load_even INT)
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 100) DO
+IF i%2 = 0 AND load_even = 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+IF i%2 != 0 AND load_even != 1 THEN
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+END IF;
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+50
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+CREATE INDEX idx_title ON t1(title);
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_id idx_id 5 const 1
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 20;
+class id title
+20 20 a20
+SELECT * FROM t1 WHERE title = 'a20';
+class id title
+20 20 a20
+SELECT * FROM t1 WHERE id = 30;
+class id title
+30 30 a30
+SELECT * FROM t1 WHERE title = 'a30';
+class id title
+30 30 a30
+SELECT * FROM t1 WHERE id = 101;
+class id title
+SELECT * FROM t1 WHERE title = 'a101';
+class id title
+/*Insert/Update/Delete. */
+DELETE FROM t1 WHERE id < 40 AND id > 30;
+INSERT INTO t1 VALUES(38, 38, 'b38');
+UPDATE t1 SET title = CONCAT('b', id) WHERE id < 30 AND id > 20;
+SELECT * FROM t1 WHERE id = 28;
+class id title
+28 28 b28
+SELECT * FROM t1 WHERE title = 'a28';
+class id title
+SELECT * FROM t1 WHERE title = 'b28';
+class id title
+28 28 b28
+SELECT * FROM t1 WHERE id = 38;
+class id title
+38 38 b38
+SELECT * FROM t1 WHERE title = 'a38';
+class id title
+SELECT * FROM t1 WHERE title = 'b38';
+class id title
+38 38 b38
+SELECT * FROM t1 WHERE id = 101;
+class id title
+SELECT * FROM t1 WHERE title = 'a101';
+class id title
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+97
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 20;
+class id title
+20 20 a20
+SELECT * FROM t1 WHERE title = 'a20';
+class id title
+20 20 a20
+SELECT * FROM t1 WHERE id = 30;
+class id title
+30 30 a30
+SELECT * FROM t1 WHERE title = 'a30';
+class id title
+30 30 a30
+SELECT * FROM t1 WHERE id = 101;
+class id title
+SELECT * FROM t1 WHERE title = 'a101';
+class id title
+CREATE TABLE t_part (
+class INT ,
+id INT ,
+title VARCHAR(30)
+) ENGINE=InnoDB
+PARTITION BY RANGE(id)
+SUBPARTITION BY KEY(id)
+SUBPARTITIONS 4
+(
+PARTITION p0 VALUES LESS THAN (5000),
+PARTITION p1 VALUES LESS THAN (MAXVALUE)
+);
+INSERT INTO t_part SELECT * FROM t1;
+ALTER TABLE t_part ADD INDEX `idx` (class,id,title(10));
+SELECT * FROM t_part WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t_part WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t_part WHERE id = 20;
+class id title
+20 20 a20
+SELECT * FROM t_part WHERE title = 'a20';
+class id title
+20 20 a20
+SELECT * FROM t_part WHERE id = 30;
+class id title
+30 30 a30
+SELECT * FROM t_part WHERE title = 'a30';
+class id title
+30 30 a30
+SELECT * FROM t_part WHERE id = 101;
+class id title
+SELECT * FROM t_part WHERE title = 'a101';
+class id title
+include/sync_slave_sql_with_master.inc
+connection slave;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `class` int(11) DEFAULT NULL,
+ `id` int(11) DEFAULT NULL,
+ `title` varchar(100) DEFAULT NULL,
+ KEY `idx_id` (`id`),
+ KEY `idx_title` (`title`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t_part;
+Table Create Table
+t_part CREATE TABLE `t_part` (
+ `class` int(11) DEFAULT NULL,
+ `id` int(11) DEFAULT NULL,
+ `title` varchar(30) DEFAULT NULL,
+ KEY `idx` (`class`,`id`,`title`(10))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+ PARTITION BY RANGE (`id`)
+SUBPARTITION BY KEY (`id`)
+SUBPARTITIONS 4
+(PARTITION `p0` VALUES LESS THAN (5000) ENGINE = InnoDB,
+ PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = InnoDB)
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+97
+SELECT COUNT(*) FROM t_part;
+COUNT(*)
+97
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 20;
+class id title
+20 20 a20
+SELECT * FROM t1 WHERE title = 'a20';
+class id title
+20 20 a20
+SELECT * FROM t1 WHERE id = 30;
+class id title
+30 30 a30
+SELECT * FROM t1 WHERE title = 'a30';
+class id title
+30 30 a30
+SELECT * FROM t1 WHERE id = 101;
+class id title
+SELECT * FROM t1 WHERE title = 'a101';
+class id title
+SELECT * FROM t_part WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t_part WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t_part WHERE id = 20;
+class id title
+20 20 a20
+SELECT * FROM t_part WHERE title = 'a20';
+class id title
+20 20 a20
+SELECT * FROM t_part WHERE id = 30;
+class id title
+30 30 a30
+SELECT * FROM t_part WHERE title = 'a30';
+class id title
+30 30 a30
+SELECT * FROM t_part WHERE id = 101;
+class id title
+SELECT * FROM t_part WHERE title = 'a101';
+class id title
+connection master;
+DROP PROCEDURE populate_t1;
+DROP TABLE t1;
+DROP TABLE t_part;
+include/rpl_end.inc
diff --git a/mysql-test/suite/innodb/r/innodb_bulk_create_index_small.result b/mysql-test/suite/innodb/r/innodb_bulk_create_index_small.result
new file mode 100644
index 00000000000..b48207d4497
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_bulk_create_index_small.result
@@ -0,0 +1,139 @@
+CREATE PROCEDURE populate_t1()
+BEGIN
+DECLARE i int DEFAULT 1;
+START TRANSACTION;
+WHILE (i <= 1000) DO
+INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+SET i = i + 1;
+END WHILE;
+COMMIT;
+END|
+SELECT @@innodb_fill_factor;
+@@innodb_fill_factor
+100
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1000
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+CREATE INDEX idx_title ON t1(title);
+/* Check table. */
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_id idx_id 5 const 1
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 500;
+class id title
+500 500 a500
+SELECT * FROM t1 WHERE title = 'a500';
+class id title
+500 500 a500
+SELECT * FROM t1 WHERE id = 1000;
+class id title
+1000 1000 a1000
+SELECT * FROM t1 WHERE title = 'a1000';
+class id title
+1000 1000 a1000
+SELECT * FROM t1 WHERE id = 1010;
+class id title
+SELECT * FROM t1 WHERE title = 'a1010';
+class id title
+DROP TABLE t1;
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+INSERT INTO t1 VALUES
+(1, REPEAT('a',10000), 'a'),
+(2, REPEAT('b',20000), 'b'),
+(3, REPEAT('c',40000), 'c'),
+(4, REPEAT('d',60000), 'd');
+ALTER TABLE t1 DROP COLUMN c;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+DROP TABLE t1;
+SET GLOBAL innodb_file_per_table=default;
+SET GLOBAL innodb_file_per_table=1;
+CREATE TABLE t1(
+class INT,
+id INT,
+title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1000
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+CREATE INDEX idx_title ON t1(title);
+/* Check table. */
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_id idx_id 5 const 1
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx_title idx_title 103 const 1 Using index condition
+SELECT * FROM t1 WHERE id = 10;
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE title = 'a10';
+class id title
+10 10 a10
+SELECT * FROM t1 WHERE id = 500;
+class id title
+500 500 a500
+SELECT * FROM t1 WHERE title = 'a500';
+class id title
+500 500 a500
+SELECT * FROM t1 WHERE id = 1000;
+class id title
+1000 1000 a1000
+SELECT * FROM t1 WHERE title = 'a1000';
+class id title
+1000 1000 a1000
+SELECT * FROM t1 WHERE id = 1010;
+class id title
+SELECT * FROM t1 WHERE title = 'a1010';
+class id title
+DROP TABLE t1;
+CREATE TABLE t1(
+a INT PRIMARY KEY,
+b TEXT,
+c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+INSERT INTO t1 VALUES
+(1, REPEAT('a',10000), 'a'),
+(2, REPEAT('b',20000), 'b'),
+(3, REPEAT('c',40000), 'c'),
+(4, REPEAT('d',60000), 'd');
+ALTER TABLE t1 DROP COLUMN c;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+CHAR_LENGTH(b)
+DROP TABLE t1;
+SET GLOBAL innodb_file_per_table=default;
+DROP PROCEDURE populate_t1;
diff --git a/mysql-test/suite/innodb/r/innodb_corrupt_bit.result b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result
index d614ebff751..2000db03efa 100644
--- a/mysql-test/suite/innodb/r/innodb_corrupt_bit.result
+++ b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result
@@ -16,18 +16,15 @@ INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+1,z+1 FROM corrupt_bit_test_ā;
select count(*) from corrupt_bit_test_ā;
count(*)
2
-SET SESSION debug="+d,dict_set_index_corrupted";
-Warnings:
-Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
+SET @save_dbug = @@SESSION.debug_dbug;
+SET debug_dbug = '+d,dict_set_index_corrupted';
check table corrupt_bit_test_ā;
Table Op Msg_type Msg_text
test.corrupt_bit_test_ā check Warning InnoDB: Index idx is marked as corrupted
test.corrupt_bit_test_ā check Warning InnoDB: Index idxā is marked as corrupted
test.corrupt_bit_test_ā check Warning InnoDB: Index idxē is marked as corrupted
test.corrupt_bit_test_ā check error Corrupt
-SET SESSION debug="-d,dict_set_index_corrupted";
-Warnings:
-Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
+SET debug_dbug = @save_dbug;
CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c);
ERROR HY000: Index idx is corrupted
CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z);
diff --git a/mysql-test/suite/innodb/r/innodb_max_recordsize_32k.result b/mysql-test/suite/innodb/r/innodb_max_recordsize_32k.result
index c2bb0ba0aa8..117b7e4418e 100644
--- a/mysql-test/suite/innodb/r/innodb_max_recordsize_32k.result
+++ b/mysql-test/suite/innodb/r/innodb_max_recordsize_32k.result
@@ -2,14 +2,7 @@ call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the
SELECT @@innodb_page_size;
@@innodb_page_size
32768
-SET GLOBAL innodb_file_per_table=ON;
-SET @@innodb_strict_mode=ON;
-SELECT @@innodb_file_per_table;
-@@innodb_file_per_table
-1
-SELECT @@innodb_strict_mode;
-@@innodb_strict_mode
-1
+SET innodb_strict_mode=ON;
CREATE TABLE tab5(col1 CHAR (255), col2 CHAR (255), col3 CHAR(255),col4 CHAR(255), col5 CHAR(255),
col6 CHAR(255), col7 CHAR(255), col8 CHAR(255), col9 CHAR(255),col10 CHAR(255), col11 CHAR(255),
col12 CHAR(255), col13 CHAR(255),col14 CHAR(255),col15 CHAR(255),col16 CHAR(255), col17 CHAR(255),
@@ -333,11 +326,9 @@ FLUSH TABLE t;
ANALYZE TABLE t;
Table Op Msg_type Msg_text
test.t analyze status OK
-SELECT stat_value FROM mysql.innodb_index_stats where database_name = 'test' and table_name= 't' and stat_name='n_leaf_pages';
-stat_value
-6
-SELECT clustered_index_size from mysql.innodb_table_stats where database_name = 'test' and table_name= 't';
-clustered_index_size
+SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE name = 'test/t';
+clust_index_size
7
DROP TABLE t;
CREATE TABLE t(col BLOB) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
@@ -355,11 +346,9 @@ FLUSH TABLE t;
ANALYZE TABLE t;
Table Op Msg_type Msg_text
test.t analyze status OK
-SELECT stat_value FROM mysql.innodb_index_stats where database_name = 'test' and table_name= 't' and stat_name='n_leaf_pages';
-stat_value
-4
-SELECT clustered_index_size from mysql.innodb_table_stats where database_name = 'test' and table_name= 't';
-clustered_index_size
+SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE name = 'test/t';
+clust_index_size
5
DROP TABLE t;
CREATE TABLE t(col BLOB) ENGINE=InnoDB ROW_FORMAT=COMPACT;
@@ -377,11 +366,8 @@ FLUSH TABLE t;
ANALYZE TABLE t;
Table Op Msg_type Msg_text
test.t analyze status OK
-SELECT stat_value FROM mysql.innodb_index_stats where database_name = 'test' and table_name= 't' and stat_name='n_leaf_pages';
-stat_value
-4
-SELECT clustered_index_size from mysql.innodb_table_stats where database_name = 'test' and table_name= 't';
-clustered_index_size
+SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE name = 'test/t';
+clust_index_size
5
DROP TABLE t;
-# Success
diff --git a/mysql-test/suite/innodb/r/innodb_max_recordsize_64k.result b/mysql-test/suite/innodb/r/innodb_max_recordsize_64k.result
index 31dcae834bf..de957023ff8 100644
--- a/mysql-test/suite/innodb/r/innodb_max_recordsize_64k.result
+++ b/mysql-test/suite/innodb/r/innodb_max_recordsize_64k.result
@@ -2,14 +2,7 @@ call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the
SELECT @@innodb_page_size;
@@innodb_page_size
65536
-SET GLOBAL innodb_file_per_table=ON;
-SET @@innodb_strict_mode=ON;
-SELECT @@innodb_file_per_table;
-@@innodb_file_per_table
-1
-SELECT @@innodb_strict_mode;
-@@innodb_strict_mode
-1
+SET innodb_strict_mode=ON;
CREATE TABLE tab5(col1 CHAR (255), col2 CHAR (255), col3 CHAR(255),col4 CHAR(255), col5 CHAR(255),
col6 CHAR(255), col7 CHAR(255), col8 CHAR(255), col9 CHAR(255),col10 CHAR(255), col11 CHAR(255),
col12 CHAR(255), col13 CHAR(255),col14 CHAR(255),col15 CHAR(255),col16 CHAR(255), col17 CHAR(255),
@@ -536,11 +529,9 @@ FLUSH TABLE t;
ANALYZE TABLE t;
Table Op Msg_type Msg_text
test.t analyze status OK
-SELECT stat_value FROM mysql.innodb_index_stats where database_name = 'test' and table_name= 't' and stat_name='n_leaf_pages';
-stat_value
-4
-SELECT clustered_index_size from mysql.innodb_table_stats where database_name = 'test' and table_name= 't';
-clustered_index_size
+SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE name = 'test/t';
+clust_index_size
5
DROP TABLE t;
CREATE TABLE t(col BLOB) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
@@ -558,11 +549,9 @@ FLUSH TABLE t;
ANALYZE TABLE t;
Table Op Msg_type Msg_text
test.t analyze status OK
-SELECT stat_value FROM mysql.innodb_index_stats where database_name = 'test' and table_name= 't' and stat_name='n_leaf_pages';
-stat_value
-3
-SELECT clustered_index_size from mysql.innodb_table_stats where database_name = 'test' and table_name= 't';
-clustered_index_size
+SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE name = 'test/t';
+clust_index_size
4
DROP TABLE t;
CREATE TABLE t(col BLOB) ENGINE=InnoDB ROW_FORMAT=COMPACT;
@@ -580,11 +569,8 @@ FLUSH TABLE t;
ANALYZE TABLE t;
Table Op Msg_type Msg_text
test.t analyze status OK
-SELECT stat_value FROM mysql.innodb_index_stats where database_name = 'test' and table_name= 't' and stat_name='n_leaf_pages';
-stat_value
-3
-SELECT clustered_index_size from mysql.innodb_table_stats where database_name = 'test' and table_name= 't';
-clustered_index_size
+SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE name = 'test/t';
+clust_index_size
4
DROP TABLE t;
-# Success
diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result
index cdfdbad9e20..3663c18ea44 100644
--- a/mysql-test/suite/innodb/r/innodb_mysql.result
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result
@@ -238,14 +238,14 @@ select 1, max(1) from t1i where 1=99;
1 NULL
explain select count(*), min(7), max(7) from t1m, t1i;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found
+1 SIMPLE t1m system NULL NULL NULL NULL 0 Const row not found
1 SIMPLE t1i ALL NULL NULL NULL NULL 1
select count(*), min(7), max(7) from t1m, t1i;
count(*) min(7) max(7)
0 NULL NULL
explain select count(*), min(7), max(7) from t1m, t2i;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found
+1 SIMPLE t1m system NULL NULL NULL NULL 0 Const row not found
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
select count(*), min(7), max(7) from t1m, t2i;
count(*) min(7) max(7)
@@ -1853,7 +1853,7 @@ explain
select b from t1 where a not in (select max(b) from t1,t2 group by a) group by a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
+2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 0 Const row not found
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1
set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t2;
diff --git a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
index 103937fa408..79f0e73e745 100644
--- a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
+++ b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
@@ -395,6 +395,6 @@ NAME CREATE_FILE CREATE_LINE OS_WAITS
Warnings:
Warning 1012 InnoDB: SELECTing from INFORMATION_SCHEMA.innodb_mutexes but the InnoDB storage engine is not installed
select * from information_schema.innodb_sys_semaphore_waits;
-THREAD_ID OBJECT_NAME FILE LINE WAIT_TIME WAIT_OBJECT WAIT_TYPE HOLDER_THREAD_ID HOLDER_FILE HOLDER_LINE CREATED_FILE CREATED_LINE WRITER_THREAD RESERVATION_MODE READERS WAITERS_FLAG LOCK_WORD LAST_READER_FILE LAST_READER_LINE LAST_WRITER_FILE LAST_WRITER_LINE OS_WAIT_COUNT
+THREAD_ID OBJECT_NAME FILE LINE WAIT_TIME WAIT_OBJECT WAIT_TYPE HOLDER_THREAD_ID HOLDER_FILE HOLDER_LINE CREATED_FILE CREATED_LINE WRITER_THREAD RESERVATION_MODE READERS WAITERS_FLAG LOCK_WORD LAST_WRITER_FILE LAST_WRITER_LINE OS_WAIT_COUNT
Warnings:
Warning 1012 InnoDB: SELECTing from INFORMATION_SCHEMA.innodb_sys_semaphore_waits but the InnoDB storage engine is not installed
diff --git a/mysql-test/suite/innodb/r/instant_alter,4k.rdiff b/mysql-test/suite/innodb/r/instant_alter,4k.rdiff
index 098d9fa3b5d..d274d834faa 100644
--- a/mysql-test/suite/innodb/r/instant_alter,4k.rdiff
+++ b/mysql-test/suite/innodb/r/instant_alter,4k.rdiff
@@ -9,7 +9,7 @@
connection default;
ROLLBACK;
connection analyze;
-@@ -191,7 +191,7 @@
+@@ -250,7 +250,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -18,7 +18,7 @@
connection default;
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
-@@ -202,7 +202,7 @@
+@@ -261,7 +261,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -27,7 +27,7 @@
connection default;
ROLLBACK;
connection analyze;
-@@ -212,7 +212,7 @@
+@@ -271,7 +271,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -36,7 +36,7 @@
connection default;
ALTER TABLE t2 DROP p;
affected rows: 0
-@@ -317,7 +317,7 @@
+@@ -374,7 +374,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
@@ -45,7 +45,7 @@
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
-@@ -340,7 +340,7 @@
+@@ -397,7 +397,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
@@ -54,16 +54,16 @@
connection default;
ROLLBACK;
CHECKSUM TABLE big;
-@@ -353,7 +353,7 @@
+@@ -410,7 +410,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
+8
connection default;
- DROP TABLE big;
- CREATE TABLE t1
-@@ -532,7 +532,7 @@
+ InnoDB 0 transactions not purged
+ DROP TABLE t1,t2,t3,big;
+@@ -600,7 +600,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -72,7 +72,7 @@
connection default;
ROLLBACK;
connection analyze;
-@@ -542,7 +542,7 @@
+@@ -610,7 +610,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -81,7 +81,7 @@
connection default;
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
-@@ -553,7 +553,7 @@
+@@ -621,7 +621,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -90,7 +90,7 @@
connection default;
ROLLBACK;
connection analyze;
-@@ -563,7 +563,7 @@
+@@ -631,7 +631,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -99,7 +99,7 @@
connection default;
ALTER TABLE t2 DROP p;
affected rows: 0
-@@ -668,7 +668,7 @@
+@@ -734,7 +734,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
@@ -108,7 +108,7 @@
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
-@@ -691,7 +691,7 @@
+@@ -757,7 +757,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
@@ -117,16 +117,16 @@
connection default;
ROLLBACK;
CHECKSUM TABLE big;
-@@ -704,7 +704,7 @@
+@@ -770,7 +770,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
+7
connection default;
- DROP TABLE big;
- CREATE TABLE t1
-@@ -883,7 +883,7 @@
+ InnoDB 0 transactions not purged
+ DROP TABLE t1,t2,t3,big;
+@@ -960,7 +960,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -135,7 +135,7 @@
connection default;
ROLLBACK;
connection analyze;
-@@ -893,7 +893,7 @@
+@@ -970,7 +970,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -144,7 +144,7 @@
connection default;
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
-@@ -904,7 +904,7 @@
+@@ -981,7 +981,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -153,7 +153,7 @@
connection default;
ROLLBACK;
connection analyze;
-@@ -914,7 +914,7 @@
+@@ -991,7 +991,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -162,7 +162,7 @@
connection default;
ALTER TABLE t2 DROP p;
affected rows: 0
-@@ -1019,7 +1019,7 @@
+@@ -1094,7 +1094,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
@@ -171,7 +171,7 @@
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
-@@ -1042,7 +1042,7 @@
+@@ -1117,7 +1117,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
@@ -180,12 +180,12 @@
connection default;
ROLLBACK;
CHECKSUM TABLE big;
-@@ -1055,7 +1055,7 @@
+@@ -1130,7 +1130,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
+7
connection default;
- DROP TABLE big;
- disconnect analyze;
+ InnoDB 0 transactions not purged
+ DROP TABLE t1,t2,t3,big;
diff --git a/mysql-test/suite/innodb/r/instant_alter,8k.rdiff b/mysql-test/suite/innodb/r/instant_alter,8k.rdiff
index a313765df3a..b96262866e5 100644
--- a/mysql-test/suite/innodb/r/instant_alter,8k.rdiff
+++ b/mysql-test/suite/innodb/r/instant_alter,8k.rdiff
@@ -1,6 +1,6 @@
--- instant_alter.result
+++ instant_alter,8k.result
-@@ -181,7 +181,7 @@
+@@ -240,7 +240,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -9,7 +9,7 @@
connection default;
ROLLBACK;
connection analyze;
-@@ -191,7 +191,7 @@
+@@ -250,7 +250,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -18,7 +18,7 @@
connection default;
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
-@@ -202,7 +202,7 @@
+@@ -261,7 +261,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -27,7 +27,7 @@
connection default;
ROLLBACK;
connection analyze;
-@@ -212,7 +212,7 @@
+@@ -271,7 +271,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -36,7 +36,7 @@
connection default;
ALTER TABLE t2 DROP p;
affected rows: 0
-@@ -317,7 +317,7 @@
+@@ -374,7 +374,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
@@ -45,7 +45,7 @@
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
-@@ -340,7 +340,7 @@
+@@ -397,7 +397,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
@@ -54,16 +54,16 @@
connection default;
ROLLBACK;
CHECKSUM TABLE big;
-@@ -353,7 +353,7 @@
+@@ -410,7 +410,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
+5
connection default;
- DROP TABLE big;
- CREATE TABLE t1
-@@ -532,7 +532,7 @@
+ InnoDB 0 transactions not purged
+ DROP TABLE t1,t2,t3,big;
+@@ -600,7 +600,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -72,7 +72,7 @@
connection default;
ROLLBACK;
connection analyze;
-@@ -542,7 +542,7 @@
+@@ -610,7 +610,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -81,7 +81,7 @@
connection default;
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
-@@ -553,7 +553,7 @@
+@@ -621,7 +621,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -90,7 +90,7 @@
connection default;
ROLLBACK;
connection analyze;
-@@ -563,7 +563,7 @@
+@@ -631,7 +631,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -99,7 +99,7 @@
connection default;
ALTER TABLE t2 DROP p;
affected rows: 0
-@@ -668,7 +668,7 @@
+@@ -734,7 +734,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
@@ -108,7 +108,7 @@
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
-@@ -691,7 +691,7 @@
+@@ -757,7 +757,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
@@ -117,16 +117,16 @@
connection default;
ROLLBACK;
CHECKSUM TABLE big;
-@@ -704,7 +704,7 @@
+@@ -770,7 +770,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
+5
connection default;
- DROP TABLE big;
- CREATE TABLE t1
-@@ -883,7 +883,7 @@
+ InnoDB 0 transactions not purged
+ DROP TABLE t1,t2,t3,big;
+@@ -960,7 +960,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -135,7 +135,7 @@
connection default;
ROLLBACK;
connection analyze;
-@@ -893,7 +893,7 @@
+@@ -970,7 +970,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -144,7 +144,7 @@
connection default;
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
-@@ -904,7 +904,7 @@
+@@ -981,7 +981,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -153,7 +153,7 @@
connection default;
ROLLBACK;
connection analyze;
-@@ -914,7 +914,7 @@
+@@ -991,7 +991,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
@@ -162,7 +162,7 @@
connection default;
ALTER TABLE t2 DROP p;
affected rows: 0
-@@ -1019,7 +1019,7 @@
+@@ -1094,7 +1094,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
@@ -171,7 +171,7 @@
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
-@@ -1042,7 +1042,7 @@
+@@ -1117,7 +1117,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
@@ -180,12 +180,12 @@
connection default;
ROLLBACK;
CHECKSUM TABLE big;
-@@ -1055,7 +1055,7 @@
+@@ -1130,7 +1130,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
+5
connection default;
- DROP TABLE big;
- disconnect analyze;
+ InnoDB 0 transactions not purged
+ DROP TABLE t1,t2,t3,big;
diff --git a/mysql-test/suite/innodb/r/instant_alter.result b/mysql-test/suite/innodb/r/instant_alter.result
index 1bf2d1025a0..1580ba29717 100644
--- a/mysql-test/suite/innodb/r/instant_alter.result
+++ b/mysql-test/suite/innodb/r/instant_alter.result
Binary files differ
diff --git a/mysql-test/suite/innodb/r/instant_alter_crash.result b/mysql-test/suite/innodb/r/instant_alter_crash.result
index 1c967e538aa..2daaf10fa67 100644
--- a/mysql-test/suite/innodb/r/instant_alter_crash.result
+++ b/mysql-test/suite/innodb/r/instant_alter_crash.result
@@ -1,3 +1,4 @@
+FLUSH TABLES;
#
# MDEV-11369: Instant ADD COLUMN for InnoDB
#
diff --git a/mysql-test/suite/innodb/r/instant_alter_debug.result b/mysql-test/suite/innodb/r/instant_alter_debug.result
index b1407aad1f3..3aec7553ff0 100644
--- a/mysql-test/suite/innodb/r/instant_alter_debug.result
+++ b/mysql-test/suite/innodb/r/instant_alter_debug.result
@@ -35,7 +35,7 @@ ALTER TABLE t4 ADD COLUMN b INT;
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
LEFT JOIN t4 ON (NUMERIC_SCALE = pk);
COUNT(*)
-1734
+1748
SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL enter WAIT_FOR delete';
ALTER TABLE t4 ADD COLUMN c INT;
connect dml,localhost,root,,;
diff --git a/mysql-test/suite/innodb/r/instant_alter_rollback.result b/mysql-test/suite/innodb/r/instant_alter_rollback.result
index 786bfa81336..ce49cea2343 100644
--- a/mysql-test/suite/innodb/r/instant_alter_rollback.result
+++ b/mysql-test/suite/innodb/r/instant_alter_rollback.result
@@ -1,3 +1,4 @@
+FLUSH TABLES;
#
# MDEV-11369: Instant ADD COLUMN for InnoDB
#
diff --git a/mysql-test/suite/innodb/r/lock_deleted.result b/mysql-test/suite/innodb/r/lock_deleted.result
new file mode 100644
index 00000000000..0fcb8bd5aa8
--- /dev/null
+++ b/mysql-test/suite/innodb/r/lock_deleted.result
@@ -0,0 +1,57 @@
+connect stop_purge, localhost, root,,;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connect delete, localhost, root,,;
+connection default;
+CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(1,1);
+DELETE FROM t1;
+SET DEBUG_SYNC='row_ins_sec_index_unique SIGNAL inserted WAIT_FOR locked';
+BEGIN;
+INSERT INTO t1 VALUES(1,1);
+connection delete;
+SET DEBUG_SYNC='now WAIT_FOR inserted';
+SET DEBUG_SYNC='innodb_row_search_for_mysql_exit SIGNAL locked';
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+DELETE FROM t1 WHERE b=1;
+connection default;
+connection delete;
+COMMIT;
+connection default;
+SET DEBUG_SYNC='RESET';
+ROLLBACK;
+SET DEBUG_SYNC='row_ins_sec_index_unique SIGNAL inserted WAIT_FOR locked';
+BEGIN;
+INSERT INTO t1 VALUES(1,1);
+connection delete;
+SET DEBUG_SYNC='now WAIT_FOR inserted';
+SET DEBUG_SYNC='innodb_row_search_for_mysql_exit SIGNAL locked';
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+BEGIN;
+DELETE FROM t1 WHERE b=1;
+connection default;
+connection delete;
+COMMIT;
+connection default;
+SET DEBUG_SYNC='RESET';
+ROLLBACK;
+SET DEBUG_SYNC='row_ins_sec_index_unique SIGNAL inserted WAIT_FOR locked';
+BEGIN;
+SET innodb_lock_wait_timeout=1;
+INSERT INTO t1 VALUES(1,1);
+connection delete;
+SET DEBUG_SYNC='now WAIT_FOR inserted';
+SET DEBUG_SYNC='innodb_row_search_for_mysql_exit SIGNAL locked';
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+DELETE FROM t1 WHERE b=1;
+connection default;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+COMMIT;
+SET DEBUG_SYNC='RESET';
+connection delete;
+COMMIT;
+disconnect delete;
+disconnect stop_purge;
+connection default;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/log_corruption.result b/mysql-test/suite/innodb/r/log_corruption.result
index 35b7b00ead6..6bc10c970fc 100644
--- a/mysql-test/suite/innodb/r/log_corruption.result
+++ b/mysql-test/suite/innodb/r/log_corruption.result
@@ -17,6 +17,13 @@ WHERE engine = 'innodb'
AND support IN ('YES', 'DEFAULT', 'ENABLED');
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
FOUND 1 /InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and it appears corrupted/ in mysqld.1.err
+# empty redo log from before MariaDB 10.2.2
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES
+WHERE engine = 'innodb'
+AND support IN ('YES', 'DEFAULT', 'ENABLED');
+COUNT(*)
+1
+FOUND 1 /InnoDB: Upgrading redo log:/ in mysqld.1.err
# redo log from "after" MariaDB 10.2.2, but with invalid header checksum
SELECT * FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'
@@ -40,14 +47,15 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'
AND support IN ('YES', 'DEFAULT', 'ENABLED');
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
-FOUND 1 /InnoDB: Upgrade after a crash is not supported\. The redo log was created with malicious intentions, or perhaps, and it appears corrupted\./ in mysqld.1.err
+FOUND 1 /InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 3362026715 found: 144444122/ in mysqld.1.err
+FOUND 1 /InnoDB: Missing MLOG_CHECKPOINT between the checkpoint 1213964 and the end 1213952\./ in mysqld.1.err
# same, but with current-version header
SELECT * FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'
AND support IN ('YES', 'DEFAULT', 'ENABLED');
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
-FOUND 1 /InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 3362026715 found: 144444122/ in mysqld.1.err
-FOUND 1 /InnoDB: Missing MLOG_CHECKPOINT between the checkpoint 1213964 and the end 1213952\./ in mysqld.1.err
+FOUND 2 /InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 3362026715 found: 144444122/ in mysqld.1.err
+FOUND 2 /InnoDB: Missing MLOG_CHECKPOINT between the checkpoint 1213964 and the end 1213952\./ in mysqld.1.err
# --innodb-force-recovery=6 (skip the entire redo log)
SELECT * FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'
@@ -92,12 +100,32 @@ AND support IN ('YES', 'DEFAULT', 'ENABLED');
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
FOUND 1 /InnoDB: MLOG_FILE_NAME incorrect:bigot/ in mysqld.1.err
FOUND 1 /len 22; hex 38000000000012860cb7809781e800066269676f7400; asc 8 bigot ;/ in mysqld.1.err
-# missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT
+# 10.2 missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT
+SELECT * FROM INFORMATION_SCHEMA.ENGINES
+WHERE engine = 'innodb'
+AND support IN ('YES', 'DEFAULT', 'ENABLED');
+ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
+FOUND 1 /InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT for tablespace 42/ in mysqld.1.err
+# 10.3 missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT
SELECT * FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'
AND support IN ('YES', 'DEFAULT', 'ENABLED');
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
-NOT FOUND /InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT for tablespace 42$/ in mysqld.1.err
+FOUND 2 /InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT for tablespace 42/ in mysqld.1.err
+# Empty 10.3 redo log
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES
+WHERE engine = 'innodb'
+AND support IN ('YES', 'DEFAULT', 'ENABLED');
+COUNT(*)
+1
+FOUND 1 /InnoDB: .* started; log sequence number 121397[09]/ in mysqld.1.err
+# Empty 10.2 redo log
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES
+WHERE engine = 'innodb'
+AND support IN ('YES', 'DEFAULT', 'ENABLED');
+COUNT(*)
+1
+FOUND 2 /InnoDB: Upgrading redo log:/ in mysqld.1.err
# Minimal MariaDB 10.1.21 encrypted redo log
SELECT * FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'
diff --git a/mysql-test/suite/innodb/r/mvcc.result b/mysql-test/suite/innodb/r/mvcc.result
new file mode 100644
index 00000000000..fc2d403fa63
--- /dev/null
+++ b/mysql-test/suite/innodb/r/mvcc.result
@@ -0,0 +1,32 @@
+SET @save_per_table= @@GLOBAL.innodb_file_per_table;
+SET GLOBAL innodb_file_per_table= 1;
+#
+# MDEV-15249 Crash in MVCC read after IMPORT TABLESPACE
+#
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(0);
+FLUSH TABLES t1 WITH READ LOCK;
+UNLOCK TABLES;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connect con1,localhost,root,,;
+ALTER TABLE t1 FORCE, ALGORITHM=COPY;
+connection default;
+SELECT * FROM t1;
+ERROR HY000: Table definition has changed, please retry transaction
+COMMIT;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection con1;
+ALTER TABLE t1 DISCARD TABLESPACE;
+ALTER TABLE t1 IMPORT TABLESPACE;
+disconnect con1;
+connection default;
+# FIXME: Block this with ER_TABLE_DEF_CHANGED
+SELECT * FROM t1;
+a
+0
+COMMIT;
+SELECT * FROM t1;
+a
+0
+DROP TABLE t1;
+SET GLOBAL innodb_file_per_table= @save_per_table;
diff --git a/mysql-test/suite/innodb/r/purge_secondary.result b/mysql-test/suite/innodb/r/purge_secondary.result
new file mode 100644
index 00000000000..2312434a2bd
--- /dev/null
+++ b/mysql-test/suite/innodb/r/purge_secondary.result
@@ -0,0 +1,148 @@
+SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
+SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
+CREATE TABLE t1 (
+a SERIAL, b CHAR(255) NOT NULL DEFAULT '', c BOOLEAN DEFAULT false,
+l LINESTRING NOT NULL DEFAULT ST_linefromtext('linestring(448 -689,
+ 453 -684,451 -679,453 -677,458 -681,463 -681,468 -678,470 -676,470 -678,
+ 468 -675,472 -675,472 -675,474 -674,479 -676,477 -675,473 -676,475 1324,
+ 479 1319,484 1322,483 1323,486 1323,491 1328,492 1325,496 1325,498 1325,
+ 501 1330,498 1331,500 1331,504 1330,508 1329,512 1332,513 1337,518 1339,
+ 518 1339,513 1344,513 1344,512 1346,514 1351,515 1353,519 1358,518 1362,
+ 522 1365,525 1360,526 1362,527 1362,528 1367,525 1371,528 1366,532 1369,
+ 536 1374,539 1377,543 1379,539 1381,541 1382,543 1383,546 1388,549 1393,
+ 554 1393,554 1395,554 1392,550 1394,550 1392,546 1394,549 1397,550 1393,
+ 549 1394,554 1390,554 1391,549 1396,551 1396,547 1400,547 1402,551 1407,
+ 554 1412,554 1415,558 1418,463 -681,465 -677,465 -675,470 -670,470 -665,
+ 470 -660,470 -659,473 -656,476 -656,481 -655,482 -652,486 -654,486 -652,
+ 486 -648,491 -646,490 -651,494 -646,493 -644,493 -644,490 -644,491 2356,
+ 495 2359,495 2364,500 2359,503 5359,504 5364,509 5368,504 5367,499 5368,
+ 498 5371,498 5369,500 5370,504 5370,508 5370,511 5370,507 5374,508 5378,
+ 511 5382,507 5387,509 5389,512 5388,515 5393,520 5396,517 5397,517 5402,
+ 515 5404,520 5402,521 5405,525 5405,526 5408,530 7408,535 7413,533 7415,
+ 529 7412,532 7416,4532 7416,4534 7421,4533 7417,4536 7413,4536 7418,
+ 4540 3418,4545 3418,4549 3415,4551 3419,4554 3421,4559 3423,4559 3426,
+ 4557 3424,4561 3428,4558 3428,4563 3431,4565 3435,4569 3439,4569 3439,
+ 4569 3444,4567 3444,4572 3446,4577 3447,4581 3444,4581 3448,4584 3448,
+ 4579 3447,4580 3450,4583 3449,4583 3453,4587 3455,4588 3458,4593 3463,
+ 4598 3465,4601 3468,4598 3464,4598 3460,4593 5460,4595 5461,4600 5464,
+ 4600 5465,4601 5466,4606 5466,4608 5466,4605 5464,4608 5467,4607 5468,
+ 4609 5465,4614 5461,4618 5463,4621 5467,4623 5470,4622 5470,4622 5470,
+ 4625 6470,4627 6471,4627 6472,4627 6473,6627 6474,6625 6474,6628 6477,
+ 6633 6481,6633 6480,6637 6475,7637 6479,7638 6482,7643 6487,7644 6492,
+ 7647 6492,7648 6495,7646 6498,7650 6499,7646 6494,7644 6499,7644 6497,
+ 7644 6499,7647 6502,7649 6504,7650 6501,7647 6503,7649 6504,7650 6508,
+ 7651 6503,7652 6508,7655 6508,7650 6511,7655 6515,7658 6513,7663 6513,
+ 7665 6514,7669 6512,7667 6510,7664 6510,472 -675,477 -670,479 -666,
+ 482 -663,484 -668,484 -666,485 -664,481 -664,479 -659,482 -659,484 -658,
+ 483 -659,488 2341,493 2339,489 2338,491 2342,491 2346,494 2346,490 2348,
+ 493 2348,498 2349,498 2350,499 2349,502 2350,503 2348,506 2348,506 2348,
+ 507 2353,507 2355,504 2359,504 2364,504 2361,499 2365,502 2360,502 2358,
+ 503 2357,504 2353,504 2357,500 2356,497 2355,498 2355,500 2359,502 2361,
+ 505 2364,508 2364,506 2368,506 2370,504 2373,499 2373,496 2372,493 2377,
+ 497 2380,495 2383,496 7383,493 7386,497 7391,494 7387,495 7389,498 7392,
+ 498 7392,495 7395,493 7398,498 7401,498 7403,503 7400,498 8400,501 8401,
+ 503 8401,503 8401,501 10401,496 10396,491 10401,492 10399,493 10403,
+ 496 10403,491 10403,493 10407,489 10410,493 10407,489 10403,498 7403,
+ 497 7399,496 7403,500 7405,500 7407,503 7411,508 7415,511 7415,511 7420,
+ 515 7420,520 7423,523 7423,520 7427,523 7427,523 7427,522 7432,525 4432,
+ 527 4434,530 4437,534 4441,529 4446,529 4441,534 4436,537 4436,535 4437,
+ 532 4437,534 4432,535 4429,538 4430,542 4427,542 4431,538 4431,541 4431,
+ 541 4433,543 4433,545 4432,549 4428,552 4426,556 4427,557 4423,560 4427,
+ 561 4428,558 4430,559 4434,559 4432,561 4434,561 4437,563 4435,559 4430,
+ 561 4435,4561 4437,4566 4441,4568 4446,4568 4450,4569 4455,4565 4458,
+ 4561 4463,4561 9463,4564 9463,4565 9461,9565 9463,9560 9467,9560 9466,
+ 9555 9469,9555 9471,9559 9469,9557 9473,9553 9478,9555 9480,9557 9481,
+ 9557 9481,9557 9483,9562 9487,9558 9487,9558 9490,9561 9493,9562 9493,
+ 9557 9493,9560 9496,9555 9501,9553 9503,9553 9506,9557 9510,9558 9511,
+ 9561 9514,9563 9512,9568 9514,9567 9514,9567 13514,9570 13517,9566 13521,
+ 9571 13521,9571 13526,9573 13521,9571 13521,9576 10521,9580 10526,9582 10525,
+ 9584 10528,9584 10531,9584 10533,9589 10533,9588 10537,9588 10541,9589 10542,
+ 9593 10544,9595 10540,9597 10541,9600 10545,9601 15545,9603 15549,9605 15553,
+ 9601 15558,9601 15553,9605 15551,9605 15550,9605 15554,9607 15556,9605 15556,
+ 9604 15561,9607 15559,9603 15559,9603 15562,9604 15563,9608 15566,9612 15570,
+ 9617 15565,9622 15568,9627 15566,9628 15564,9629 15564,9633 15569,9636 15569,
+ 9634 15571,9634 15572,9636 15574,9634 15570,9629 15570,9631 15567,9629 15570,
+ 9626 15574,9626 15575,498 7401,502 7401,506 7397,506 7395,502 7398,497 7401,
+ 502 7402,505 7397,508 7400,504 7404,3504 7409,3505 7405,3508 7410,3511 7413,
+ 3511 7416,3511 7419,3511 7419,3513 7421,3517 7424,3519 7426,3520 11426,
+ 3523 11421,3527 11418,3530 11415,3530 11416,3533 11418,7533 11415,7531 11415,
+ 7531 11417,7536 11420,7541 11424,7543 11425,7543 11427,7543 11429,7540 11429,
+ 7542 11425,7541 11420,7542 11421,7542 11422,7540 11424,7540 11423,7543 11422,
+ 7546 11426,7550 11431,7553 11436,7555 16436,7553 16438,7558 16438,7559 16438,
+ 7560 16439,7565 16437,7560 16435,7563 16435,7566 16440,7566 16444,7564 16447,
+ 7559 16443,7561 16443,7566 16448,7570 16451,7574 16456,7578 16459,
+ 12578 16459,12578 20459,12577 20456,12581 20454,12585 20456,12585 20456,
+ 12585 20456,12583 20456,12579 20459,12580 20461,12580 20462,12580 20460,
+ 12585 20465,12586 20467,12590 20470,12590 20470,12589 20471,12584 20471,
+ 12589 20471,9589 20472,9594 20472,9595 20472,9596 20477,9598 20482,
+ 9603 20480,9608 20484,9613 20484,9610 20486,9608 20488,9608 20489,9610 20489,
+ 9614 20486,9619 20481,9620 20481,9618 21481,9621 21483,9626 21483,9628 21485,
+ 9623 21487,9622 21490,9626 21493,9621 21495,9626 21498,9622 21499,9624 21504,
+ 9625 21499,9629 21501,9633 21498,9637 21495,9639 21498,9644 21501,9557 9481,
+ 9560 9485,9561 9490,9563 9488,9560 9486,9558 9488,9561 9492,9563 9495,
+ 9567 9492,9567 9488,9564 9490,9559 9495,9559 9498,9557 9502,9562 9506,
+ 9564 9509,9569 9512,9569 9516,9569 9518,9569 9515,9571 9513,9571 9512,
+ 9573 9513,9578 9516,9581 9516,9585 11516,9585 11521,9590 10521,9586 10524,
+ 9589 10529,9589 10527,9589 10527,9594 10532,9594 10534,9598 10536,9598 10540,
+ 9600 10542,9604 10538,9607 10538,9609 10543,9613 10538,9613 10533,9613 10537,
+ 9610 10537,9614 10542,9609 10542,9610 10543,9610 10548,9611 10553,9616 7553,
+ 9620 7553,9621 7557,9618 7559,9618 7554,9622 7557,9622 7561,9622 7556,
+ 9622 7560,9619 7560,9620 7565,9622 7563,9627 7566,9630 7570,9630 7571,
+ 9632 7573,9637 7576,9639 7578,9640 7576,9640 7579,9640 7575,9642 7570,
+ 9646 7570,9651 7574,9653 7577,9652 7572,9653 7576,9653 7576,9651 7581,
+ 9656 7585,9660 7586,9659 7591,9657 7594,9661 7598,9664 7602,9668 12602,
+ 9673 12604,9676 12606,9679 12602,9682 12605,9677 12610,9674 12606,9674 12601,
+ 9674 12603,9672 9603,9668 9605,9671 9606,9668 9611,9668 9606,9671 9611,
+ 9675 9615,9677 9620,9678 9622,9679 9624,9684 9626,9685 9627,9685 9622,
+ 9685 9626,9689 9628,9694 9633,9699 9637,9699 9637,9704 9636,9708 9637,
+ 9709 9638,9707 9639,9705 9642,9707 9647,9710 9649,9711 9653,9716 9649,
+ 9716 9648,9720 9650,9721 9648,9723 9648,9726 4648,12726 4653,12731 4655,
+ 12734 4660,12730 4661,12733 4664,12733 4665,12735 4670,12737 4674,12741 4674,
+ 12738 4675,12740 4675,12737 4675,12742 4678,12743 4681,12746 4677)'),
+INDEX(b,c), SPATIAL INDEX(l)
+) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+INSERT INTO t1 () VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),();
+SELECT LENGTH(l) FROM t1;
+LENGTH(l)
+11197
+11197
+11197
+11197
+11197
+11197
+11197
+11197
+11197
+11197
+11197
+11197
+11197
+11197
+11197
+11197
+11197
+INSERT INTO t1 (a) SELECT NULL FROM t1;
+INSERT INTO t1 (a) SELECT NULL FROM t1;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+UPDATE t1 SET c=true, l=ST_linefromtext('linestring(0 0,1 1,2 2)');
+DELETE FROM t1;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+InnoDB 0 transactions not purged
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+SELECT OTHER_INDEX_SIZE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE NAME='test/t1';
+OTHER_INDEX_SIZE
+1
+# Note: The OTHER_INDEX_SIZE does not cover any SPATIAL INDEX.
+# To test that all indexes were emptied, replace DROP TABLE
+# with the following, and examine the root pages in t1.ibd:
+# FLUSH TABLES t1 FOR EXPORT;
+# UNLOCK TABLES;
+DROP TABLE t1;
+SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
diff --git a/mysql-test/suite/innodb/r/read_only_recover_committed.result b/mysql-test/suite/innodb/r/read_only_recover_committed.result
new file mode 100644
index 00000000000..34b33f60f1b
--- /dev/null
+++ b/mysql-test/suite/innodb/r/read_only_recover_committed.result
@@ -0,0 +1,47 @@
+connect con1, localhost, root;
+CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t VALUES(1);
+BEGIN;
+INSERT INTO t VALUES(2);
+DELETE FROM t WHERE a=2;
+connect con2, localhost, root;
+# Normal MariaDB shutdown would roll back the above transaction.
+# We want the transaction to remain open, so we will kill the server
+# after ensuring that any non-transactional files are clean.
+FLUSH TABLES;
+# Create another transaction that will be recovered as COMMITTED.
+BEGIN;
+SET DEBUG_SYNC='after_trx_committed_in_memory SIGNAL committed WAIT_FOR ever';
+COMMIT;
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR committed';
+# Ensure that the above incomplete transactions become durable.
+SET GLOBAL innodb_flush_log_at_trx_commit=1;
+BEGIN;
+INSERT INTO t VALUES(-10000);
+ROLLBACK;
+disconnect con1;
+disconnect con2;
+SELECT * FROM t;
+a
+1
+SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+SELECT * FROM t;
+a
+1
+UPDATE t SET a=3 WHERE a=1;
+# Starting with MariaDB 10.2, innodb_read_only implies READ UNCOMMITTED.
+# In earlier versions, this would return the last committed version
+# (empty table)!
+SELECT * FROM t;
+a
+3
+SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+SELECT * FROM t;
+a
+3
+SELECT * FROM t;
+a
+3
+DROP TABLE t;
+FOUND 1 /Rolled back recovered transaction [^0]/ in mysqld.1.err
diff --git a/mysql-test/suite/innodb/r/read_only_recovery.result b/mysql-test/suite/innodb/r/read_only_recovery.result
index 97ec938fb2a..e639e8abacc 100644
--- a/mysql-test/suite/innodb/r/read_only_recovery.result
+++ b/mysql-test/suite/innodb/r/read_only_recovery.result
@@ -37,3 +37,4 @@ SELECT * FROM t;
a
3
DROP TABLE t;
+FOUND 1 /Rolled back recovered transaction [^0]/ in mysqld.1.err
diff --git a/mysql-test/suite/innodb/r/recovery_shutdown.result b/mysql-test/suite/innodb/r/recovery_shutdown.result
new file mode 100644
index 00000000000..d26163a0c4a
--- /dev/null
+++ b/mysql-test/suite/innodb/r/recovery_shutdown.result
@@ -0,0 +1,66 @@
+FLUSH TABLES;
+#
+# MDEV-13797 InnoDB may hang if shutdown is initiated soon after startup
+# while rolling back recovered incomplete transactions
+#
+CREATE TABLE t (a INT) ENGINE=InnoDB;
+BEGIN;
+COMMIT;
+connect con$c,localhost,root,,;
+CREATE TABLE t8 (a SERIAL, b INT UNIQUE, c INT UNIQUE) ENGINE=InnoDB;
+BEGIN;
+INSERT INTO t8 (a) SELECT NULL FROM t;
+UPDATE t8 SET a=a+100, b=a;
+DELETE FROM t8;
+connect con$c,localhost,root,,;
+CREATE TABLE t7 (a SERIAL, b INT UNIQUE, c INT UNIQUE) ENGINE=InnoDB;
+BEGIN;
+INSERT INTO t7 (a) SELECT NULL FROM t;
+UPDATE t7 SET a=a+100, b=a;
+DELETE FROM t7;
+connect con$c,localhost,root,,;
+CREATE TABLE t6 (a SERIAL, b INT UNIQUE, c INT UNIQUE) ENGINE=InnoDB;
+BEGIN;
+INSERT INTO t6 (a) SELECT NULL FROM t;
+UPDATE t6 SET a=a+100, b=a;
+DELETE FROM t6;
+connect con$c,localhost,root,,;
+CREATE TABLE t5 (a SERIAL, b INT UNIQUE, c INT UNIQUE) ENGINE=InnoDB;
+BEGIN;
+INSERT INTO t5 (a) SELECT NULL FROM t;
+UPDATE t5 SET a=a+100, b=a;
+DELETE FROM t5;
+connect con$c,localhost,root,,;
+CREATE TABLE t4 (a SERIAL, b INT UNIQUE, c INT UNIQUE) ENGINE=InnoDB;
+BEGIN;
+INSERT INTO t4 (a) SELECT NULL FROM t;
+UPDATE t4 SET a=a+100, b=a;
+DELETE FROM t4;
+connect con$c,localhost,root,,;
+CREATE TABLE t3 (a SERIAL, b INT UNIQUE, c INT UNIQUE) ENGINE=InnoDB;
+BEGIN;
+INSERT INTO t3 (a) SELECT NULL FROM t;
+UPDATE t3 SET a=a+100, b=a;
+DELETE FROM t3;
+connect con$c,localhost,root,,;
+CREATE TABLE t2 (a SERIAL, b INT UNIQUE, c INT UNIQUE) ENGINE=InnoDB;
+BEGIN;
+INSERT INTO t2 (a) SELECT NULL FROM t;
+UPDATE t2 SET a=a+100, b=a;
+DELETE FROM t2;
+connect con$c,localhost,root,,;
+CREATE TABLE t1 (a SERIAL, b INT UNIQUE, c INT UNIQUE) ENGINE=InnoDB;
+BEGIN;
+INSERT INTO t1 (a) SELECT NULL FROM t;
+UPDATE t1 SET a=a+100, b=a;
+DELETE FROM t1;
+INSERT INTO t1(a) SELECT NULL FROM t;
+INSERT INTO t1(a) SELECT NULL FROM t1;
+INSERT INTO t1(a) SELECT NULL FROM t1;
+INSERT INTO t1(a) SELECT NULL FROM t1;
+INSERT INTO t1(a) SELECT NULL FROM t1;
+connection default;
+SET GLOBAL innodb_flush_log_at_trx_commit=1;
+CREATE TABLE u(a SERIAL) ENGINE=INNODB;
+FLUSH TABLES;
+DROP TABLE t,u;
diff --git a/mysql-test/suite/innodb/r/rename_table_debug.result b/mysql-test/suite/innodb/r/rename_table_debug.result
new file mode 100644
index 00000000000..976b609bdd5
--- /dev/null
+++ b/mysql-test/suite/innodb/r/rename_table_debug.result
@@ -0,0 +1,12 @@
+CREATE TABLE t1 (a SERIAL, b INT, c INT, d INT) ENGINE=InnoDB;
+INSERT INTO t1 () VALUES ();
+connect con1,localhost,root,,test;
+SET DEBUG_SYNC='before_rename_table_commit SIGNAL renamed WAIT_FOR ever';
+RENAME TABLE t1 TO t2;
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR renamed';
+disconnect con1;
+SELECT * FROM t1;
+a b c d
+1 NULL NULL NULL
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/restart.result b/mysql-test/suite/innodb/r/restart.result
new file mode 100644
index 00000000000..c70adac3a55
--- /dev/null
+++ b/mysql-test/suite/innodb/r/restart.result
@@ -0,0 +1,29 @@
+#
+# MDEV-15333 MariaDB (still) slow start
+#
+# FIXME: Unlike MySQL, maybe MariaDB should not read the .ibd files
+# of tables with .isl file or DATA DIRECTORY attribute.
+call mtr.add_suppression("\\[ERROR\\] InnoDB: Invalid flags 0x7a207879 in .*td\\.ibd");
+# FIXME: This is much more noisy than MariaDB 10.1!
+call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot read first page in datafile: .*td\\.ibd, Space ID:2048948345, Flags: 2048948345");
+call mtr.add_suppression("\\[ERROR\\] InnoDB: Operating system error number .* in a file operation\\.");
+call mtr.add_suppression("\\[ERROR\\] InnoDB: The error means the system cannot find the path specified\\.");
+call mtr.add_suppression("\\[ERROR\\] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them\\.");
+call mtr.add_suppression("\\[Warning\\] InnoDB: Ignoring tablespace for `test`\\.`td` because it could not be opened\\.");
+CREATE TABLE tr(a INT)ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+CREATE TABLE tc(a INT)ENGINE=InnoDB ROW_FORMAT=COMPACT
+PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=9;
+CREATE TABLE td(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC
+STATS_PERSISTENT=0 DATA DIRECTORY='MYSQL_TMP_DIR';
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES
+WHERE engine = 'innodb'
+AND support IN ('YES', 'DEFAULT', 'ENABLED');
+COUNT(*)
+1
+SELECT * FROM tr;
+a
+SELECT * FROM tc;
+a
+SELECT * FROM td;
+a
+DROP TABLE tr,tc,td;
diff --git a/mysql-test/suite/innodb/r/row_format_redundant.result b/mysql-test/suite/innodb/r/row_format_redundant.result
index a2d5bbef8df..6deecd10ada 100644
--- a/mysql-test/suite/innodb/r/row_format_redundant.result
+++ b/mysql-test/suite/innodb/r/row_format_redundant.result
@@ -72,7 +72,7 @@ DROP TABLE t1;
Warnings:
Warning 1932 Table 'test.t1' doesn't exist in engine
DROP TABLE t2,t3;
-FOUND 49 /\[ERROR\] InnoDB: Table `test`\.`t1` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=255\b/ in mysqld.1.err
+FOUND 49 /\[ERROR\] InnoDB: Table `test`\.`t1` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=511\b/ in mysqld.1.err
ib_buffer_pool
ib_logfile0
ib_logfile1
diff --git a/mysql-test/suite/innodb/r/table_flags.result b/mysql-test/suite/innodb/r/table_flags.result
index 0d636d84529..c82cd6ceccb 100644
--- a/mysql-test/suite/innodb/r/table_flags.result
+++ b/mysql-test/suite/innodb/r/table_flags.result
@@ -116,8 +116,16 @@ SHOW CREATE TABLE tr;
ERROR 42S02: Table 'test.tr' doesn't exist in engine
SHOW CREATE TABLE tc;
ERROR 42S02: Table 'test.tc' doesn't exist in engine
+SELECT * FROM tc;
+ERROR 42S02: Table 'test.tc' doesn't exist in engine
SHOW CREATE TABLE td;
-ERROR 42S02: Table 'test.td' doesn't exist in engine
+Table Create Table
+td CREATE TABLE `td` (
+ `a` int(11) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
+SELECT * FROM td;
+a
SHOW CREATE TABLE tz;
Table Create Table
tz CREATE TABLE `tz` (
@@ -132,8 +140,7 @@ a
42
SHOW CREATE TABLE tp;
ERROR 42S02: Table 'test.tp' doesn't exist in engine
-FOUND 4 /InnoDB: Table `test`.`t[cp]` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=(129|289|3873|1232[13]) SYS_TABLES\.N_COLS=2147483649/ in mysqld.1.err
-FOUND 2 /InnoDB: Refusing to load '\..test.td\.ibd' \(id=3, flags=0x1?[2ae]1\); dictionary contains id=3, flags=0x10[01][2ae]1\b/ in mysqld.1.err
+FOUND 5 /InnoDB: Table `test`.`t[cp]` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=(129|289|3873|1232[13]) SYS_TABLES\.N_COLS=2147483649/ in mysqld.1.err
FOUND 2 /InnoDB: Table `test`\.`tr` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=65 SYS_TABLES\.MIX_LEN=4294967295\b/ in mysqld.1.err
Restoring SYS_TABLES clustered index root page (8)
SHOW CREATE TABLE tr;
diff --git a/mysql-test/suite/innodb/r/truncate_inject.result b/mysql-test/suite/innodb/r/truncate_inject.result
new file mode 100644
index 00000000000..5ec532a0f83
--- /dev/null
+++ b/mysql-test/suite/innodb/r/truncate_inject.result
@@ -0,0 +1,114 @@
+SET @save_dbug = @@SESSION.debug_dbug;
+call mtr.add_suppression("InnoDB: Flagged corruption of .* in table `test`\\.`t` in TRUNCATE TABLE");
+# 1. Error in assigning undo logs for truncate action
+CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100), INDEX ck(c))
+ENGINE = InnoDB;
+insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
+check table t;
+Table Op Msg_type Msg_text
+test.t check status OK
+SET debug_dbug = '+d,ib_err_trunc_assigning_undo_log';
+truncate table t;
+ERROR HY000: Got error 168 "Unknown (generic) error from engine" from storage engine InnoDB
+SET debug_dbug = @save_dbug;
+check table t;
+Table Op Msg_type Msg_text
+test.t check status OK
+select * from t;
+i f c
+1 1.1 a
+2 2.2 b
+3 3.3 c
+# 2. Error while preparing for truncate
+SET debug_dbug = '+d,ib_err_trunc_preparing_for_truncate';
+truncate table t;
+ERROR HY000: Got error 168 "Unknown (generic) error from engine" from storage engine InnoDB
+SET debug_dbug = @save_dbug;
+check table t;
+Table Op Msg_type Msg_text
+test.t check status OK
+select * from t;
+i f c
+1 1.1 a
+2 2.2 b
+3 3.3 c
+# 3. Error while dropping/creating indexes
+SET debug_dbug = '+d,ib_err_trunc_drop_index';
+truncate table t;
+ERROR HY000: Got error 168 "Unknown (generic) error from engine" from storage engine InnoDB
+SET debug_dbug = @save_dbug;
+check table t;
+Table Op Msg_type Msg_text
+test.t check Warning InnoDB: Index PRIMARY is marked as corrupted
+test.t check error Corrupt
+select * from t;
+Got one of the listed errors
+drop table t;
+CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100), INDEX ck(c))
+ENGINE = InnoDB;
+insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
+check table t;
+Table Op Msg_type Msg_text
+test.t check status OK
+SET debug_dbug = '+d,ib_err_trunc_create_index';
+truncate table t;
+ERROR HY000: Got error 168 "Unknown (generic) error from engine" from storage engine InnoDB
+SET debug_dbug = @save_dbug;
+check table t;
+Table Op Msg_type Msg_text
+test.t check Warning InnoDB: Index PRIMARY is marked as corrupted
+test.t check error Corrupt
+select * from t;
+Got one of the listed errors
+drop table t;
+CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100), INDEX ck(c))
+ENGINE = InnoDB;
+insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
+check table t;
+Table Op Msg_type Msg_text
+test.t check status OK
+SET debug_dbug = '+d,ib_err_trunc_temp_recreate_index';
+truncate table t;
+SET debug_dbug = @save_dbug;
+check table t;
+Table Op Msg_type Msg_text
+test.t check status OK
+select * from t;
+i f c
+drop table t;
+# 4. Error while completing truncate of table involving FTS
+CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100),
+FULLTEXT INDEX(c)) ENGINE = InnoDB;
+insert into t values (1, 1.1, 'mysql is now oracle company'),
+(2, 2.2, 'innodb is part of mysql'),
+(3, 3.3, 'innodb is default storage engine of mysql');
+check table t;
+Table Op Msg_type Msg_text
+test.t check status OK
+SET debug_dbug = '+d,ib_err_trunc_temp_recreate_index';
+truncate table t;
+SET debug_dbug = @save_dbug;
+check table t;
+Table Op Msg_type Msg_text
+test.t check status OK
+select * from t;
+i f c
+drop table t;
+# 5. Error while updating sys-tables
+CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100),
+FULLTEXT INDEX(c)) ENGINE = InnoDB;
+insert into t values (1, 1.1, 'mysql is now oracle company'),
+(2, 2.2, 'innodb is part of mysql'),
+(3, 3.3, 'innodb is default storage engine of mysql');
+check table t;
+Table Op Msg_type Msg_text
+test.t check status OK
+SET debug_dbug = '+d,ib_err_trunc_temp_recreate_index';
+truncate table t;
+SET debug_dbug = @save_dbug;
+check table t;
+Table Op Msg_type Msg_text
+test.t check status OK
+select * from t order by i;
+i f c
+drop table t;
diff --git a/mysql-test/suite/innodb/r/truncate_restart.result b/mysql-test/suite/innodb/r/truncate_restart.result
new file mode 100644
index 00000000000..b6d14124371
--- /dev/null
+++ b/mysql-test/suite/innodb/r/truncate_restart.result
@@ -0,0 +1,12 @@
+SET GLOBAL innodb_stats_persistent= ON;
+CREATE TABLE t1 (t TEXT) ENGINE=InnoDB STATS_PERSISTENT=1;
+connect con1,localhost,root,,test;
+SET DEBUG_SYNC='ib_trunc_table_trunc_completing SIGNAL committed WAIT_FOR ever';
+TRUNCATE TABLE t1;
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR committed';
+disconnect con1;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/update-cascade.result b/mysql-test/suite/innodb/r/update-cascade.result
new file mode 100644
index 00000000000..a3c8fed931e
--- /dev/null
+++ b/mysql-test/suite/innodb/r/update-cascade.result
@@ -0,0 +1,290 @@
+#
+# Bug #18451287 REDUNDANT DELETE MARKING AFTER DB_LOCK_WAIT
+#
+create table t1 (f1 int primary key, f2 blob) engine=innodb;
+create table t2 (f1 int primary key, f2 int,
+foreign key (f2) references t1(f1) on update cascade) engine=innodb;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ `f2` blob DEFAULT NULL,
+ PRIMARY KEY (`f1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f1` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ KEY `f2` (`f2`),
+ CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+insert into t1 values (1, repeat('+', 20000));
+insert into t1 values (2, repeat('-', 20000));
+insert into t1 values (3, repeat('=', 20000));
+insert into t2 values (1, 2);
+select f1, right(f2, 20) as p2 from t1;
+f1 p2
+1 ++++++++++++++++++++
+2 --------------------
+3 ====================
+select f1, f2 from t2;
+f1 f2
+1 2
+connect con1,localhost,root,,test;
+start transaction;
+select f1, f2 from t2 for update;
+f1 f2
+1 2
+connection default;
+set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd';
+update t1 set f1 = 10 where f1 = 2;
+connection con1;
+set debug_sync='now WAIT_FOR upd_waiting';
+rollback;
+set debug_sync='now SIGNAL go_upd';
+connection default;
+# reap: update t1 set f1 = 10 where f1 = 2;
+select f1, right(f2, 20) as p2 from t1;
+f1 p2
+1 ++++++++++++++++++++
+3 ====================
+10 --------------------
+select f1, f2 from t2;
+f1 f2
+1 10
+drop table t2, t1;
+set debug_sync = reset;
+#
+# Test Scenario: Two tables t1 -> t2 are involved in update cascade.
+# If DB_LOCK_WAIT happens when t1 is being updated and FK constraints
+# are being checked in t2, then retry must happen on t1. The update
+# cascade happens in secondary index. For secondary index testing,
+# blobs are not needed.
+#
+create table t1 (f1 int primary key, f2 int, key k1(f2)) engine=innodb;
+create table t2 (f1 int primary key, f2 int,
+foreign key (f2) references t1(f2) on update cascade) engine=innodb;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ KEY `k1` (`f2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f1` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ KEY `f2` (`f2`),
+ CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f2`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+insert into t1 values (1, 91);
+insert into t2 values (1, 91);
+select f1, f2 from t1;
+f1 f2
+1 91
+select f1, f2 from t2;
+f1 f2
+1 91
+connection con1;
+start transaction;
+select f1, f2 from t2 for update;
+f1 f2
+1 91
+connection default;
+set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd';
+update t1 set f2 = 28 where f2 = 91;
+connection con1;
+set debug_sync='now WAIT_FOR upd_waiting';
+rollback;
+set debug_sync='now SIGNAL go_upd';
+connection default;
+# reap: update t1 set f1 = 10 where f1 = 2;
+select f1, f2 from t1;
+f1 f2
+1 28
+select f1, f2 from t2;
+f1 f2
+1 28
+drop table t2, t1;
+set debug_sync = reset;
+#
+# Test Scenario: Three tables t1 -> t2 -> t3 are involved in update cascade.
+# If DB_LOCK_WAIT happens when t2 is being updated, then retry must happen
+# on t2.
+#
+create table t1 (f1 int primary key, f2 blob) engine=innodb;
+create table t2 (f1 int primary key, f2 blob,
+foreign key (f1) references t1(f1) on update cascade) engine=innodb;
+create table t3 (f1 int primary key, f2 blob,
+foreign key (f1) references t2(f1) on update cascade) engine=innodb;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ `f2` blob DEFAULT NULL,
+ PRIMARY KEY (`f1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f1` int(11) NOT NULL,
+ `f2` blob DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `f1` int(11) NOT NULL,
+ `f2` blob DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`f1`) REFERENCES `t2` (`f1`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+insert into t1 values (2, repeat('-', 20000));
+insert into t2 values (2, repeat('%', 20000));
+insert into t3 values (2, repeat('+', 20000));
+select f1, right(f2, 20) as p2 from t1;
+f1 p2
+2 --------------------
+select f1, right(f2, 20) as p2 from t2;
+f1 p2
+2 %%%%%%%%%%%%%%%%%%%%
+select f1, right(f2, 20) as p2 from t3;
+f1 p2
+2 ++++++++++++++++++++
+connection con1;
+start transaction;
+select f1 from t3 for update;
+f1
+2
+connection default;
+set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd';
+update t1 set f1 = 10 where f1 = 2;
+connection con1;
+set debug_sync='now WAIT_FOR upd_waiting';
+rollback;
+# The table t1 is updated.
+# In t2 delete-mark happened. Retry will happen on t2.
+# In t3 yet to be updated.
+set session transaction isolation level read uncommitted;
+start transaction;
+select f1, right(f2, 20) as p2 from t1;
+f1 p2
+select f1, right(f2, 20) as p2 from t2;
+f1 p2
+select f1, right(f2, 20) as p2 from t3;
+f1 p2
+2 ++++++++++++++++++++
+commit;
+set debug_sync='now SIGNAL go_upd';
+connection default;
+# reap: update t1 set f1 = 10 where f1 = 2;
+start transaction;
+select f1, right(f2, 20) as p2 from t1;
+f1 p2
+10 --------------------
+select f1, right(f2, 20) as p2 from t2;
+f1 p2
+10 %%%%%%%%%%%%%%%%%%%%
+select f1, right(f2, 20) as p2 from t3;
+f1 p2
+10 ++++++++++++++++++++
+commit;
+drop table t3, t2, t1;
+set debug_sync = reset;
+#
+# Test Scenario: Three tables t1 -> t2 -> t3 are involved in update
+# cascade. If DB_LOCK_WAIT happens when t2 is being updated, then
+# retry must happen on t2. The update cascade is happening via
+# secondary index (hence blobs are not needed).
+#
+create table t1 (f1 int primary key, f2 int, key k1(f2)) engine=innodb;
+create table t2 (f1 int primary key, f2 int,
+foreign key (f2) references t1(f2) on update cascade) engine=innodb;
+create table t3 (f1 int primary key, f2 int,
+foreign key (f2) references t2(f2) on update cascade) engine=innodb;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ KEY `k1` (`f2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f1` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ KEY `f2` (`f2`),
+ CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f2`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `f1` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ KEY `f2` (`f2`),
+ CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t2` (`f2`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+insert into t1 values (2, 91);
+insert into t2 values (2, 91);
+insert into t3 values (2, 91);
+select f1, f2 from t1;
+f1 f2
+2 91
+select f1, f2 from t2;
+f1 f2
+2 91
+select f1, f2 from t3;
+f1 f2
+2 91
+connection con1;
+start transaction;
+select f1 from t3 for update;
+f1
+2
+connection default;
+set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd';
+update t1 set f2 = 28 where f2 = 91;
+connection con1;
+set debug_sync='now WAIT_FOR upd_waiting';
+rollback;
+# The table t1 is updated.
+# In t2 delete-mark happened. Retry will happen on t2.
+# In t3 yet to be updated.
+set session transaction isolation level read uncommitted;
+start transaction;
+select f1, f2 from t1;
+f1 f2
+select f1, f2 from t2;
+f1 f2
+select f1, f2 from t3;
+f1 f2
+2 91
+commit;
+set debug_sync='now SIGNAL go_upd';
+disconnect con1;
+connection default;
+# reap: update t1 set f2 = 28 where f2 = 91;
+start transaction;
+select f1, f2 from t1;
+f1 f2
+2 28
+select f1, f2 from t2;
+f1 f2
+2 28
+select f1, f2 from t3;
+f1 f2
+2 28
+commit;
+drop table t3, t2, t1;
+set debug_sync = reset;
diff --git a/mysql-test/suite/innodb/r/update_time.result b/mysql-test/suite/innodb/r/update_time.result
new file mode 100644
index 00000000000..d8b9069b1ae
--- /dev/null
+++ b/mysql-test/suite/innodb/r/update_time.result
@@ -0,0 +1,53 @@
+#
+# Test that INFORMATION_SCHEMA.TABLES.UPDATE_TIME is filled
+# correctly for InnoDB tables.
+#
+CREATE TABLE t (a INT) ENGINE=INNODB;
+SELECT update_time FROM information_schema.tables WHERE table_name = 't';
+update_time
+NULL
+INSERT INTO t VALUES (1);
+SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't'
+AND update_time IS NOT NULL;
+COUNT(*)
+1
+# We cant deterministically check that the saved value is correct, but
+# at least we check that it is a timestamp not older than 2 minutes.
+# Usually update_time and NOW() are equal below, but on heavily loaded
+# machines NOW() could be younger.
+SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't'
+AND TIMESTAMPDIFF(SECOND, update_time, NOW()) < 120;
+COUNT(*)
+1
+CREATE TEMPORARY TABLE big (a TEXT) ENGINE=INNODB;
+SELECT COUNT(*) FROM information_schema.innodb_buffer_page
+WHERE table_name = '`test`.`t`';
+COUNT(*)
+1
+# INSERT lots of data in table 'big': begin
+# INSERT lots of data in table 'big': end
+SELECT COUNT(*) FROM information_schema.innodb_buffer_page
+WHERE table_name = '`test`.`t`';
+COUNT(*)
+0
+SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't'
+AND update_time IS NOT NULL;
+COUNT(*)
+1
+DROP TEMPORARY TABLE big;
+# Test the behavior after restart with a prepared XA transaction
+XA START 'xatrx';
+INSERT INTO t VALUES (5);
+XA END 'xatrx';
+XA PREPARE 'xatrx';
+CONNECT con1,localhost,root,,;
+call mtr.add_suppression("Found 1 prepared XA transactions");
+FLUSH TABLES;
+SELECT update_time FROM information_schema.tables WHERE table_name = 't';
+update_time
+NULL
+XA COMMIT 'xatrx';
+SELECT COUNT(update_time) FROM information_schema.tables WHERE table_name='t';
+COUNT(update_time)
+1
+DROP TABLE t;
diff --git a/mysql-test/suite/innodb/r/update_time_wl6658.result b/mysql-test/suite/innodb/r/update_time_wl6658.result
new file mode 100644
index 00000000000..fcd7a53351a
--- /dev/null
+++ b/mysql-test/suite/innodb/r/update_time_wl6658.result
@@ -0,0 +1,228 @@
+CREATE TABLE tab1(c1 int,c2 varchar(30), c3 BLOB) ENGINE=InnoDB;
+CREATE TABLE tab1u LIKE tab1;
+CREATE TABLE tab1d LIKE tab1;
+CREATE TABLE tab1i LIKE tab1;
+CREATE TABLE tab3(c1 int,c2 varchar(30)) ENGINE=InnoDB;
+CREATE TABLE tab4(c1 int,c2 varchar(30)) ENGINE=InnoDB;
+CREATE TABLE tab5(c1 int,c2 varchar(30)) ENGINE=InnoDB;
+INSERT INTO tab1u VALUES(1,'Testing the wl6658','Testing the wl6658');
+INSERT INTO tab1d VALUES(1,'Updated','Updated');
+INSERT INTO tab4 VALUES(1,'Test for Update');
+INSERT INTO tab5 VALUES(1,'Test for Delete');
+CREATE TRIGGER test_trig BEFORE INSERT ON tab1
+FOR EACH ROW BEGIN
+INSERT INTO tab3 VALUES(1,'Inserted From Trigger');
+UPDATE tab4 SET c2='Updated from Trigger' WHERE c1=1;
+DELETE FROM tab5;
+END |
+CREATE TABLE tab2(
+id INT NOT NULL,
+store_name VARCHAR(30),
+parts VARCHAR(30),
+store_id INT
+) ENGINE=InnoDB
+PARTITION BY LIST(store_id) (
+PARTITION pNorth VALUES IN (10,20,30),
+PARTITION pEast VALUES IN (40,50,60),
+PARTITION pWest VALUES IN (70,80,100)
+);
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab2';
+update_time
+NULL
+CREATE PROCEDURE proc_wl6658()
+BEGIN
+INSERT INTO tab2 VALUES(1,'ORACLE','NUTT',10);
+INSERT INTO tab2 VALUES(2,'HUAWEI','BOLT',40);
+COMMIT;
+END |
+CALL proc_wl6658;
+SELECT * FROM tab2 ORDER BY id,store_id;
+id store_name parts store_id
+1 ORACLE NUTT 10
+2 HUAWEI BOLT 40
+SELECT COUNT(update_time)
+FROM information_schema.tables WHERE table_name='tab2';
+COUNT(update_time)
+1
+TRUNCATE TABLE tab2;
+SELECT COUNT(update_time)
+FROM information_schema.tables WHERE table_name='tab2';
+COUNT(update_time)
+1
+CREATE TABLE tab7(c1 INT NOT NULL, PRIMARY KEY (c1)) ENGINE=INNODB;
+CREATE TABLE tab8(c1 INT PRIMARY KEY,c2 INT,
+FOREIGN KEY (c2) REFERENCES tab7(c1) ON DELETE CASCADE )
+ENGINE=INNODB;
+SELECT table_name,update_time
+FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
+GROUP BY table_name ORDER BY table_name;
+table_name update_time
+tab7 NULL
+tab8 NULL
+INSERT INTO tab7 VALUES(1);
+INSERT INTO tab8 VALUES(1,1);
+SELECT table_name,COUNT(update_time)
+FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
+GROUP BY table_name ORDER BY table_name;
+table_name COUNT(update_time)
+tab7 1
+tab8 1
+#restart the server
+SELECT table_name,update_time
+FROM information_schema.tables
+WHERE table_name IN ('tab1','tab2','tab3','tab4','tab5','tab7','tab8')
+ORDER BY table_name;
+table_name update_time
+tab1 NULL
+tab2 NULL
+tab3 NULL
+tab4 NULL
+tab5 NULL
+tab7 NULL
+tab8 NULL
+#case1:
+BEGIN WORK;
+INSERT INTO tab1
+VALUES(1,'Testing the wl6658', 'Testing the wl6658');
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1';
+update_time
+NULL
+COMMIT;
+SELECT * FROM tab1;
+c1 c2 c3
+1 Testing the wl6658 Testing the wl6658
+SELECT * FROM tab3;
+c1 c2
+1 Inserted From Trigger
+SELECT * FROM tab4;
+c1 c2
+1 Updated from Trigger
+SELECT * FROM tab5;
+c1 c2
+SELECT table_name,COUNT(update_time)
+FROM information_schema.tables
+WHERE table_name IN ('tab1','tab3','tab4','tab5')
+GROUP BY table_name ORDER BY table_name;
+table_name COUNT(update_time)
+tab1 1
+tab3 1
+tab4 1
+tab5 1
+Testcase with UPDATE stmt and transaction
+SELECT * FROM tab1u;
+c1 c2 c3
+1 Testing the wl6658 Testing the wl6658
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1u';
+update_time
+NULL
+#case2:
+START TRANSACTION;
+UPDATE tab1u SET c2='Updated',c3='Updated' WHERE c1=1;
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1u';
+update_time
+NULL
+COMMIT;
+SELECT * FROM tab1u;
+c1 c2 c3
+1 Updated Updated
+SELECT COUNT(update_time)
+FROM information_schema.tables WHERE table_name='tab1u';
+COUNT(update_time)
+1
+SELECT * FROM tab1d;
+c1 c2 c3
+1 Updated Updated
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1d';
+update_time
+NULL
+#case3:
+START TRANSACTION;
+DELETE FROM tab1d;
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1d';
+update_time
+NULL
+COMMIT;
+SELECT * FROM tab1d;
+c1 c2 c3
+SELECT COUNT(update_time)
+FROM information_schema.tables WHERE table_name='tab1d';
+COUNT(update_time)
+1
+SELECT * FROM tab1i;
+c1 c2 c3
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1i';
+update_time
+NULL
+#case4:
+START TRANSACTION;
+INSERT INTO tab1i
+VALUES(1,'Testing the wl6658', 'Testing the wl6658');
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1i';
+update_time
+NULL
+ROLLBACK;
+SELECT * FROM tab1i;
+c1 c2 c3
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1i';
+update_time
+NULL
+BEGIN WORK;
+DELETE FROM tab1i;
+SAVEPOINT A;
+INSERT INTO tab2 VALUES(1,'Oracle','NUTT',10);
+INSERT INTO tab2 VALUES(2,'HUAWEI','BOLT',40);
+SAVEPOINT B;
+INSERT INTO tab2 VALUES(3,'IBM','NAIL',70);
+SAVEPOINT C;
+ROLLBACK to A;
+SELECT * FROM tab2;
+id store_name parts store_id
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab2';
+update_time
+NULL
+#execute DDL instead of commit
+create table tab6(c1 int);
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab2';
+update_time
+NULL
+START TRANSACTION;
+DELETE FROM tab7;
+ROLLBACK;
+SELECT * FROM tab7;
+c1
+1
+SELECT * FROM tab8;
+c1 c2
+1 1
+SELECT table_name,update_time
+FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
+GROUP BY table_name ORDER BY table_name;
+table_name update_time
+tab7 NULL
+tab8 NULL
+DELETE FROM tab7;
+SELECT * FROM tab7;
+c1
+SELECT * FROM tab8;
+c1 c2
+SELECT table_name,COUNT(update_time)
+FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
+GROUP BY table_name ORDER BY table_name;
+table_name COUNT(update_time)
+tab7 1
+tab8 1
+#cleanup
+DROP TRIGGER test_trig;
+DROP TABLE tab1,tab1u,tab1d,tab1i,tab2,tab3,tab4,tab5,tab6,tab8,tab7;
+DROP PROCEDURE proc_wl6658;
diff --git a/mysql-test/suite/innodb/t/alter_copy.test b/mysql-test/suite/innodb/t/alter_copy.test
new file mode 100644
index 00000000000..0dce61994b5
--- /dev/null
+++ b/mysql-test/suite/innodb/t/alter_copy.test
@@ -0,0 +1,91 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/not_embedded.inc
+
+--echo #
+--echo # MDEV-11415 AVOID INTERMEDIATE COMMIT WHILE DOING
+--echo # ALTER TABLE...ALGORITHM=COPY
+--echo #
+
+CREATE TABLE t(a SERIAL, b INT, c INT, d INT) ENGINE=InnoDB;
+CREATE TABLE t1(a INT, b TEXT, c TEXT,
+ FULLTEXT(b), FULLTEXT(c(3)), FULLTEXT(b,c)) ENGINE=InnoDB;
+
+let $c = 999;
+BEGIN;
+--disable_query_log
+while ($c) {
+INSERT INTO t() VALUES();
+dec $c;
+}
+--enable_query_log
+COMMIT;
+
+SELECT COUNT(*) FROM t;
+# try to make the to-be-created secondary index keys randomly distributed
+UPDATE t SET b=a%7, c=a%11, d=a%13;
+
+INSERT INTO t1 VALUES(1, 'This is a first b column', 'This is a first c column');
+INSERT INTO t1 VALUES(2, 'This is a second b column', 'This is a second c column');
+INSERT INTO t1(a) VALUES(3);
+INSERT INTO t1 VALUES(4, 'This is a third b column', 'This is a third c column');
+DELETE FROM t1 WHERE a = 2;
+SELECT * FROM t1 WHERE MATCH(b) AGAINST ('first');
+SELECT * FROM t1 WHERE MATCH(c) AGAINST ('first');
+SELECT * FROM t1 WHERE MATCH(b,c) AGAINST ('column');
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 FORCE, ALGORITHM=COPY;
+
+# crash right after the last write_row(), before the first commit of ALTER TABLE
+--source include/expect_crash.inc
+
+SET DEBUG_DBUG='+d,crash_commit_before';
+--error 2013
+# create 32 secondary indexes
+ALTER TABLE t ADD INDEX(b,c,d,a),ADD INDEX(b,c,a,d),ADD INDEX(b,a,c,d),ADD INDEX(b,a,d,c),
+ ADD INDEX(b,d,a,c),ADD INDEX(b,d,c,a),ADD INDEX(a,b,c,d),ADD INDEX(a,b,d,c),
+ ADD INDEX(a,c,b,d),ADD INDEX(a,c,d,b),ADD INDEX(a,d,b,c),ADD INDEX(a,d,c,b),
+ ADD INDEX(c,a,b,d),ADD INDEX(c,a,d,b),ADD INDEX(c,b,a,d),ADD INDEX(c,b,d,a),
+ ADD INDEX(c,d,a,b),ADD INDEX(c,d,b,a),ADD INDEX(d,a,b,c),ADD INDEX(d,a,c,b),
+ ADD INDEX(d,b,a,c),ADD INDEX(d,b,c,a),ADD INDEX(d,c,a,b),ADD INDEX(d,c,b,a),
+ ADD INDEX(a,b,c), ADD INDEX(a,c,b), ADD INDEX(a,c,d), ADD INDEX(a,d,c),
+ ADD INDEX(a,b,d), ADD INDEX(a,d,b), ADD INDEX(b,c,d), ADD INDEX(b,d,c),
+ ALGORITHM=COPY;
+
+--let $restart_parameters= --innodb-force-recovery=3
+--source include/start_mysqld.inc
+let $datadir=`select @@datadir`;
+--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ /FTS_[0-9a-f]*_[0-9a-f]*/FTS/
+--list_files $datadir/test
+SHOW CREATE TABLE t;
+SELECT COUNT(*) FROM t;
+CHECK TABLE t;
+SELECT * FROM t1 WHERE MATCH(b) AGAINST ('first');
+SELECT * FROM t1 WHERE MATCH(c) AGAINST ('first');
+SELECT * FROM t1 WHERE MATCH(b,c) AGAINST ('column');
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+
+--let $restart_parameters= --innodb-read-only
+--source include/restart_mysqld.inc
+--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ /FTS_[0-9a-f]*_[0-9a-f]*/FTS/
+
+--list_files $datadir/test
+SHOW CREATE TABLE t;
+SELECT COUNT(*) FROM t;
+CHECK TABLE t;
+SELECT * FROM t1 WHERE MATCH(b) AGAINST ('first');
+SELECT * FROM t1 WHERE MATCH(c) AGAINST ('first');
+SELECT * FROM t1 WHERE MATCH(b,c) AGAINST ('column');
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+
+--let $restart_parameters=
+--source include/restart_mysqld.inc
+--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ /FTS_[0-9a-f]*_[0-9a-f]*/FTS/
+--list_files $datadir/test
+DROP TABLE t1,t;
+
+# Work around missing crash recovery at the SQL layer.
+--remove_files_wildcard $datadir/test #sql-*.frm
diff --git a/mysql-test/suite/innodb/t/alter_crash.test b/mysql-test/suite/innodb/t/alter_crash.test
index 1751e2d6c8b..101e0fa44c2 100644
--- a/mysql-test/suite/innodb/t/alter_crash.test
+++ b/mysql-test/suite/innodb/t/alter_crash.test
@@ -72,31 +72,25 @@ let $orig_table_id = `SELECT table_id
--error 2013
ALTER TABLE t1 ADD PRIMARY KEY (f2, f1);
---echo # Restart mysqld after the crash and reconnect.
---source include/start_mysqld.inc
-
-let $temp_table_name = `SELECT SUBSTR(name, 6)
- FROM information_schema.innodb_sys_tables
- WHERE table_id = $orig_table_id`;
-
---echo # Manual *.frm recovery begin.
-
---move_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/$temp_table_name.frm
-
+let TABLENAME_INC= $MYSQLTEST_VARDIR/tmp/tablename.inc;
perl;
-my @frm_file = glob "$ENV{'datadir'}/test/#sql-*.frm";
-my $t1_frm = "$ENV{'datadir'}/test/t1.frm";
-rename($frm_file[0], $t1_frm);
+die unless open OUT, ">$ENV{TABLENAME_INC}";
+chdir "$ENV{'datadir'}/test";
+my @frm_file = map { substr($_, 0, -4) } glob "#sql-*.frm";
+print OUT 'let $tablename=', $frm_file[0], ';';
+close OUT or die;
EOF
+source $TABLENAME_INC;
+remove_file $TABLENAME_INC;
---echo # Manual recovery end
+move_file $datadir/test/$tablename.frm $datadir/test/t1.frm;
-FLUSH TABLES;
+--echo # Restart mysqld after the crash and reconnect.
+--source include/start_mysqld.inc
---echo # Drop the orphaned original table.
---disable_query_log
-eval DROP TABLE `$temp_table_name`;
---enable_query_log
+--replace_result $orig_table_id ID
+eval SELECT * FROM information_schema.innodb_sys_tables
+WHERE table_id = $orig_table_id;
--echo # Files in datadir after manual recovery.
--list_files $MYSQLD_DATADIR/test
@@ -131,35 +125,13 @@ let $orig_table_id = `SELECT table_id
--error 2013
ALTER TABLE t2 ADD PRIMARY KEY (f2, f1);
+remove_files_wildcard $datadir/test #sql-*.frm;
+
--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%"`;
-
---echo # Manual *.frm 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.
-
-let TABLENAME_INC= $MYSQLTEST_VARDIR/tmp/tablename.inc;
-perl;
-die unless open OUT, ">$ENV{TABLENAME_INC}";
-chdir "$ENV{'datadir'}/test";
-my @frm_file = map { substr($_, 0, -4) } glob "#sql-*.frm";
-print OUT 'let $tablename=', $frm_file[0], ';';
-close OUT or die;
-EOF
-source $TABLENAME_INC;
-remove_file $TABLENAME_INC;
-
---echo # Manual recovery end
-
---echo # Drop the orphaned rebuilt table.
---disable_query_log
-eval DROP TABLE `#mysql50#$tablename`;
---enable_query_log
+SELECT * FROM information_schema.innodb_sys_tables
+WHERE name LIKE 'test/#sql-%';
SHOW TABLES;
INSERT INTO t2 VALUES (5,6),(7,8);
@@ -195,30 +167,24 @@ let $orig_table_id = `select table_id from
--error 2013
ALTER TABLE t1 ADD INDEX (b), CHANGE c d int, ALGORITHM=INPLACE;
---echo # Restart mysqld after the crash and reconnect.
---source include/start_mysqld.inc
-
-let $temp_table_name = `SELECT SUBSTR(name, 6)
- FROM information_schema.innodb_sys_tables
- WHERE table_id = $orig_table_id`;
-
---echo # Manual *.frm recovery begin.
---move_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/$temp_table_name.frm
-
perl;
-my @frm_file = glob "$ENV{'datadir'}/test/#sql-*.frm";
-my $t1_frm = "$ENV{'datadir'}/test/t1.frm";
-rename($frm_file[0], $t1_frm);
+die unless open OUT, ">$ENV{TABLENAME_INC}";
+chdir "$ENV{'datadir'}/test";
+my @frm_file = map { substr($_, 0, -4) } glob "#sql-*.frm";
+print OUT 'let $tablename=', $frm_file[0], ';';
+close OUT or die;
EOF
+source $TABLENAME_INC;
+remove_file $TABLENAME_INC;
---echo # Manual recovery end
+move_file $datadir/test/$tablename.frm $datadir/test/t1.frm;
-FLUSH TABLES;
+--echo # Restart mysqld after the crash and reconnect.
+--source include/start_mysqld.inc
---echo # Drop the orphaned original table.
---disable_query_log
-eval DROP TABLE `#mysql50#$temp_table_name`;
---enable_query_log
+--replace_result $orig_table_id ID
+eval SELECT * FROM information_schema.innodb_sys_tables
+WHERE table_id = $orig_table_id;
--echo # Files in datadir after manual recovery.
--list_files $MYSQLD_DATADIR/test
diff --git a/mysql-test/suite/innodb/t/ddl_purge.test b/mysql-test/suite/innodb/t/ddl_purge.test
new file mode 100644
index 00000000000..60d17acead8
--- /dev/null
+++ b/mysql-test/suite/innodb/t/ddl_purge.test
@@ -0,0 +1,36 @@
+--source innodb_default_row_format.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+
+CREATE TABLE t0 (pk INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t1 (pk INT PRIMARY KEY, b INT) ENGINE=InnoDB;
+
+--connect (con1,localhost,root,,test)
+BEGIN;
+INSERT INTO t0 SET pk=1;
+
+--connect (con2,localhost,root,,test)
+BEGIN;
+INSERT INTO t0 SET pk=2;
+
+--connection default
+SET DEBUG_SYNC='alter_table_inplace_after_lock_downgrade SIGNAL prepared WAIT_FOR logged';
+send ALTER TABLE t1 FORCE;
+
+--connection con1
+SET DEBUG_SYNC='now WAIT_FOR prepared';
+INSERT INTO t1 SET pk=1;
+COMMIT;
+--disconnect con1
+
+--connection con2
+UPDATE t1 SET b=1;
+DELETE FROM t1;
+ROLLBACK;
+SET DEBUG_SYNC='now SIGNAL logged';
+--disconnect con2
+
+--connection default
+reap;
+SET DEBUG_SYNC='RESET';
+DROP TABLE t0,t1;
diff --git a/mysql-test/suite/innodb/t/deadlock_detect.test b/mysql-test/suite/innodb/t/deadlock_detect.test
index 85d8c1f67f2..babdb54719f 100644
--- a/mysql-test/suite/innodb/t/deadlock_detect.test
+++ b/mysql-test/suite/innodb/t/deadlock_detect.test
@@ -18,6 +18,8 @@ CREATE TABLE t1(
INSERT INTO t1 VALUES(1), (2), (3);
+# We are not interested query results, only errors
+--disable_result_log
BEGIN;
SELECT * FROM t1 WHERE id = 1 FOR UPDATE;
@@ -39,12 +41,22 @@ reap;
ROLLBACK;
+#
+# Note here that con1 is the older transaction as it
+# query started wait first. Thus, con1 gets lock
+# wait timeout first. There is possibility that
+# default connection gets lock timeout also or
+# as con1 is rolled back it gets the locks it waited
+# and does the update.
+#
connection default;
---error ER_LOCK_WAIT_TIMEOUT
+--error 0,ER_LOCK_WAIT_TIMEOUT
reap;
ROLLBACK;
+--enable_result_log
+
DROP TABLE t1;
disconnect con1;
diff --git a/mysql-test/suite/innodb/t/drop_table_background.test b/mysql-test/suite/innodb/t/drop_table_background.test
index 0f596dec574..8d82bea9675 100644
--- a/mysql-test/suite/innodb/t/drop_table_background.test
+++ b/mysql-test/suite/innodb/t/drop_table_background.test
@@ -9,6 +9,9 @@ KEY(c3), KEY(c3,c1), KEY(c3,c2), KEY(c3,c2,c1),
KEY(c4), KEY(c4,c1), KEY(c4,c2), KEY(c4,c2,c1),
KEY(c4,c3), KEY(c4,c3,c1), KEY(c4,c3,c2), KEY(c4,c3,c2,c1)) ENGINE=InnoDB;
+CREATE TABLE `#mysql50##sql-ib-foo`(a SERIAL) ENGINE=InnoDB;
+INSERT INTO t (c1) VALUES (1),(2),(1);
+
let $n= 10;
SET DEBUG_DBUG='+d,row_drop_table_add_to_background';
@@ -24,7 +27,18 @@ while ($i) {
dec $i;
}
--enable_query_log
+--error ER_DUP_ENTRY
+CREATE TABLE target (PRIMARY KEY(c1)) ENGINE=InnoDB SELECT * FROM t;
+--error ER_NO_SUCH_TABLE
+SELECT * from target;
DROP TABLE t;
--source include/restart_mysqld.inc
CREATE TABLE t (a INT) ENGINE=InnoDB;
DROP TABLE t;
+--error ER_BAD_TABLE_ERROR
+DROP TABLE target;
+CREATE TABLE target (a INT) ENGINE=InnoDB;
+DROP TABLE target;
+--error ER_NO_SUCH_TABLE_IN_ENGINE
+SELECT * FROM `#mysql50##sql-ib-foo`;
+DROP TABLE `#mysql50##sql-ib-foo`;
diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/innodb/t/foreign_key.test
index 3d3466c90f0..862717647b5 100644
--- a/mysql-test/suite/innodb/t/foreign_key.test
+++ b/mysql-test/suite/innodb/t/foreign_key.test
@@ -236,4 +236,44 @@ DELETE FROM t1 WHERE id = 1;
SELECT * FROM t2;
DROP TABLE t2, t1;
+--echo #
+--echo # MDEV-15199 Referential integrity broken in ON DELETE CASCADE
+--echo #
+
+CREATE TABLE member (id int AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO member VALUES (1);
+CREATE TABLE address (
+ id int AUTO_INCREMENT PRIMARY KEY,
+ member_id int NOT NULL,
+ KEY address_FI_1 (member_id),
+ CONSTRAINT address_FK_1 FOREIGN KEY (member_id) REFERENCES member (id)
+ ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB;
+
+INSERT INTO address VALUES (2,1);
+CREATE TABLE payment_method (
+ id int AUTO_INCREMENT PRIMARY KEY,
+ member_id int NOT NULL,
+ cardholder_address_id int DEFAULT NULL,
+ KEY payment_method_FI_1 (member_id),
+ KEY payment_method_FI_2 (cardholder_address_id),
+ CONSTRAINT payment_method_FK_1 FOREIGN KEY (member_id) REFERENCES member (id) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT payment_method_FK_2 FOREIGN KEY (cardholder_address_id) REFERENCES address (id) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB;
+
+INSERT INTO payment_method VALUES (3,1,2);
+
+BEGIN;
+UPDATE member SET id=42;
+SELECT * FROM member;
+SELECT * FROM address;
+SELECT * FROM payment_method;
+DELETE FROM member;
+COMMIT;
+SELECT * FROM member;
+SELECT * FROM address;
+SELECT * FROM payment_method;
+
+DROP TABLE payment_method,address,member;
+
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/innodb/t/ibuf_not_empty.test b/mysql-test/suite/innodb/t/ibuf_not_empty.test
index a1a2da1f903..5adbfb72550 100644
--- a/mysql-test/suite/innodb/t/ibuf_not_empty.test
+++ b/mysql-test/suite/innodb/t/ibuf_not_empty.test
@@ -9,6 +9,8 @@
--disable_query_log
call mtr.add_suppression("InnoDB: Failed to find tablespace for table `test`\\.`t1` in the cache\\. Attempting to load the tablespace with space id");
call mtr.add_suppression("InnoDB: Allocated tablespace ID \\d+ for test.t1, old maximum was");
+call mtr.add_suppression("InnoDB: Failed to find tablespace for table `mysql`\\.`transaction_registry` in the cache\\. Attempting to load the tablespace with space id");
+call mtr.add_suppression("InnoDB: Allocated tablespace ID \\d+ for mysql.transaction_registry, old maximum was");
--enable_query_log
CREATE TABLE t1(
diff --git a/mysql-test/suite/innodb/t/innodb-alter-tempfile.test b/mysql-test/suite/innodb/t/innodb-alter-tempfile.test
index f2038da8c4c..f7635e96d50 100644
--- a/mysql-test/suite/innodb/t/innodb-alter-tempfile.test
+++ b/mysql-test/suite/innodb/t/innodb-alter-tempfile.test
@@ -32,24 +32,12 @@ SET debug_dbug='+d,innodb_alter_commit_crash_before_commit';
--error 2013
ALTER TABLE t1 ADD PRIMARY KEY (f2, f1);
-let TABLENAME_INC= $MYSQLTEST_VARDIR/tmp/tablename.inc;
-perl;
-die unless open OUT, ">$ENV{TABLENAME_INC}";
-chdir "$ENV{'datadir'}/test";
-my @frm_file = map { substr($_, 0, -4) } glob "#sql-*.frm";
-print OUT 'let $temp_table_name=', $frm_file[0], ';';
-close OUT or die;
-EOF
-source $TABLENAME_INC;
-remove_file $TABLENAME_INC;
+remove_files_wildcard $datadir/test #sql-*.frm;
--source include/start_mysqld.inc
show create table t1;
--echo # Consecutive Alter table does not create same temporary file name
ALTER TABLE t1 ADD PRIMARY KEY (f2, f1);
---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-autoinc.test b/mysql-test/suite/innodb/t/innodb-autoinc.test
index 9b526c7c433..db265ff8f67 100644
--- a/mysql-test/suite/innodb/t/innodb-autoinc.test
+++ b/mysql-test/suite/innodb/t/innodb-autoinc.test
@@ -683,3 +683,20 @@ INSERT INTO t VALUES (NULL);
SELECT * FROM t;
SHOW CREATE TABLE t;
DROP TABLE t;
+
+--echo #
+--echo # MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())
+--echo #
+
+SET sql_mode=STRICT_ALL_TABLES;
+CREATE TABLE t1 (
+ c1 DOUBLE NOT NULL PRIMARY KEY AUTO_INCREMENT
+) ENGINE=InnoDB AUTO_INCREMENT=10000000000000000000;
+INSERT INTO t1 VALUES ();
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a DOUBLE PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (-1);
+SELECT * FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/innodb-index-debug.test b/mysql-test/suite/innodb/t/innodb-index-debug.test
index de598740e6a..e680fb719cc 100644
--- a/mysql-test/suite/innodb/t/innodb-index-debug.test
+++ b/mysql-test/suite/innodb/t/innodb-index-debug.test
@@ -114,6 +114,45 @@ connection default;
show create table t1;
drop table t1;
drop table t480;
+--echo #
+--echo # MDEV-12827 Assertion failure when reporting duplicate key error
+--echo # in online table rebuild
+--echo #
+
+CREATE TABLE t1 (j INT UNIQUE, i INT UNIQUE) ENGINE=InnoDB;
+--connect (con1,localhost,root,,test)
+SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL built WAIT_FOR log';
+--send
+ALTER TABLE t1 DROP j, FORCE;
+
+--connection default
+SET DEBUG_SYNC='now WAIT_FOR built';
+--error ER_DUP_ENTRY
+INSERT INTO t1 (i) VALUES (0),(0);
+SET DEBUG_SYNC='now SIGNAL log';
+
+--connection con1
+--error ER_DUP_ENTRY
+reap;
+SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL built2 WAIT_FOR log2';
+--send
+ALTER TABLE t1 DROP j, FORCE;
+
+--connection default
+SET DEBUG_SYNC='now WAIT_FOR built2';
+INSERT INTO t1 (i) VALUES (0),(1);
+--error ER_DUP_ENTRY
+UPDATE t1 SET i=0;
+SET DEBUG_SYNC='now SIGNAL log2';
+
+--connection con1
+--error ER_DUP_ENTRY
+reap;
+--disconnect con1
+--connection default
+SET DEBUG_SYNC='RESET';
+DROP TABLE t1;
+
SET DEBUG_SYNC='RESET';
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/innodb/t/innodb-index-online.test b/mysql-test/suite/innodb/t/innodb-index-online.test
index 5509d985edc..efe1c796cf1 100644
--- a/mysql-test/suite/innodb/t/innodb-index-online.test
+++ b/mysql-test/suite/innodb/t/innodb-index-online.test
@@ -457,8 +457,6 @@ connection default;
reap;
--enable_parsing
#remove below con1 disconnect if above test case is enabled
-connection con1;
-disconnect con1;
connection default;
SHOW CREATE TABLE t1;
@@ -474,6 +472,31 @@ SET GLOBAL innodb_monitor_disable = module_ddl;
DROP TABLE t1;
+--echo #
+--echo # MDEV-13205 assertion !dict_index_is_online_ddl(index) upon ALTER TABLE
+--echo #
+CREATE TABLE t1 (c VARCHAR(64)) ENGINE=InnoDB;
+SET DEBUG_SYNC = 'row_log_apply_before SIGNAL t1u_created WAIT_FOR dup_done';
+send ALTER TABLE t1 ADD UNIQUE(c);
+
+connection con1;
+SET DEBUG_SYNC = 'now WAIT_FOR t1u_created';
+BEGIN;
+INSERT INTO t1 VALUES('bar'),('bar');
+SET DEBUG_SYNC = 'now SIGNAL dup_done';
+
+connection default;
+--error ER_DUP_ENTRY
+reap;
+
+SET DEBUG_SYNC = 'RESET';
+disconnect con1;
+CREATE TABLE t2 (c VARCHAR(64)) ENGINE=InnoDB;
+--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
+--error ER_CANT_CREATE_TABLE
+ALTER TABLE t2 ADD FOREIGN KEY (c) REFERENCES t1 (c);
+DROP TABLE t2,t1;
+
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/innodb/t/innodb-lru-force-no-free-page.test b/mysql-test/suite/innodb/t/innodb-lru-force-no-free-page.test
new file mode 100644
index 00000000000..d4f08b5afe6
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-lru-force-no-free-page.test
@@ -0,0 +1,24 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/not_embedded.inc
+
+call mtr.add_suppression("InnoDB: Difficult to find free blocks in the buffer pool");
+
+SET @saved_debug = @@SESSION.debug_dbug;
+SET SESSION debug_dbug="+d,ib_lru_force_no_free_page";
+
+CREATE TABLE t1 (j LONGBLOB) ENGINE = InnoDB;
+BEGIN;
+INSERT INTO t1 VALUES (repeat('abcdefghijklmnopqrstuvwxyz',200));
+COMMIT;
+
+SET debug_dbug = @saved_debug;
+
+DROP TABLE t1;
+
+#
+# There should be only one message
+#
+let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
+--let SEARCH_PATTERN=InnoDB: Difficult to find free blocks
+--source include/search_pattern_in_file.inc
diff --git a/mysql-test/suite/innodb/t/innodb-master.opt b/mysql-test/suite/innodb/t/innodb-master.opt
index 5266978e4f0..2e71d62206d 100644
--- a/mysql-test/suite/innodb/t/innodb-master.opt
+++ b/mysql-test/suite/innodb/t/innodb-master.opt
@@ -2,3 +2,5 @@
--default-storage-engine=MyISAM
--innodb-strict-mode=0
--innodb-file-per-table=0
+--loose-innodb-track-changed-pages
+--loose-innodb-log-archive
diff --git a/mysql-test/suite/innodb/t/innodb-on-duplicate-update.test b/mysql-test/suite/innodb/t/innodb-on-duplicate-update.test
new file mode 100644
index 00000000000..cc80198d24a
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-on-duplicate-update.test
@@ -0,0 +1,63 @@
+--source include/have_innodb.inc
+
+#
+# MDEV-13206: INSERT ON DUPLICATE KEY UPDATE foreign key fail
+#
+set sql_mode='';
+set innodb_strict_mode=0;
+
+CREATE TABLE `v` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+INSERT v values (1);
+
+CREATE TABLE `vp` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `v_id` int(10) unsigned NOT NULL,
+ `p_id` int(10) unsigned NOT NULL,
+ `ppp` varchar(255) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `IDX_vp_uniq` (`v_id`,`p_id`),
+ KEY `FK_vp_v` (`v_id`),
+ CONSTRAINT `FK_vp_v` FOREIGN KEY (`v_id`) REFERENCES `v` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+INSERT vp VALUES (12, 1, 100, 'text12');
+INSERT INTO `vp` (`id`,`ppp`) VALUES (12, 'test12-2') ON DUPLICATE KEY UPDATE `ppp` = VALUES(`ppp`);
+SELECT * FROM vp;
+DROP TABLE vp, v;
+
+CREATE TABLE t1 (i int PRIMARY KEY) ENGINE=InnoDB;
+INSERT into t1 values (1);
+
+CREATE TABLE t2 (
+ i int not null primary key,
+ vi int not null,
+ m int,
+ UNIQUE KEY (vi),
+ CONSTRAINT `cc` FOREIGN KEY (vi) REFERENCES t1 (i) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB;
+
+INSERT into t2 VALUES (1, 1, 100);
+INSERT INTO t2 (i,m) VALUES (1, 2) ON DUPLICATE KEY UPDATE m=3;
+SELECT * FROM t2;
+
+DROP TABLE t2,t1;
+
+CREATE TABLE t1 (i int PRIMARY KEY) ENGINE=InnoDB;
+INSERT into t1 values (1);
+
+CREATE TABLE t2 (
+ i int not null primary key,
+ vi int not null,
+ m int,
+ KEY (vi),
+ CONSTRAINT `cc` FOREIGN KEY (vi) REFERENCES t1 (i) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB;
+
+INSERT into t2 VALUES (1, 1, 100);
+INSERT INTO t2 (i,m) VALUES (1, 2) ON DUPLICATE KEY UPDATE m=3;
+SELECT * FROM t2;
+DROP TABLE t2, t1;
diff --git a/mysql-test/suite/innodb/t/innodb-replace-debug.test b/mysql-test/suite/innodb/t/innodb-replace-debug.test
new file mode 100644
index 00000000000..7e710ae154c
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-replace-debug.test
@@ -0,0 +1,16 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+
+--echo #
+--echo # Bug#17604730 ASSERTION: *CURSOR->INDEX->NAME == TEMP_INDEX_PREFIX
+--echo #
+
+create table t1 (f1 int primary key, f2 int, f3 int, unique key k1(f2),
+ key k2(f3)) engine=innodb;
+insert into t1 values (14, 24, 34);
+set @old_dbug= @@session.debug_dbug;
+set debug_dbug = '+d,row_ins_sec_index_entry_timeout';
+replace into t1 values (14, 25, 34);
+select * from t1;
+drop table t1;
+set debug_dbug = @old_dbug;
diff --git a/mysql-test/suite/innodb/t/innodb.test b/mysql-test/suite/innodb/t/innodb.test
index a4ba60ec94c..472b47899db 100644
--- a/mysql-test/suite/innodb/t/innodb.test
+++ b/mysql-test/suite/innodb/t/innodb.test
@@ -5,6 +5,10 @@ let $MYSQLD_DATADIR= `select @@datadir`;
let collation=utf8_unicode_ci;
--source include/have_collation.inc
+
+create temporary table t (a char(1) character set filename) engine=innodb;
+drop temporary table t;
+
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
@@ -1054,82 +1058,18 @@ DROP TABLE t2,t1;
#
# test for FK cascade depth limit
#
-call mtr.add_suppression("Cannot delete/update rows with cascading foreign key constraints that exceed max depth of 255. Please drop excessive foreign constraints and try again");
+call mtr.add_suppression("Cannot delete/update rows with cascading foreign key constraints that exceed max depth of 15\\. Please drop excessive foreign constraints and try again");
create table t1(
id int primary key,
pid int,
index(pid),
foreign key(pid) references t1(id) on delete cascade) engine=innodb;
-insert into t1 values
-( 0, 0), ( 1, 0), ( 2, 1), ( 3, 2),
-( 4, 3), ( 5, 4), ( 6, 5), ( 7, 6),
-( 8, 7), ( 9, 8), ( 10, 9), ( 11, 10),
-( 12, 11), ( 13, 12), ( 14, 13), ( 15, 14),
-( 16, 15), ( 17, 16), ( 18, 17), ( 19, 18),
-( 20, 19), ( 21, 20), ( 22, 21), ( 23, 22),
-( 24, 23), ( 25, 24), ( 26, 25), ( 27, 26),
-( 28, 27), ( 29, 28), ( 30, 29), ( 31, 30),
-( 32, 31), ( 33, 32), ( 34, 33), ( 35, 34),
-( 36, 35), ( 37, 36), ( 38, 37), ( 39, 38),
-( 40, 39), ( 41, 40), ( 42, 41), ( 43, 42),
-( 44, 43), ( 45, 44), ( 46, 45), ( 47, 46),
-( 48, 47), ( 49, 48), ( 50, 49), ( 51, 50),
-( 52, 51), ( 53, 52), ( 54, 53), ( 55, 54),
-( 56, 55), ( 57, 56), ( 58, 57), ( 59, 58),
-( 60, 59), ( 61, 60), ( 62, 61), ( 63, 62),
-( 64, 63), ( 65, 64), ( 66, 65), ( 67, 66),
-( 68, 67), ( 69, 68), ( 70, 69), ( 71, 70),
-( 72, 71), ( 73, 72), ( 74, 73), ( 75, 74),
-( 76, 75), ( 77, 76), ( 78, 77), ( 79, 78),
-( 80, 79), ( 81, 80), ( 82, 81), ( 83, 82),
-( 84, 83), ( 85, 84), ( 86, 85), ( 87, 86),
-( 88, 87), ( 89, 88), ( 90, 89), ( 91, 90),
-( 92, 91), ( 93, 92), ( 94, 93), ( 95, 94),
-( 96, 95), ( 97, 96), ( 98, 97), ( 99, 98),
-(100, 99), (101, 100), (102, 101), (103, 102),
-(104, 103), (105, 104), (106, 105), (107, 106),
-(108, 107), (109, 108), (110, 109), (111, 110),
-(112, 111), (113, 112), (114, 113), (115, 114),
-(116, 115), (117, 116), (118, 117), (119, 118),
-(120, 119), (121, 120), (122, 121), (123, 122),
-(124, 123), (125, 124), (126, 125), (127, 126),
-(128, 127), (129, 128), (130, 129), (131, 130),
-(132, 131), (133, 132), (134, 133), (135, 134),
-(136, 135), (137, 136), (138, 137), (139, 138),
-(140, 139), (141, 140), (142, 141), (143, 142),
-(144, 143), (145, 144), (146, 145), (147, 146),
-(148, 147), (149, 148), (150, 149), (151, 150),
-(152, 151), (153, 152), (154, 153), (155, 154),
-(156, 155), (157, 156), (158, 157), (159, 158),
-(160, 159), (161, 160), (162, 161), (163, 162),
-(164, 163), (165, 164), (166, 165), (167, 166),
-(168, 167), (169, 168), (170, 169), (171, 170),
-(172, 171), (173, 172), (174, 173), (175, 174),
-(176, 175), (177, 176), (178, 177), (179, 178),
-(180, 179), (181, 180), (182, 181), (183, 182),
-(184, 183), (185, 184), (186, 185), (187, 186),
-(188, 187), (189, 188), (190, 189), (191, 190),
-(192, 191), (193, 192), (194, 193), (195, 194),
-(196, 195), (197, 196), (198, 197), (199, 198),
-(200, 199), (201, 200), (202, 201), (203, 202),
-(204, 203), (205, 204), (206, 205), (207, 206),
-(208, 207), (209, 208), (210, 209), (211, 210),
-(212, 211), (213, 212), (214, 213), (215, 214),
-(216, 215), (217, 216), (218, 217), (219, 218),
-(220, 219), (221, 220), (222, 221), (223, 222),
-(224, 223), (225, 224), (226, 225), (227, 226),
-(228, 227), (229, 228), (230, 229), (231, 230),
-(232, 231), (233, 232), (234, 233), (235, 234),
-(236, 235), (237, 236), (238, 237), (239, 238),
-(240, 239), (241, 240), (242, 241), (243, 242),
-(244, 243), (245, 244), (246, 245), (247, 246),
-(248, 247), (249, 248), (250, 249), (251, 250),
-(252, 251), (253, 252), (254, 253), (255, 254);
+insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
+(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
--error ER_GET_ERRMSG,ER_ROW_IS_REFERENCED_2
delete from t1 where id=0;
-delete from t1 where id=255;
---error 0,ER_ROW_IS_REFERENCED_2
+delete from t1 where id=15;
delete from t1 where id=0;
drop table t1;
@@ -2583,17 +2523,73 @@ select f1 from t1;
show status like "handler_read_key";
drop table t1;
-#######################################################################
-# #
-# Please, DO NOT TOUCH this file as well as the innodb.result file. #
-# These files are to be modified ONLY BY INNOBASE guys. #
-# #
-# Use innodb_mysql.[test|result] files instead. #
-# #
-# If nevertheless you need to make some changes here, please, forward #
-# your commit message #
-# To: innodb_dev_ww@oracle.com #
-# Cc: dev-innodb@mysql.com #
-# (otherwise your changes may be erased). #
-# #
-#######################################################################
+#
+# Test handling of writes to TEMPORARY tables for read-only transactions
+#
+CREATE TABLE t1 (c1 INT) ENGINE=InnoDB;
+CREATE TEMPORARY TABLE t2 (c1 INT) ENGINE=InnoDB;
+
+# Check that the rollback works
+START TRANSACTION READ ONLY;
+INSERT INTO t2 VALUES(0);
+--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
+INSERT INTO t1 VALUES(0);
+ROLLBACK;
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+START TRANSACTION READ ONLY;
+--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
+INSERT INTO t1 VALUES(0);
+INSERT INTO t2 VALUES(1);
+COMMIT;
+
+SET TRANSACTION READ ONLY;
+START TRANSACTION;
+INSERT INTO t2 VALUES(3);
+--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
+INSERT INTO t1 VALUES(0);
+COMMIT;
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+DROP TABLE t2;
+
+# This time with some indexes
+CREATE TEMPORARY TABLE t2 (
+ c1 INT AUTO_INCREMENT PRIMARY KEY,
+ c2 INT, INDEX idx(c2)) ENGINE=InnoDB;
+
+SHOW CREATE TABLE t2;
+
+# Check that the rollback works
+START TRANSACTION READ ONLY;
+INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3);
+--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
+INSERT INTO t1 VALUES(0);
+ROLLBACK;
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+START TRANSACTION READ ONLY;
+--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
+INSERT INTO t1 VALUES(0);
+INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3);
+COMMIT;
+
+SET TRANSACTION READ ONLY;
+START TRANSACTION;
+INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3);
+--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
+INSERT INTO t1 VALUES(0);
+COMMIT;
+
+SHOW CREATE TABLE t2;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.opt b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.opt
new file mode 100644
index 00000000000..39543543a53
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.opt
@@ -0,0 +1,2 @@
+--innodb-buffer-pool-size=8M
+--innodb-page-size=4k
diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test
new file mode 100644
index 00000000000..77fdb49a57d
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test
@@ -0,0 +1,74 @@
+#
+# WL6117 : Resize the InnoDB Buffer Pool Online
+#
+
+--source include/have_innodb.inc
+--source include/big_test.inc
+
+let $wait_timeout = 180;
+let $wait_condition =
+ SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at '
+ FROM information_schema.global_status
+ WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status';
+
+--disable_query_log
+set @old_innodb_buffer_pool_size = @@innodb_buffer_pool_size;
+set @old_innodb_adaptive_hash_index = @@innodb_adaptive_hash_index;
+if (`select (version() like '%debug%') > 0`)
+{
+ set @old_innodb_disable_resize = @@innodb_disable_resize_buffer_pool_debug;
+ set global innodb_disable_resize_buffer_pool_debug = OFF;
+}
+--enable_query_log
+
+set global innodb_adaptive_hash_index=ON;
+
+select @@innodb_buffer_pool_size;
+
+# Expand buffer pool
+set global innodb_buffer_pool_size = 10485760;
+
+--source include/wait_condition.inc
+
+select @@innodb_buffer_pool_size;
+
+# fill buffer pool
+create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
+create or replace view view0 as select 1 union all select 1;
+
+set @`v_id` := 0;
+set @`v_val` := 0;
+
+# 2^18 == 262144 records
+replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17;
+
+# Shrink buffer pool
+set global innodb_buffer_pool_size = 7340032;
+--source include/wait_condition.inc
+
+select @@innodb_buffer_pool_size;
+
+select count(val) from t1;
+
+set global innodb_adaptive_hash_index=OFF;
+
+# Expand buffer pool to 24MB
+set global innodb_buffer_pool_size = 25165824;
+--source include/wait_condition.inc
+
+select @@innodb_buffer_pool_size;
+
+select count(val) from t1;
+
+drop table t1;
+drop view view0;
+
+--disable_query_log
+set global innodb_adaptive_hash_index = @old_innodb_adaptive_hash_index;
+set global innodb_buffer_pool_size = @old_innodb_buffer_pool_size;
+if (`select (version() like '%debug%') > 0`)
+{
+ set global innodb_disable_resize_buffer_pool_debug = @old_innodb_disable_resize;
+}
+--enable_query_log
+--source include/wait_condition.inc
diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.opt b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.opt
new file mode 100644
index 00000000000..b97a3995457
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.opt
@@ -0,0 +1,3 @@
+--innodb-buffer-pool-size=16M
+--innodb-buffer-pool-chunk-size=2M
+--innodb-page-size=4k
diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.test b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.test
new file mode 100644
index 00000000000..b04b0306bf1
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.test
@@ -0,0 +1,63 @@
+#
+# WL6117 : Resize the InnoDB Buffer Pool Online
+# (innodb_buffer_pool_chunk_size used case)
+#
+
+--source include/have_innodb.inc
+--source include/big_test.inc
+
+let $wait_timeout = 180;
+let $wait_condition =
+ SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at '
+ FROM information_schema.global_status
+ WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status';
+
+--disable_query_log
+set @old_innodb_buffer_pool_size = @@innodb_buffer_pool_size;
+if (`select (version() like '%debug%') > 0`)
+{
+ set @old_innodb_disable_resize = @@innodb_disable_resize_buffer_pool_debug;
+ set global innodb_disable_resize_buffer_pool_debug = OFF;
+}
+--enable_query_log
+
+select @@innodb_buffer_pool_chunk_size;
+
+# fill buffer pool
+create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
+create or replace view view0 as select 1 union all select 1;
+
+set @`v_id` := 0;
+set @`v_val` := 0;
+
+# 2^18 == 262144 records
+replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17;
+
+# Shrink buffer pool to 7MB
+set global innodb_buffer_pool_size = 7340032;
+--source include/wait_condition.inc
+
+select count(val) from t1;
+
+# Expand buffer pool to 16MB
+set global innodb_buffer_pool_size = 16777216;
+--source include/wait_condition.inc
+
+select count(val) from t1;
+
+drop table t1;
+drop view view0;
+
+# Try to shrink buffer pool to smaller than chunk size
+set global innodb_buffer_pool_size = 1048576;
+--source include/wait_condition.inc
+select @@innodb_buffer_pool_size;
+
+--disable_query_log
+set global innodb_buffer_pool_size = @old_innodb_buffer_pool_size;
+if (`select (version() like '%debug%') > 0`)
+{
+ set global innodb_disable_resize_buffer_pool_debug = @old_innodb_disable_resize;
+}
+--enable_query_log
+--source include/wait_condition.inc
diff --git a/mysql-test/suite/innodb/t/innodb_bug14147491.test b/mysql-test/suite/innodb/t/innodb_bug14147491.test
index 620b93aae04..44b9d16ca78 100644
--- a/mysql-test/suite/innodb/t/innodb_bug14147491.test
+++ b/mysql-test/suite/innodb/t/innodb_bug14147491.test
@@ -8,12 +8,10 @@
-- source include/not_encrypted.inc
--disable_query_log
-call mtr.add_suppression("InnoDB: Table `test`.`t1` is corrupted. Please drop the table and recreate.");
-call mtr.add_suppression("InnoDB: Cannot open table test/t1 from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.");
-call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page \[page id: space=[0-9]+, page number=[0-9]+\]. You may have to recover from a backup.");
-call mtr.add_suppression("InnoDB: We detected index corruption in an InnoDB type table.*");
-call mtr.add_suppression("mysqld: Index for table 't1' is corrupt; try to repair it");
-call mtr.add_suppression("mysqld.exe: Index for table 't1' is corrupt; try to repair it");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted\\. Please drop the table and recreate\\.");
+call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page");
+call mtr.add_suppression("InnoDB: We detected index corruption in an InnoDB type table");
+call mtr.add_suppression("Index for table 't1' is corrupt; try to repair it");
--enable_query_log
--echo # Ensure that purge will not crash on the table after we corrupt it.
diff --git a/mysql-test/suite/innodb/t/innodb_bulk_create_index.test b/mysql-test/suite/innodb/t/innodb_bulk_create_index.test
new file mode 100644
index 00000000000..534b4de87f7
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bulk_create_index.test
@@ -0,0 +1,46 @@
+######## suite/innodb/t/innodb_bulk_create_index.test #####
+# #
+# Testcase for worklog WL#7277: InnoDB: Bulk Load for Create Index #
+# The basic idea of bulk load is to build an index from bottom up #
+# (also known as sorted index build). #
+# Earlier index was create by repeatedly inserting records #
+# Test scenario : #
+# - Run bulk create index on 10K rows #
+# - Run bulk create index on table with various row types #
+# - Run DML and SELECT after bulk index creation #
+# Creation: #
+# 2014-06-19 Implemented this test as part of WL#7277 #
+# #
+######################################################################
+
+-- source include/not_embedded.inc
+-- source include/innodb_page_size_small.inc
+-- source include/big_test.inc
+
+# Test Row Format: REDUNDANT.
+let $row_format = REDUNDANT;
+-- source suite/innodb/include/innodb_bulk_create_index.inc
+
+# Test Row Format: COMPACT.
+let $row_format = COMPACT;
+-- source suite/innodb/include/innodb_bulk_create_index.inc
+
+# Test Row Format: DYNAMIC.
+let $row_format = DYNAMIC;
+-- source suite/innodb/include/innodb_bulk_create_index.inc
+
+# Test Row Format: COMPRESSED.
+let $row_format = COMPRESSED;
+-- source suite/innodb/include/innodb_bulk_create_index.inc
+
+# Test Fill Factor: 10
+let $row_format = COMPACT;
+SET GLOBAL innodb_fill_factor=10;
+-- source suite/innodb/include/innodb_bulk_create_index.inc
+
+# Test Fill Factor: 50
+let $row_format = COMPACT;
+SET GLOBAL innodb_fill_factor=50;
+-- source suite/innodb/include/innodb_bulk_create_index.inc
+
+SET GLOBAL innodb_fill_factor=default;
diff --git a/mysql-test/suite/innodb/t/innodb_bulk_create_index_debug.test b/mysql-test/suite/innodb/t/innodb_bulk_create_index_debug.test
new file mode 100644
index 00000000000..83a12431802
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bulk_create_index_debug.test
@@ -0,0 +1,23 @@
+#
+# wl#7277: InnoDB: Bulk Load for Create Index
+#
+
+# Test Restart & Crash Recovery.
+-- source include/big_test.inc
+-- source include/innodb_page_size_small.inc
+
+# Test Row Format: REDUNDANT.
+let $row_format = REDUNDANT;
+-- source suite/innodb/include/innodb_bulk_create_index_debug.inc
+
+# Test Row Format: COMPACT.
+let $row_format = COMPACT;
+-- source suite/innodb/include/innodb_bulk_create_index_debug.inc
+
+# Test Row Format: DYNAMIC.
+let $row_format = DYNAMIC;
+-- source suite/innodb/include/innodb_bulk_create_index_debug.inc
+
+# Test Row Format: COMPRESSED.
+let $row_format = COMPRESSED;
+-- source suite/innodb/include/innodb_bulk_create_index_debug.inc
diff --git a/mysql-test/suite/innodb/t/innodb_bulk_create_index_flush.test b/mysql-test/suite/innodb/t/innodb_bulk_create_index_flush.test
new file mode 100644
index 00000000000..cffca0cc773
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bulk_create_index_flush.test
@@ -0,0 +1,75 @@
+#
+# Test flush on error in bulk load to make sure we do a proper cleanup.
+# Note: We flush all dirty pages before applying any online log in bulk load.
+#
+
+-- source include/have_innodb.inc
+-- source include/have_debug.inc
+
+# Create Insert Procedure
+DELIMITER |;
+CREATE PROCEDURE populate_t1()
+BEGIN
+ DECLARE i int DEFAULT 1;
+
+ START TRANSACTION;
+ WHILE (i <= 10000) DO
+ INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+ SET i = i + 1;
+ END WHILE;
+ COMMIT;
+END|
+DELIMITER ;|
+
+CREATE TABLE t1(
+ class INT,
+ id INT,
+ title VARCHAR(100)
+) ENGINE=InnoDB;
+
+-- disable_query_log
+CALL populate_t1();
+-- enable_query_log
+
+SELECT COUNT(*) FROM t1;
+
+SET @saved_dbug= @@SESSION.debug_dbug;
+SET debug_dbug='+d,ib_index_build_fail_before_flush';
+
+-- error ER_QUERY_INTERRUPTED
+CREATE INDEX idx_id ON t1(id);
+
+CHECK TABLE t1;
+
+-- error ER_QUERY_INTERRUPTED
+CREATE INDEX idx_title ON t1(title);
+
+CHECK TABLE t1;
+
+-- error ER_QUERY_INTERRUPTED
+CREATE FULLTEXT INDEX fidx_title ON t1(title);
+
+CHECK TABLE t1;
+
+-- error ER_QUERY_INTERRUPTED
+ALTER TABLE t1 ADD COLUMN content TEXT, FORCE;
+
+CHECK TABLE t1;
+
+SET debug_dbug= @saved_dbug;
+
+INSERT INTO t1 VALUES(10001, 10001, 'a10000');
+
+-- error ER_DUP_ENTRY
+ALTER TABLE t1 ADD UNIQUE INDEX idx_title(title);
+
+CHECK TABLE t1;
+
+-- error ER_DUP_ENTRY
+ALTER TABLE t1 ADD UNIQUE INDEX idx_id(id), ADD UNIQUE INDEX idx_title(title);
+
+CHECK TABLE t1;
+
+DROP TABLE t1;
+
+DROP PROCEDURE populate_t1;
diff --git a/mysql-test/suite/innodb/t/innodb_bulk_create_index_replication.test b/mysql-test/suite/innodb/t/innodb_bulk_create_index_replication.test
new file mode 100644
index 00000000000..5b4eaae7557
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bulk_create_index_replication.test
@@ -0,0 +1,182 @@
+######## suite/innodb/t/innodb_wl7277_1.test #####
+# #
+# Testcase for worklog WL#7277: InnoDB: Bulk Load for Create Index #
+# The basic idea of bulk load is to build an index from bottom up #
+# (also known as sorted index build). #
+# Earlier index was create by repeatedly inserting records #
+# Test scenario : #
+# - Run bulk create index on replication setup #
+# - Run bulk create on partitioned table and see its replictaed #
+# to slave #
+# Creation: #
+# 2014-06-19 Implemented this test as part of WL#7277 #
+# #
+######################################################################
+
+--source include/not_embedded.inc
+-- source include/have_innodb.inc
+-- source include/have_partition.inc
+-- source include/master-slave.inc
+
+-- connection master
+# Create Insert Procedure
+DELIMITER |;
+CREATE PROCEDURE populate_t1(load_even INT)
+BEGIN
+ DECLARE i int DEFAULT 1;
+
+ START TRANSACTION;
+ WHILE (i <= 100) DO
+ IF i%2 = 0 AND load_even = 1 THEN
+ INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+ END IF;
+ IF i%2 != 0 AND load_even != 1 THEN
+ INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+ END IF;
+ SET i = i + 1;
+ END WHILE;
+ COMMIT;
+END|
+DELIMITER ;|
+
+CREATE TABLE t1(
+ class INT,
+ id INT,
+ title VARCHAR(100)
+) ENGINE=InnoDB ;
+
+
+
+
+-- disable_query_log
+# Load half records
+CALL populate_t1(1);
+-- enable_query_log
+
+SELECT COUNT(*) FROM t1;
+
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+
+CREATE INDEX idx_title ON t1(title);
+
+
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE id = 10;
+SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE id = 20;
+SELECT * FROM t1 WHERE title = 'a20';
+
+SELECT * FROM t1 WHERE id = 30;
+SELECT * FROM t1 WHERE title = 'a30';
+
+SELECT * FROM t1 WHERE id = 101;
+SELECT * FROM t1 WHERE title = 'a101';
+
+/*Insert/Update/Delete. */
+DELETE FROM t1 WHERE id < 40 AND id > 30;
+INSERT INTO t1 VALUES(38, 38, 'b38');
+UPDATE t1 SET title = CONCAT('b', id) WHERE id < 30 AND id > 20;
+
+SELECT * FROM t1 WHERE id = 28;
+SELECT * FROM t1 WHERE title = 'a28';
+SELECT * FROM t1 WHERE title = 'b28';
+
+SELECT * FROM t1 WHERE id = 38;
+SELECT * FROM t1 WHERE title = 'a38';
+SELECT * FROM t1 WHERE title = 'b38';
+
+SELECT * FROM t1 WHERE id = 101;
+SELECT * FROM t1 WHERE title = 'a101';
+
+-- disable_query_log
+# Load half records (follow up load)
+CALL populate_t1(0);
+-- enable_query_log
+SELECT COUNT(*) FROM t1;
+
+
+SELECT * FROM t1 WHERE id = 10;
+SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE id = 20;
+SELECT * FROM t1 WHERE title = 'a20';
+
+SELECT * FROM t1 WHERE id = 30;
+SELECT * FROM t1 WHERE title = 'a30';
+
+SELECT * FROM t1 WHERE id = 101;
+SELECT * FROM t1 WHERE title = 'a101';
+
+# Create partition table
+CREATE TABLE t_part (
+ class INT ,
+ id INT ,
+ title VARCHAR(30)
+ ) ENGINE=InnoDB
+ PARTITION BY RANGE(id)
+ SUBPARTITION BY KEY(id)
+ SUBPARTITIONS 4
+ (
+ PARTITION p0 VALUES LESS THAN (5000),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE)
+ );
+INSERT INTO t_part SELECT * FROM t1;
+ALTER TABLE t_part ADD INDEX `idx` (class,id,title(10));
+
+SELECT * FROM t_part WHERE id = 10;
+SELECT * FROM t_part WHERE title = 'a10';
+
+SELECT * FROM t_part WHERE id = 20;
+SELECT * FROM t_part WHERE title = 'a20';
+
+SELECT * FROM t_part WHERE id = 30;
+SELECT * FROM t_part WHERE title = 'a30';
+
+SELECT * FROM t_part WHERE id = 101;
+SELECT * FROM t_part WHERE title = 'a101';
+
+
+--source include/sync_slave_sql_with_master.inc
+-- connection slave
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t_part;
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(*) FROM t_part;
+
+SELECT * FROM t1 WHERE id = 10;
+SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE id = 20;
+SELECT * FROM t1 WHERE title = 'a20';
+
+SELECT * FROM t1 WHERE id = 30;
+SELECT * FROM t1 WHERE title = 'a30';
+
+SELECT * FROM t1 WHERE id = 101;
+SELECT * FROM t1 WHERE title = 'a101';
+
+
+
+SELECT * FROM t_part WHERE id = 10;
+SELECT * FROM t_part WHERE title = 'a10';
+
+SELECT * FROM t_part WHERE id = 20;
+SELECT * FROM t_part WHERE title = 'a20';
+
+SELECT * FROM t_part WHERE id = 30;
+SELECT * FROM t_part WHERE title = 'a30';
+
+SELECT * FROM t_part WHERE id = 101;
+SELECT * FROM t_part WHERE title = 'a101';
+
+
+-- connection master
+DROP PROCEDURE populate_t1;
+DROP TABLE t1;
+DROP TABLE t_part;
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/innodb/t/innodb_bulk_create_index_small.test b/mysql-test/suite/innodb/t/innodb_bulk_create_index_small.test
new file mode 100644
index 00000000000..d04dd59f7e7
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bulk_create_index_small.test
@@ -0,0 +1,148 @@
+#
+# wl#7277: InnoDB: Bulk Load for Create Index
+#
+
+-- source include/innodb_page_size_small.inc
+
+# Create Insert Procedure
+DELIMITER |;
+CREATE PROCEDURE populate_t1()
+BEGIN
+ DECLARE i int DEFAULT 1;
+
+ START TRANSACTION;
+ WHILE (i <= 1000) DO
+ INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
+ SET i = i + 1;
+ END WHILE;
+ COMMIT;
+END|
+DELIMITER ;|
+
+SELECT @@innodb_fill_factor;
+
+# Test Compact Table
+CREATE TABLE t1(
+ class INT,
+ id INT,
+ title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+
+-- disable_query_log
+CALL populate_t1();
+-- enable_query_log
+
+SELECT COUNT(*) FROM t1;
+
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+
+CREATE INDEX idx_title ON t1(title);
+
+/* Check table. */
+CHECK TABLE t1;
+
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE id = 10;
+SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE id = 500;
+SELECT * FROM t1 WHERE title = 'a500';
+
+SELECT * FROM t1 WHERE id = 1000;
+SELECT * FROM t1 WHERE title = 'a1000';
+
+SELECT * FROM t1 WHERE id = 1010;
+SELECT * FROM t1 WHERE title = 'a1010';
+
+DROP TABLE t1;
+
+# Test Blob
+CREATE TABLE t1(
+ a INT PRIMARY KEY,
+ b TEXT,
+ c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+
+INSERT INTO t1 VALUES
+ (1, REPEAT('a',10000), 'a'),
+ (2, REPEAT('b',20000), 'b'),
+ (3, REPEAT('c',40000), 'c'),
+ (4, REPEAT('d',60000), 'd');
+
+ALTER TABLE t1 DROP COLUMN c;
+
+CHECK TABLE t1;
+
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+
+DROP TABLE t1;
+
+SET GLOBAL innodb_file_per_table=default;
+
+# Test Compressed Table
+SET GLOBAL innodb_file_per_table=1;
+
+CREATE TABLE t1(
+ class INT,
+ id INT,
+ title VARCHAR(100)
+) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+
+-- disable_query_log
+CALL populate_t1();
+-- enable_query_log
+
+SELECT COUNT(*) FROM t1;
+
+/* Create index. */
+CREATE INDEX idx_id ON t1(id);
+
+CREATE INDEX idx_title ON t1(title);
+
+/* Check table. */
+CHECK TABLE t1;
+
+/* Select by index. */
+EXPLAIN SELECT * FROM t1 WHERE id = 10;
+EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE id = 10;
+SELECT * FROM t1 WHERE title = 'a10';
+
+SELECT * FROM t1 WHERE id = 500;
+SELECT * FROM t1 WHERE title = 'a500';
+
+SELECT * FROM t1 WHERE id = 1000;
+SELECT * FROM t1 WHERE title = 'a1000';
+
+SELECT * FROM t1 WHERE id = 1010;
+SELECT * FROM t1 WHERE title = 'a1010';
+
+DROP TABLE t1;
+
+# Test Compression & Blob
+CREATE TABLE t1(
+ a INT PRIMARY KEY,
+ b TEXT,
+ c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+
+INSERT INTO t1 VALUES
+ (1, REPEAT('a',10000), 'a'),
+ (2, REPEAT('b',20000), 'b'),
+ (3, REPEAT('c',40000), 'c'),
+ (4, REPEAT('d',60000), 'd');
+
+ALTER TABLE t1 DROP COLUMN c;
+
+CHECK TABLE t1;
+
+SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975;
+
+DROP TABLE t1;
+
+SET GLOBAL innodb_file_per_table=default;
+
+DROP PROCEDURE populate_t1;
diff --git a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test
index 52a318f0fa8..1d723c0bbc3 100644
--- a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test
+++ b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test
@@ -33,9 +33,10 @@ INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+1,z+1 FROM corrupt_bit_test_ā;
select count(*) from corrupt_bit_test_ā;
# This will flag all secondary indexes corrupted
-SET SESSION debug="+d,dict_set_index_corrupted";
+SET @save_dbug = @@SESSION.debug_dbug;
+SET debug_dbug = '+d,dict_set_index_corrupted';
check table corrupt_bit_test_ā;
-SET SESSION debug="-d,dict_set_index_corrupted";
+SET debug_dbug = @save_dbug;
# Cannot create new indexes while corrupted indexes exist
--error ER_INDEX_CORRUPT
diff --git a/mysql-test/suite/innodb/t/innodb_default_row_format.combinations b/mysql-test/suite/innodb/t/innodb_default_row_format.combinations
new file mode 100644
index 00000000000..f3bc2cc0c25
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_default_row_format.combinations
@@ -0,0 +1,4 @@
+[redundant]
+innodb_default_row_format=redundant
+[dynamic]
+innodb_default_row_format=dynamic
diff --git a/mysql-test/suite/innodb/t/innodb_default_row_format.inc b/mysql-test/suite/innodb/t/innodb_default_row_format.inc
new file mode 100644
index 00000000000..15c61dc6342
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_default_row_format.inc
@@ -0,0 +1,2 @@
+# See also innodb_default_row_format.combinations
+--source include/have_innodb.inc
diff --git a/mysql-test/suite/innodb/t/innodb_force_recovery.test b/mysql-test/suite/innodb/t/innodb_force_recovery.test
index f9af16f6609..9dae9f8e7c9 100644
--- a/mysql-test/suite/innodb/t/innodb_force_recovery.test
+++ b/mysql-test/suite/innodb/t/innodb_force_recovery.test
@@ -7,6 +7,7 @@
--disable_query_log
call mtr.add_suppression("InnoDB: Failed to find tablespace for table .* in the cache. Attempting to load the tablespace with space id");
call mtr.add_suppression("InnoDB: Allocated tablespace ID \\d+ for test.t[12], old maximum was");
+call mtr.add_suppression("InnoDB: Allocated tablespace ID \\d+ for mysql.transaction_registry, old maximum was");
--enable_query_log
create table t1(f1 int not null, f2 int not null, index idx(f2))engine=innodb;
diff --git a/mysql-test/suite/innodb/t/innodb_max_recordsize_32k.opt b/mysql-test/suite/innodb/t/innodb_max_recordsize_32k.opt
index f543bd0da39..587a2d7e6c1 100644
--- a/mysql-test/suite/innodb/t/innodb_max_recordsize_32k.opt
+++ b/mysql-test/suite/innodb/t/innodb_max_recordsize_32k.opt
@@ -1,3 +1,4 @@
--innodb-page-size=32K
--innodb_buffer_pool_size=32M
---innodb-stats-persistent=ON
+--skip-innodb-stats-persistent
+--innodb-sys-tablestats
diff --git a/mysql-test/suite/innodb/t/innodb_max_recordsize_32k.test b/mysql-test/suite/innodb/t/innodb_max_recordsize_32k.test
index 138917593da..aa816a9b0e8 100644
--- a/mysql-test/suite/innodb/t/innodb_max_recordsize_32k.test
+++ b/mysql-test/suite/innodb/t/innodb_max_recordsize_32k.test
@@ -6,16 +6,7 @@ call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the
# Check page size 32k
SELECT @@innodb_page_size;
-let $innodb_file_per_table = `SELECT @@innodb_file_per_table`;
-let $innodb_strict_mode = `SELECT @@innodb_strict_mode`;
-
---disable_warnings
-SET GLOBAL innodb_file_per_table=ON;
-SET @@innodb_strict_mode=ON;
---enable_warnings
-
-SELECT @@innodb_file_per_table;
-SELECT @@innodb_strict_mode;
+SET innodb_strict_mode=ON;
# Check the error when the max record length > 16K for innodb_page_size=32k
--error ER_TOO_BIG_ROWSIZE
@@ -356,9 +347,8 @@ INSERT INTO t VALUES (REPEAT('a',65535));
SELECT LENGTH(col) FROM t;
FLUSH TABLE t;
ANALYZE TABLE t;
-# retrieve the number of leaf pages
-SELECT stat_value FROM mysql.innodb_index_stats where database_name = 'test' and table_name= 't' and stat_name='n_leaf_pages';
-SELECT clustered_index_size from mysql.innodb_table_stats where database_name = 'test' and table_name= 't';
+SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE name = 'test/t';
DROP TABLE t;
CREATE TABLE t(col BLOB) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
@@ -369,9 +359,8 @@ INSERT INTO t VALUES (REPEAT('a',65535));
SELECT LENGTH(col) FROM t;
FLUSH TABLE t;
ANALYZE TABLE t;
-# retrieve the number of leaf pages
-SELECT stat_value FROM mysql.innodb_index_stats where database_name = 'test' and table_name= 't' and stat_name='n_leaf_pages';
-SELECT clustered_index_size from mysql.innodb_table_stats where database_name = 'test' and table_name= 't';
+SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE name = 'test/t';
DROP TABLE t;
CREATE TABLE t(col BLOB) ENGINE=InnoDB ROW_FORMAT=COMPACT;
@@ -382,18 +371,6 @@ INSERT INTO t VALUES (REPEAT('a',65535));
SELECT LENGTH(col) FROM t;
FLUSH TABLE t;
ANALYZE TABLE t;
-# retrieve the number of leaf pages
-SELECT stat_value FROM mysql.innodb_index_stats where database_name = 'test' and table_name= 't' and stat_name='n_leaf_pages';
-SELECT clustered_index_size from mysql.innodb_table_stats where database_name = 'test' and table_name= 't';
+SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE name = 'test/t';
DROP TABLE t;
-
-# cleanup
---disable_query_log
---disable_warnings
-eval SET GLOBAL INNODB_FILE_PER_TABLE=$innodb_file_per_table;
-eval SET GLOBAL INNODB_STRICT_MODE=$innodb_strict_mode;
---enable_warnings
---enable_query_log
-
---echo # Success
-
diff --git a/mysql-test/suite/innodb/t/innodb_max_recordsize_64k.opt b/mysql-test/suite/innodb/t/innodb_max_recordsize_64k.opt
index 8c9b8ae1e48..1a8442b841f 100644
--- a/mysql-test/suite/innodb/t/innodb_max_recordsize_64k.opt
+++ b/mysql-test/suite/innodb/t/innodb_max_recordsize_64k.opt
@@ -1,3 +1,4 @@
--innodb-page-size=64K
--innodb_buffer_pool_size=32M
---innodb-stats-persistent=ON
+--skip-innodb-stats-persistent
+--innodb-sys-tablestats
diff --git a/mysql-test/suite/innodb/t/innodb_max_recordsize_64k.test b/mysql-test/suite/innodb/t/innodb_max_recordsize_64k.test
index 7b830096afa..598cc3d77bf 100644
--- a/mysql-test/suite/innodb/t/innodb_max_recordsize_64k.test
+++ b/mysql-test/suite/innodb/t/innodb_max_recordsize_64k.test
@@ -6,16 +6,7 @@ call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the
# Check page size 64k
SELECT @@innodb_page_size;
-let $innodb_file_per_table = `SELECT @@innodb_file_per_table`;
-let $innodb_strict_mode = `SELECT @@innodb_strict_mode`;
-
---disable_warnings
-SET GLOBAL innodb_file_per_table=ON;
-SET @@innodb_strict_mode=ON;
---enable_warnings
-
-SELECT @@innodb_file_per_table;
-SELECT @@innodb_strict_mode;
+SET innodb_strict_mode=ON;
# Check the error when the max record length > 32K for innodb_page_size=64k
--error ER_TOO_BIG_ROWSIZE
@@ -560,9 +551,8 @@ INSERT INTO t VALUES (REPEAT('a',65535));
SELECT LENGTH(col) FROM t;
FLUSH TABLE t;
ANALYZE TABLE t;
-# retrieve the number of leaf pages
-SELECT stat_value FROM mysql.innodb_index_stats where database_name = 'test' and table_name= 't' and stat_name='n_leaf_pages';
-SELECT clustered_index_size from mysql.innodb_table_stats where database_name = 'test' and table_name= 't';
+SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE name = 'test/t';
DROP TABLE t;
CREATE TABLE t(col BLOB) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
@@ -573,9 +563,8 @@ INSERT INTO t VALUES (REPEAT('a',65535));
SELECT LENGTH(col) FROM t;
FLUSH TABLE t;
ANALYZE TABLE t;
-# retrieve the number of leaf pages
-SELECT stat_value FROM mysql.innodb_index_stats where database_name = 'test' and table_name= 't' and stat_name='n_leaf_pages';
-SELECT clustered_index_size from mysql.innodb_table_stats where database_name = 'test' and table_name= 't';
+SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE name = 'test/t';
DROP TABLE t;
CREATE TABLE t(col BLOB) ENGINE=InnoDB ROW_FORMAT=COMPACT;
@@ -586,18 +575,6 @@ INSERT INTO t VALUES (REPEAT('a',65535));
SELECT LENGTH(col) FROM t;
FLUSH TABLE t;
ANALYZE TABLE t;
-# retrieve the number of leaf pages
-SELECT stat_value FROM mysql.innodb_index_stats where database_name = 'test' and table_name= 't' and stat_name='n_leaf_pages';
-SELECT clustered_index_size from mysql.innodb_table_stats where database_name = 'test' and table_name= 't';
+SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE name = 'test/t';
DROP TABLE t;
-
-# cleanup
---disable_query_log
---disable_warnings
-eval SET GLOBAL INNODB_FILE_PER_TABLE=$innodb_file_per_table;
-eval SET GLOBAL INNODB_STRICT_MODE=$innodb_strict_mode;
---enable_warnings
---enable_query_log
-
---echo # Success
-
diff --git a/mysql-test/suite/innodb/t/instant_alter.test b/mysql-test/suite/innodb/t/instant_alter.test
index 4045ce282e8..d95f412fb37 100644
--- a/mysql-test/suite/innodb/t/instant_alter.test
+++ b/mysql-test/suite/innodb/t/instant_alter.test
@@ -56,7 +56,7 @@ eval CREATE TABLE t1
SPATIAL INDEX(c3)) $engine;
INSERT INTO t1 (id, c2) values(1,1);
-SELECT * FROM t1;
+SELECT id,c2,ST_AsText(c3) c3 FROM t1;
--enable_info
ALTER TABLE t1 ADD COLUMN (
@@ -68,7 +68,7 @@ ALTER TABLE t1 ADD INDEX(d3);
BEGIN;
UPDATE t1 SET d3='';
ROLLBACK;
-SELECT * FROM t1;
+SELECT id,c2,ST_AsText(c3) c3, d1, d2, d3, d4 FROM t1;
INSERT INTO t1 (id) VALUES(2),(3),(4),(5),(6);
--enable_info
@@ -80,7 +80,7 @@ CHANGE d4 dfour TIMESTAMP NOT NULL DEFAULT now();
UPDATE t1 SET d3='foo' WHERE id = 2;
UPDATE t1 SET d3=DEFAULT WHERE id = 4;
INSERT INTO t1 SET id = 7;
-SELECT * FROM t1;
+SELECT id,c2,ST_AsText(c3) c3, d1, d2, d3, dfour FROM t1;
CHECK TABLE t1;
# add virtual columns
@@ -106,9 +106,9 @@ UPDATE t1 SET d3 = 'xxxxx' WHERE id = 2;
# transaction rollback
BEGIN;
UPDATE t1 SET d3 = 'xxxxx' WHERE id = 3;
-SELECT * FROM t1 WHERE id = 3;
+SELECT id, c2, ST_AsText(c3) c3, d1, d2, d3, dfour, e1, e2, e3, d5, d6, d7 FROM t1 WHERE id = 3;
ROLLBACK;
-SELECT * FROM t1 WHERE id = 3;
+SELECT id, c2, ST_AsText(c3) c3, d1, d2, d3, dfour, e1, e2, e3, d5, d6, d7 FROM t1 WHERE id = 3;
# NULL to NULL, no change
BEGIN;
@@ -116,9 +116,9 @@ UPDATE t1 SET d7 = NULL WHERE ID = 5;
ROLLBACK;
BEGIN;
UPDATE t1 SET d7 = NULL, d6 = 10 WHERE id = 5;
-SELECT * FROM t1 WHERE id = 5;
+SELECT id, c2, ST_AsText(c3) c3, d1, d2, d3, dfour, e1, e2, e3, d5, d6, d7 FROM t1 WHERE id = 5;
ROLLBACK;
-SELECT * FROM t1 WHERE id = 5;
+SELECT id, c2, ST_AsText(c3) c3, d1, d2, d3, dfour, e1, e2, e3, d5, d6, d7 FROM t1 WHERE id = 5;
# add virtual stored columns; not instant
--enable_info
@@ -128,7 +128,7 @@ ALTER TABLE t1 ADD COLUMN (f1 VARCHAR(20) AS (concat('x', e2)) STORED);
ALTER TABLE t1 ADD COLUMN (d8 VARCHAR(20) DEFAULT 'omnopq');
--disable_info
-SELECT * FROM t1;
+SELECT id, c2, ST_AsText(c3) c3, d1, d2, d3, dfour, e1, e2, e3, d5, d6, d7, f1, d8 FROM t1;
SHOW CREATE TABLE t1;
--enable_info
@@ -160,7 +160,7 @@ COMMIT;
--enable_info
ALTER TABLE t2 ADD COLUMN d1 VARCHAR(2000) DEFAULT REPEAT('asdf',500);
--disable_info
-SELECT * FROM t2;
+SELECT id, c1, ST_AsText(p) p, d1 FROM t2;
# inplace update, rollback
BEGIN;
@@ -206,17 +206,17 @@ eval CREATE TABLE t3
SPATIAL INDEX(c3))
$engine;
INSERT INTO t3(id,c2) VALUES(1,1),(2,2),(3,3);
-SELECT * FROM t3;
+SELECT id, c2, ST_AsText(c3) c3 FROM t3;
--enable_info
ALTER TABLE t3 ADD COLUMN
(c4 DATETIME DEFAULT current_timestamp(),
c5 TIMESTAMP NOT NULL DEFAULT current_timestamp(),
c6 POINT);
-SELECT * FROM t3;
+SELECT id, c2, ST_AsText(c3) c3, c4, c5, c6 FROM t3;
ALTER TABLE t3 ADD COLUMN c7 TIME NOT NULL DEFAULT current_timestamp();
ALTER TABLE t3 ADD COLUMN c8 DATE NOT NULL DEFAULT current_timestamp();
--disable_info
-SELECT * FROM t3;
+SELECT id, c2, ST_AsText(c3) c3, c4, c5, c6, c7, c8 FROM t3;
--enable_info
ALTER TABLE t3 ADD COLUMN t TEXT CHARSET utf8
@@ -230,12 +230,32 @@ ALTER TABLE t3 CHANGE t phrase TEXT DEFAULT 0xc3a4c3a448,
CHANGE b b BLOB NOT NULL DEFAULT 'binary line of business';
--disable_info
INSERT INTO t3 SET id=5, c2=9;
-SELECT * FROM t3;
+SELECT id, c2, ST_AsText(c3) c3, c4, c5, c6, c7, c8, phrase, b FROM t3;
--enable_info
ALTER TABLE t3 DROP c3, DROP c7;
--disable_info
SELECT * FROM t3;
+eval CREATE TABLE t4
+(id INT, foo INT DEFAULT 0, c1 VARCHAR(4000),
+ p GEOMETRY NOT NULL DEFAULT ST_GeomFromText('LINESTRING(0 0,0 1,1 1)'),
+ PRIMARY KEY(id,foo))
+$engine;
+
+INSERT INTO t4 (id,c1) VALUES (1, REPEAT('a', 4000)), (2, REPEAT('a', 4000));
+ALTER TABLE t4 ADD COLUMN d1 INT;
+
+BEGIN;
+UPDATE t4 SET c1 = repeat('1', 4000), foo=1 WHERE id=1;
+INSERT INTO t4 (id,c1) VALUES (1, REPEAT('a', 4000));
+UPDATE t4 SET c1 = repeat('2', 4000), foo=1 WHERE id=2;
+ROLLBACK;
+
+BEGIN;
+UPDATE t4 SET d1 = 1,foo=2 WHERE id=1;
+INSERT INTO t4 (id,foo,c1) VALUES (1, 1, REPEAT('1', 4000));
+COMMIT;
+
eval CREATE TABLE big
(id INT PRIMARY KEY, c1 VARCHAR(4000), c2 VARCHAR(4000), c3 VARCHAR(1000),
p POINT NOT NULL DEFAULT ST_GeomFromText('POINT(0 0)'), SPATIAL INDEX(p))
@@ -279,7 +299,17 @@ WHERE name = 'test/big';
connection default;
--source include/wait_all_purged.inc
-DROP TABLE t1,t2,t3,big;
+DROP TABLE t1,t2,t3,t4,big;
+
+# MDEV-14837 Duplicate primary keys are allowed after ADD COLUMN / UPDATE
+eval CREATE TABLE t1 (a VARCHAR(1) PRIMARY KEY) $engine;
+INSERT INTO t1 SET a='a';
+ALTER TABLE t1 ADD COLUMN b INT NOT NULL DEFAULT 0;
+UPDATE t1 SET b = 1;
+--error ER_DUP_ENTRY
+INSERT INTO t1 SET a='a';
+SELECT * FROM t1;
+DROP TABLE t1;
dec $format;
}
diff --git a/mysql-test/suite/innodb/t/instant_alter_crash.test b/mysql-test/suite/innodb/t/instant_alter_crash.test
index 1bdde904fc2..fe7301b4f78 100644
--- a/mysql-test/suite/innodb/t/instant_alter_crash.test
+++ b/mysql-test/suite/innodb/t/instant_alter_crash.test
@@ -4,6 +4,8 @@
--source include/have_debug.inc
--source include/have_debug_sync.inc
+FLUSH TABLES;
+
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
let MYSQLD_DATADIR=`select @@datadir`;
diff --git a/mysql-test/suite/innodb/t/instant_alter_rollback.test b/mysql-test/suite/innodb/t/instant_alter_rollback.test
index c27f198b4c6..487a60dcbe1 100644
--- a/mysql-test/suite/innodb/t/instant_alter_rollback.test
+++ b/mysql-test/suite/innodb/t/instant_alter_rollback.test
@@ -2,6 +2,9 @@
# The embedded server tests do not support restarting.
--source include/not_embedded.inc
+# Flush any open myisam tables from previous tests
+FLUSH TABLES;
+
--echo #
--echo # MDEV-11369: Instant ADD COLUMN for InnoDB
--echo #
diff --git a/mysql-test/suite/innodb/t/lock_deleted.test b/mysql-test/suite/innodb/t/lock_deleted.test
new file mode 100644
index 00000000000..8dbad90d354
--- /dev/null
+++ b/mysql-test/suite/innodb/t/lock_deleted.test
@@ -0,0 +1,72 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+
+--source include/count_sessions.inc
+
+connect(stop_purge, localhost, root,,);
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connect(delete, localhost, root,,);
+connection default;
+
+CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(1,1);
+DELETE FROM t1;
+
+let $i=2;
+while ($i) {
+let $iso= `SELECT CASE $i WHEN 1 THEN 'UNCOMMITTED' ELSE 'COMMITTED' END`;
+
+SET DEBUG_SYNC='row_ins_sec_index_unique SIGNAL inserted WAIT_FOR locked';
+BEGIN;
+send INSERT INTO t1 VALUES(1,1);
+
+connection delete;
+SET DEBUG_SYNC='now WAIT_FOR inserted';
+SET DEBUG_SYNC='innodb_row_search_for_mysql_exit SIGNAL locked';
+eval SET SESSION TRANSACTION ISOLATION LEVEL READ $iso;
+BEGIN;
+send DELETE FROM t1 WHERE b=1;
+
+connection default;
+reap;
+connection delete;
+reap;
+COMMIT;
+
+connection default;
+SET DEBUG_SYNC='RESET';
+ROLLBACK;
+
+dec $i;
+}
+
+SET DEBUG_SYNC='row_ins_sec_index_unique SIGNAL inserted WAIT_FOR locked';
+BEGIN;
+SET innodb_lock_wait_timeout=1;
+send INSERT INTO t1 VALUES(1,1);
+
+connection delete;
+SET DEBUG_SYNC='now WAIT_FOR inserted';
+SET DEBUG_SYNC='innodb_row_search_for_mysql_exit SIGNAL locked';
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+send DELETE FROM t1 WHERE b=1;
+
+connection default;
+--error ER_LOCK_WAIT_TIMEOUT
+reap;
+COMMIT;
+SET DEBUG_SYNC='RESET';
+
+connection delete;
+reap;
+COMMIT;
+
+disconnect delete;
+disconnect stop_purge;
+
+connection default;
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/innodb/t/log_corruption.test b/mysql-test/suite/innodb/t/log_corruption.test
index 3bf68cab4cc..e9b081cff76 100644
--- a/mysql-test/suite/innodb/t/log_corruption.test
+++ b/mysql-test/suite/innodb/t/log_corruption.test
@@ -16,6 +16,7 @@ call mtr.add_suppression("InnoDB: Log scan aborted at LSN");
call mtr.add_suppression("InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT for tablespace 42\\r?$");
call mtr.add_suppression("InnoDB: Obtaining redo log encryption key version 1 failed");
call mtr.add_suppression("InnoDB: Decrypting checkpoint failed");
+call mtr.add_suppression("InnoDB: Are you sure you are using the right ib_logfiles to start up the database\\? Log sequence number in the ib_logfiles is 1213964,");
--enable_query_log
let bugdir= $MYSQLTEST_VARDIR/tmp/log_corruption;
@@ -140,6 +141,24 @@ eval $check_no_innodb;
let SEARCH_PATTERN=InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\\.2\\.2, and it appears corrupted;
--source include/search_pattern_in_file.inc
+--echo # empty redo log from before MariaDB 10.2.2
+perl;
+die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0";
+binmode OUT;
+die unless seek(OUT, 0x800, 0);
+print OUT pack("NnnNx[496]N", 0x80000944, 12, 12, 0, 0xb2a);
+close OUT or die;
+EOF
+--let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=1m
+--source include/start_mysqld.inc
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES
+WHERE engine = 'innodb'
+AND support IN ('YES', 'DEFAULT', 'ENABLED');
+--source include/shutdown_mysqld.inc
+--let SEARCH_PATTERN= InnoDB: Upgrading redo log:
+--source include/search_pattern_in_file.inc
+--let $restart_parameters= $dirs
+
--echo # redo log from "after" MariaDB 10.2.2, but with invalid header checksum
perl;
die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0";
@@ -204,7 +223,9 @@ EOF
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
-let SEARCH_PATTERN=InnoDB: Upgrade after a crash is not supported\. The redo log was created with malicious intentions, or perhaps, and it appears corrupted\.;
+let SEARCH_PATTERN=InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 3362026715 found: 144444122;
+--source include/search_pattern_in_file.inc
+let SEARCH_PATTERN=InnoDB: Missing MLOG_CHECKPOINT between the checkpoint 1213964 and the end 1213952\.;
--source include/search_pattern_in_file.inc
--echo # same, but with current-version header
@@ -334,13 +355,14 @@ let SEARCH_PATTERN=InnoDB: MLOG_FILE_NAME incorrect:bigot;
--let SEARCH_PATTERN= len 22; hex 38000000000012860cb7809781e800066269676f7400; asc 8 bigot ;
--source include/search_pattern_in_file.inc
---echo # missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT
+--echo # 10.2 missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT
perl;
die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0";
binmode OUT;
# header block
-print OUT pack("Nx[5]nx[5]", 103, 0x1286), "MariaDB 10.3.1";
-print OUT pack("x[478]N", 0x85021a0f);
+print OUT pack("Nx[5]nx[5]", 1, 0x1286);
+print OUT "ibbackup was here!!!1!";
+print OUT pack("x[470]N", 0x52b54540);
# invalid (all-zero) checkpoint page 1 and an empty log page
print OUT chr(0) x 1024;
# valid checkpoint block 2
@@ -361,7 +383,74 @@ EOF
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
---let SEARCH_PATTERN= InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT for tablespace 42\$
+--let SEARCH_PATTERN= InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT for tablespace 42
+--source include/search_pattern_in_file.inc
+
+--echo # 10.3 missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT
+perl;
+die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0";
+binmode OUT;
+print OUT pack("Nx[5]nx[5]", 103, 0x1286), "MariaDB 10.3.1";
+print OUT pack("x[478]N", 0x85021a0f);
+close OUT or die;
+EOF
+
+--source include/start_mysqld.inc
+eval $check_no_innodb;
+--source include/shutdown_mysqld.inc
+--let SEARCH_PATTERN= InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT for tablespace 42
+--source include/search_pattern_in_file.inc
+
+--echo # Empty 10.3 redo log
+perl;
+die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0";
+binmode OUT;
+die unless seek(OUT, 0x800, 0);
+print OUT pack("NnnNx[496]N", 0x80000944, 12, 12, 1, 0x46c8a2a2);
+close OUT or die;
+EOF
+
+--let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=1m
+--source include/start_mysqld.inc
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES
+WHERE engine = 'innodb'
+AND support IN ('YES', 'DEFAULT', 'ENABLED');
+--source include/shutdown_mysqld.inc
+# In encryption.innodb_encrypt_log_corruption, we would convert the
+# log to encrypted format. Writing an extra log checkpoint before the
+# redo log conversion would advance the LSN by the size of a
+# MLOG_CHECKPOINT record (9 bytes).
+--let SEARCH_PATTERN= InnoDB: .* started; log sequence number 121397[09]
+--source include/search_pattern_in_file.inc
+
+--echo # Empty 10.2 redo log
+perl;
+die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0";
+binmode OUT;
+# header block
+print OUT pack("Nx[5]nx[5]", 1, 0x1286);
+print OUT "ibbackup was here!!!1!";
+print OUT pack("x[470]N", 0x52b54540);
+# In encryption.innodb_log_corruption the previous step would
+# replace the block with an encrypted one and update the checkpoint.
+# Restore them.
+# invalid (all-zero) checkpoint page 1 and an empty log page
+print OUT chr(0) x 1024;
+# valid checkpoint block 2
+print OUT pack("x[12]NNNx[264]", 0x12860c, 0, 0x80c);
+# pointer to the MLOG_CHECKPOINT record, and checkpoint page checksum
+print OUT pack("H*x[204]NNN", "590DBAACFE922582", 0x128612, 0, 0x101741b);
+# log page
+print OUT pack("NnnNx[496]N", 0x80000944, 12, 12, 1, 0x46c8a2a2);
+close OUT or die;
+EOF
+
+--source include/start_mysqld.inc
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES
+WHERE engine = 'innodb'
+AND support IN ('YES', 'DEFAULT', 'ENABLED');
+--source include/shutdown_mysqld.inc
+--let SEARCH_PATTERN= InnoDB: Upgrading redo log:
--source include/search_pattern_in_file.inc
--echo # Minimal MariaDB 10.1.21 encrypted redo log
diff --git a/mysql-test/suite/innodb/t/log_file_name.test b/mysql-test/suite/innodb/t/log_file_name.test
index 2ee8c49aa7c..87c1681d443 100644
--- a/mysql-test/suite/innodb/t/log_file_name.test
+++ b/mysql-test/suite/innodb/t/log_file_name.test
@@ -163,6 +163,7 @@ call mtr.add_suppression("InnoDB: Cannot rename.*because the target file exists"
call mtr.add_suppression("InnoDB: Log scan aborted at LSN");
# The following are for the --innodb-force-recovery=1 with broken u* tables:
call mtr.add_suppression("InnoDB: Header page consists of zero bytes in datafile: .*u1.ibd");
+call mtr.add_suppression("InnoDB: The size of the file .*u1\\.ibd is only 16384 bytes, should be at least 65536");
call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified");
call mtr.add_suppression("InnoDB: .*you must create directories");
call mtr.add_suppression("InnoDB: Cannot open datafile for read-only: '.*u[1-5]\.ibd'");
diff --git a/mysql-test/suite/innodb/t/log_file_size.test b/mysql-test/suite/innodb/t/log_file_size.test
index 140198de4ab..44cb155c7d9 100644
--- a/mysql-test/suite/innodb/t/log_file_size.test
+++ b/mysql-test/suite/innodb/t/log_file_size.test
@@ -17,7 +17,8 @@ call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE faile
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: Cannot (create|resize) log files in read-only mode");
+call mtr.add_suppression("InnoDB: Can't initiate database recovery, running 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");
diff --git a/mysql-test/suite/innodb/t/mvcc.test b/mysql-test/suite/innodb/t/mvcc.test
new file mode 100644
index 00000000000..bf76a5de798
--- /dev/null
+++ b/mysql-test/suite/innodb/t/mvcc.test
@@ -0,0 +1,52 @@
+--source include/have_innodb.inc
+
+SET @save_per_table= @@GLOBAL.innodb_file_per_table;
+SET GLOBAL innodb_file_per_table= 1;
+
+let MYSQLD_DATADIR =`SELECT @@datadir`;
+
+--echo #
+--echo # MDEV-15249 Crash in MVCC read after IMPORT TABLESPACE
+--echo #
+
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(0);
+FLUSH TABLES t1 WITH READ LOCK;
+perl;
+do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
+ib_backup_tablespace("test", "t1");
+EOF
+UNLOCK TABLES;
+
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+
+connect (con1,localhost,root,,);
+ALTER TABLE t1 FORCE, ALGORITHM=COPY;
+
+connection default;
+--error ER_TABLE_DEF_CHANGED
+SELECT * FROM t1;
+COMMIT;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+
+connection con1;
+
+ALTER TABLE t1 DISCARD TABLESPACE;
+
+perl;
+do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
+ib_restore_tablespace("test", "t1");
+EOF
+
+ALTER TABLE t1 IMPORT TABLESPACE;
+disconnect con1;
+
+connection default;
+--echo # FIXME: Block this with ER_TABLE_DEF_CHANGED
+SELECT * FROM t1;
+COMMIT;
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+SET GLOBAL innodb_file_per_table= @save_per_table;
diff --git a/mysql-test/suite/innodb/t/purge_secondary.opt b/mysql-test/suite/innodb/t/purge_secondary.opt
new file mode 100644
index 00000000000..99bf0e5a28b
--- /dev/null
+++ b/mysql-test/suite/innodb/t/purge_secondary.opt
@@ -0,0 +1 @@
+--innodb-sys-tablestats
diff --git a/mysql-test/suite/innodb/t/purge_secondary.test b/mysql-test/suite/innodb/t/purge_secondary.test
new file mode 100644
index 00000000000..47cfaec41ca
--- /dev/null
+++ b/mysql-test/suite/innodb/t/purge_secondary.test
@@ -0,0 +1,131 @@
+--source include/have_innodb.inc
+
+# Ensure that the history list length will actually be decremented by purge.
+SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
+SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
+
+CREATE TABLE t1 (
+ a SERIAL, b CHAR(255) NOT NULL DEFAULT '', c BOOLEAN DEFAULT false,
+ l LINESTRING NOT NULL DEFAULT ST_linefromtext('linestring(448 -689,
+ 453 -684,451 -679,453 -677,458 -681,463 -681,468 -678,470 -676,470 -678,
+ 468 -675,472 -675,472 -675,474 -674,479 -676,477 -675,473 -676,475 1324,
+ 479 1319,484 1322,483 1323,486 1323,491 1328,492 1325,496 1325,498 1325,
+ 501 1330,498 1331,500 1331,504 1330,508 1329,512 1332,513 1337,518 1339,
+ 518 1339,513 1344,513 1344,512 1346,514 1351,515 1353,519 1358,518 1362,
+ 522 1365,525 1360,526 1362,527 1362,528 1367,525 1371,528 1366,532 1369,
+ 536 1374,539 1377,543 1379,539 1381,541 1382,543 1383,546 1388,549 1393,
+ 554 1393,554 1395,554 1392,550 1394,550 1392,546 1394,549 1397,550 1393,
+ 549 1394,554 1390,554 1391,549 1396,551 1396,547 1400,547 1402,551 1407,
+ 554 1412,554 1415,558 1418,463 -681,465 -677,465 -675,470 -670,470 -665,
+ 470 -660,470 -659,473 -656,476 -656,481 -655,482 -652,486 -654,486 -652,
+ 486 -648,491 -646,490 -651,494 -646,493 -644,493 -644,490 -644,491 2356,
+ 495 2359,495 2364,500 2359,503 5359,504 5364,509 5368,504 5367,499 5368,
+ 498 5371,498 5369,500 5370,504 5370,508 5370,511 5370,507 5374,508 5378,
+ 511 5382,507 5387,509 5389,512 5388,515 5393,520 5396,517 5397,517 5402,
+ 515 5404,520 5402,521 5405,525 5405,526 5408,530 7408,535 7413,533 7415,
+ 529 7412,532 7416,4532 7416,4534 7421,4533 7417,4536 7413,4536 7418,
+ 4540 3418,4545 3418,4549 3415,4551 3419,4554 3421,4559 3423,4559 3426,
+ 4557 3424,4561 3428,4558 3428,4563 3431,4565 3435,4569 3439,4569 3439,
+ 4569 3444,4567 3444,4572 3446,4577 3447,4581 3444,4581 3448,4584 3448,
+ 4579 3447,4580 3450,4583 3449,4583 3453,4587 3455,4588 3458,4593 3463,
+ 4598 3465,4601 3468,4598 3464,4598 3460,4593 5460,4595 5461,4600 5464,
+ 4600 5465,4601 5466,4606 5466,4608 5466,4605 5464,4608 5467,4607 5468,
+ 4609 5465,4614 5461,4618 5463,4621 5467,4623 5470,4622 5470,4622 5470,
+ 4625 6470,4627 6471,4627 6472,4627 6473,6627 6474,6625 6474,6628 6477,
+ 6633 6481,6633 6480,6637 6475,7637 6479,7638 6482,7643 6487,7644 6492,
+ 7647 6492,7648 6495,7646 6498,7650 6499,7646 6494,7644 6499,7644 6497,
+ 7644 6499,7647 6502,7649 6504,7650 6501,7647 6503,7649 6504,7650 6508,
+ 7651 6503,7652 6508,7655 6508,7650 6511,7655 6515,7658 6513,7663 6513,
+ 7665 6514,7669 6512,7667 6510,7664 6510,472 -675,477 -670,479 -666,
+ 482 -663,484 -668,484 -666,485 -664,481 -664,479 -659,482 -659,484 -658,
+ 483 -659,488 2341,493 2339,489 2338,491 2342,491 2346,494 2346,490 2348,
+ 493 2348,498 2349,498 2350,499 2349,502 2350,503 2348,506 2348,506 2348,
+ 507 2353,507 2355,504 2359,504 2364,504 2361,499 2365,502 2360,502 2358,
+ 503 2357,504 2353,504 2357,500 2356,497 2355,498 2355,500 2359,502 2361,
+ 505 2364,508 2364,506 2368,506 2370,504 2373,499 2373,496 2372,493 2377,
+ 497 2380,495 2383,496 7383,493 7386,497 7391,494 7387,495 7389,498 7392,
+ 498 7392,495 7395,493 7398,498 7401,498 7403,503 7400,498 8400,501 8401,
+ 503 8401,503 8401,501 10401,496 10396,491 10401,492 10399,493 10403,
+ 496 10403,491 10403,493 10407,489 10410,493 10407,489 10403,498 7403,
+ 497 7399,496 7403,500 7405,500 7407,503 7411,508 7415,511 7415,511 7420,
+ 515 7420,520 7423,523 7423,520 7427,523 7427,523 7427,522 7432,525 4432,
+ 527 4434,530 4437,534 4441,529 4446,529 4441,534 4436,537 4436,535 4437,
+ 532 4437,534 4432,535 4429,538 4430,542 4427,542 4431,538 4431,541 4431,
+ 541 4433,543 4433,545 4432,549 4428,552 4426,556 4427,557 4423,560 4427,
+ 561 4428,558 4430,559 4434,559 4432,561 4434,561 4437,563 4435,559 4430,
+ 561 4435,4561 4437,4566 4441,4568 4446,4568 4450,4569 4455,4565 4458,
+ 4561 4463,4561 9463,4564 9463,4565 9461,9565 9463,9560 9467,9560 9466,
+ 9555 9469,9555 9471,9559 9469,9557 9473,9553 9478,9555 9480,9557 9481,
+ 9557 9481,9557 9483,9562 9487,9558 9487,9558 9490,9561 9493,9562 9493,
+ 9557 9493,9560 9496,9555 9501,9553 9503,9553 9506,9557 9510,9558 9511,
+ 9561 9514,9563 9512,9568 9514,9567 9514,9567 13514,9570 13517,9566 13521,
+ 9571 13521,9571 13526,9573 13521,9571 13521,9576 10521,9580 10526,9582 10525,
+ 9584 10528,9584 10531,9584 10533,9589 10533,9588 10537,9588 10541,9589 10542,
+ 9593 10544,9595 10540,9597 10541,9600 10545,9601 15545,9603 15549,9605 15553,
+ 9601 15558,9601 15553,9605 15551,9605 15550,9605 15554,9607 15556,9605 15556,
+ 9604 15561,9607 15559,9603 15559,9603 15562,9604 15563,9608 15566,9612 15570,
+ 9617 15565,9622 15568,9627 15566,9628 15564,9629 15564,9633 15569,9636 15569,
+ 9634 15571,9634 15572,9636 15574,9634 15570,9629 15570,9631 15567,9629 15570,
+ 9626 15574,9626 15575,498 7401,502 7401,506 7397,506 7395,502 7398,497 7401,
+ 502 7402,505 7397,508 7400,504 7404,3504 7409,3505 7405,3508 7410,3511 7413,
+ 3511 7416,3511 7419,3511 7419,3513 7421,3517 7424,3519 7426,3520 11426,
+ 3523 11421,3527 11418,3530 11415,3530 11416,3533 11418,7533 11415,7531 11415,
+ 7531 11417,7536 11420,7541 11424,7543 11425,7543 11427,7543 11429,7540 11429,
+ 7542 11425,7541 11420,7542 11421,7542 11422,7540 11424,7540 11423,7543 11422,
+ 7546 11426,7550 11431,7553 11436,7555 16436,7553 16438,7558 16438,7559 16438,
+ 7560 16439,7565 16437,7560 16435,7563 16435,7566 16440,7566 16444,7564 16447,
+ 7559 16443,7561 16443,7566 16448,7570 16451,7574 16456,7578 16459,
+ 12578 16459,12578 20459,12577 20456,12581 20454,12585 20456,12585 20456,
+ 12585 20456,12583 20456,12579 20459,12580 20461,12580 20462,12580 20460,
+ 12585 20465,12586 20467,12590 20470,12590 20470,12589 20471,12584 20471,
+ 12589 20471,9589 20472,9594 20472,9595 20472,9596 20477,9598 20482,
+ 9603 20480,9608 20484,9613 20484,9610 20486,9608 20488,9608 20489,9610 20489,
+ 9614 20486,9619 20481,9620 20481,9618 21481,9621 21483,9626 21483,9628 21485,
+ 9623 21487,9622 21490,9626 21493,9621 21495,9626 21498,9622 21499,9624 21504,
+ 9625 21499,9629 21501,9633 21498,9637 21495,9639 21498,9644 21501,9557 9481,
+ 9560 9485,9561 9490,9563 9488,9560 9486,9558 9488,9561 9492,9563 9495,
+ 9567 9492,9567 9488,9564 9490,9559 9495,9559 9498,9557 9502,9562 9506,
+ 9564 9509,9569 9512,9569 9516,9569 9518,9569 9515,9571 9513,9571 9512,
+ 9573 9513,9578 9516,9581 9516,9585 11516,9585 11521,9590 10521,9586 10524,
+ 9589 10529,9589 10527,9589 10527,9594 10532,9594 10534,9598 10536,9598 10540,
+ 9600 10542,9604 10538,9607 10538,9609 10543,9613 10538,9613 10533,9613 10537,
+ 9610 10537,9614 10542,9609 10542,9610 10543,9610 10548,9611 10553,9616 7553,
+ 9620 7553,9621 7557,9618 7559,9618 7554,9622 7557,9622 7561,9622 7556,
+ 9622 7560,9619 7560,9620 7565,9622 7563,9627 7566,9630 7570,9630 7571,
+ 9632 7573,9637 7576,9639 7578,9640 7576,9640 7579,9640 7575,9642 7570,
+ 9646 7570,9651 7574,9653 7577,9652 7572,9653 7576,9653 7576,9651 7581,
+ 9656 7585,9660 7586,9659 7591,9657 7594,9661 7598,9664 7602,9668 12602,
+ 9673 12604,9676 12606,9679 12602,9682 12605,9677 12610,9674 12606,9674 12601,
+ 9674 12603,9672 9603,9668 9605,9671 9606,9668 9611,9668 9606,9671 9611,
+ 9675 9615,9677 9620,9678 9622,9679 9624,9684 9626,9685 9627,9685 9622,
+ 9685 9626,9689 9628,9694 9633,9699 9637,9699 9637,9704 9636,9708 9637,
+ 9709 9638,9707 9639,9705 9642,9707 9647,9710 9649,9711 9653,9716 9649,
+ 9716 9648,9720 9650,9721 9648,9723 9648,9726 4648,12726 4653,12731 4655,
+ 12734 4660,12730 4661,12733 4664,12733 4665,12735 4670,12737 4674,12741 4674,
+ 12738 4675,12740 4675,12737 4675,12742 4678,12743 4681,12746 4677)'),
+ INDEX(b,c), SPATIAL INDEX(l)
+) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+INSERT INTO t1 () VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),();
+SELECT LENGTH(l) FROM t1;
+INSERT INTO t1 (a) SELECT NULL FROM t1;
+INSERT INTO t1 (a) SELECT NULL FROM t1;
+CHECK TABLE t1;
+UPDATE t1 SET c=true, l=ST_linefromtext('linestring(0 0,1 1,2 2)');
+DELETE FROM t1;
+CHECK TABLE t1;
+
+source include/wait_all_purged.inc;
+
+ANALYZE TABLE t1;
+SELECT OTHER_INDEX_SIZE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
+WHERE NAME='test/t1';
+
+--echo # Note: The OTHER_INDEX_SIZE does not cover any SPATIAL INDEX.
+--echo # To test that all indexes were emptied, replace DROP TABLE
+--echo # with the following, and examine the root pages in t1.ibd:
+--echo # FLUSH TABLES t1 FOR EXPORT;
+--echo # UNLOCK TABLES;
+
+DROP TABLE t1;
+
+SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
diff --git a/mysql-test/suite/innodb/t/read_only_recover_committed.test b/mysql-test/suite/innodb/t/read_only_recover_committed.test
new file mode 100644
index 00000000000..c75b91d05db
--- /dev/null
+++ b/mysql-test/suite/innodb/t/read_only_recover_committed.test
@@ -0,0 +1,67 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+# need to restart server
+--source include/not_embedded.inc
+
+--connect(con1, localhost, root)
+CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t VALUES(1);
+BEGIN;
+# Generate insert_undo log.
+INSERT INTO t VALUES(2);
+# Generate update_undo log.
+DELETE FROM t WHERE a=2;
+--connect(con2, localhost, root)
+--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 # Create another transaction that will be recovered as COMMITTED.
+BEGIN;
+# Generate multiple pages of both insert_undo and update_undo, so that
+# the state TRX_UNDO_CACHE will not be chosen.
+--disable_query_log
+let $n= 10000;
+while ($n) {
+dec $n;
+eval INSERT INTO t VALUES(-$n);
+eval DELETE FROM t WHERE a=-$n;
+}
+--enable_query_log
+SET DEBUG_SYNC='after_trx_committed_in_memory SIGNAL committed WAIT_FOR ever';
+send COMMIT;
+
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR committed';
+--echo # Ensure that the above incomplete transactions become durable.
+SET GLOBAL innodb_flush_log_at_trx_commit=1;
+BEGIN;
+INSERT INTO t VALUES(-10000);
+ROLLBACK;
+--let $restart_parameters= --innodb-force-recovery=3
+--let $shutdown_timeout= 0
+--source include/restart_mysqld.inc
+--let $shutdown_timeout= 30
+--disconnect con1
+--disconnect con2
+SELECT * FROM t;
+SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+SELECT * FROM t;
+# refused on MySQL 5.6, MariaDB 10.0, 10.1, but not MariaDB 10.2+
+UPDATE t SET a=3 WHERE a=1;
+--let $restart_parameters= --innodb-read-only
+--source include/restart_mysqld.inc
+--echo # Starting with MariaDB 10.2, innodb_read_only implies READ UNCOMMITTED.
+--echo # In earlier versions, this would return the last committed version
+--echo # (empty table)!
+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;
+let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
+--let SEARCH_PATTERN= Rolled back recovered transaction [^0]
+--source include/search_pattern_in_file.inc
diff --git a/mysql-test/suite/innodb/t/read_only_recovery.test b/mysql-test/suite/innodb/t/read_only_recovery.test
index aea676d3644..7da012efb74 100644
--- a/mysql-test/suite/innodb/t/read_only_recovery.test
+++ b/mysql-test/suite/innodb/t/read_only_recovery.test
@@ -41,3 +41,6 @@ SELECT * FROM t;
--source include/restart_mysqld.inc
SELECT * FROM t;
DROP TABLE t;
+let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
+--let SEARCH_PATTERN= Rolled back recovered transaction [^0]
+--source include/search_pattern_in_file.inc
diff --git a/mysql-test/suite/innodb/t/recovery_shutdown.test b/mysql-test/suite/innodb/t/recovery_shutdown.test
new file mode 100644
index 00000000000..d796189c724
--- /dev/null
+++ b/mysql-test/suite/innodb/t/recovery_shutdown.test
@@ -0,0 +1,64 @@
+--source include/have_innodb.inc
+--source include/not_embedded.inc
+
+# Flush any open myisam tables from previous tests
+FLUSH TABLES;
+
+--echo #
+--echo # MDEV-13797 InnoDB may hang if shutdown is initiated soon after startup
+--echo # while rolling back recovered incomplete transactions
+--echo #
+
+CREATE TABLE t (a INT) ENGINE=InnoDB;
+let $size = 100;
+let $trx = 8;
+let $c = $size;
+BEGIN;
+--disable_query_log
+while ($c) {
+INSERT INTO t VALUES();
+dec $c;
+}
+--enable_query_log
+COMMIT;
+
+let $c = $trx;
+while ($c)
+{
+connect (con$c,localhost,root,,);
+eval CREATE TABLE t$c (a SERIAL, b INT UNIQUE, c INT UNIQUE) ENGINE=InnoDB;
+BEGIN;
+eval INSERT INTO t$c (a) SELECT NULL FROM t;
+eval UPDATE t$c SET a=a+$size, b=a;
+eval DELETE FROM t$c;
+dec $c;
+}
+
+INSERT INTO t1(a) SELECT NULL FROM t;
+INSERT INTO t1(a) SELECT NULL FROM t1;
+INSERT INTO t1(a) SELECT NULL FROM t1;
+INSERT INTO t1(a) SELECT NULL FROM t1;
+INSERT INTO t1(a) SELECT NULL FROM t1;
+
+--connection default
+SET GLOBAL innodb_flush_log_at_trx_commit=1;
+CREATE TABLE u(a SERIAL) ENGINE=INNODB;
+
+FLUSH TABLES;
+
+--let $shutdown_timeout=0
+--source include/restart_mysqld.inc
+--let $shutdown_timeout=60
+--source include/restart_mysqld.inc
+
+--disable_query_log
+let $c = $trx;
+while ($c)
+{
+disconnect con$c;
+eval DROP TABLE t$c;
+dec $c;
+}
+--enable_query_log
+
+DROP TABLE t,u;
diff --git a/mysql-test/suite/innodb/t/rename_table_debug.test b/mysql-test/suite/innodb/t/rename_table_debug.test
new file mode 100644
index 00000000000..df4331cf8bb
--- /dev/null
+++ b/mysql-test/suite/innodb/t/rename_table_debug.test
@@ -0,0 +1,21 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/not_embedded.inc
+
+LET $datadir= `SELECT @@datadir`;
+
+CREATE TABLE t1 (a SERIAL, b INT, c INT, d INT) ENGINE=InnoDB;
+INSERT INTO t1 () VALUES ();
+
+--connect (con1,localhost,root,,test)
+SET DEBUG_SYNC='before_rename_table_commit SIGNAL renamed WAIT_FOR ever';
+--send
+RENAME TABLE t1 TO t2;
+--connection default
+SET DEBUG_SYNC='now WAIT_FOR renamed';
+--let $shutdown_timeout=0
+--source include/restart_mysqld.inc
+--disconnect con1
+SELECT * FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/restart.test b/mysql-test/suite/innodb/t/restart.test
new file mode 100644
index 00000000000..2fd7ca244e5
--- /dev/null
+++ b/mysql-test/suite/innodb/t/restart.test
@@ -0,0 +1,80 @@
+--source include/innodb_page_size.inc
+--source include/not_embedded.inc
+
+let datadir= `select @@datadir`;
+let page_size= `select @@innodb_page_size`;
+
+--echo #
+--echo # MDEV-15333 MariaDB (still) slow start
+--echo #
+
+# Ensure that on normal startup, no data files are read.
+# Note: just like in MySQL, all .ibd files will still be
+# opened at least once.
+
+--echo # FIXME: Unlike MySQL, maybe MariaDB should not read the .ibd files
+--echo # of tables with .isl file or DATA DIRECTORY attribute.
+call mtr.add_suppression("\\[ERROR\\] InnoDB: Invalid flags 0x7a207879 in .*td\\.ibd");
+--echo # FIXME: This is much more noisy than MariaDB 10.1!
+call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot read first page in datafile: .*td\\.ibd, Space ID:2048948345, Flags: 2048948345");
+call mtr.add_suppression("\\[ERROR\\] InnoDB: Operating system error number .* in a file operation\\.");
+call mtr.add_suppression("\\[ERROR\\] InnoDB: The error means the system cannot find the path specified\\.");
+call mtr.add_suppression("\\[ERROR\\] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them\\.");
+call mtr.add_suppression("\\[Warning\\] InnoDB: Ignoring tablespace for `test`\\.`td` because it could not be opened\\.");
+
+CREATE TABLE tr(a INT)ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+CREATE TABLE tc(a INT)ENGINE=InnoDB ROW_FORMAT=COMPACT
+PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=9;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval CREATE TABLE td(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC
+STATS_PERSISTENT=0 DATA DIRECTORY='$MYSQL_TMP_DIR';
+
+--source include/shutdown_mysqld.inc
+
+--move_file $datadir/test/tr.ibd $datadir/test/tr0.ibd
+--move_file $datadir/test/tc.ibd $datadir/test/tc0.ibd
+--move_file $MYSQL_TMP_DIR/test/td.ibd $datadir/test/td0.ibd
+# TODO: test that MariaDB does not even attempt to open the files
+#--mkdir $datadir/test/tr.ibd
+#--mkdir $datadir/test/tc.ibd
+#--mkdir $MYSQL_TMP_DIR/test/td.ibd
+
+perl;
+die unless open OUT, ">", "$ENV{datadir}/test/tr.ibd";
+print OUT "foo " x $ENV{page_size};
+close OUT or die;
+die unless open OUT, ">", "$ENV{datadir}/test/tc.ibd";
+print OUT "bar " x $ENV{page_size};
+close OUT or die;
+die unless open OUT, ">", "$ENV{MYSQL_TMP_DIR}/test/td.ibd";
+print OUT "xyz " x $ENV{page_size};
+close OUT or die;
+EOF
+
+--let $restart_parameters= --skip-innodb-buffer-pool-load-at-startup
+--source include/start_mysqld.inc
+--let $restart_parameters=
+
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES
+WHERE engine = 'innodb'
+AND support IN ('YES', 'DEFAULT', 'ENABLED');
+
+--source include/shutdown_mysqld.inc
+
+# TODO: test that MariaDB does not even attempt to open the files
+#--rmdir $datadir/test/tr.ibd
+#--rmdir $datadir/test/tc.ibd
+#--rmdir $MYSQL_TMP_DIR/test/td.ibd
+--remove_file $datadir/test/tr.ibd
+--remove_file $datadir/test/tc.ibd
+--remove_file $MYSQL_TMP_DIR/test/td.ibd
+
+--move_file $datadir/test/tr0.ibd $datadir/test/tr.ibd
+--move_file $datadir/test/tc0.ibd $datadir/test/tc.ibd
+--move_file $datadir/test/td0.ibd $MYSQL_TMP_DIR/test/td.ibd
+
+--source include/start_mysqld.inc
+SELECT * FROM tr;
+SELECT * FROM tc;
+SELECT * FROM td;
+DROP TABLE tr,tc,td;
diff --git a/mysql-test/suite/innodb/t/row_format_redundant.test b/mysql-test/suite/innodb/t/row_format_redundant.test
index af3fe3b52cf..81541fb0582 100644
--- a/mysql-test/suite/innodb/t/row_format_redundant.test
+++ b/mysql-test/suite/innodb/t/row_format_redundant.test
@@ -4,7 +4,7 @@
--disable_query_log
call mtr.add_suppression("InnoDB: Table `mysql`\\.`innodb_table_stats` not found");
-call mtr.add_suppression("InnoDB: Table `test`.`t1` in InnoDB data dictionary contains invalid flags. SYS_TABLES\\.TYPE=1 SYS_TABLES\\.MIX_LEN=255\\r?$");
+call mtr.add_suppression("InnoDB: Table `test`.`t1` in InnoDB data dictionary contains invalid flags. SYS_TABLES\\.TYPE=1 SYS_TABLES\\.MIX_LEN=511\\r?$");
call mtr.add_suppression("InnoDB: Parent table of FTS auxiliary table test/FTS_.* not found");
call mtr.add_suppression("InnoDB: Cannot open table test/t1 from the internal data dictionary");
call mtr.add_suppression("InnoDB: Table `test`.`t1` does not exist in the InnoDB internal data dictionary though MariaDB is trying to (rename|drop)");
@@ -115,7 +115,7 @@ for (my $offset= 0x65; $offset;
if ($i == 7 && $name =~ '^test/t[123]')
{
print "corrupted SYS_TABLES.MIX_LEN for $name\n";
- substr($page,$offset+$start,$end-$start)= pack("N", 255);
+ substr($page,$offset+$start,$end-$start)= pack("N", 511);
}
$start= $end & 0x7f;
}
@@ -141,7 +141,7 @@ RENAME TABLE t1 TO tee_one;
DROP TABLE t1;
DROP TABLE t2,t3;
---let SEARCH_PATTERN= \[ERROR\] InnoDB: Table `test`\.`t1` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=255\b
+--let SEARCH_PATTERN= \[ERROR\] InnoDB: Table `test`\.`t1` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=511\b
--source include/search_pattern_in_file.inc
--let $restart_parameters=
diff --git a/mysql-test/suite/innodb/t/table_definition_cache_debug.opt b/mysql-test/suite/innodb/t/table_definition_cache_debug.opt
index 6195e055dc8..c2db7e1df6e 100644
--- a/mysql-test/suite/innodb/t/table_definition_cache_debug.opt
+++ b/mysql-test/suite/innodb/t/table_definition_cache_debug.opt
@@ -1 +1 @@
---innodb-open-files=13
+--innodb-open-files=30
diff --git a/mysql-test/suite/innodb/t/table_flags.test b/mysql-test/suite/innodb/t/table_flags.test
index 2c0b55bcaae..2d2a32e9547 100644
--- a/mysql-test/suite/innodb/t/table_flags.test
+++ b/mysql-test/suite/innodb/t/table_flags.test
@@ -14,6 +14,7 @@ call mtr.add_suppression("InnoDB: Ignoring tablespace for `test`.`td` because it
call mtr.add_suppression("InnoDB: Operating system error number .* in a file operation");
call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified");
call mtr.add_suppression("InnoDB: If you are installing InnoDB, remember that you must create directories yourself");
+call mtr.add_suppression("InnoDB: adjusting FSP_SPACE_FLAGS of tablespace");
FLUSH TABLES;
--enable_query_log
@@ -136,7 +137,9 @@ SHOW CREATE TABLE tr;
--error ER_NO_SUCH_TABLE_IN_ENGINE
SHOW CREATE TABLE tc;
--error ER_NO_SUCH_TABLE_IN_ENGINE
+SELECT * FROM tc;
SHOW CREATE TABLE td;
+SELECT * FROM td;
# This table was converted to NO_ROLLBACK due to the SYS_TABLES.TYPE change.
SHOW CREATE TABLE tz;
BEGIN;
@@ -151,8 +154,6 @@ SHOW CREATE TABLE tp;
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
--let SEARCH_PATTERN= InnoDB: Table `test`.`t[cp]` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=(129|289|3873|1232[13]) SYS_TABLES\.N_COLS=2147483649
--source include/search_pattern_in_file.inc
---let SEARCH_PATTERN= InnoDB: Refusing to load '\..test.td\.ibd' \(id=3, flags=0x1?[2ae]1\); dictionary contains id=3, flags=0x10[01][2ae]1\b
---source include/search_pattern_in_file.inc
--let SEARCH_PATTERN= InnoDB: Table `test`\.`tr` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=65 SYS_TABLES\.MIX_LEN=4294967295\b
--source include/search_pattern_in_file.inc
diff --git a/mysql-test/suite/innodb/t/truncate_inject.test b/mysql-test/suite/innodb/t/truncate_inject.test
new file mode 100644
index 00000000000..35e516324bb
--- /dev/null
+++ b/mysql-test/suite/innodb/t/truncate_inject.test
@@ -0,0 +1,97 @@
+# This test is based on innodb_zip.wl6501_error_1 in MySQL 5.7.
+
+--source include/have_innodb.inc
+--source include/innodb_row_format.inc
+--source include/have_debug.inc
+
+SET @save_dbug = @@SESSION.debug_dbug;
+
+call mtr.add_suppression("InnoDB: Flagged corruption of .* in table `test`\\.`t` in TRUNCATE TABLE");
+
+--echo # 1. Error in assigning undo logs for truncate action
+CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100), INDEX ck(c))
+ENGINE = InnoDB;
+insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
+check table t;
+#
+SET debug_dbug = '+d,ib_err_trunc_assigning_undo_log';
+--error ER_GET_ERRNO
+truncate table t;
+SET debug_dbug = @save_dbug;
+check table t;
+select * from t;
+
+--echo # 2. Error while preparing for truncate
+SET debug_dbug = '+d,ib_err_trunc_preparing_for_truncate';
+--error ER_GET_ERRNO
+truncate table t;
+SET debug_dbug = @save_dbug;
+check table t;
+select * from t;
+
+--echo # 3. Error while dropping/creating indexes
+SET debug_dbug = '+d,ib_err_trunc_drop_index';
+--error ER_GET_ERRNO
+truncate table t;
+SET debug_dbug = @save_dbug;
+check table t;
+--error ER_TABLE_CORRUPT,ER_GET_ERRNO
+select * from t;
+drop table t;
+
+CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100), INDEX ck(c))
+ENGINE = InnoDB;
+insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
+check table t;
+
+SET debug_dbug = '+d,ib_err_trunc_create_index';
+--error ER_GET_ERRNO
+truncate table t;
+SET debug_dbug = @save_dbug;
+check table t;
+--error ER_TABLE_CORRUPT,ER_GET_ERRNO
+select * from t;
+drop table t;
+
+CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100), INDEX ck(c))
+ENGINE = InnoDB;
+insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
+check table t;
+
+SET debug_dbug = '+d,ib_err_trunc_temp_recreate_index';
+truncate table t;
+SET debug_dbug = @save_dbug;
+
+check table t;
+select * from t;
+drop table t;
+
+--echo # 4. Error while completing truncate of table involving FTS
+CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100),
+FULLTEXT INDEX(c)) ENGINE = InnoDB;
+insert into t values (1, 1.1, 'mysql is now oracle company'),
+ (2, 2.2, 'innodb is part of mysql'),
+ (3, 3.3, 'innodb is default storage engine of mysql');
+check table t;
+SET debug_dbug = '+d,ib_err_trunc_temp_recreate_index';
+truncate table t;
+SET debug_dbug = @save_dbug;
+
+check table t;
+select * from t;
+drop table t;
+
+--echo # 5. Error while updating sys-tables
+CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100),
+FULLTEXT INDEX(c)) ENGINE = InnoDB;
+insert into t values (1, 1.1, 'mysql is now oracle company'),
+ (2, 2.2, 'innodb is part of mysql'),
+ (3, 3.3, 'innodb is default storage engine of mysql');
+check table t;
+SET debug_dbug = '+d,ib_err_trunc_temp_recreate_index';
+truncate table t;
+SET debug_dbug = @save_dbug;
+
+check table t;
+select * from t order by i;
+drop table t;
diff --git a/mysql-test/suite/innodb/t/truncate_restart.test b/mysql-test/suite/innodb/t/truncate_restart.test
new file mode 100644
index 00000000000..60a3d83cd81
--- /dev/null
+++ b/mysql-test/suite/innodb/t/truncate_restart.test
@@ -0,0 +1,16 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+
+SET GLOBAL innodb_stats_persistent= ON;
+CREATE TABLE t1 (t TEXT) ENGINE=InnoDB STATS_PERSISTENT=1;
+--connect (con1,localhost,root,,test)
+SET DEBUG_SYNC='ib_trunc_table_trunc_completing SIGNAL committed WAIT_FOR ever';
+--send
+TRUNCATE TABLE t1;
+--connection default
+SET DEBUG_SYNC='now WAIT_FOR committed';
+--source include/restart_mysqld.inc
+--disconnect con1
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/update-cascade.test b/mysql-test/suite/innodb/t/update-cascade.test
new file mode 100644
index 00000000000..de8294703b4
--- /dev/null
+++ b/mysql-test/suite/innodb/t/update-cascade.test
@@ -0,0 +1,221 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+--echo #
+--echo # Bug #18451287 REDUNDANT DELETE MARKING AFTER DB_LOCK_WAIT
+--echo #
+
+create table t1 (f1 int primary key, f2 blob) engine=innodb;
+create table t2 (f1 int primary key, f2 int,
+ foreign key (f2) references t1(f1) on update cascade) engine=innodb;
+
+show create table t1;
+show create table t2;
+insert into t1 values (1, repeat('+', 20000));
+insert into t1 values (2, repeat('-', 20000));
+insert into t1 values (3, repeat('=', 20000));
+insert into t2 values (1, 2);
+
+select f1, right(f2, 20) as p2 from t1;
+select f1, f2 from t2;
+
+connect(con1,localhost,root,,test);
+start transaction;
+select f1, f2 from t2 for update;
+
+connection default;
+set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd';
+send update t1 set f1 = 10 where f1 = 2;
+
+connection con1;
+set debug_sync='now WAIT_FOR upd_waiting';
+rollback;
+set debug_sync='now SIGNAL go_upd';
+
+connection default;
+--echo # reap: update t1 set f1 = 10 where f1 = 2;
+reap;
+
+select f1, right(f2, 20) as p2 from t1;
+select f1, f2 from t2;
+
+drop table t2, t1;
+
+set debug_sync = reset;
+
+--echo #
+--echo # Test Scenario: Two tables t1 -> t2 are involved in update cascade.
+--echo # If DB_LOCK_WAIT happens when t1 is being updated and FK constraints
+--echo # are being checked in t2, then retry must happen on t1. The update
+--echo # cascade happens in secondary index. For secondary index testing,
+--echo # blobs are not needed.
+--echo #
+
+create table t1 (f1 int primary key, f2 int, key k1(f2)) engine=innodb;
+create table t2 (f1 int primary key, f2 int,
+ foreign key (f2) references t1(f2) on update cascade) engine=innodb;
+
+show create table t1;
+show create table t2;
+insert into t1 values (1, 91);
+insert into t2 values (1, 91);
+
+select f1, f2 from t1;
+select f1, f2 from t2;
+
+connection con1;
+start transaction;
+select f1, f2 from t2 for update;
+
+connection default;
+set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd';
+send update t1 set f2 = 28 where f2 = 91;
+
+connection con1;
+set debug_sync='now WAIT_FOR upd_waiting';
+rollback;
+set debug_sync='now SIGNAL go_upd';
+
+connection default;
+--echo # reap: update t1 set f1 = 10 where f1 = 2;
+--reap
+
+select f1, f2 from t1;
+select f1, f2 from t2;
+
+drop table t2, t1;
+
+set debug_sync = reset;
+
+--echo #
+--echo # Test Scenario: Three tables t1 -> t2 -> t3 are involved in update cascade.
+--echo # If DB_LOCK_WAIT happens when t2 is being updated, then retry must happen
+--echo # on t2.
+--echo #
+
+create table t1 (f1 int primary key, f2 blob) engine=innodb;
+create table t2 (f1 int primary key, f2 blob,
+ foreign key (f1) references t1(f1) on update cascade) engine=innodb;
+create table t3 (f1 int primary key, f2 blob,
+ foreign key (f1) references t2(f1) on update cascade) engine=innodb;
+
+show create table t1;
+show create table t2;
+show create table t3;
+
+insert into t1 values (2, repeat('-', 20000));
+insert into t2 values (2, repeat('%', 20000));
+insert into t3 values (2, repeat('+', 20000));
+
+select f1, right(f2, 20) as p2 from t1;
+select f1, right(f2, 20) as p2 from t2;
+select f1, right(f2, 20) as p2 from t3;
+
+connection con1;
+start transaction;
+select f1 from t3 for update;
+
+connection default;
+set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd';
+send update t1 set f1 = 10 where f1 = 2;
+
+connection con1;
+set debug_sync='now WAIT_FOR upd_waiting';
+rollback;
+
+--echo # The table t1 is updated.
+--echo # In t2 delete-mark happened. Retry will happen on t2.
+--echo # In t3 yet to be updated.
+set session transaction isolation level read uncommitted;
+start transaction;
+select f1, right(f2, 20) as p2 from t1;
+select f1, right(f2, 20) as p2 from t2;
+select f1, right(f2, 20) as p2 from t3;
+commit;
+
+set debug_sync='now SIGNAL go_upd';
+
+connection default;
+--echo # reap: update t1 set f1 = 10 where f1 = 2;
+--reap;
+
+start transaction;
+select f1, right(f2, 20) as p2 from t1;
+select f1, right(f2, 20) as p2 from t2;
+select f1, right(f2, 20) as p2 from t3;
+commit;
+
+drop table t3, t2, t1;
+
+set debug_sync = reset;
+
+--echo #
+--echo # Test Scenario: Three tables t1 -> t2 -> t3 are involved in update
+--echo # cascade. If DB_LOCK_WAIT happens when t2 is being updated, then
+--echo # retry must happen on t2. The update cascade is happening via
+--echo # secondary index (hence blobs are not needed).
+--echo #
+
+create table t1 (f1 int primary key, f2 int, key k1(f2)) engine=innodb;
+create table t2 (f1 int primary key, f2 int,
+ foreign key (f2) references t1(f2) on update cascade) engine=innodb;
+create table t3 (f1 int primary key, f2 int,
+ foreign key (f2) references t2(f2) on update cascade) engine=innodb;
+
+show create table t1;
+show create table t2;
+show create table t3;
+
+insert into t1 values (2, 91);
+insert into t2 values (2, 91);
+insert into t3 values (2, 91);
+
+select f1, f2 from t1;
+select f1, f2 from t2;
+select f1, f2 from t3;
+
+connection con1;
+start transaction;
+select f1 from t3 for update;
+
+connection default;
+set debug_sync='lock_wait_suspend_thread_enter SIGNAL upd_waiting WAIT_FOR go_upd';
+send update t1 set f2 = 28 where f2 = 91;
+
+connection con1;
+set debug_sync='now WAIT_FOR upd_waiting';
+rollback;
+
+--echo # The table t1 is updated.
+--echo # In t2 delete-mark happened. Retry will happen on t2.
+--echo # In t3 yet to be updated.
+set session transaction isolation level read uncommitted;
+start transaction;
+select f1, f2 from t1;
+select f1, f2 from t2;
+select f1, f2 from t3;
+commit;
+
+set debug_sync='now SIGNAL go_upd';
+disconnect con1;
+
+connection default;
+--echo # reap: update t1 set f2 = 28 where f2 = 91;
+--reap;
+
+start transaction;
+select f1, f2 from t1;
+select f1, f2 from t2;
+select f1, f2 from t3;
+commit;
+
+drop table t3, t2, t1;
+
+set debug_sync = reset;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/innodb/t/update_time-master.opt b/mysql-test/suite/innodb/t/update_time-master.opt
new file mode 100644
index 00000000000..9f283a9503f
--- /dev/null
+++ b/mysql-test/suite/innodb/t/update_time-master.opt
@@ -0,0 +1 @@
+--innodb-buffer-pool-size=10M
diff --git a/mysql-test/suite/innodb/t/update_time.test b/mysql-test/suite/innodb/t/update_time.test
new file mode 100644
index 00000000000..1a00e3b9f73
--- /dev/null
+++ b/mysql-test/suite/innodb/t/update_time.test
@@ -0,0 +1,79 @@
+###################################################################
+-- echo #
+-- echo # Test that INFORMATION_SCHEMA.TABLES.UPDATE_TIME is filled
+-- echo # correctly for InnoDB tables.
+-- echo #
+
+-- source include/have_innodb.inc
+-- source include/have_innodb_max_16k.inc
+# restart does not work with embedded
+-- source include/not_embedded.inc
+
+CREATE TABLE t (a INT) ENGINE=INNODB;
+
+SELECT update_time FROM information_schema.tables WHERE table_name = 't';
+
+INSERT INTO t VALUES (1);
+
+SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't'
+AND update_time IS NOT NULL;
+
+-- echo # We cant deterministically check that the saved value is correct, but
+-- echo # at least we check that it is a timestamp not older than 2 minutes.
+-- echo # Usually update_time and NOW() are equal below, but on heavily loaded
+-- echo # machines NOW() could be younger.
+SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't'
+AND TIMESTAMPDIFF(SECOND, update_time, NOW()) < 120;
+
+CREATE TEMPORARY TABLE big (a TEXT) ENGINE=INNODB;
+
+SELECT COUNT(*) FROM information_schema.innodb_buffer_page
+WHERE table_name = '`test`.`t`';
+
+# evict table 't' by inserting as much data as the BP size itself
+-- echo # INSERT lots of data in table 'big': begin
+-- disable_query_log
+BEGIN;
+-- let $i = 10240
+while ($i)
+{
+ INSERT INTO big VALUES (REPEAT('a', 1024));
+ dec $i;
+}
+COMMIT;
+-- enable_query_log
+-- echo # INSERT lots of data in table 'big': end
+
+# confirm that all pages for table 't' have been evicted
+SELECT COUNT(*) FROM information_schema.innodb_buffer_page
+WHERE table_name = '`test`.`t`';
+
+# The result from this query will change once update_time becomes persistent
+# (WL#6917).
+SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't'
+AND update_time IS NOT NULL;
+
+DROP TEMPORARY TABLE big;
+
+-- echo # Test the behavior after restart with a prepared XA transaction
+
+XA START 'xatrx';
+INSERT INTO t VALUES (5);
+XA END 'xatrx';
+XA PREPARE 'xatrx';
+
+CONNECT (con1,localhost,root,,);
+
+call mtr.add_suppression("Found 1 prepared XA transactions");
+FLUSH TABLES;
+
+--let $shutdown_timeout=0
+--source include/restart_mysqld.inc
+
+SELECT update_time FROM information_schema.tables WHERE table_name = 't';
+
+XA COMMIT 'xatrx';
+
+SELECT COUNT(update_time) FROM information_schema.tables WHERE table_name='t';
+
+DROP TABLE t;
diff --git a/mysql-test/suite/innodb/t/update_time_wl6658.test b/mysql-test/suite/innodb/t/update_time_wl6658.test
new file mode 100644
index 00000000000..0adc6a867fe
--- /dev/null
+++ b/mysql-test/suite/innodb/t/update_time_wl6658.test
@@ -0,0 +1,232 @@
+###################################################################
+#Testing functionality of the WL6658
+#case1: begin work with INSERT with Triggers
+#case2: (tab1u) begin transaction with UPDATE
+#case3: (tab1d) begin transaction with DELETE
+#case4: (tab1i) Rollback & INSERT
+#case5: (tab2) partitioned table and procedures
+#case6: (tab2) SAVEPOINT
+#case7: (tab7,tab8) pk-fk with ON DELETE CASCADE
+###################################################################
+--source include/no_valgrind_without_big.inc
+--source include/have_innodb.inc
+--source include/have_partition.inc
+--source include/not_embedded.inc
+
+CREATE TABLE tab1(c1 int,c2 varchar(30), c3 BLOB) ENGINE=InnoDB;
+CREATE TABLE tab1u LIKE tab1;
+CREATE TABLE tab1d LIKE tab1;
+CREATE TABLE tab1i LIKE tab1;
+CREATE TABLE tab3(c1 int,c2 varchar(30)) ENGINE=InnoDB;
+CREATE TABLE tab4(c1 int,c2 varchar(30)) ENGINE=InnoDB;
+CREATE TABLE tab5(c1 int,c2 varchar(30)) ENGINE=InnoDB;
+
+INSERT INTO tab1u VALUES(1,'Testing the wl6658','Testing the wl6658');
+INSERT INTO tab1d VALUES(1,'Updated','Updated');
+INSERT INTO tab4 VALUES(1,'Test for Update');
+INSERT INTO tab5 VALUES(1,'Test for Delete');
+
+delimiter |;
+
+CREATE TRIGGER test_trig BEFORE INSERT ON tab1
+FOR EACH ROW BEGIN
+ INSERT INTO tab3 VALUES(1,'Inserted From Trigger');
+ UPDATE tab4 SET c2='Updated from Trigger' WHERE c1=1;
+ DELETE FROM tab5;
+END |
+
+delimiter ;|
+
+CREATE TABLE tab2(
+ id INT NOT NULL,
+ store_name VARCHAR(30),
+ parts VARCHAR(30),
+ store_id INT
+) ENGINE=InnoDB
+PARTITION BY LIST(store_id) (
+ PARTITION pNorth VALUES IN (10,20,30),
+ PARTITION pEast VALUES IN (40,50,60),
+ PARTITION pWest VALUES IN (70,80,100)
+);
+
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab2';
+
+delimiter |;
+
+CREATE PROCEDURE proc_wl6658()
+BEGIN
+INSERT INTO tab2 VALUES(1,'ORACLE','NUTT',10);
+INSERT INTO tab2 VALUES(2,'HUAWEI','BOLT',40);
+COMMIT;
+END |
+
+delimiter ;|
+
+CALL proc_wl6658;
+
+SELECT * FROM tab2 ORDER BY id,store_id;
+
+SELECT COUNT(update_time)
+FROM information_schema.tables WHERE table_name='tab2';
+
+TRUNCATE TABLE tab2;
+
+SELECT COUNT(update_time)
+FROM information_schema.tables WHERE table_name='tab2';
+
+CREATE TABLE tab7(c1 INT NOT NULL, PRIMARY KEY (c1)) ENGINE=INNODB;
+
+CREATE TABLE tab8(c1 INT PRIMARY KEY,c2 INT,
+FOREIGN KEY (c2) REFERENCES tab7(c1) ON DELETE CASCADE )
+ENGINE=INNODB;
+
+SELECT table_name,update_time
+FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
+GROUP BY table_name ORDER BY table_name;
+
+INSERT INTO tab7 VALUES(1);
+
+INSERT INTO tab8 VALUES(1,1);
+
+SELECT table_name,COUNT(update_time)
+FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
+GROUP BY table_name ORDER BY table_name;
+
+--echo #restart the server
+--source include/restart_mysqld.inc
+
+SELECT table_name,update_time
+FROM information_schema.tables
+WHERE table_name IN ('tab1','tab2','tab3','tab4','tab5','tab7','tab8')
+ORDER BY table_name;
+
+--echo #case1:
+
+BEGIN WORK;
+
+INSERT INTO tab1
+VALUES(1,'Testing the wl6658', 'Testing the wl6658');
+
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1';
+
+COMMIT;
+
+SELECT * FROM tab1;
+SELECT * FROM tab3;
+SELECT * FROM tab4;
+SELECT * FROM tab5;
+
+SELECT table_name,COUNT(update_time)
+FROM information_schema.tables
+WHERE table_name IN ('tab1','tab3','tab4','tab5')
+GROUP BY table_name ORDER BY table_name;
+
+--echo Testcase with UPDATE stmt and transaction
+
+SELECT * FROM tab1u;
+
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1u';
+
+--echo #case2:
+START TRANSACTION;
+
+UPDATE tab1u SET c2='Updated',c3='Updated' WHERE c1=1;
+
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1u';
+
+COMMIT;
+
+SELECT * FROM tab1u;
+
+SELECT COUNT(update_time)
+FROM information_schema.tables WHERE table_name='tab1u';
+
+SELECT * FROM tab1d;
+
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1d';
+
+--echo #case3:
+START TRANSACTION;
+
+DELETE FROM tab1d;
+
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1d';
+
+COMMIT;
+
+SELECT * FROM tab1d;
+
+SELECT COUNT(update_time)
+FROM information_schema.tables WHERE table_name='tab1d';
+
+SELECT * FROM tab1i;
+
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1i';
+
+--echo #case4:
+START TRANSACTION;
+
+INSERT INTO tab1i
+VALUES(1,'Testing the wl6658', 'Testing the wl6658');
+
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1i';
+
+ROLLBACK;
+
+SELECT * FROM tab1i;
+
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab1i';
+
+BEGIN WORK;
+DELETE FROM tab1i;
+SAVEPOINT A;
+INSERT INTO tab2 VALUES(1,'Oracle','NUTT',10);
+INSERT INTO tab2 VALUES(2,'HUAWEI','BOLT',40);
+SAVEPOINT B;
+INSERT INTO tab2 VALUES(3,'IBM','NAIL',70);
+SAVEPOINT C;
+ROLLBACK to A;
+
+SELECT * FROM tab2;
+
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab2';
+
+--echo #execute DDL instead of commit
+create table tab6(c1 int);
+
+SELECT update_time
+FROM information_schema.tables WHERE table_name='tab2';
+
+START TRANSACTION;
+DELETE FROM tab7;
+ROLLBACK;
+
+SELECT * FROM tab7;
+SELECT * FROM tab8;
+
+SELECT table_name,update_time
+FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
+GROUP BY table_name ORDER BY table_name;
+
+DELETE FROM tab7;
+SELECT * FROM tab7;
+SELECT * FROM tab8;
+
+SELECT table_name,COUNT(update_time)
+FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
+GROUP BY table_name ORDER BY table_name;
+
+--echo #cleanup
+DROP TRIGGER test_trig;
+DROP TABLE tab1,tab1u,tab1d,tab1i,tab2,tab3,tab4,tab5,tab6,tab8,tab7;
+DROP PROCEDURE proc_wl6658;