List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:October 10 2007 9:01pm
Subject:bk commit into 4.1 tree (kaa:1.2685) BUG#31174
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of kaa. When kaa does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-10-10 23:01:21+04:00, kaa@polly.(none) +3 -0
  Fix for bug #31174: "Repair" command on MyISAM crashes with small
myisam_sort_buffer_size.
  
  An incorrect length of the sort buffer was used when calculating the maximum number of
keys. This resulted in the number of keys < number of BUFFPEK structures, which in
turn led to use of uninitialized BUFFPEK structures.

  myisam/sort.c@stripped, 2007-10-10 23:01:18+04:00, kaa@polly.(none) +4 -2
    Use a correct buffer length when calculating the maximum number of keys.
    Assert that for each BUFFPEK structure there is at least one corresponding key.
Otherwise we would fail earlier and not reach merge_buffers().

  mysql-test/r/repair.result@stripped, 2007-10-10 23:01:18+04:00, kaa@polly.(none) +27 -0
    Added a test case for bug #31174.

  mysql-test/t/repair.test@stripped, 2007-10-10 23:01:18+04:00, kaa@polly.(none) +30 -1
    Added a test case for bug #31174.

diff -Nrup a/myisam/sort.c b/myisam/sort.c
--- a/myisam/sort.c	2007-05-05 01:38:28 +04:00
+++ b/myisam/sort.c	2007-10-10 23:01:18 +04:00
@@ -559,9 +559,10 @@ int thr_write_keys(MI_SORT_PARAM *sort_p
       if (!mergebuf)
       {
         length=param->sort_buffer_length;
-        while (length >= MIN_SORT_MEMORY && !mergebuf)
+        while (length >= MIN_SORT_MEMORY)
         {
-          mergebuf=my_malloc(length, MYF(0));
+          if ((mergebuf= my_malloc(length, MYF(0))))
+              break;
           length=length*3/4;
         }
         if (!mergebuf)
@@ -897,6 +898,7 @@ merge_buffers(MI_SORT_PARAM *info, uint 
 
   count=error=0;
   maxcount=keys/((uint) (Tb-Fb) +1);
+  DBUG_ASSERT(maxcount > 0);
   LINT_INIT(to_start_filepos);
   if (to_file)
     to_start_filepos=my_b_tell(to_file);
diff -Nrup a/mysql-test/r/repair.result b/mysql-test/r/repair.result
--- a/mysql-test/r/repair.result	2007-05-05 01:38:28 +04:00
+++ b/mysql-test/r/repair.result	2007-10-10 23:01:18 +04:00
@@ -83,3 +83,30 @@ test.t1	repair	status	OK
 SET myisam_repair_threads=@@global.myisam_repair_threads;
 SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
 DROP TABLE t1;
+CREATE TABLE t1(a CHAR(255), KEY(a));
+SET myisam_sort_buffer_size=4196;
+INSERT INTO t1 VALUES
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0');
+SET myisam_repair_threads=2;
+REPAIR TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	repair	status	OK
+SET myisam_repair_threads=@@global.myisam_repair_threads;
+SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
+DROP TABLE t1;
+End of 4.1 tests
diff -Nrup a/mysql-test/t/repair.test b/mysql-test/t/repair.test
--- a/mysql-test/t/repair.test	2006-10-19 16:35:04 +04:00
+++ b/mysql-test/t/repair.test	2007-10-10 23:01:18 +04:00
@@ -83,4 +83,33 @@ SET myisam_repair_threads=@@global.myisa
 SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
 DROP TABLE t1;
 
-# End of 4.1 tests
+#
+# BUG#31174 - "Repair" command on MyISAM crashes with small 
+#              myisam_sort_buffer_size
+#
+CREATE TABLE t1(a CHAR(255), KEY(a));
+SET myisam_sort_buffer_size=4196;
+INSERT INTO t1 VALUES
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0');
+SET myisam_repair_threads=2;
+REPAIR TABLE t1;
+SET myisam_repair_threads=@@global.myisam_repair_threads;
+SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
+DROP TABLE t1;
+
+--echo End of 4.1 tests
Thread
bk commit into 4.1 tree (kaa:1.2685) BUG#31174Alexey Kopytov10 Oct
  • Re: bk commit into 4.1 tree (kaa:1.2685) BUG#31174Ingo Strüwing11 Oct
    • Re: bk commit into 4.1 tree (kaa:1.2685) BUG#31174Alexey Kopytov11 Oct