From 446af393375dee2ba15b3c9908bdb087de5721fd Mon Sep 17 00:00:00 2001 From: "mikael@dator5.(none)" <> Date: Thu, 22 Jun 2006 10:46:02 -0400 Subject: [PATCH] BUG#20583: index_last causes crash when performed on single partition --- mysql-test/r/partition.result | 8 ++++++++ mysql-test/t/partition.test | 9 +++++++++ sql/ha_partition.cc | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index fa1baaec07e..f6f5073f241 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1043,4 +1043,12 @@ alter table t1 add partition (partition p2 values in (3)); alter table t1 drop partition p2; use test; drop database db99; +create table t1 (a int, index(a)) +partition by hash(a); +insert into t1 values (1),(2); +select * from t1 ORDER BY a DESC; +a +2 +1 +drop table t1; End of 5.1 tests diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index f62bb2dcd01..758a551cc95 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1199,4 +1199,13 @@ alter table t1 drop partition p2; use test; drop database db99; +# +# Bug 20583 Partitions: Crash using index_last +# +create table t1 (a int, index(a)) +partition by hash(a); +insert into t1 values (1),(2); +select * from t1 ORDER BY a DESC; +drop table t1; + --echo End of 5.1 tests diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 93fb6409f9f..293085a2630 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3399,7 +3399,8 @@ int ha_partition::common_first_last(byte *buf) if ((error= partition_scan_set_up(buf, FALSE))) return error; - if (!m_ordered_scan_ongoing) + if (!m_ordered_scan_ongoing && + m_index_scan_type != partition_index_last) return handle_unordered_scan_next_partition(buf); return handle_ordered_index_scan(buf); }