Description:
MySQL can control page merging by setting the value of MERGE_THRESHOLD in the comment. However, in the implementation, the function strstr is used to check whether MERGE_THRESHOLD is configured in the comment. This may lead to unexpected results if the comment uses the lowercase "merge_threshold."
The method to set merge threshold for tables is to configure it in comment, like this:
```
CREATE TABLE t1 (
id INT,
KEY id_index (id)
) COMMENT='MERGE_THRESHOLD=45';
```
The code about this is:
```
static ulint innobase_parse_merge_threshold(THD *thd, const char *str) {
static const char *label = "MERGE_THRESHOLD=";
static const size_t label_len = strlen(label);
const char *pos = str;
pos = strstr(str, label);
if (pos == nullptr) {
return (0);
}
...
}
```
How to repeat:
```
mysql> create database test;
Query OK, 1 row affected (0.01 sec)
mysql> use test;
Database changed
mysql> create table t1 (c1 int primary key, c2 int) engine=innodb COMMENT "merge_threshold=30";
Query OK, 0 rows affected (0.11 sec)
mysql> create table t2 (c1 int primary key, c2 int) engine=innodb COMMENT "MERGE_THRESHOLD=30";
Query OK, 0 rows affected (0.12 sec)
mysql> use information_schema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select INNODB_TABLES.TABLE_ID, INNODB_TABLES.NAME, INNODB_INDEXES.MERGE_THRESHOLD from INNODB_TABLES INNER JOIN INNODB_INDEXES
ON INNODB_TABLES.TABLE_ID=INNODB_INDEXES.TABLE_ID WHERE INNODB_TABLES.NAME like "%test%";
+----------+---------+-----------------+
| TABLE_ID | NAME | MERGE_THRESHOLD |
+----------+---------+-----------------+
| 1070 | test/t1 | 50 |
| 1071 | test/t2 | 30 |
+----------+---------+-----------------+
2 rows in set (0.50 sec)
```
Suggested fix:
For a better experience, this configuration should be consistent with other configurations, making it case-insensitive. The implementation can be easily improved by using strcasestr instead of strstr to handle the comment.
```
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -13394,7 +13394,7 @@ static ulint innobase_parse_merge_threshold(THD *thd, const char *str) {
static const size_t label_len = strlen(label);
const char *pos = str;
- pos = strstr(str, label);
+ pos = strcasestr(str, label);
if (pos == nullptr) {
return (0);
```