Skip to content

Commit d2fa9fd

Browse files
author
svoj@mysql.com/april.(none)
committed
Merge mysql.com:/home/svoj/devel/mysql/BUG23175/mysql-4.1-engines
into mysql.com:/home/svoj/devel/mysql/engines/mysql-4.1-engines
2 parents b6f909b + a2e0059 commit d2fa9fd

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

myisam/sort.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
148148
skr=maxbuffer;
149149
if (memavl < sizeof(BUFFPEK)*(uint) maxbuffer ||
150150
(keys=(memavl-sizeof(BUFFPEK)*(uint) maxbuffer)/
151-
(sort_length+sizeof(char*))) <= 1)
151+
(sort_length+sizeof(char*))) <= 1 ||
152+
keys < (uint) maxbuffer)
152153
{
153154
mi_check_print_error(info->sort_info->param,
154155
"sort_buffer_size is to small");
@@ -363,7 +364,8 @@ pthread_handler_decl(thr_find_all_keys,arg)
363364
skr=maxbuffer;
364365
if (memavl < sizeof(BUFFPEK)*maxbuffer ||
365366
(keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/
366-
(sort_length+sizeof(char*))) <= 1)
367+
(sort_length+sizeof(char*))) <= 1 ||
368+
keys < (uint) maxbuffer)
367369
{
368370
mi_check_print_error(sort_param->sort_info->param,
369371
"sort_buffer_size is to small");
@@ -497,6 +499,8 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
497499
if (!sinfo->sort_keys)
498500
{
499501
got_error=1;
502+
my_free(mi_get_rec_buff_ptr(info, sinfo->rec_buff),
503+
MYF(MY_ALLOW_ZERO_PTR));
500504
continue;
501505
}
502506
if (!got_error)

mysql-test/r/repair.result

+28
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,31 @@ Table Op Msg_type Msg_text
5555
test.t1 repair status OK
5656
USE test;
5757
DROP TABLE t1;
58+
CREATE TABLE t1(a CHAR(255), KEY(a));
59+
SET myisam_sort_buffer_size=4096;
60+
INSERT INTO t1 VALUES
61+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
62+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
63+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
64+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
65+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
66+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
67+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
68+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
69+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
70+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
71+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
72+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
73+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
74+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
75+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
76+
('0'),('0'),('0'),('0'),('0'),('0'),('0');
77+
SET myisam_repair_threads=2;
78+
REPAIR TABLE t1;
79+
Table Op Msg_type Msg_text
80+
test.t1 repair error sort_buffer_size is to small
81+
test.t1 repair warning Number of rows changed from 0 to 157
82+
test.t1 repair status OK
83+
SET myisam_repair_threads=@@global.myisam_repair_threads;
84+
SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
85+
DROP TABLE t1;

mysql-test/t/repair.test

+28
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,32 @@ REPAIR TABLE test.t1 USE_FRM;
5555
USE test;
5656
DROP TABLE t1;
5757

58+
#
59+
# BUG#23175 - MYISAM crash/repair failed during repair
60+
#
61+
CREATE TABLE t1(a CHAR(255), KEY(a));
62+
SET myisam_sort_buffer_size=4096;
63+
INSERT INTO t1 VALUES
64+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
65+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
66+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
67+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
68+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
69+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
70+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
71+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
72+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
73+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
74+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
75+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
76+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
77+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
78+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
79+
('0'),('0'),('0'),('0'),('0'),('0'),('0');
80+
SET myisam_repair_threads=2;
81+
REPAIR TABLE t1;
82+
SET myisam_repair_threads=@@global.myisam_repair_threads;
83+
SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
84+
DROP TABLE t1;
85+
5886
# End of 4.1 tests

0 commit comments

Comments
 (0)