Skip to content

Commit a918487

Browse files
author
kaa@polly.(none)
committed
Merge polly.(none):/home/kaa/src/maint/mysql-5.0-maint
into polly.(none):/home/kaa/src/maint/mysql-5.1-maint
2 parents a152ff1 + 5cb0d70 commit a918487

File tree

3 files changed

+61
-3
lines changed

3 files changed

+61
-3
lines changed

mysql-test/r/repair.result

+27
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,33 @@ test.t1 repair status OK
8888
SET myisam_repair_threads=@@global.myisam_repair_threads;
8989
SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
9090
DROP TABLE t1;
91+
CREATE TABLE t1(a CHAR(255), KEY(a));
92+
SET myisam_sort_buffer_size=4196;
93+
INSERT INTO t1 VALUES
94+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
95+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
96+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
97+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
98+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
99+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
100+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
101+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
102+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
103+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
104+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
105+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
106+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
107+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
108+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
109+
('0'),('0'),('0'),('0'),('0'),('0'),('0');
110+
SET myisam_repair_threads=2;
111+
REPAIR TABLE t1;
112+
Table Op Msg_type Msg_text
113+
test.t1 repair status OK
114+
SET myisam_repair_threads=@@global.myisam_repair_threads;
115+
SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
116+
DROP TABLE t1;
117+
End of 4.1 tests
91118
DROP TABLE IF EXISTS tt1;
92119
CREATE TEMPORARY TABLE tt1 (c1 INT);
93120
REPAIR TABLE tt1 USE_FRM;

mysql-test/t/repair.test

+30-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,36 @@ SET myisam_repair_threads=@@global.myisam_repair_threads;
8383
SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
8484
DROP TABLE t1;
8585

86-
# End of 4.1 tests
86+
#
87+
# BUG#31174 - "Repair" command on MyISAM crashes with small
88+
# myisam_sort_buffer_size
89+
#
90+
CREATE TABLE t1(a CHAR(255), KEY(a));
91+
SET myisam_sort_buffer_size=4196;
92+
INSERT INTO t1 VALUES
93+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
94+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
95+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
96+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
97+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
98+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
99+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
100+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
101+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
102+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
103+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
104+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
105+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
106+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
107+
('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
108+
('0'),('0'),('0'),('0'),('0'),('0'),('0');
109+
SET myisam_repair_threads=2;
110+
REPAIR TABLE t1;
111+
SET myisam_repair_threads=@@global.myisam_repair_threads;
112+
SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
113+
DROP TABLE t1;
114+
115+
--echo End of 4.1 tests
87116
# End of 5.0 tests
88117

89118
#

storage/myisam/sort.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,10 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
565565
if (!mergebuf)
566566
{
567567
length=param->sort_buffer_length;
568-
while (length >= MIN_SORT_MEMORY && !mergebuf)
568+
while (length >= MIN_SORT_MEMORY)
569569
{
570-
mergebuf=my_malloc(length, MYF(0));
570+
if ((mergebuf= my_malloc(length, MYF(0))))
571+
break;
571572
length=length*3/4;
572573
}
573574
if (!mergebuf)
@@ -904,6 +905,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
904905

905906
count=error=0;
906907
maxcount=keys/((uint) (Tb-Fb) +1);
908+
DBUG_ASSERT(maxcount > 0);
907909
LINT_INIT(to_start_filepos);
908910
if (to_file)
909911
to_start_filepos=my_b_tell(to_file);

0 commit comments

Comments
 (0)