From aa796cab7dac5bb8a9ce311b558cdfb96f7b3ece Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 15 Feb 2006 14:34:51 +0400 Subject: [PATCH] Fix for bug#16907 Partitions: crash, SELECT goes into last partition, UNIQUE INDEX In presense of subpartitioning use get_part_partition_id() to calculate part_id --- mysql-test/r/partition.result | 11 +++++++++++ mysql-test/t/partition.test | 12 ++++++++++++ sql/sql_partition.cc | 5 ++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index ea88efa6d73..699f448689b 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -289,3 +289,14 @@ select * from t1 where f1 = 2; f1 f2 f3 2 2 2 drop table t1; +create table t1 (f1 integer,f2 integer, unique index(f1)) +partition by range(f1 div 2) +subpartition by hash(f1) subpartitions 2 +(partition partb values less than (2), +partition parte values less than (4), +partition partf values less than (10000)); +insert into t1 values(10,1); +select * from t1 where f1 = 10; +f1 f2 +10 1 +drop table t1; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 9b688525dfb..fd7e3bf7b70 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -368,3 +368,15 @@ insert into t1 values(2,2,'2'); select * from t1 where f1 = 2; drop table t1; +# +# Bug #16907 Partitions: crash, SELECT goes into last partition, UNIQUE INDEX +# +create table t1 (f1 integer,f2 integer, unique index(f1)) +partition by range(f1 div 2) +subpartition by hash(f1) subpartitions 2 +(partition partb values less than (2), +partition parte values less than (4), +partition partf values less than (10000)); +insert into t1 values(10,1); +select * from t1 where f1 = 10; +drop table t1; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 9830d24b604..e566c13a125 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -6009,7 +6009,10 @@ static uint32 get_next_partition_via_walking(PARTITION_ITERATOR *part_iter) field->store(part_iter->field_vals.start, FALSE); part_iter->field_vals.start++; longlong dummy; - if (!part_iter->part_info->get_partition_id(part_iter->part_info, + if (is_sub_partitioned(part_iter->part_info) && + !part_iter->part_info->get_part_partition_id(part_iter->part_info, + &part_id, &dummy) || + !part_iter->part_info->get_partition_id(part_iter->part_info, &part_id, &dummy)) return part_id; }