From 76374fe5643edcca1067070912efef5599f48e70 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 15 Feb 2006 13:42:43 +0400 Subject: [PATCH] Fix for bug#16901 Partitions: crash, SELECT, column of part. function=first column of primary key use part_info->no_subparts to calculate partition range in case of subpartitions mysql-test/r/partition.result: Fix for bug#16901 Partitions: crash, SELECT, column of part. function=first column of primary key test case mysql-test/t/partition.test: Fix for bug#16901 Partitions: crash, SELECT, column of part. function=first column of primary key test case --- mysql-test/r/partition.result | 11 +++++++++++ mysql-test/t/partition.test | 15 +++++++++++++++ sql/sql_partition.cc | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index a638babc365..ea88efa6d73 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -278,3 +278,14 @@ partition p1 values in (14) insert into t1 values (10,1); ERROR HY000: Table has no partition for value 11 drop table t1; +create table t1 (f1 integer,f2 integer, f3 varchar(10), primary key(f1,f2)) +partition by range(f1) subpartition by hash(f2) subpartitions 2 +(partition p1 values less than (0), +partition p2 values less than (2), +partition p3 values less than (2147483647)); +insert into t1 values(10,10,'10'); +insert into t1 values(2,2,'2'); +select * from t1 where f1 = 2; +f1 f2 f3 +2 2 2 +drop table t1; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 301c1971c91..9b688525dfb 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -353,3 +353,18 @@ insert into t1 values (10,1); drop table t1; +# +# Bug#16901 Partitions: crash, SELECT, column of part. +# function=first column of primary key +# +create table t1 (f1 integer,f2 integer, f3 varchar(10), primary key(f1,f2)) +partition by range(f1) subpartition by hash(f2) subpartitions 2 +(partition p1 values less than (0), + partition p2 values less than (2), + partition p3 values less than (2147483647)); + +insert into t1 values(10,10,'10'); +insert into t1 values(2,2,'2'); +select * from t1 where f1 = 2; +drop table t1; + diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 290d512198f..9830d24b604 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -3754,7 +3754,7 @@ void get_partition_set(const TABLE *table, byte *buf, const uint index, subpartitions. This is a range without holes. */ DBUG_ASSERT(sub_part == no_parts); - part_spec->start_part= part_part * part_info->no_parts; + part_spec->start_part= part_part * part_info->no_subparts; part_spec->end_part= part_spec->start_part+part_info->no_subparts - 1; } else