From 0eadadad25d9e44232e1567897cf9dcb957ccdcd Mon Sep 17 00:00:00 2001 From: Debarun Banerjee Date: Wed, 24 Jun 2015 10:27:12 +0530 Subject: 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()] 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 RB: 9345 --- sql/partition_info.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'sql/partition_info.cc') diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 958f77f5bd0..336010cc7dd 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify 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, { int err= 0; + /* Check for partition expression. */ if (!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) - err= subpart_expr->walk(&Item::check_partition_func_processor, 0, - NULL); } + + /* Check for sub partition expression. */ + if (!err && is_sub_partitioned() && !list_of_subpart_fields) + { + DBUG_ASSERT(subpart_expr); + err= subpart_expr->walk(&Item::check_partition_func_processor, 0, + NULL); + } + if (err) { my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0)); -- cgit v1.2.1 From 359f102ad157adaacc904a1c81f5ddcb9ce3662b Mon Sep 17 00:00:00 2001 From: Debarun Banerjee Date: Wed, 8 Jul 2015 10:00:53 +0530 Subject: BUG#16613004 PARTITIONING DDL, CRASH IN FIELD_VARSTRING::CMP_MAX Problem : --------- The specific issue reported in this bug is with range/list column value that is allocated and initialized by evaluating partition expression(item tree) during execution. After evaluation the range list value is marked fixed [part_column_list_val]. During next execution, we don't re-evaluate the expression and use the old value since it is marked fixed. Solution : ---------- One way to solve the issue is to mark all column values as not fixed during clone so that the expression is always re-evaluated once we attempt partition_info::fix_column_value_functions() after cloning the part_info object during execution of DDL on partitioned table. Reviewed-by: Jimmy Yang Reviewed-by: Mattias Jonsson RB: 9424 --- sql/partition_info.cc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'sql/partition_info.cc') diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 336010cc7dd..a0d09557b81 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -31,7 +31,7 @@ #include "ha_partition.h" -partition_info *partition_info::get_clone() +partition_info *partition_info::get_clone(bool reset /* = false */) { if (!this) return 0; @@ -57,6 +57,26 @@ partition_info *partition_info::get_clone() return NULL; } memcpy(part_clone, part, sizeof(partition_element)); + + /* + Mark that RANGE and LIST values needs to be fixed so that we don't + use old values. fix_column_value_functions would evaluate the values + from Item expression. + */ + if (reset) + { + clone->defined_max_value = false; + List_iterator list_it(part_clone->list_val_list); + while (part_elem_value *list_value= list_it++) + { + part_column_list_val *col_val= list_value->col_val_array; + for (uint i= 0; i < num_columns; col_val++, i++) + { + col_val->fixed= 0; + } + } + } + part_clone->subpartitions.empty(); while ((subpart= (subpart_it++))) { -- cgit v1.2.1