# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2006/08/05 16:12:24-04:00 mikael@dator5.(none)
# BUG#21339: Crash at EXPLAIN PARTITIONS
# Caused by missing check for end of partitions in prune range check
#
# mysql-test/r/partition.result
# 2006/08/05 16:12:22-04:00 mikael@dator5.(none) +28 -0
# Added test case for duplicate bug#21388
#
# mysql-test/r/partition_range.result
# 2006/08/05 16:12:22-04:00 mikael@dator5.(none) +10 -0
# Added new test case for bug#21339
#
# mysql-test/t/partition.test
# 2006/08/05 16:12:22-04:00 mikael@dator5.(none) +18 -0
# Added test case for duplicate bug#21388
#
# mysql-test/t/partition_range.test
# 2006/08/05 16:12:22-04:00 mikael@dator5.(none) +13 -0
# Added new test case for bug#21339
#
# sql/sql_partition.cc
# 2006/08/05 16:12:22-04:00 mikael@dator5.(none) +7 -4
# Check so that we don't set outer range to be larger than
max_partition
#
diff -Nru a/mysql-test/r/partition.result
b/mysql-test/r/partition.result
--- a/mysql-test/r/partition.result 2006-08-05 16:18:23 -04:00
+++ b/mysql-test/r/partition.result 2006-08-05 16:18:23 -04:00
@@ -1117,4 +1117,32 @@
hello/master-data/tmpinx/t1#P#p2#SP#subpart20.MYI
hello/master-data/tmpinx/t1#P#p2#SP#subpart21.MYI
drop table t1;
+create table t1 (a bigint unsigned not null, primary key(a))
+engine = myisam
+partition by key (a)
+partitions 10;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a)
PARTITIONS 10 */
+insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE),
+(18446744073709551613), (18446744073709551612);
+select * from t1;
+a
+18446744073709551612
+18446744073709551613
+18446744073709551614
+18446744073709551615
+select * from t1 where a = 18446744073709551615;
+a
+18446744073709551615
+delete from t1 where a = 18446744073709551615;
+select * from t1;
+a
+18446744073709551612
+18446744073709551613
+18446744073709551614
+drop table t1;
End of 5.1 tests
diff -Nru a/mysql-test/r/partition_range.result
b/mysql-test/r/partition_range.result
--- a/mysql-test/r/partition_range.result 2006-08-05 16:18:23 -04:00
+++ b/mysql-test/r/partition_range.result 2006-08-05 16:18:23 -04:00
@@ -1,4 +1,14 @@
drop table if exists t1;
+create table t1 (a date)
+engine = innodb
+partition by range (year(a))
+(partition p0 values less than (2006),
+partition p1 values less than (2007));
+explain partitions select * from t1
+where a between '2006-01-01' and '2007-06-01';
+id select_type table partitions type possible_keys key key_len ref
rows Extra
+1 SIMPLE t1 p1 ALL NULL NULL NULL NULL 2 Using where
+drop table t1;
create table t1 (a int unsigned)
partition by range (a)
(partition pnull values less than (0),
diff -Nru a/mysql-test/t/partition.test b/mysql-test/t/partition.test
--- a/mysql-test/t/partition.test 2006-08-05 16:18:23 -04:00
+++ b/mysql-test/t/partition.test 2006-08-05 16:18:23 -04:00
@@ -1300,4 +1300,22 @@
drop table t1;
--exec rmdir $MYSQLTEST_VARDIR/master-data/tmpdata || true
--exec rmdir $MYSQLTEST_VARDIR/master-data/tmpinx || true
+
+#
+# Bug 21388: Bigint fails to find record
+#
+create table t1 (a bigint unsigned not null, primary key(a))
+engine = myisam
+partition by key (a)
+partitions 10;
+
+show create table t1;
+insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE),
+(18446744073709551613), (18446744073709551612);
+select * from t1;
+select * from t1 where a = 18446744073709551615;
+delete from t1 where a = 18446744073709551615;
+select * from t1;
+drop table t1;
+
--echo End of 5.1 tests
diff -Nru a/mysql-test/t/partition_range.test
b/mysql-test/t/partition_range.test
--- a/mysql-test/t/partition_range.test 2006-08-05 16:18:23 -04:00
+++ b/mysql-test/t/partition_range.test 2006-08-05 16:18:23 -04:00
@@ -10,6 +10,18 @@
--enable_warnings
#
+# Bug 21339: Crash in Explain Partitions
+#
+create table t1 (a date)
+engine = innodb
+partition by range (year(a))
+(partition p0 values less than (2006),
+ partition p1 values less than (2007));
+explain partitions select * from t1
+where a between '2006-01-01' and '2007-06-01';
+drop table t1;
+
+#
# More checks for partition pruning
#
create table t1 (a int unsigned)
@@ -686,3 +698,4 @@
WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR
(a >= '2005-07-01' AND a <= '2005-09-30');
DROP TABLE t1;
+
diff -Nru a/sql/sql_partition.cc b/sql/sql_partition.cc
--- a/sql/sql_partition.cc 2006-08-05 16:18:23 -04:00
+++ b/sql/sql_partition.cc 2006-08-05 16:18:23 -04:00
@@ -2573,10 +2573,13 @@
}
else
{
- if (part_func_value == range_array[loc_part_id])
- loc_part_id += test(include_endpoint);
- else if (part_func_value > range_array[loc_part_id])
- loc_part_id++;
+ if (loc_part_id < max_partition)
+ {
+ if (part_func_value == range_array[loc_part_id])
+ loc_part_id += test(include_endpoint);
+ else if (part_func_value > range_array[loc_part_id])
+ loc_part_id++;
+ }
loc_part_id++;
}
DBUG_RETURN(loc_part_id);
Mikael Ronstrom, Senior Software Architect
MySQL AB, www.mysql.com
Jumpstart your cluster:
http://www.mysql.com/consulting/packaged/cluster.html
My blog:
http://mikaelronstrom.blogspot.com
| Thread |
|---|
| • bk commit - 5.1 tree (mikael:1.2265) BUG#21339 | Mikael Ronström | 5 Aug |