List:Commits« Previous MessageNext Message »
From:Mattias Jonsson Date:November 4 2008 3:35pm
Subject:bzr commit into mysql-5.1 branch (mattias.jonsson:2776) Bug#40494
View as plain text  
#At file:///Users/mattiasj/clones/bzrroot/b40494-51-5129rc/

 2776 Mattias Jonsson	2008-11-04
      Bug#40494: MYSQL server crashes on range access with
      partitioning and order by
      
      Problem was that the first index read was unordered,
      and the next was ordered, resulting in use of
      uninitialized data
      
      Solution was to use the correct variable to see if
      the 'next' call should be ordered or not.
modified:
  mysql-test/r/partition.result
  mysql-test/t/partition.test
  sql/ha_partition.cc

per-file messages:
  mysql-test/r/partition.result
    Bug#40494: MYSQL server crashes on range access with
    partitioning and order by
    
    Added test case for the bug
  mysql-test/t/partition.test
    Bug#40494: MYSQL server crashes on range access with
    partitioning and order by
    
    Added test case for the bug
  sql/ha_partition.cc
    Bug#40494: MYSQL server crashes on range access with
    partitioning and order by
    
    Used the wrong variable to decide to continue with
    ordered or unordered scan.
=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2008-10-07 15:19:32 +0000
+++ b/mysql-test/r/partition.result	2008-11-04 15:35:31 +0000
@@ -1,4 +1,44 @@
 drop table if exists t1, t2;
+CREATE TABLE t1 (a INT NOT NULL, KEY(a))
+PARTITION BY RANGE(a)
+(PARTITION p1 VALUES LESS THAN (200), PARTITION pmax VALUES LESS THAN MAXVALUE);
+INSERT INTO t1 VALUES (2), (40), (40), (70), (60), (90), (199);
+SELECT a FROM t1 WHERE a BETWEEN 60 AND 95 ORDER BY a ASC;
+a
+60
+70
+90
+INSERT INTO t1 VALUES (200), (250), (210);
+SELECT a FROM t1 WHERE a BETWEEN 60 AND 220 ORDER BY a ASC;
+a
+60
+70
+90
+199
+200
+210
+SELECT a FROM t1 WHERE a BETWEEN 200 AND 220 ORDER BY a ASC;
+a
+200
+210
+SELECT a FROM t1 WHERE a BETWEEN 60 AND 95 ORDER BY a DESC;
+a
+90
+70
+60
+SELECT a FROM t1 WHERE a BETWEEN 60 AND 220 ORDER BY a DESC;
+a
+210
+200
+199
+90
+70
+60
+SELECT a FROM t1 WHERE a BETWEEN 200 AND 220 ORDER BY a DESC;
+a
+210
+200
+DROP TABLE t1;
 CREATE TABLE t1 (
 a INT NOT NULL,   
 b MEDIUMINT NOT NULL,   

=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test	2008-10-07 15:19:32 +0000
+++ b/mysql-test/t/partition.test	2008-11-04 15:35:31 +0000
@@ -15,6 +15,23 @@ drop table if exists t1, t2;
 --enable_warnings
 
 #
+# Bug#40494: Crash MYSQL server crashes on range access with partitioning
+#            and order by
+#
+CREATE TABLE t1 (a INT NOT NULL, KEY(a))
+PARTITION BY RANGE(a)
+(PARTITION p1 VALUES LESS THAN (200), PARTITION pmax VALUES LESS THAN MAXVALUE);
+INSERT INTO t1 VALUES (2), (40), (40), (70), (60), (90), (199);
+SELECT a FROM t1 WHERE a BETWEEN 60 AND 95 ORDER BY a ASC;
+INSERT INTO t1 VALUES (200), (250), (210);
+SELECT a FROM t1 WHERE a BETWEEN 60 AND 220 ORDER BY a ASC;
+SELECT a FROM t1 WHERE a BETWEEN 200 AND 220 ORDER BY a ASC;
+SELECT a FROM t1 WHERE a BETWEEN 60 AND 95 ORDER BY a DESC;
+SELECT a FROM t1 WHERE a BETWEEN 60 AND 220 ORDER BY a DESC;
+SELECT a FROM t1 WHERE a BETWEEN 200 AND 220 ORDER BY a DESC;
+DROP TABLE t1;
+
+#
 # Bug35931: Index search may return duplicates
 #
 CREATE TABLE t1 (

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2008-10-06 13:14:20 +0000
+++ b/sql/ha_partition.cc	2008-11-04 15:35:31 +0000
@@ -4084,7 +4084,7 @@ int ha_partition::read_range_next()
 {
   DBUG_ENTER("ha_partition::read_range_next");
 
-  if (m_ordered)
+  if (m_ordered_scan_ongoing)
   {
     DBUG_RETURN(handle_ordered_next(table->record[0], eq_range));
   }

Thread
bzr commit into mysql-5.1 branch (mattias.jonsson:2776) Bug#40494Mattias Jonsson4 Nov