diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-10-12 00:37:58 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-10-12 00:37:58 +0200 |
commit | dfb74dea300f83880c11600dc726a9cae559f356 (patch) | |
tree | 76da0d6e23f188bc13520bf80496e9053f227d9a /sql/partition_info.cc | |
parent | b785857d00a0fd9c98cb52823357bfad8fb18289 (diff) | |
parent | e7cb032e560e14865941ecdcb553cd3aba856b68 (diff) | |
download | mariadb-git-dfb74dea300f83880c11600dc726a9cae559f356.tar.gz |
Merge branch '10.0' into 10.1
Diffstat (limited to 'sql/partition_info.cc')
-rw-r--r-- | sql/partition_info.cc | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/sql/partition_info.cc b/sql/partition_info.cc index f16ed0e879e..a92c7686eaf 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2006, 2013, Oracle and/or its affiliates. +/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. + Copyright (c) 2010, 2015, MariaDB 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 @@ -69,7 +70,7 @@ partition_info *partition_info::get_clone(THD *thd) part_clone->subpartitions.empty(); while ((subpart= (subpart_it++))) { - partition_element *subpart_clone= new partition_element(); + partition_element *subpart_clone= new (mem_root) partition_element(); if (!subpart_clone) { mem_alloc_error(sizeof(partition_element)); @@ -79,6 +80,41 @@ partition_info *partition_info::get_clone(THD *thd) part_clone->subpartitions.push_back(subpart_clone, mem_root); } clone->partitions.push_back(part_clone, mem_root); + part_clone->list_val_list.empty(); + List_iterator<part_elem_value> list_val_it(part->list_val_list); + part_elem_value *new_val_arr= + (part_elem_value *)alloc_root(mem_root, sizeof(part_elem_value) * + part->list_val_list.elements); + if (!new_val_arr) + { + mem_alloc_error(sizeof(part_elem_value) * part->list_val_list.elements); + DBUG_RETURN(NULL); + } + p_column_list_val *new_colval_arr= + (p_column_list_val*)alloc_root(mem_root, sizeof(p_column_list_val) * + num_columns * + part->list_val_list.elements); + if (!new_colval_arr) + { + mem_alloc_error(sizeof(p_column_list_val) * num_columns * + part->list_val_list.elements); + DBUG_RETURN(NULL); + } + part_elem_value *val; + while ((val= list_val_it++)) + { + part_elem_value *new_val= new_val_arr++; + memcpy(new_val, val, sizeof(part_elem_value)); + if (!val->null_value) + { + p_column_list_val *new_colval= new_colval_arr; + new_colval_arr+= num_columns; + memcpy(new_colval, val->col_val_array, + sizeof(p_column_list_val) * num_columns); + new_val->col_val_array= new_colval; + } + part_clone->list_val_list.push_back(new_val, mem_root); + } } DBUG_RETURN(clone); } @@ -1627,15 +1663,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)); |