Skip to content

Commit 352b6bc

Browse files
author
Marko Makela
committed
Bug#19584379 Reporting corruption may corrupt the innodb data dictionary
dict_set_corrupted(): Use the canonical way of searching for less-than-equal (PAGE_CUR_LE) and then checking low_match. The code that was introduced in MySQL 5.5.17 in Bug#11830883 SUPPORT "CORRUPTED" BIT FOR INNODB TABLES AND INDEXES could position the cursor on the page supremum, and then attempt to overwrite non-existing 7th field of the 1-field supremum record. Approved by Jimmy Yang
1 parent 5057f47 commit 352b6bc

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

mysql-test/suite/innodb/r/innodb_corrupt_bit.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,5 @@ z
7878
31
7979
32
8080
drop table corrupt_bit_test_ā;
81+
DROP DATABASE pad;
8182
SET GLOBAL innodb_change_buffering_debug = 0;

mysql-test/suite/innodb/t/innodb_corrupt_bit.test

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@
1616
# It instructs InnoDB to try to evict pages from the buffer pool when
1717
# change buffering is possible, so that the change buffer will be used
1818
# whenever possible.
19-
-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE
2019
SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug;
21-
-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE
2220
SET GLOBAL innodb_change_buffering_debug = 1;
2321

2422
# Turn off Unique Check to create corrupted index with dup key
2523
SET UNIQUE_CHECKS=0;
2624

25+
CREATE DATABASE pad;
26+
let $i=345;
27+
while ($i)
28+
{
29+
--eval CREATE TABLE pad.t$i (a INT PRIMARY KEY) ENGINE=InnoDB;
30+
dec $i;
31+
}
32+
2733
-- enable_query_log
2834

2935
set names utf8;
@@ -119,6 +125,6 @@ select z from corrupt_bit_test_ā limit 10;
119125

120126
# Drop table
121127
drop table corrupt_bit_test_ā;
128+
DROP DATABASE pad;
122129

123-
-- error 0, ER_UNKNOWN_SYSTEM_VARIABLE
124130
SET GLOBAL innodb_change_buffering_debug = 0;

storage/innobase/dict/dict0dict.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5498,11 +5498,11 @@ dict_set_corrupted(
54985498

54995499
dict_index_copy_types(tuple, sys_index, 2);
55005500

5501-
btr_cur_search_to_nth_level(sys_index, 0, tuple, PAGE_CUR_GE,
5501+
btr_cur_search_to_nth_level(sys_index, 0, tuple, PAGE_CUR_LE,
55025502
BTR_MODIFY_LEAF,
55035503
&cursor, 0, __FILE__, __LINE__, &mtr);
55045504

5505-
if (cursor.up_match == dtuple_get_n_fields(tuple)) {
5505+
if (cursor.low_match == dtuple_get_n_fields(tuple)) {
55065506
/* UPDATE SYS_INDEXES SET TYPE=index->type
55075507
WHERE TABLE_ID=index->table->id AND INDEX_ID=index->id */
55085508
ulint len;

0 commit comments

Comments
 (0)