List:Commits« Previous MessageNext Message »
From:Ramil Kalimullin Date:April 1 2009 5:35am
Subject:bzr commit into mysql-5.1-bugteam branch (ramil:2841) Bug#42944
View as plain text  
#At file:///home/ram/mysql/b42944-5.1-bugteam/ based on revid:staale.smedseng@stripped

 2841 Ramil Kalimullin	2009-04-01
      Fix for bug#42944: partition not pruned correctly
      
      Problem: we don't prune a LESS THAN partition if MAXVALUE is given and
      given value is equal to a LESS THAN value.
      
      Fix: prune partitions in such cases.
     @ mysql-test/r/partition.result
        Fix for bug#42944: partition not pruned correctly
          - test result.
     @ mysql-test/t/partition.test
        Fix for bug#42944: partition not pruned correctly
          - test case.
     @ sql/sql_partition.cc
        Fix for bug#42944: partition not pruned correctly
          - prune partition if given value is equal to a LESS THAN value
            and it's not a "PARTITION ... LESS THAN MAXVALUE" one.

    modified:
      mysql-test/r/partition.result
      mysql-test/t/partition.test
      sql/sql_partition.cc
=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2009-02-18 20:10:19 +0000
+++ b/mysql-test/r/partition.result	2009-04-01 05:34:59 +0000
@@ -1911,5 +1911,18 @@ select count(*) from t1;
 count(*)
 288
 drop table t1;
+#
+# Bug#42944: partition not pruned correctly
+#
+CREATE TABLE t1 (a int) PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN (200),
+PARTITION p2 VALUES LESS THAN (300),
+PARTITION p3 VALUES LESS THAN MAXVALUE);
+INSERT INTO t1 VALUES (10), (100), (200), (300), (400);
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a>=200;
+id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	p2,p3	ALL	NULL	NULL	NULL	NULL	3	Using where
+DROP TABLE t1;
 End of 5.1 tests
 SET @@global.general_log= @old_general_log;

=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test	2009-02-18 20:10:19 +0000
+++ b/mysql-test/t/partition.test	2009-04-01 05:34:59 +0000
@@ -1922,6 +1922,19 @@ insert into t1 select s1 from t1 where s
 select count(*) from t1;
 drop table t1;
 
+
+--echo #
+--echo # Bug#42944: partition not pruned correctly
+--echo #
+CREATE TABLE t1 (a int) PARTITION BY RANGE (a)
+  (PARTITION p0 VALUES LESS THAN (100),
+   PARTITION p1 VALUES LESS THAN (200),
+   PARTITION p2 VALUES LESS THAN (300),
+   PARTITION p3 VALUES LESS THAN MAXVALUE);
+INSERT INTO t1 VALUES (10), (100), (200), (300), (400);
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a>=200;
+DROP TABLE t1;
+
 --echo End of 5.1 tests
 
 

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2009-01-09 13:18:08 +0000
+++ b/sql/sql_partition.cc	2009-04-01 05:34:59 +0000
@@ -2937,7 +2937,8 @@ uint32 get_partition_id_range_for_endpoi
       the maximum value is in the current partition.
     */
     if (part_func_value > bound ||
-        (part_func_value == bound && !part_info->defined_max_value))
+        (part_func_value == bound &&
+         (!part_info->defined_max_value || loc_part_id < max_partition)))
       loc_part_id++;
   }
   else 


Attachment: [text/bzr-bundle] bzr/ramil@mysql.com-20090401053459-07x8z2pw2ev94xck.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (ramil:2841) Bug#42944Ramil Kalimullin1 Apr
  • Re: bzr commit into mysql-5.1-bugteam branch (ramil:2841) Bug#42944Mattias Jonsson1 Apr