summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@sun.com>2008-12-02 11:18:01 +0100
committerMattias Jonsson <mattias.jonsson@sun.com>2008-12-02 11:18:01 +0100
commit8f39d2584ba0ba33998461aa93a714f8cadf498d (patch)
treecb5e6f2879630e8707a6a568eac7954d2fb398f6
parent54eaadf01c4f5fa823af021600b82274d84e1cd3 (diff)
downloadmariadb-git-8f39d2584ba0ba33998461aa93a714f8cadf498d.tar.gz
Bug#40389: REORGANIZE PARTITION crashes when only using one partition
The non documented command 'ALTER PARTITION t REORGANIZE PARTITION' (without any partitions!) which only make sense for nativly partitioned engines, such as NDB, crashes the server if there was no change of number of partitions. The problem was wrong usage of fast_end_partition function, which led to usage of a non initialized variable.
-rw-r--r--mysql-test/r/partition_mgm.result7
-rw-r--r--mysql-test/t/partition_mgm.test11
-rw-r--r--sql/partition_info.cc1
-rw-r--r--sql/sql_partition.cc5
4 files changed, 21 insertions, 3 deletions
diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result
index 9ef220028b3..eeb9be949a0 100644
--- a/mysql-test/r/partition_mgm.result
+++ b/mysql-test/r/partition_mgm.result
@@ -1,4 +1,11 @@
DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY)
+ENGINE MYISAM
+PARTITION BY HASH (a)
+PARTITIONS 1;
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
+ALTER TABLE t1 REORGANIZE PARTITION;
+DROP TABLE t1;
create table t1 (a int)
partition by range (a)
subpartition by key (a)
diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test
index 68da4a5b390..1f53989b4d4 100644
--- a/mysql-test/t/partition_mgm.test
+++ b/mysql-test/t/partition_mgm.test
@@ -4,6 +4,17 @@ DROP TABLE IF EXISTS t1;
--enable_warnings
#
+# Bug 40389: REORGANIZE PARTITION crashes when only using one partition
+#
+CREATE TABLE t1 (a INT PRIMARY KEY)
+ENGINE MYISAM
+PARTITION BY HASH (a)
+PARTITIONS 1;
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
+ALTER TABLE t1 REORGANIZE PARTITION;
+DROP TABLE t1;
+
+#
# Bug 21143: mysqld hang when error in number of subparts in
# REORGANIZE command
#
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 02f2c9b0ab1..e2027d3571e 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -867,6 +867,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
if (part_type != HASH_PARTITION || !list_of_part_fields)
{
+ DBUG_ASSERT(part_expr);
err= part_expr->walk(&Item::check_partition_func_processor, 0,
NULL);
if (!err && is_sub_partitioned() && !list_of_subpart_fields)
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index da80a2125e9..6fb803ce4ff 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -4228,9 +4228,8 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
after the change as before. Thus we can reply ok immediately
without any changes at all.
*/
- DBUG_RETURN(fast_end_partition(thd, ULL(0), ULL(0),
- table, NULL,
- TRUE, NULL, FALSE));
+ *fast_alter_partition= TRUE;
+ DBUG_RETURN(FALSE);
}
else if (new_part_no > curr_part_no)
{