summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-02-17 10:23:39 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2017-02-19 14:51:19 +0200
commitcc4b2b185d73963ad55730f8e3e205530a491d30 (patch)
tree2d210af362b8a50902ae9772072561489aba702c
parentd58b4bc6a6a0379fa5da7d53094b91c240eb58ea (diff)
downloadmariadb-git-cc4b2b185d73963ad55730f8e3e205530a491d30.tar.gz
MDEV-11802 preparation: Clean up the purge tests.
Revert the MDEV-4396 tweak to innodb.innodb_bug14676111. We must fix the root cause instead. Allow gcol.innodb_virtual_purge to run on a non-debug build (If wait_innodb_all_purged.inc is used in a non-debug test, it will have no effect.) Add the test innodb.index_merge_threshold from MySQL 5.7.
-rw-r--r--mysql-test/include/wait_innodb_all_purged.inc3
-rw-r--r--mysql-test/suite/gcol/t/innodb_virtual_purge.test4
-rw-r--r--mysql-test/suite/innodb/include/innodb_merge_threshold_delete.inc119
-rw-r--r--mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc165
-rw-r--r--mysql-test/suite/innodb/include/innodb_merge_threshold_update.inc101
-rw-r--r--mysql-test/suite/innodb/r/index_merge_threshold.result1325
-rw-r--r--mysql-test/suite/innodb/r/innodb_bug14676111.result5
-rw-r--r--mysql-test/suite/innodb/t/index_merge_threshold.opt1
-rw-r--r--mysql-test/suite/innodb/t/index_merge_threshold.test189
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug14676111-master.opt1
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug14676111.test11
11 files changed, 1906 insertions, 18 deletions
diff --git a/mysql-test/include/wait_innodb_all_purged.inc b/mysql-test/include/wait_innodb_all_purged.inc
index 97b038acc44..a77e6ec1573 100644
--- a/mysql-test/include/wait_innodb_all_purged.inc
+++ b/mysql-test/include/wait_innodb_all_purged.inc
@@ -9,8 +9,8 @@
# --source include/wait_innodb_all_purged.inc
#
--source include/have_innodb.inc
---source include/have_debug.inc
+if (`select version() like '%debug%'`) {
--disable_query_log
let $wait_counter_init= 300;
@@ -57,3 +57,4 @@ if (!$success)
}
--enable_query_log
+}
diff --git a/mysql-test/suite/gcol/t/innodb_virtual_purge.test b/mysql-test/suite/gcol/t/innodb_virtual_purge.test
index f9fd02d970b..ab6ba52c2c3 100644
--- a/mysql-test/suite/gcol/t/innodb_virtual_purge.test
+++ b/mysql-test/suite/gcol/t/innodb_virtual_purge.test
@@ -32,7 +32,7 @@ COMMIT;
UPDATE t1 SET a=1;
connection default;
-# wait for purge to process the update_undo record.
+# wait for purge to process the update_undo record (in debug builds)
--source include/wait_innodb_all_purged.inc
CHECK TABLE t1;
@@ -118,7 +118,7 @@ COMMIT;
disconnect con1;
connection default;
-# wait for purge to process the update_undo record.
+# wait for purge to process the update_undo record (in debug builds)
--source include/wait_innodb_all_purged.inc
CHECK TABLE t1;
diff --git a/mysql-test/suite/innodb/include/innodb_merge_threshold_delete.inc b/mysql-test/suite/innodb/include/innodb_merge_threshold_delete.inc
new file mode 100644
index 00000000000..6aad7afa878
--- /dev/null
+++ b/mysql-test/suite/innodb/include/innodb_merge_threshold_delete.inc
@@ -0,0 +1,119 @@
+#
+# Test to cause merge of the pages (by deleting)
+# test/tab1 should be created already with innodb_file_per_table=ON
+# The definition is intended to be based on
+# "create table tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB;"
+#
+
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_innodb_16k.inc
+
+# turn on flags
+--disable_query_log
+SET GLOBAL innodb_monitor_enable=index_page_merge_attempts;
+SET GLOBAL innodb_monitor_reset=index_page_merge_attempts;
+SET GLOBAL innodb_monitor_enable=index_page_merge_successful;
+SET GLOBAL innodb_monitor_reset=index_page_merge_successful;
+--enable_query_log
+
+--echo # check MERGE_THRESHOLD
+--replace_result tab1#P tab1#p
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+
+insert into tab1 values (1, repeat('a',2048));
+insert into tab1 values (2, repeat('a',2048));
+insert into tab1 values (3, repeat('a',2048));
+insert into tab1 values (8, repeat('a',2048));
+insert into tab1 values (9, repeat('a',2048));
+insert into tab1 values (10, repeat('a',2048));
+insert into tab1 values (11, repeat('a',2048));
+insert into tab1 values (12, repeat('a',2048));
+insert into tab1 values (4, repeat('a',2048));
+insert into tab1 values (5, repeat('a',2048));
+insert into tab1 values (6, repeat('a',2048));
+insert into tab1 values (7, repeat('a',2048));
+insert into tab1 values (13, repeat('a',2048));
+insert into tab1 values (14, repeat('a',2048));
+
+# filled 2 leaf pages have been prepared
+# | 1,..,7 | 8,..,14 |
+
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 12;
+delete from tab1 where a = 13;
+delete from tab1 where a = 14;
+delete from tab1 where a = 5;
+delete from tab1 where a = 6;
+delete from tab1 where a = 7;
+set global innodb_purge_run_now=ON;
+
+# wait for purge view progress (records are deleted actually by purge)
+--source include/wait_innodb_all_purged.inc
+
+# not merged yet
+# | 1,2,3,4 | 8,9,10,11 |
+
+--echo # check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+
+
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 11;
+set global innodb_purge_run_now=ON;
+# wait for purge view progress (records are deleted actually by purge)
+--source include/wait_innodb_all_purged.inc
+
+--echo # check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+
+
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 10;
+set global innodb_purge_run_now=ON;
+# wait for purge view progress (records are deleted actually by purge)
+--source include/wait_innodb_all_purged.inc
+
+--echo # check page merge happens (MERGE_THRESHOLD=35 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+
+
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 9;
+set global innodb_purge_run_now=ON;
+# wait for purge view progress (records are deleted actually by purge)
+--source include/wait_innodb_all_purged.inc
+
+--echo # check page merge happens (MERGE_THRESHOLD=25 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+
+--disable_query_log
+# Reset flags
+SET GLOBAL innodb_monitor_disable=index_page_merge_attempts;
+SET GLOBAL innodb_monitor_disable=index_page_merge_successful;
+
+--disable_warnings
+set global innodb_monitor_enable = default;
+set global innodb_monitor_disable = default;
+set global innodb_monitor_reset = default;
+set global innodb_monitor_reset_all = default;
+--enable_warnings
+--enable_query_log
diff --git a/mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc b/mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc
new file mode 100644
index 00000000000..72242ea2e1b
--- /dev/null
+++ b/mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc
@@ -0,0 +1,165 @@
+#
+# Test to cause merge of the pages (at secondary index by deleting)
+# test/tab1 should be created already with innodb_file_per_table=ON
+# The definition is intended to be based on
+# "create table tab1 (a bigint primary key, b blob) engine=InnoDB row_format=dynamic;"
+# "create index index1 on tab1(b(750));"
+#
+
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_innodb_16k.inc
+
+# turn on flags
+--disable_query_log
+SET GLOBAL innodb_monitor_enable=index_page_merge_attempts;
+SET GLOBAL innodb_monitor_reset=index_page_merge_attempts;
+SET GLOBAL innodb_monitor_enable=index_page_merge_successful;
+SET GLOBAL innodb_monitor_reset=index_page_merge_successful;
+--enable_query_log
+
+--echo # check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+
+INSERT INTO tab1 VALUES (1, concat("01", repeat('a',8190)));
+INSERT INTO tab1 VALUES (2, concat("02", repeat('a',8190)));
+INSERT INTO tab1 VALUES (3, concat("03", repeat('a',8190)));
+INSERT INTO tab1 VALUES (4, concat("04", repeat('a',8190)));
+INSERT INTO tab1 VALUES (5, concat("05", repeat('a',8190)));
+INSERT INTO tab1 VALUES (6, concat("06", repeat('a',8190)));
+INSERT INTO tab1 VALUES (7, concat("07", repeat('a',8190)));
+INSERT INTO tab1 VALUES (8, concat("08", repeat('a',8190)));
+INSERT INTO tab1 VALUES (9, concat("09", repeat('a',8190)));
+INSERT INTO tab1 VALUES (10, concat("10", repeat('a',8190)));
+
+INSERT INTO tab1 VALUES (22, concat("22", repeat('a',8190)));
+INSERT INTO tab1 VALUES (23, concat("23", repeat('a',8190)));
+INSERT INTO tab1 VALUES (24, concat("24", repeat('a',8190)));
+INSERT INTO tab1 VALUES (25, concat("25", repeat('a',8190)));
+INSERT INTO tab1 VALUES (26, concat("26", repeat('a',8190)));
+INSERT INTO tab1 VALUES (27, concat("27", repeat('a',8190)));
+INSERT INTO tab1 VALUES (28, concat("28", repeat('a',8190)));
+INSERT INTO tab1 VALUES (29, concat("29", repeat('a',8190)));
+INSERT INTO tab1 VALUES (30, concat("30", repeat('a',8190)));
+INSERT INTO tab1 VALUES (31, concat("31", repeat('a',8190)));
+INSERT INTO tab1 VALUES (32, concat("32", repeat('a',8190)));
+INSERT INTO tab1 VALUES (33, concat("33", repeat('a',8190)));
+
+INSERT INTO tab1 VALUES (11, concat("11", repeat('a',8190)));
+INSERT INTO tab1 VALUES (12, concat("12", repeat('a',8190)));
+INSERT INTO tab1 VALUES (13, concat("13", repeat('a',8190)));
+INSERT INTO tab1 VALUES (14, concat("14", repeat('a',8190)));
+INSERT INTO tab1 VALUES (15, concat("15", repeat('a',8190)));
+INSERT INTO tab1 VALUES (16, concat("16", repeat('a',8190)));
+INSERT INTO tab1 VALUES (17, concat("17", repeat('a',8190)));
+INSERT INTO tab1 VALUES (18, concat("18", repeat('a',8190)));
+INSERT INTO tab1 VALUES (19, concat("19", repeat('a',8190)));
+INSERT INTO tab1 VALUES (20, concat("20", repeat('a',8190)));
+INSERT INTO tab1 VALUES (21, concat("21", repeat('a',8190)));
+
+INSERT INTO tab1 VALUES (34, concat("34", repeat('a',8190)));
+INSERT INTO tab1 VALUES (35, concat("35", repeat('a',8190)));
+INSERT INTO tab1 VALUES (36, concat("36", repeat('a',8190)));
+INSERT INTO tab1 VALUES (37, concat("37", repeat('a',8190)));
+INSERT INTO tab1 VALUES (38, concat("38", repeat('a',8190)));
+INSERT INTO tab1 VALUES (39, concat("39", repeat('a',8190)));
+INSERT INTO tab1 VALUES (40, concat("40", repeat('a',8190)));
+INSERT INTO tab1 VALUES (41, concat("41", repeat('a',8190)));
+INSERT INTO tab1 VALUES (42, concat("42", repeat('a',8190)));
+
+# clustered index is still root page only with the 42 records.
+# secondary index is filled 2 leaf pages have been prepared
+# | 1,..,21 | 22,..,42 |
+
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 33;
+delete from tab1 where a = 34;
+delete from tab1 where a = 35;
+delete from tab1 where a = 36;
+delete from tab1 where a = 37;
+delete from tab1 where a = 38;
+delete from tab1 where a = 39;
+delete from tab1 where a = 40;
+delete from tab1 where a = 41;
+delete from tab1 where a = 42;
+delete from tab1 where a = 12;
+delete from tab1 where a = 13;
+delete from tab1 where a = 14;
+delete from tab1 where a = 15;
+delete from tab1 where a = 16;
+delete from tab1 where a = 17;
+delete from tab1 where a = 18;
+delete from tab1 where a = 19;
+delete from tab1 where a = 20;
+delete from tab1 where a = 21;
+set global innodb_purge_run_now=ON;
+
+# wait for purge view progress (records are deleted actually by purge)
+--source include/wait_innodb_all_purged.inc
+
+# secondary index is not merged yet
+# | 1,..,11 | 22,..,32 |
+
+--echo # check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+
+
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 32;
+set global innodb_purge_run_now=ON;
+# wait for purge view progress (records are deleted actually by purge)
+--source include/wait_innodb_all_purged.inc
+
+--echo # check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+
+
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 31;
+set global innodb_purge_run_now=ON;
+# wait for purge view progress (records are deleted actually by purge)
+--source include/wait_innodb_all_purged.inc
+
+--echo # check page merge happens (MERGE_THRESHOLD=45 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+
+
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 30;
+set global innodb_purge_run_now=ON;
+# wait for purge view progress (records are deleted actually by purge)
+--source include/wait_innodb_all_purged.inc
+
+--echo # check page merge happens (MERGE_THRESHOLD=40 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+
+--disable_query_log
+# Reset flags
+SET GLOBAL innodb_monitor_disable=index_page_merge_attempts;
+SET GLOBAL innodb_monitor_disable=index_page_merge_successful;
+
+--disable_warnings
+set global innodb_monitor_enable = default;
+set global innodb_monitor_disable = default;
+set global innodb_monitor_reset = default;
+set global innodb_monitor_reset_all = default;
+--enable_warnings
+--enable_query_log
diff --git a/mysql-test/suite/innodb/include/innodb_merge_threshold_update.inc b/mysql-test/suite/innodb/include/innodb_merge_threshold_update.inc
new file mode 100644
index 00000000000..ff34cafd24a
--- /dev/null
+++ b/mysql-test/suite/innodb/include/innodb_merge_threshold_update.inc
@@ -0,0 +1,101 @@
+#
+# Test to cause merge of the pages (by updating to smaller)
+# test/tab1 should be created already with innodb_file_per_table=ON
+# The definition is intended to be based on
+# "create table tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB;"
+#
+
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_innodb_16k.inc
+
+# turn on flags
+--disable_query_log
+SET GLOBAL innodb_monitor_enable=index_page_merge_attempts;
+SET GLOBAL innodb_monitor_reset=index_page_merge_attempts;
+SET GLOBAL innodb_monitor_enable=index_page_merge_successful;
+SET GLOBAL innodb_monitor_reset=index_page_merge_successful;
+--enable_query_log
+
+--echo # check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+
+insert into tab1 values (1, repeat('a',2048));
+insert into tab1 values (2, repeat('a',2048));
+insert into tab1 values (3, repeat('a',2048));
+insert into tab1 values (8, repeat('a',2048));
+insert into tab1 values (9, repeat('a',2048));
+insert into tab1 values (10, repeat('a',2048));
+insert into tab1 values (11, repeat('a',2048));
+insert into tab1 values (12, repeat('a',2048));
+insert into tab1 values (4, repeat('a',2048));
+insert into tab1 values (5, repeat('a',2048));
+insert into tab1 values (6, repeat('a',2048));
+insert into tab1 values (7, repeat('a',2048));
+insert into tab1 values (13, repeat('a',2048));
+insert into tab1 values (14, repeat('a',2048));
+
+# filled 2 leaf pages have been prepared
+# | 1,..,7 | 8,..,14 |
+
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+
+update tab1 set b='' where a = 12;
+update tab1 set b='' where a = 13;
+update tab1 set b='' where a = 14;
+update tab1 set b='' where a = 5;
+update tab1 set b='' where a = 6;
+update tab1 set b='' where a = 7;
+
+# not merged yet
+# | 1,2,3,4 | 8,9,10,11 |
+
+--echo # check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+
+
+update tab1 set b='' where a = 11;
+
+--echo # check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+
+
+update tab1 set b='' where a = 10;
+
+--echo # check page merge happens (MERGE_THRESHOLD=35 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+
+
+update tab1 set b='' where a = 9;
+
+--echo # check page merge happens (MERGE_THRESHOLD=25 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+
+--disable_query_log
+# Reset flags
+SET GLOBAL innodb_monitor_disable=index_page_merge_attempts;
+SET GLOBAL innodb_monitor_disable=index_page_merge_successful;
+
+--disable_warnings
+set global innodb_monitor_enable = default;
+set global innodb_monitor_disable = default;
+set global innodb_monitor_reset = default;
+set global innodb_monitor_reset_all = default;
+--enable_warnings
+--enable_query_log
diff --git a/mysql-test/suite/innodb/r/index_merge_threshold.result b/mysql-test/suite/innodb/r/index_merge_threshold.result
new file mode 100644
index 00000000000..092bb69aa65
--- /dev/null
+++ b/mysql-test/suite/innodb/r/index_merge_threshold.result
@@ -0,0 +1,1325 @@
+CREATE TABLE tab(a BIGINT PRIMARY KEY,c1 TINYTEXT,c2 TEXT,c3 MEDIUMTEXT,
+c4 TINYBLOB,c5 BLOB,c6 MEDIUMBLOB,c7 LONGBLOB) ENGINE=InnoDB;
+CREATE INDEX index1 ON tab(c1(255)) COMMENT 'Check index level merge MERGE_THRESHOLD=51';
+Warnings:
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+CREATE INDEX index2 ON tab(c2(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=-1';
+Warnings:
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+CREATE INDEX index3 ON tab(c3(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=20';
+Warnings:
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+CREATE INDEX index4 ON tab(c4(255)) COMMENT 'Check index level merge MERGE_THRESHOLD=25';
+Warnings:
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+CREATE INDEX index5 ON tab(c5(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=30';
+Warnings:
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+CREATE INDEX index6 ON tab(c6(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=35';
+Warnings:
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+CREATE INDEX index7 ON tab(c7(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=40';
+Warnings:
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+SHOW CREATE TABLE tab;
+Table Create Table
+tab CREATE TABLE `tab` (
+ `a` bigint(20) NOT NULL,
+ `c1` tinytext DEFAULT NULL,
+ `c2` text DEFAULT NULL,
+ `c3` mediumtext DEFAULT NULL,
+ `c4` tinyblob DEFAULT NULL,
+ `c5` blob DEFAULT NULL,
+ `c6` mediumblob DEFAULT NULL,
+ `c7` longblob DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `index1` (`c1`(255)) COMMENT 'Check index level merge MERGE_THRESHOLD=51',
+ KEY `index2` (`c2`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=-1',
+ KEY `index3` (`c3`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=20',
+ KEY `index4` (`c4`(255)) COMMENT 'Check index level merge MERGE_THRESHOLD=25',
+ KEY `index5` (`c5`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=30',
+ KEY `index6` (`c6`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=35',
+ KEY `index7` (`c7`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=40'
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SELECT t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+WHERE t.TABLE_ID = i.TABLE_ID AND t.NAME = 'test/tab';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab PRIMARY 50
+test/tab index1 50
+test/tab index2 50
+test/tab index3 20
+test/tab index4 25
+test/tab index5 30
+test/tab index6 35
+test/tab index7 40
+ALTER TABLE tab comment='MERGE_THRESHOLD=49';
+Warnings:
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+SHOW CREATE TABLE tab;
+Table Create Table
+tab CREATE TABLE `tab` (
+ `a` bigint(20) NOT NULL,
+ `c1` tinytext DEFAULT NULL,
+ `c2` text DEFAULT NULL,
+ `c3` mediumtext DEFAULT NULL,
+ `c4` tinyblob DEFAULT NULL,
+ `c5` blob DEFAULT NULL,
+ `c6` mediumblob DEFAULT NULL,
+ `c7` longblob DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `index1` (`c1`(255)) COMMENT 'Check index level merge MERGE_THRESHOLD=51',
+ KEY `index2` (`c2`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=-1',
+ KEY `index3` (`c3`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=20',
+ KEY `index4` (`c4`(255)) COMMENT 'Check index level merge MERGE_THRESHOLD=25',
+ KEY `index5` (`c5`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=30',
+ KEY `index6` (`c6`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=35',
+ KEY `index7` (`c7`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=40'
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='MERGE_THRESHOLD=49'
+SELECT t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+WHERE t.TABLE_ID = i.TABLE_ID AND t.NAME = 'test/tab';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab PRIMARY 49
+test/tab index1 49
+test/tab index2 49
+test/tab index3 20
+test/tab index4 25
+test/tab index5 30
+test/tab index6 35
+test/tab index7 40
+ALTER TABLE tab MODIFY COLUMN c7 VARCHAR(2048) ;
+Warnings:
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+SHOW CREATE TABLE tab;
+Table Create Table
+tab CREATE TABLE `tab` (
+ `a` bigint(20) NOT NULL,
+ `c1` tinytext DEFAULT NULL,
+ `c2` text DEFAULT NULL,
+ `c3` mediumtext DEFAULT NULL,
+ `c4` tinyblob DEFAULT NULL,
+ `c5` blob DEFAULT NULL,
+ `c6` mediumblob DEFAULT NULL,
+ `c7` varchar(2048) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `index1` (`c1`(255)) COMMENT 'Check index level merge MERGE_THRESHOLD=51',
+ KEY `index2` (`c2`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=-1',
+ KEY `index3` (`c3`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=20',
+ KEY `index4` (`c4`(255)) COMMENT 'Check index level merge MERGE_THRESHOLD=25',
+ KEY `index5` (`c5`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=30',
+ KEY `index6` (`c6`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=35',
+ KEY `index7` (`c7`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=40'
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='MERGE_THRESHOLD=49'
+SELECT t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+WHERE t.TABLE_ID = i.TABLE_ID AND t.NAME = 'test/tab';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab PRIMARY 49
+test/tab index1 49
+test/tab index2 49
+test/tab index3 20
+test/tab index4 25
+test/tab index5 30
+test/tab index6 35
+test/tab index7 40
+ALTER TABLE tab ADD INDEX index8 (c7(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=45';
+Warnings:
+Note 1831 Duplicate index `index8`. This is deprecated and will be disallowed in a future release
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+Warning 1478 InnoDB: Invalid value for MERGE_THRESHOLD in the CREATE TABLE statement. The value is ignored.
+SHOW CREATE TABLE tab;
+Table Create Table
+tab CREATE TABLE `tab` (
+ `a` bigint(20) NOT NULL,
+ `c1` tinytext DEFAULT NULL,
+ `c2` text DEFAULT NULL,
+ `c3` mediumtext DEFAULT NULL,
+ `c4` tinyblob DEFAULT NULL,
+ `c5` blob DEFAULT NULL,
+ `c6` mediumblob DEFAULT NULL,
+ `c7` varchar(2048) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `index1` (`c1`(255)) COMMENT 'Check index level merge MERGE_THRESHOLD=51',
+ KEY `index2` (`c2`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=-1',
+ KEY `index3` (`c3`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=20',
+ KEY `index4` (`c4`(255)) COMMENT 'Check index level merge MERGE_THRESHOLD=25',
+ KEY `index5` (`c5`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=30',
+ KEY `index6` (`c6`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=35',
+ KEY `index7` (`c7`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=40',
+ KEY `index8` (`c7`(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=45'
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='MERGE_THRESHOLD=49'
+SELECT t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+WHERE t.TABLE_ID = i.TABLE_ID AND t.NAME = 'test/tab';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab PRIMARY 49
+test/tab index1 49
+test/tab index2 49
+test/tab index3 20
+test/tab index4 25
+test/tab index5 30
+test/tab index6 35
+test/tab index7 40
+test/tab index8 45
+DROP TABLE tab;
+#
+# behavior for deleting records
+#
+# test to confirm behavior (MERGE_THRESHOLD=50 (default))
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB;
+# check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab1 PRIMARY 50
+insert into tab1 values (1, repeat('a',2048));
+insert into tab1 values (2, repeat('a',2048));
+insert into tab1 values (3, repeat('a',2048));
+insert into tab1 values (8, repeat('a',2048));
+insert into tab1 values (9, repeat('a',2048));
+insert into tab1 values (10, repeat('a',2048));
+insert into tab1 values (11, repeat('a',2048));
+insert into tab1 values (12, repeat('a',2048));
+insert into tab1 values (4, repeat('a',2048));
+insert into tab1 values (5, repeat('a',2048));
+insert into tab1 values (6, repeat('a',2048));
+insert into tab1 values (7, repeat('a',2048));
+insert into tab1 values (13, repeat('a',2048));
+insert into tab1 values (14, repeat('a',2048));
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 2
+4 7
+5 7
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 12;
+delete from tab1 where a = 13;
+delete from tab1 where a = 14;
+delete from tab1 where a = 5;
+delete from tab1 where a = 6;
+delete from tab1 where a = 7;
+set global innodb_purge_run_now=ON;
+# check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 2
+4 4
+5 4
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 11;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 10;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=35 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 2
+index_page_merge_successful 2
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 9;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=25 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 2
+index_page_merge_successful 2
+DROP TABLE tab1;
+# test to confirm behavior (MERGE_THRESHOLD=35)
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB
+COMMENT='MERGE_THRESHOLD=35';
+# check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab1 PRIMARY 35
+insert into tab1 values (1, repeat('a',2048));
+insert into tab1 values (2, repeat('a',2048));
+insert into tab1 values (3, repeat('a',2048));
+insert into tab1 values (8, repeat('a',2048));
+insert into tab1 values (9, repeat('a',2048));
+insert into tab1 values (10, repeat('a',2048));
+insert into tab1 values (11, repeat('a',2048));
+insert into tab1 values (12, repeat('a',2048));
+insert into tab1 values (4, repeat('a',2048));
+insert into tab1 values (5, repeat('a',2048));
+insert into tab1 values (6, repeat('a',2048));
+insert into tab1 values (7, repeat('a',2048));
+insert into tab1 values (13, repeat('a',2048));
+insert into tab1 values (14, repeat('a',2048));
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 2
+4 7
+5 7
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 12;
+delete from tab1 where a = 13;
+delete from tab1 where a = 14;
+delete from tab1 where a = 5;
+delete from tab1 where a = 6;
+delete from tab1 where a = 7;
+set global innodb_purge_run_now=ON;
+# check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 2
+4 4
+5 4
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 11;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 10;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=35 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 9;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=25 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 2
+index_page_merge_successful 2
+DROP TABLE tab1;
+# test to confirm behavior (MERGE_THRESHOLD=25)
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB
+COMMENT='MERGE_THRESHOLD=25';
+# check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab1 PRIMARY 25
+insert into tab1 values (1, repeat('a',2048));
+insert into tab1 values (2, repeat('a',2048));
+insert into tab1 values (3, repeat('a',2048));
+insert into tab1 values (8, repeat('a',2048));
+insert into tab1 values (9, repeat('a',2048));
+insert into tab1 values (10, repeat('a',2048));
+insert into tab1 values (11, repeat('a',2048));
+insert into tab1 values (12, repeat('a',2048));
+insert into tab1 values (4, repeat('a',2048));
+insert into tab1 values (5, repeat('a',2048));
+insert into tab1 values (6, repeat('a',2048));
+insert into tab1 values (7, repeat('a',2048));
+insert into tab1 values (13, repeat('a',2048));
+insert into tab1 values (14, repeat('a',2048));
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 2
+4 7
+5 7
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 12;
+delete from tab1 where a = 13;
+delete from tab1 where a = 14;
+delete from tab1 where a = 5;
+delete from tab1 where a = 6;
+delete from tab1 where a = 7;
+set global innodb_purge_run_now=ON;
+# check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 2
+4 4
+5 4
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 11;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 10;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=35 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 9;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=25 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+DROP TABLE tab1;
+# test to confirm partitioned table (MERGE_THRESHOLD=35)
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048))
+COMMENT='MERGE_THRESHOLD=35'
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (20) ENGINE = InnoDB,
+PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
+# check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab1#p#p0 PRIMARY 35
+test/tab1#p#p1 PRIMARY 35
+insert into tab1 values (1, repeat('a',2048));
+insert into tab1 values (2, repeat('a',2048));
+insert into tab1 values (3, repeat('a',2048));
+insert into tab1 values (8, repeat('a',2048));
+insert into tab1 values (9, repeat('a',2048));
+insert into tab1 values (10, repeat('a',2048));
+insert into tab1 values (11, repeat('a',2048));
+insert into tab1 values (12, repeat('a',2048));
+insert into tab1 values (4, repeat('a',2048));
+insert into tab1 values (5, repeat('a',2048));
+insert into tab1 values (6, repeat('a',2048));
+insert into tab1 values (7, repeat('a',2048));
+insert into tab1 values (13, repeat('a',2048));
+insert into tab1 values (14, repeat('a',2048));
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 0
+3 2
+4 7
+5 7
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 12;
+delete from tab1 where a = 13;
+delete from tab1 where a = 14;
+delete from tab1 where a = 5;
+delete from tab1 where a = 6;
+delete from tab1 where a = 7;
+set global innodb_purge_run_now=ON;
+# check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 0
+3 2
+4 4
+5 4
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 11;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 10;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=35 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 9;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=25 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 2
+index_page_merge_successful 2
+DROP TABLE tab1;
+#
+# behavior for updating to smaller records
+#
+# test to confirm behavior (MERGE_THRESHOLD=50 (default))
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB;
+# check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab1 PRIMARY 50
+insert into tab1 values (1, repeat('a',2048));
+insert into tab1 values (2, repeat('a',2048));
+insert into tab1 values (3, repeat('a',2048));
+insert into tab1 values (8, repeat('a',2048));
+insert into tab1 values (9, repeat('a',2048));
+insert into tab1 values (10, repeat('a',2048));
+insert into tab1 values (11, repeat('a',2048));
+insert into tab1 values (12, repeat('a',2048));
+insert into tab1 values (4, repeat('a',2048));
+insert into tab1 values (5, repeat('a',2048));
+insert into tab1 values (6, repeat('a',2048));
+insert into tab1 values (7, repeat('a',2048));
+insert into tab1 values (13, repeat('a',2048));
+insert into tab1 values (14, repeat('a',2048));
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 2
+4 7
+5 7
+update tab1 set b='' where a = 12;
+update tab1 set b='' where a = 13;
+update tab1 set b='' where a = 14;
+update tab1 set b='' where a = 5;
+update tab1 set b='' where a = 6;
+update tab1 set b='' where a = 7;
+# check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 2
+4 7
+5 7
+update tab1 set b='' where a = 11;
+# check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+update tab1 set b='' where a = 10;
+# check page merge happens (MERGE_THRESHOLD=35 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+update tab1 set b='' where a = 9;
+# check page merge happens (MERGE_THRESHOLD=25 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+DROP TABLE tab1;
+# test to confirm behavior (MERGE_THRESHOLD=35)
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB
+COMMENT='MERGE_THRESHOLD=35';
+# check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab1 PRIMARY 35
+insert into tab1 values (1, repeat('a',2048));
+insert into tab1 values (2, repeat('a',2048));
+insert into tab1 values (3, repeat('a',2048));
+insert into tab1 values (8, repeat('a',2048));
+insert into tab1 values (9, repeat('a',2048));
+insert into tab1 values (10, repeat('a',2048));
+insert into tab1 values (11, repeat('a',2048));
+insert into tab1 values (12, repeat('a',2048));
+insert into tab1 values (4, repeat('a',2048));
+insert into tab1 values (5, repeat('a',2048));
+insert into tab1 values (6, repeat('a',2048));
+insert into tab1 values (7, repeat('a',2048));
+insert into tab1 values (13, repeat('a',2048));
+insert into tab1 values (14, repeat('a',2048));
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 2
+4 7
+5 7
+update tab1 set b='' where a = 12;
+update tab1 set b='' where a = 13;
+update tab1 set b='' where a = 14;
+update tab1 set b='' where a = 5;
+update tab1 set b='' where a = 6;
+update tab1 set b='' where a = 7;
+# check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 2
+4 7
+5 7
+update tab1 set b='' where a = 11;
+# check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+update tab1 set b='' where a = 10;
+# check page merge happens (MERGE_THRESHOLD=35 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+update tab1 set b='' where a = 9;
+# check page merge happens (MERGE_THRESHOLD=25 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+DROP TABLE tab1;
+# test to confirm behavior (MERGE_THRESHOLD=25)
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB
+COMMENT='MERGE_THRESHOLD=25';
+# check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab1 PRIMARY 25
+insert into tab1 values (1, repeat('a',2048));
+insert into tab1 values (2, repeat('a',2048));
+insert into tab1 values (3, repeat('a',2048));
+insert into tab1 values (8, repeat('a',2048));
+insert into tab1 values (9, repeat('a',2048));
+insert into tab1 values (10, repeat('a',2048));
+insert into tab1 values (11, repeat('a',2048));
+insert into tab1 values (12, repeat('a',2048));
+insert into tab1 values (4, repeat('a',2048));
+insert into tab1 values (5, repeat('a',2048));
+insert into tab1 values (6, repeat('a',2048));
+insert into tab1 values (7, repeat('a',2048));
+insert into tab1 values (13, repeat('a',2048));
+insert into tab1 values (14, repeat('a',2048));
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 2
+4 7
+5 7
+update tab1 set b='' where a = 12;
+update tab1 set b='' where a = 13;
+update tab1 set b='' where a = 14;
+update tab1 set b='' where a = 5;
+update tab1 set b='' where a = 6;
+update tab1 set b='' where a = 7;
+# check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 2
+4 7
+5 7
+update tab1 set b='' where a = 11;
+# check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+update tab1 set b='' where a = 10;
+# check page merge happens (MERGE_THRESHOLD=35 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+update tab1 set b='' where a = 9;
+# check page merge happens (MERGE_THRESHOLD=25 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+DROP TABLE tab1;
+# test to confirm explicit temporary table (MERGE_THRESHOLD=35)
+# (though not registered to SYS_TABLES,SYS_INDEXES, it works correctly)
+CREATE TEMPORARY TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB
+COMMENT='MERGE_THRESHOLD=35';
+# check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+insert into tab1 values (1, repeat('a',2048));
+insert into tab1 values (2, repeat('a',2048));
+insert into tab1 values (3, repeat('a',2048));
+insert into tab1 values (8, repeat('a',2048));
+insert into tab1 values (9, repeat('a',2048));
+insert into tab1 values (10, repeat('a',2048));
+insert into tab1 values (11, repeat('a',2048));
+insert into tab1 values (12, repeat('a',2048));
+insert into tab1 values (4, repeat('a',2048));
+insert into tab1 values (5, repeat('a',2048));
+insert into tab1 values (6, repeat('a',2048));
+insert into tab1 values (7, repeat('a',2048));
+insert into tab1 values (13, repeat('a',2048));
+insert into tab1 values (14, repeat('a',2048));
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+update tab1 set b='' where a = 12;
+update tab1 set b='' where a = 13;
+update tab1 set b='' where a = 14;
+update tab1 set b='' where a = 5;
+update tab1 set b='' where a = 6;
+update tab1 set b='' where a = 7;
+# check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+update tab1 set b='' where a = 11;
+# check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+update tab1 set b='' where a = 10;
+# check page merge happens (MERGE_THRESHOLD=35 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+update tab1 set b='' where a = 9;
+# check page merge happens (MERGE_THRESHOLD=25 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+DROP TABLE tab1;
+#
+# behavior for secondary index with blob
+#
+# test to confirm behavior (MERGE_THRESHOLD=50 (default))
+CREATE TABLE tab1 (a bigint primary key, b blob) engine=InnoDB row_format=dynamic;
+CREATE INDEX index1 ON tab1(b(750));
+# check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab1 PRIMARY 50
+test/tab1 index1 50
+INSERT INTO tab1 VALUES (1, concat("01", repeat('a',8190)));
+INSERT INTO tab1 VALUES (2, concat("02", repeat('a',8190)));
+INSERT INTO tab1 VALUES (3, concat("03", repeat('a',8190)));
+INSERT INTO tab1 VALUES (4, concat("04", repeat('a',8190)));
+INSERT INTO tab1 VALUES (5, concat("05", repeat('a',8190)));
+INSERT INTO tab1 VALUES (6, concat("06", repeat('a',8190)));
+INSERT INTO tab1 VALUES (7, concat("07", repeat('a',8190)));
+INSERT INTO tab1 VALUES (8, concat("08", repeat('a',8190)));
+INSERT INTO tab1 VALUES (9, concat("09", repeat('a',8190)));
+INSERT INTO tab1 VALUES (10, concat("10", repeat('a',8190)));
+INSERT INTO tab1 VALUES (22, concat("22", repeat('a',8190)));
+INSERT INTO tab1 VALUES (23, concat("23", repeat('a',8190)));
+INSERT INTO tab1 VALUES (24, concat("24", repeat('a',8190)));
+INSERT INTO tab1 VALUES (25, concat("25", repeat('a',8190)));
+INSERT INTO tab1 VALUES (26, concat("26", repeat('a',8190)));
+INSERT INTO tab1 VALUES (27, concat("27", repeat('a',8190)));
+INSERT INTO tab1 VALUES (28, concat("28", repeat('a',8190)));
+INSERT INTO tab1 VALUES (29, concat("29", repeat('a',8190)));
+INSERT INTO tab1 VALUES (30, concat("30", repeat('a',8190)));
+INSERT INTO tab1 VALUES (31, concat("31", repeat('a',8190)));
+INSERT INTO tab1 VALUES (32, concat("32", repeat('a',8190)));
+INSERT INTO tab1 VALUES (33, concat("33", repeat('a',8190)));
+INSERT INTO tab1 VALUES (11, concat("11", repeat('a',8190)));
+INSERT INTO tab1 VALUES (12, concat("12", repeat('a',8190)));
+INSERT INTO tab1 VALUES (13, concat("13", repeat('a',8190)));
+INSERT INTO tab1 VALUES (14, concat("14", repeat('a',8190)));
+INSERT INTO tab1 VALUES (15, concat("15", repeat('a',8190)));
+INSERT INTO tab1 VALUES (16, concat("16", repeat('a',8190)));
+INSERT INTO tab1 VALUES (17, concat("17", repeat('a',8190)));
+INSERT INTO tab1 VALUES (18, concat("18", repeat('a',8190)));
+INSERT INTO tab1 VALUES (19, concat("19", repeat('a',8190)));
+INSERT INTO tab1 VALUES (20, concat("20", repeat('a',8190)));
+INSERT INTO tab1 VALUES (21, concat("21", repeat('a',8190)));
+INSERT INTO tab1 VALUES (34, concat("34", repeat('a',8190)));
+INSERT INTO tab1 VALUES (35, concat("35", repeat('a',8190)));
+INSERT INTO tab1 VALUES (36, concat("36", repeat('a',8190)));
+INSERT INTO tab1 VALUES (37, concat("37", repeat('a',8190)));
+INSERT INTO tab1 VALUES (38, concat("38", repeat('a',8190)));
+INSERT INTO tab1 VALUES (39, concat("39", repeat('a',8190)));
+INSERT INTO tab1 VALUES (40, concat("40", repeat('a',8190)));
+INSERT INTO tab1 VALUES (41, concat("41", repeat('a',8190)));
+INSERT INTO tab1 VALUES (42, concat("42", repeat('a',8190)));
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 42
+4 2
+27 21
+28 21
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 33;
+delete from tab1 where a = 34;
+delete from tab1 where a = 35;
+delete from tab1 where a = 36;
+delete from tab1 where a = 37;
+delete from tab1 where a = 38;
+delete from tab1 where a = 39;
+delete from tab1 where a = 40;
+delete from tab1 where a = 41;
+delete from tab1 where a = 42;
+delete from tab1 where a = 12;
+delete from tab1 where a = 13;
+delete from tab1 where a = 14;
+delete from tab1 where a = 15;
+delete from tab1 where a = 16;
+delete from tab1 where a = 17;
+delete from tab1 where a = 18;
+delete from tab1 where a = 19;
+delete from tab1 where a = 20;
+delete from tab1 where a = 21;
+set global innodb_purge_run_now=ON;
+# check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 22
+4 2
+27 11
+28 11
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 32;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 31;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=45 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 2
+index_page_merge_successful 2
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 30;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=40 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 2
+index_page_merge_successful 2
+DROP TABLE tab1;
+# test to confirm behavior (MERGE_THRESHOLD=45)
+CREATE TABLE tab1 (a bigint primary key, b blob) engine=InnoDB row_format=dynamic;
+CREATE INDEX index1 ON tab1(b(750)) COMMENT 'MERGE_THRESHOLD=45';
+# check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab1 PRIMARY 50
+test/tab1 index1 45
+INSERT INTO tab1 VALUES (1, concat("01", repeat('a',8190)));
+INSERT INTO tab1 VALUES (2, concat("02", repeat('a',8190)));
+INSERT INTO tab1 VALUES (3, concat("03", repeat('a',8190)));
+INSERT INTO tab1 VALUES (4, concat("04", repeat('a',8190)));
+INSERT INTO tab1 VALUES (5, concat("05", repeat('a',8190)));
+INSERT INTO tab1 VALUES (6, concat("06", repeat('a',8190)));
+INSERT INTO tab1 VALUES (7, concat("07", repeat('a',8190)));
+INSERT INTO tab1 VALUES (8, concat("08", repeat('a',8190)));
+INSERT INTO tab1 VALUES (9, concat("09", repeat('a',8190)));
+INSERT INTO tab1 VALUES (10, concat("10", repeat('a',8190)));
+INSERT INTO tab1 VALUES (22, concat("22", repeat('a',8190)));
+INSERT INTO tab1 VALUES (23, concat("23", repeat('a',8190)));
+INSERT INTO tab1 VALUES (24, concat("24", repeat('a',8190)));
+INSERT INTO tab1 VALUES (25, concat("25", repeat('a',8190)));
+INSERT INTO tab1 VALUES (26, concat("26", repeat('a',8190)));
+INSERT INTO tab1 VALUES (27, concat("27", repeat('a',8190)));
+INSERT INTO tab1 VALUES (28, concat("28", repeat('a',8190)));
+INSERT INTO tab1 VALUES (29, concat("29", repeat('a',8190)));
+INSERT INTO tab1 VALUES (30, concat("30", repeat('a',8190)));
+INSERT INTO tab1 VALUES (31, concat("31", repeat('a',8190)));
+INSERT INTO tab1 VALUES (32, concat("32", repeat('a',8190)));
+INSERT INTO tab1 VALUES (33, concat("33", repeat('a',8190)));
+INSERT INTO tab1 VALUES (11, concat("11", repeat('a',8190)));
+INSERT INTO tab1 VALUES (12, concat("12", repeat('a',8190)));
+INSERT INTO tab1 VALUES (13, concat("13", repeat('a',8190)));
+INSERT INTO tab1 VALUES (14, concat("14", repeat('a',8190)));
+INSERT INTO tab1 VALUES (15, concat("15", repeat('a',8190)));
+INSERT INTO tab1 VALUES (16, concat("16", repeat('a',8190)));
+INSERT INTO tab1 VALUES (17, concat("17", repeat('a',8190)));
+INSERT INTO tab1 VALUES (18, concat("18", repeat('a',8190)));
+INSERT INTO tab1 VALUES (19, concat("19", repeat('a',8190)));
+INSERT INTO tab1 VALUES (20, concat("20", repeat('a',8190)));
+INSERT INTO tab1 VALUES (21, concat("21", repeat('a',8190)));
+INSERT INTO tab1 VALUES (34, concat("34", repeat('a',8190)));
+INSERT INTO tab1 VALUES (35, concat("35", repeat('a',8190)));
+INSERT INTO tab1 VALUES (36, concat("36", repeat('a',8190)));
+INSERT INTO tab1 VALUES (37, concat("37", repeat('a',8190)));
+INSERT INTO tab1 VALUES (38, concat("38", repeat('a',8190)));
+INSERT INTO tab1 VALUES (39, concat("39", repeat('a',8190)));
+INSERT INTO tab1 VALUES (40, concat("40", repeat('a',8190)));
+INSERT INTO tab1 VALUES (41, concat("41", repeat('a',8190)));
+INSERT INTO tab1 VALUES (42, concat("42", repeat('a',8190)));
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 42
+4 2
+27 21
+28 21
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 33;
+delete from tab1 where a = 34;
+delete from tab1 where a = 35;
+delete from tab1 where a = 36;
+delete from tab1 where a = 37;
+delete from tab1 where a = 38;
+delete from tab1 where a = 39;
+delete from tab1 where a = 40;
+delete from tab1 where a = 41;
+delete from tab1 where a = 42;
+delete from tab1 where a = 12;
+delete from tab1 where a = 13;
+delete from tab1 where a = 14;
+delete from tab1 where a = 15;
+delete from tab1 where a = 16;
+delete from tab1 where a = 17;
+delete from tab1 where a = 18;
+delete from tab1 where a = 19;
+delete from tab1 where a = 20;
+delete from tab1 where a = 21;
+set global innodb_purge_run_now=ON;
+# check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 22
+4 2
+27 11
+28 11
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 32;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 31;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=45 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 30;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=40 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 2
+index_page_merge_successful 2
+DROP TABLE tab1;
+# test to confirm behavior (MERGE_THRESHOLD=40)
+CREATE TABLE tab1 (a bigint primary key, b blob) engine=InnoDB row_format=dynamic;
+CREATE INDEX index1 ON tab1(b(750)) COMMENT 'MERGE_THRESHOLD=40';
+# check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab1 PRIMARY 50
+test/tab1 index1 40
+INSERT INTO tab1 VALUES (1, concat("01", repeat('a',8190)));
+INSERT INTO tab1 VALUES (2, concat("02", repeat('a',8190)));
+INSERT INTO tab1 VALUES (3, concat("03", repeat('a',8190)));
+INSERT INTO tab1 VALUES (4, concat("04", repeat('a',8190)));
+INSERT INTO tab1 VALUES (5, concat("05", repeat('a',8190)));
+INSERT INTO tab1 VALUES (6, concat("06", repeat('a',8190)));
+INSERT INTO tab1 VALUES (7, concat("07", repeat('a',8190)));
+INSERT INTO tab1 VALUES (8, concat("08", repeat('a',8190)));
+INSERT INTO tab1 VALUES (9, concat("09", repeat('a',8190)));
+INSERT INTO tab1 VALUES (10, concat("10", repeat('a',8190)));
+INSERT INTO tab1 VALUES (22, concat("22", repeat('a',8190)));
+INSERT INTO tab1 VALUES (23, concat("23", repeat('a',8190)));
+INSERT INTO tab1 VALUES (24, concat("24", repeat('a',8190)));
+INSERT INTO tab1 VALUES (25, concat("25", repeat('a',8190)));
+INSERT INTO tab1 VALUES (26, concat("26", repeat('a',8190)));
+INSERT INTO tab1 VALUES (27, concat("27", repeat('a',8190)));
+INSERT INTO tab1 VALUES (28, concat("28", repeat('a',8190)));
+INSERT INTO tab1 VALUES (29, concat("29", repeat('a',8190)));
+INSERT INTO tab1 VALUES (30, concat("30", repeat('a',8190)));
+INSERT INTO tab1 VALUES (31, concat("31", repeat('a',8190)));
+INSERT INTO tab1 VALUES (32, concat("32", repeat('a',8190)));
+INSERT INTO tab1 VALUES (33, concat("33", repeat('a',8190)));
+INSERT INTO tab1 VALUES (11, concat("11", repeat('a',8190)));
+INSERT INTO tab1 VALUES (12, concat("12", repeat('a',8190)));
+INSERT INTO tab1 VALUES (13, concat("13", repeat('a',8190)));
+INSERT INTO tab1 VALUES (14, concat("14", repeat('a',8190)));
+INSERT INTO tab1 VALUES (15, concat("15", repeat('a',8190)));
+INSERT INTO tab1 VALUES (16, concat("16", repeat('a',8190)));
+INSERT INTO tab1 VALUES (17, concat("17", repeat('a',8190)));
+INSERT INTO tab1 VALUES (18, concat("18", repeat('a',8190)));
+INSERT INTO tab1 VALUES (19, concat("19", repeat('a',8190)));
+INSERT INTO tab1 VALUES (20, concat("20", repeat('a',8190)));
+INSERT INTO tab1 VALUES (21, concat("21", repeat('a',8190)));
+INSERT INTO tab1 VALUES (34, concat("34", repeat('a',8190)));
+INSERT INTO tab1 VALUES (35, concat("35", repeat('a',8190)));
+INSERT INTO tab1 VALUES (36, concat("36", repeat('a',8190)));
+INSERT INTO tab1 VALUES (37, concat("37", repeat('a',8190)));
+INSERT INTO tab1 VALUES (38, concat("38", repeat('a',8190)));
+INSERT INTO tab1 VALUES (39, concat("39", repeat('a',8190)));
+INSERT INTO tab1 VALUES (40, concat("40", repeat('a',8190)));
+INSERT INTO tab1 VALUES (41, concat("41", repeat('a',8190)));
+INSERT INTO tab1 VALUES (42, concat("42", repeat('a',8190)));
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 42
+4 2
+27 21
+28 21
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 33;
+delete from tab1 where a = 34;
+delete from tab1 where a = 35;
+delete from tab1 where a = 36;
+delete from tab1 where a = 37;
+delete from tab1 where a = 38;
+delete from tab1 where a = 39;
+delete from tab1 where a = 40;
+delete from tab1 where a = 41;
+delete from tab1 where a = 42;
+delete from tab1 where a = 12;
+delete from tab1 where a = 13;
+delete from tab1 where a = 14;
+delete from tab1 where a = 15;
+delete from tab1 where a = 16;
+delete from tab1 where a = 17;
+delete from tab1 where a = 18;
+delete from tab1 where a = 19;
+delete from tab1 where a = 20;
+delete from tab1 where a = 21;
+set global innodb_purge_run_now=ON;
+# check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 22
+4 2
+27 11
+28 11
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 32;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 31;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=45 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 30;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=40 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+DROP TABLE tab1;
+# compressed table behaves same (MERGE_THRESHOLD=45)
+CREATE TABLE tab1 (a bigint primary key, b blob) engine=InnoDB
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+CREATE INDEX index1 ON tab1(b(750)) COMMENT 'MERGE_THRESHOLD=45';
+# check MERGE_THRESHOLD
+select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
+TABLE_NAME INDEX_NAME MERGE_THRESHOLD
+test/tab1 PRIMARY 50
+test/tab1 index1 45
+INSERT INTO tab1 VALUES (1, concat("01", repeat('a',8190)));
+INSERT INTO tab1 VALUES (2, concat("02", repeat('a',8190)));
+INSERT INTO tab1 VALUES (3, concat("03", repeat('a',8190)));
+INSERT INTO tab1 VALUES (4, concat("04", repeat('a',8190)));
+INSERT INTO tab1 VALUES (5, concat("05", repeat('a',8190)));
+INSERT INTO tab1 VALUES (6, concat("06", repeat('a',8190)));
+INSERT INTO tab1 VALUES (7, concat("07", repeat('a',8190)));
+INSERT INTO tab1 VALUES (8, concat("08", repeat('a',8190)));
+INSERT INTO tab1 VALUES (9, concat("09", repeat('a',8190)));
+INSERT INTO tab1 VALUES (10, concat("10", repeat('a',8190)));
+INSERT INTO tab1 VALUES (22, concat("22", repeat('a',8190)));
+INSERT INTO tab1 VALUES (23, concat("23", repeat('a',8190)));
+INSERT INTO tab1 VALUES (24, concat("24", repeat('a',8190)));
+INSERT INTO tab1 VALUES (25, concat("25", repeat('a',8190)));
+INSERT INTO tab1 VALUES (26, concat("26", repeat('a',8190)));
+INSERT INTO tab1 VALUES (27, concat("27", repeat('a',8190)));
+INSERT INTO tab1 VALUES (28, concat("28", repeat('a',8190)));
+INSERT INTO tab1 VALUES (29, concat("29", repeat('a',8190)));
+INSERT INTO tab1 VALUES (30, concat("30", repeat('a',8190)));
+INSERT INTO tab1 VALUES (31, concat("31", repeat('a',8190)));
+INSERT INTO tab1 VALUES (32, concat("32", repeat('a',8190)));
+INSERT INTO tab1 VALUES (33, concat("33", repeat('a',8190)));
+INSERT INTO tab1 VALUES (11, concat("11", repeat('a',8190)));
+INSERT INTO tab1 VALUES (12, concat("12", repeat('a',8190)));
+INSERT INTO tab1 VALUES (13, concat("13", repeat('a',8190)));
+INSERT INTO tab1 VALUES (14, concat("14", repeat('a',8190)));
+INSERT INTO tab1 VALUES (15, concat("15", repeat('a',8190)));
+INSERT INTO tab1 VALUES (16, concat("16", repeat('a',8190)));
+INSERT INTO tab1 VALUES (17, concat("17", repeat('a',8190)));
+INSERT INTO tab1 VALUES (18, concat("18", repeat('a',8190)));
+INSERT INTO tab1 VALUES (19, concat("19", repeat('a',8190)));
+INSERT INTO tab1 VALUES (20, concat("20", repeat('a',8190)));
+INSERT INTO tab1 VALUES (21, concat("21", repeat('a',8190)));
+INSERT INTO tab1 VALUES (34, concat("34", repeat('a',8190)));
+INSERT INTO tab1 VALUES (35, concat("35", repeat('a',8190)));
+INSERT INTO tab1 VALUES (36, concat("36", repeat('a',8190)));
+INSERT INTO tab1 VALUES (37, concat("37", repeat('a',8190)));
+INSERT INTO tab1 VALUES (38, concat("38", repeat('a',8190)));
+INSERT INTO tab1 VALUES (39, concat("39", repeat('a',8190)));
+INSERT INTO tab1 VALUES (40, concat("40", repeat('a',8190)));
+INSERT INTO tab1 VALUES (41, concat("41", repeat('a',8190)));
+INSERT INTO tab1 VALUES (42, concat("42", repeat('a',8190)));
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 42
+4 2
+27 21
+28 21
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 33;
+delete from tab1 where a = 34;
+delete from tab1 where a = 35;
+delete from tab1 where a = 36;
+delete from tab1 where a = 37;
+delete from tab1 where a = 38;
+delete from tab1 where a = 39;
+delete from tab1 where a = 40;
+delete from tab1 where a = 41;
+delete from tab1 where a = 42;
+delete from tab1 where a = 12;
+delete from tab1 where a = 13;
+delete from tab1 where a = 14;
+delete from tab1 where a = 15;
+delete from tab1 where a = 16;
+delete from tab1 where a = 17;
+delete from tab1 where a = 18;
+delete from tab1 where a = 19;
+delete from tab1 where a = 20;
+delete from tab1 where a = 21;
+set global innodb_purge_run_now=ON;
+# check page merge happens (nothing is expected)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+select PAGE_NUMBER, NUMBER_RECORDS
+from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
+INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
+where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
+and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
+PAGE_NUMBER NUMBER_RECORDS
+3 22
+4 2
+27 11
+28 11
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 32;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=50 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 0
+index_page_merge_successful 0
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 31;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=45 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 1
+index_page_merge_successful 1
+set global innodb_purge_stop_now=ON;
+delete from tab1 where a = 30;
+set global innodb_purge_run_now=ON;
+# check page merge happens (MERGE_THRESHOLD=40 causes merge here)
+SELECT name,count_reset FROM information_schema.innodb_metrics
+WHERE name like 'index_page_merge_%';
+name count_reset
+index_page_merge_attempts 2
+index_page_merge_successful 2
+DROP TABLE tab1;
diff --git a/mysql-test/suite/innodb/r/innodb_bug14676111.result b/mysql-test/suite/innodb/r/innodb_bug14676111.result
index c2fdfee5522..1135259cfbf 100644
--- a/mysql-test/suite/innodb/r/innodb_bug14676111.result
+++ b/mysql-test/suite/innodb/r/innodb_bug14676111.result
@@ -1,7 +1,4 @@
-drop table if exists t1;
-call mtr.add_suppression("option 'innodb-purge-threads': unsigned value 0 adjusted to*");
-set global innodb_stats_persistent = false;
-CREATE TABLE t1 (a int not null primary key) engine=InnoDB;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=0;
set global innodb_limit_optimistic_insert_debug = 2;
insert into t1 values (1);
insert into t1 values (5);
diff --git a/mysql-test/suite/innodb/t/index_merge_threshold.opt b/mysql-test/suite/innodb/t/index_merge_threshold.opt
new file mode 100644
index 00000000000..56434e883de
--- /dev/null
+++ b/mysql-test/suite/innodb/t/index_merge_threshold.opt
@@ -0,0 +1 @@
+--loose-innodb_sys_tablespaces
diff --git a/mysql-test/suite/innodb/t/index_merge_threshold.test b/mysql-test/suite/innodb/t/index_merge_threshold.test
new file mode 100644
index 00000000000..7cbde0acf03
--- /dev/null
+++ b/mysql-test/suite/innodb/t/index_merge_threshold.test
@@ -0,0 +1,189 @@
+# #############################################################
+# wl6747 : Set merge threshold at index level
+# Check with CREATE INDEX on all datatypes
+# Check with by ALTER TABLE MODIFY COLUMN TYPE
+# Check with ALTER TABLE ADD Index
+# Check by setting at index level with CREATE TABLE
+# Check with BLOB column at index level with CREATE Index
+# Check with row_format=compressed and key_block_size=8k
+# Check withe valid and invalid merge_threshold values.
+#
+# Check actual behavior for table, partitioned table and temporary table
+# #############################################################
+--source include/have_innodb_16k.inc
+--source include/have_debug.inc
+--source include/have_partition.inc
+
+# Check index merge threshold by create index on all datatypes
+
+CREATE TABLE tab(a BIGINT PRIMARY KEY,c1 TINYTEXT,c2 TEXT,c3 MEDIUMTEXT,
+c4 TINYBLOB,c5 BLOB,c6 MEDIUMBLOB,c7 LONGBLOB) ENGINE=InnoDB;
+
+# check index merge threshold on all datatypes
+CREATE INDEX index1 ON tab(c1(255)) COMMENT 'Check index level merge MERGE_THRESHOLD=51';
+CREATE INDEX index2 ON tab(c2(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=-1';
+CREATE INDEX index3 ON tab(c3(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=20';
+CREATE INDEX index4 ON tab(c4(255)) COMMENT 'Check index level merge MERGE_THRESHOLD=25';
+CREATE INDEX index5 ON tab(c5(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=30';
+CREATE INDEX index6 ON tab(c6(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=35';
+CREATE INDEX index7 ON tab(c7(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=40';
+
+SHOW CREATE TABLE tab;
+
+SELECT t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+WHERE t.TABLE_ID = i.TABLE_ID AND t.NAME = 'test/tab';
+
+ALTER TABLE tab comment='MERGE_THRESHOLD=49';
+
+SHOW CREATE TABLE tab;
+
+SELECT t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+WHERE t.TABLE_ID = i.TABLE_ID AND t.NAME = 'test/tab';
+
+ALTER TABLE tab MODIFY COLUMN c7 VARCHAR(2048) ;
+
+SHOW CREATE TABLE tab;
+
+SELECT t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+WHERE t.TABLE_ID = i.TABLE_ID AND t.NAME = 'test/tab';
+
+ALTER TABLE tab ADD INDEX index8 (c7(750)) COMMENT 'Check index level merge MERGE_THRESHOLD=45';
+
+SHOW CREATE TABLE tab;
+
+SELECT t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
+FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
+WHERE t.TABLE_ID = i.TABLE_ID AND t.NAME = 'test/tab';
+# Cleanup
+DROP TABLE tab;
+
+
+
+--echo #
+--echo # behavior for deleting records
+--echo #
+
+--echo # test to confirm behavior (MERGE_THRESHOLD=50 (default))
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB;
+
+--source suite/innodb/include/innodb_merge_threshold_delete.inc
+
+DROP TABLE tab1;
+
+
+--echo # test to confirm behavior (MERGE_THRESHOLD=35)
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB
+COMMENT='MERGE_THRESHOLD=35';
+
+--source suite/innodb/include/innodb_merge_threshold_delete.inc
+
+DROP TABLE tab1;
+
+
+--echo # test to confirm behavior (MERGE_THRESHOLD=25)
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB
+COMMENT='MERGE_THRESHOLD=25';
+
+--source suite/innodb/include/innodb_merge_threshold_delete.inc
+
+DROP TABLE tab1;
+
+
+--echo # test to confirm partitioned table (MERGE_THRESHOLD=35)
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048))
+COMMENT='MERGE_THRESHOLD=35'
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (20) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
+
+--source suite/innodb/include/innodb_merge_threshold_delete.inc
+
+DROP TABLE tab1;
+
+
+
+--echo #
+--echo # behavior for updating to smaller records
+--echo #
+
+--echo # test to confirm behavior (MERGE_THRESHOLD=50 (default))
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB;
+
+--source suite/innodb/include/innodb_merge_threshold_update.inc
+
+DROP TABLE tab1;
+
+
+--echo # test to confirm behavior (MERGE_THRESHOLD=35)
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB
+COMMENT='MERGE_THRESHOLD=35';
+
+--source suite/innodb/include/innodb_merge_threshold_update.inc
+
+DROP TABLE tab1;
+
+
+--echo # test to confirm behavior (MERGE_THRESHOLD=25)
+CREATE TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB
+COMMENT='MERGE_THRESHOLD=25';
+
+--source suite/innodb/include/innodb_merge_threshold_update.inc
+
+DROP TABLE tab1;
+
+
+--echo # test to confirm explicit temporary table (MERGE_THRESHOLD=35)
+--echo # (though not registered to SYS_TABLES,SYS_INDEXES, it works correctly)
+# Temporary tables are not purged. so deleting records is not caused
+# So, should be tested by updating case only
+CREATE TEMPORARY TABLE tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB
+COMMENT='MERGE_THRESHOLD=35';
+
+--source suite/innodb/include/innodb_merge_threshold_update.inc
+
+DROP TABLE tab1;
+
+
+--echo #
+--echo # behavior for secondary index with blob
+--echo #
+
+--echo # test to confirm behavior (MERGE_THRESHOLD=50 (default))
+# not to cause page operation at primary key, row_format=dynamic and the key is blob
+CREATE TABLE tab1 (a bigint primary key, b blob) engine=InnoDB row_format=dynamic;
+CREATE INDEX index1 ON tab1(b(750));
+
+--source suite/innodb/include/innodb_merge_threshold_secondary.inc
+
+DROP TABLE tab1;
+
+
+--echo # test to confirm behavior (MERGE_THRESHOLD=45)
+CREATE TABLE tab1 (a bigint primary key, b blob) engine=InnoDB row_format=dynamic;
+CREATE INDEX index1 ON tab1(b(750)) COMMENT 'MERGE_THRESHOLD=45';
+
+--source suite/innodb/include/innodb_merge_threshold_secondary.inc
+
+DROP TABLE tab1;
+
+
+--echo # test to confirm behavior (MERGE_THRESHOLD=40)
+CREATE TABLE tab1 (a bigint primary key, b blob) engine=InnoDB row_format=dynamic;
+CREATE INDEX index1 ON tab1(b(750)) COMMENT 'MERGE_THRESHOLD=40';
+
+--source suite/innodb/include/innodb_merge_threshold_secondary.inc
+
+DROP TABLE tab1;
+
+
+--echo # compressed table behaves same (MERGE_THRESHOLD=45)
+CREATE TABLE tab1 (a bigint primary key, b blob) engine=InnoDB
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+CREATE INDEX index1 ON tab1(b(750)) COMMENT 'MERGE_THRESHOLD=45';
+
+--source suite/innodb/include/innodb_merge_threshold_secondary.inc
+
+DROP TABLE tab1;
diff --git a/mysql-test/suite/innodb/t/innodb_bug14676111-master.opt b/mysql-test/suite/innodb/t/innodb_bug14676111-master.opt
deleted file mode 100644
index e16b9b0b895..00000000000
--- a/mysql-test/suite/innodb/t/innodb_bug14676111-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---loose-innodb-purge-threads=0
diff --git a/mysql-test/suite/innodb/t/innodb_bug14676111.test b/mysql-test/suite/innodb/t/innodb_bug14676111.test
index ba04d421fde..02ef5e5e7f0 100644
--- a/mysql-test/suite/innodb/t/innodb_bug14676111.test
+++ b/mysql-test/suite/innodb/t/innodb_bug14676111.test
@@ -10,20 +10,12 @@ if (`select count(*)=0 from information_schema.global_variables where variable_n
--disable_query_log
set @old_innodb_limit_optimistic_insert_debug = @@innodb_limit_optimistic_insert_debug;
-set @old_innodb_stats_persistent = @@innodb_stats_persistent;
set @old_innodb_undo_logs = @@innodb_undo_logs;
# Limit undo segments for stable progress of purge.
set global innodb_undo_logs = 1;
--enable_query_log
---disable_warnings
-drop table if exists t1;
---enable_warnings
-call mtr.add_suppression("option 'innodb-purge-threads': unsigned value 0 adjusted to*");
-
-set global innodb_stats_persistent = false;
-
-CREATE TABLE t1 (a int not null primary key) engine=InnoDB;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=0;
#
# make 4 leveled straight tree
@@ -139,6 +131,5 @@ drop table t1;
--disable_query_log
set global innodb_limit_optimistic_insert_debug = @old_innodb_limit_optimistic_insert_debug;
-set global innodb_stats_persistent = @old_innodb_stats_persistent;
set global innodb_undo_logs = @old_innodb_undo_logs;
--enable_query_log