Skip to content

Commit 0eadada

Browse files
author
Debarun Banerjee
committed
BUG#20310212 PARTITION DDL- CRASH AFTER THD::NOCHECK_REGISTER_ITEM_
Problem : --------- Issue-1: The root cause for the issues is that (col1 > 1) is not a valid partition function and we should have thrown error at much early stage [partition_info::check_partition_info]. We are not checking sub-partition expression when partition expression is NULL. Issue-2: Potential issue for future if any partition function needs to change item tree during open/fix_fields. We should release changed items, if any, before doing closefrm when we open the partitioned table during creation in create_table_impl. Solution : ---------- 1.check_partition_info() - Check for sub-partition expression even if no partition expression. [partition by ... columns(...) subpartition by hash(<expr>)] 2.create_table_impl() - Assert that the change list is empty before doing closefrm for partitioned table. Currently no supported partition function seems to be changing item tree during open. Reviewed-by: Mattias Jonsson <mattias.jonsson@oracle.com> RB: 9345
1 parent 1b1161a commit 0eadada

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

mysql-test/r/partition_error.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ partition by key (a)
10891089
subpartition by hash (sin(a+b))
10901090
(partition x1 (subpartition x11, subpartition x12),
10911091
partition x2 (subpartition x21, subpartition x22));
1092-
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
1092+
ERROR HY000: This partition function is not allowed
10931093
select load_file('$MYSQLD_DATADIR/test/t1.par');
10941094
load_file('$MYSQLD_DATADIR/test/t1.par')
10951095
NULL

mysql-test/t/partition_error.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ subpartition by hash (rand(a+b));
11451145
#
11461146
# Subpartition by hash, wrong subpartition function
11471147
#
1148-
--error ER_SUBPARTITION_ERROR
1148+
--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
11491149
CREATE TABLE t1 (
11501150
a int not null,
11511151
b int not null,

sql/partition_info.cc

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -1109,15 +1109,22 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
11091109
{
11101110
int err= 0;
11111111

1112+
/* Check for partition expression. */
11121113
if (!list_of_part_fields)
11131114
{
11141115
DBUG_ASSERT(part_expr);
11151116
err= part_expr->walk(&Item::check_partition_func_processor, 0,
11161117
NULL);
1117-
if (!err && is_sub_partitioned() && !list_of_subpart_fields)
1118-
err= subpart_expr->walk(&Item::check_partition_func_processor, 0,
1119-
NULL);
11201118
}
1119+
1120+
/* Check for sub partition expression. */
1121+
if (!err && is_sub_partitioned() && !list_of_subpart_fields)
1122+
{
1123+
DBUG_ASSERT(subpart_expr);
1124+
err= subpart_expr->walk(&Item::check_partition_func_processor, 0,
1125+
NULL);
1126+
}
1127+
11211128
if (err)
11221129
{
11231130
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));

sql/sql_table.cc

+6
Original file line numberDiff line numberDiff line change
@@ -3913,6 +3913,12 @@ static bool check_if_created_table_can_be_opened(THD *thd,
39133913
result= (open_table_def(thd, &share, 0) ||
39143914
open_table_from_share(thd, &share, "", 0, (uint) READ_ALL,
39153915
0, &table, TRUE));
3916+
/*
3917+
Assert that the change list is empty as no partition function currently
3918+
needs to modify item tree. May need call THD::rollback_item_tree_changes
3919+
later before calling closefrm if the change list is not empty.
3920+
*/
3921+
DBUG_ASSERT(thd->change_list.is_empty());
39163922
if (! result)
39173923
(void) closefrm(&table, 0);
39183924

0 commit comments

Comments
 (0)