Skip to content

Commit 3d65d0d

Browse files
committed
MDEV-9137 MariaDB Crash on Query Using Aria Engine
Two bugs in Aria, related to 2-level fulltext indexes: * REPAIR calculated the key number incorrectly * CHECK copied the key into last_key too early and checking the second-level btree was overwriting it
1 parent fc70f21 commit 3d65d0d

File tree

3 files changed

+67
-6
lines changed

3 files changed

+67
-6
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
CREATE TABLE t1 (
2+
i int(10) unsigned not null auto_increment primary key,
3+
a varchar(255) not null,
4+
FULLTEXT KEY (a)
5+
) ENGINE=Aria ROW_FORMAT=DYNAMIC MAX_ROWS=2000000000000;
6+
repair table t1 quick;
7+
Table Op Msg_type Msg_text
8+
test.t1 repair status OK
9+
check table t1;
10+
Table Op Msg_type Msg_text
11+
test.t1 check status OK
12+
repair table t1;
13+
Table Op Msg_type Msg_text
14+
test.t1 repair status OK
15+
check table t1;
16+
Table Op Msg_type Msg_text
17+
test.t1 check status OK
18+
repair table t1;
19+
Table Op Msg_type Msg_text
20+
test.t1 repair status OK
21+
drop table t1;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
# test of new fulltext search features
3+
#
4+
5+
let collation=utf8_unicode_ci;
6+
source include/have_collation.inc;
7+
8+
#
9+
# two-level tree
10+
#
11+
12+
CREATE TABLE t1 (
13+
i int(10) unsigned not null auto_increment primary key,
14+
a varchar(255) not null,
15+
FULLTEXT KEY (a)
16+
) ENGINE=Aria ROW_FORMAT=DYNAMIC MAX_ROWS=2000000000000;
17+
18+
# two-level entry, second-level tree with depth 2
19+
disable_query_log;
20+
let $1=1024;
21+
while ($1)
22+
{
23+
eval insert t1 (a) values ('aaaxxx');
24+
dec $1;
25+
}
26+
27+
# one-level entry (entries)
28+
let $1=150;
29+
while ($1)
30+
{
31+
eval insert t1 (a) values ('aaayyy');
32+
dec $1;
33+
}
34+
enable_query_log;
35+
36+
repair table t1 quick;
37+
check table t1;
38+
repair table t1;
39+
check table t1;
40+
repair table t1;
41+
42+
43+
drop table t1;

storage/maria/ma_check.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
891891
if (level > param->max_level)
892892
param->max_level=level;
893893

894-
if (_ma_get_keynr(share, anc_page->buff) !=
895-
(uint) (keyinfo - share->keyinfo))
894+
if (_ma_get_keynr(share, anc_page->buff) != keyinfo->key_nr)
896895
_ma_check_print_error(param, "Page at %s is not marked for index %u",
897896
llstr(anc_page->pos, llbuff),
898897
(uint) (keyinfo - share->keyinfo));
@@ -916,7 +915,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
916915
info->last_key.keyinfo= tmp_key.keyinfo= keyinfo;
917916
info->lastinx= ~0; /* Safety */
918917
tmp_key.data= tmp_key_buff;
919-
for ( ;; )
918+
for ( ;; _ma_copy_key(&info->last_key, &tmp_key))
920919
{
921920
if (nod_flag)
922921
{
@@ -998,7 +997,6 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
998997
tmp_key.data);
999998
}
1000999
}
1001-
_ma_copy_key(&info->last_key, &tmp_key);
10021000
(*key_checksum)+= maria_byte_checksum(tmp_key.data, tmp_key.data_length);
10031001
record= _ma_row_pos_from_key(&tmp_key);
10041002

@@ -5728,8 +5726,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param,
57285726
a_length= share->keypage_header + nod_flag;
57295727
key_block->end_pos= anc_buff + share->keypage_header;
57305728
bzero(anc_buff, share->keypage_header);
5731-
_ma_store_keynr(share, anc_buff, (uint) (sort_param->keyinfo -
5732-
share->keyinfo));
5729+
_ma_store_keynr(share, anc_buff, sort_param->keyinfo->key_nr);
57335730
lastkey=0;/* No previous key in block */
57345731
}
57355732
else

0 commit comments

Comments
 (0)