List:Commits« Previous MessageNext Message »
From:Sergey Petrunia Date:September 8 2007 6:14pm
Subject:bk commit into 5.0 tree (sergefp:1.2523) BUG#30385
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of psergey. When psergey 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-09-08 20:14:17+04:00, sergefp@stripped +3 -0
  BUG#30385: Server crash when deleting with ORDER BY and LIMIT
  in get_index_for_order(), don't walk over the end of the index key parts
  when matching index description and needed ordering.

  mysql-test/r/delete.result@stripped, 2007-09-08 20:14:13+04:00, sergefp@stripped +12 -0
    BUG#30385: Testcase

  mysql-test/t/delete.test@stripped, 2007-09-08 20:14:13+04:00, sergefp@stripped +16 -0
    BUG#30385: Testcase

  sql/opt_range.cc@stripped, 2007-09-08 20:14:13+04:00, sergefp@stripped +2 -1
    BUG#30385: Server crash when deleting with ORDER BY and LIMIT
    in get_index_for_order(), don't walk over the end of the index key parts
    when matching index description and needed ordering.

diff -Nrup a/mysql-test/r/delete.result b/mysql-test/r/delete.result
--- a/mysql-test/r/delete.result	2007-09-03 13:55:33 +04:00
+++ b/mysql-test/r/delete.result	2007-09-08 20:14:13 +04:00
@@ -260,3 +260,15 @@ a
 DROP TABLE t1, t2;
 DROP DATABASE db1;
 DROP DATABASE db2;
+CREATE TABLE t1 (
+`date` date ,
+`time` time ,
+`seq` int(10) unsigned NOT NULL auto_increment,
+PRIMARY KEY  (`seq`),
+KEY `seq` (`seq`),
+KEY `time` (`time`),
+KEY `date` (`date`)
+);
+DELETE FROM t1 ORDER BY date ASC, time ASC LIMIT 1;
+drop table t1;
+End of 5.0 tests
diff -Nrup a/mysql-test/t/delete.test b/mysql-test/t/delete.test
--- a/mysql-test/t/delete.test	2007-09-03 13:55:33 +04:00
+++ b/mysql-test/t/delete.test	2007-09-08 20:14:13 +04:00
@@ -265,3 +265,19 @@ SELECT * FROM t1;
 DROP TABLE t1, t2;
 DROP DATABASE db1;
 DROP DATABASE db2;
+
+# BUG#30385 "Server crash when deleting with order by and limit"
+CREATE TABLE t1 (
+  `date` date ,
+  `time` time ,
+  `seq` int(10) unsigned NOT NULL auto_increment,
+  PRIMARY KEY  (`seq`),
+  KEY `seq` (`seq`),
+  KEY `time` (`time`),
+  KEY `date` (`date`)
+);
+DELETE FROM t1 ORDER BY date ASC, time ASC LIMIT 1;
+drop table t1;
+
+-- echo End of 5.0 tests
+
diff -Nrup a/sql/opt_range.cc b/sql/opt_range.cc
--- a/sql/opt_range.cc	2007-08-15 19:37:11 +04:00
+++ b/sql/opt_range.cc	2007-09-08 20:14:13 +04:00
@@ -1619,6 +1619,7 @@ uint get_index_for_order(TABLE *table, O
     if (!(table->keys_in_use_for_query.is_set(idx)))
       continue;
     KEY_PART_INFO *keyinfo= table->key_info[idx].key_part;
+    uint n_parts=  table->key_info[idx].key_parts;
     uint partno= 0;
     
     /* 
@@ -1628,7 +1629,7 @@ uint get_index_for_order(TABLE *table, O
     */
     if (!(table->file->index_flags(idx, 0, 1) & HA_READ_ORDER))
       continue;
-    for (ord= order; ord; ord= ord->next, partno++)
+    for (ord= order; ord && partno < n_parts; ord= ord->next, partno++)
     {
       Item *item= order->item[0];
       if (!(item->type() == Item::FIELD_ITEM &&
Thread
bk commit into 5.0 tree (sergefp:1.2523) BUG#30385Sergey Petrunia8 Sep