Commit 8f39d258 authored by Mattias Jonsson's avatar Mattias Jonsson

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.
parent 54eaadf0
DROP TABLE IF EXISTS t1; 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) create table t1 (a int)
partition by range (a) partition by range (a)
subpartition by key (a) subpartition by key (a)
......
...@@ -3,6 +3,17 @@ ...@@ -3,6 +3,17 @@
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
--enable_warnings --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 # Bug 21143: mysqld hang when error in number of subparts in
# REORGANIZE command # REORGANIZE command
......
...@@ -867,6 +867,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, ...@@ -867,6 +867,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
if (part_type != HASH_PARTITION || !list_of_part_fields) if (part_type != HASH_PARTITION || !list_of_part_fields)
{ {
DBUG_ASSERT(part_expr);
err= part_expr->walk(&Item::check_partition_func_processor, 0, err= part_expr->walk(&Item::check_partition_func_processor, 0,
NULL); NULL);
if (!err && is_sub_partitioned() && !list_of_subpart_fields) if (!err && is_sub_partitioned() && !list_of_subpart_fields)
......
...@@ -4228,9 +4228,8 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, ...@@ -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 after the change as before. Thus we can reply ok immediately
without any changes at all. without any changes at all.
*/ */
DBUG_RETURN(fast_end_partition(thd, ULL(0), ULL(0), *fast_alter_partition= TRUE;
table, NULL, DBUG_RETURN(FALSE);
TRUE, NULL, FALSE));
} }
else if (new_part_no > curr_part_no) else if (new_part_no > curr_part_no)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment