diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-03-30 14:50:23 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-03-30 14:50:23 +0300 |
commit | e2f1f88fa60680cb87833a7cceb172f5d436a804 (patch) | |
tree | 5e48f8ed5c7a169af6692c72de9f1007af48737e /sql | |
parent | 9eae063e79376fd71586e1106e750a366467a984 (diff) | |
parent | b092d35f13ceae37cda26478635b127f9b401e2c (diff) | |
download | mariadb-git-e2f1f88fa60680cb87833a7cceb172f5d436a804.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_partition.cc | 53 | ||||
-rw-r--r-- | sql/item.cc | 50 | ||||
-rw-r--r-- | sql/item_row.cc | 13 | ||||
-rw-r--r-- | sql/opt_split.cc | 2 | ||||
-rw-r--r-- | sql/slave.cc | 2 | ||||
-rw-r--r-- | sql/sql_class.cc | 3 | ||||
-rw-r--r-- | sql/sql_connect.cc | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 8 | ||||
-rw-r--r-- | sql/sql_select.h | 5 | ||||
-rw-r--r-- | sql/sql_show.cc | 7 | ||||
-rw-r--r-- | sql/sql_string.h | 6 | ||||
-rw-r--r-- | sql/sql_table.cc | 12 |
13 files changed, 97 insertions, 68 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index d65a4963905..af60ca68c82 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -10071,7 +10071,8 @@ ha_partition::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { uint index= 0; - enum_alter_inplace_result result= HA_ALTER_INPLACE_NO_LOCK; + enum_alter_inplace_result result; + alter_table_operations orig_ops; ha_partition_inplace_ctx *part_inplace_ctx; bool first_is_set= false; THD *thd= ha_thd(); @@ -10098,33 +10099,35 @@ ha_partition::check_if_supported_inplace_alter(TABLE *altered_table, if (!part_inplace_ctx->handler_ctx_array) DBUG_RETURN(HA_ALTER_ERROR); - /* Set all to NULL, including the terminating one. */ - for (index= 0; index <= m_tot_parts; index++) - part_inplace_ctx->handler_ctx_array[index]= NULL; + do { + result= HA_ALTER_INPLACE_NO_LOCK; + /* Set all to NULL, including the terminating one. */ + for (index= 0; index <= m_tot_parts; index++) + part_inplace_ctx->handler_ctx_array[index]= NULL; - ha_alter_info->handler_flags |= ALTER_PARTITIONED; - for (index= 0; index < m_tot_parts; index++) - { - enum_alter_inplace_result p_result= - m_file[index]->check_if_supported_inplace_alter(altered_table, - ha_alter_info); - part_inplace_ctx->handler_ctx_array[index]= ha_alter_info->handler_ctx; - - if (index == 0) + ha_alter_info->handler_flags |= ALTER_PARTITIONED; + orig_ops= ha_alter_info->handler_flags; + for (index= 0; index < m_tot_parts; index++) { - first_is_set= (ha_alter_info->handler_ctx != NULL); - } - else if (first_is_set != (ha_alter_info->handler_ctx != NULL)) - { - /* Either none or all partitions must set handler_ctx! */ - DBUG_ASSERT(0); - DBUG_RETURN(HA_ALTER_ERROR); + enum_alter_inplace_result p_result= + m_file[index]->check_if_supported_inplace_alter(altered_table, + ha_alter_info); + part_inplace_ctx->handler_ctx_array[index]= ha_alter_info->handler_ctx; + + if (index == 0) + first_is_set= (ha_alter_info->handler_ctx != NULL); + else if (first_is_set != (ha_alter_info->handler_ctx != NULL)) + { + /* Either none or all partitions must set handler_ctx! */ + DBUG_ASSERT(0); + DBUG_RETURN(HA_ALTER_ERROR); + } + if (p_result < result) + result= p_result; + if (result == HA_ALTER_ERROR) + break; } - if (p_result < result) - result= p_result; - if (result == HA_ALTER_ERROR) - break; - } + } while (orig_ops != ha_alter_info->handler_flags); ha_alter_info->handler_ctx= part_inplace_ctx; /* diff --git a/sql/item.cc b/sql/item.cc index 9b721266e9d..0d5c39086a6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB Corporation + Copyright (c) 2010, 2020, MariaDB Corporation. 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 @@ -2559,42 +2559,46 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll, /** @brief Building clone for Item_func_or_sum - + @param thd thread handle - @param mem_root part of the memory for the clone + @param mem_root part of the memory for the clone @details - This method gets copy of the current item and also - build clones for its referencies. For the referencies - build_copy is called again. - - @retval - clone of the item - 0 if an error occurred -*/ + This method first builds clones of the arguments. If it is successful with + buiding the clones then it constructs a copy of this Item_func_or_sum object + and attaches to it the built clones of the arguments. + + @return clone of the item + @retval 0 on a failure +*/ Item* Item_func_or_sum::build_clone(THD *thd) { - Item_func_or_sum *copy= (Item_func_or_sum *) get_copy(thd); - if (unlikely(!copy)) - return 0; + Item *copy_tmp_args[2]= {0,0}; + Item **copy_args= copy_tmp_args; if (arg_count > 2) { - copy->args= - (Item**) alloc_root(thd->mem_root, sizeof(Item*) * arg_count); - if (unlikely(!copy->args)) + copy_args= static_cast<Item**> + (alloc_root(thd->mem_root, sizeof(Item*) * arg_count)); + if (unlikely(!copy_args)) return 0; } - else if (arg_count > 0) - copy->args= copy->tmp_arg; - - for (uint i= 0; i < arg_count; i++) { Item *arg_clone= args[i]->build_clone(thd); - if (!arg_clone) + if (unlikely(!arg_clone)) return 0; - copy->args[i]= arg_clone; + copy_args[i]= arg_clone; + } + Item_func_or_sum *copy= static_cast<Item_func_or_sum *>(get_copy(thd)); + if (unlikely(!copy)) + return 0; + if (arg_count > 2) + copy->args= copy_args; + else if (arg_count > 0) + { + copy->args= copy->tmp_arg; + memcpy(copy->args, copy_args, sizeof(Item *) * arg_count); } return copy; } diff --git a/sql/item_row.cc b/sql/item_row.cc index 150d57263b6..a363f9b5576 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2002, 2011, Oracle and/or its affiliates. + Copyright (c) 2011, 2020, MariaDB Corporation. 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 @@ -165,16 +166,20 @@ void Item_row::bring_value() Item* Item_row::build_clone(THD *thd) { - Item_row *copy= (Item_row *) get_copy(thd); - if (!copy) + Item **copy_args= static_cast<Item**> + (alloc_root(thd->mem_root, sizeof(Item*) * arg_count)); + if (unlikely(!copy_args)) return 0; - copy->args= (Item**) alloc_root(thd->mem_root, sizeof(Item*) * arg_count); for (uint i= 0; i < arg_count; i++) { Item *arg_clone= args[i]->build_clone(thd); if (!arg_clone) return 0; - copy->args[i]= arg_clone; + copy_args[i]= arg_clone; } + Item_row *copy= (Item_row *) get_copy(thd); + if (unlikely(!copy)) + return 0; + copy->args= copy_args; return copy; } diff --git a/sql/opt_split.cc b/sql/opt_split.cc index 6f8248c315c..c70fac49930 100644 --- a/sql/opt_split.cc +++ b/sql/opt_split.cc @@ -968,7 +968,7 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count, The plan for the chosen key has not been found in the cache. Build a new plan and save info on it in the cache */ - table_map all_table_map= (1 << join->table_count) - 1; + table_map all_table_map= (((table_map) 1) << join->table_count) - 1; reset_validity_vars_for_keyuses(best_key_keyuse_ext_start, best_table, best_key, remaining_tables, true); choose_plan(join, all_table_map & ~join->const_table_map); diff --git a/sql/slave.cc b/sql/slave.cc index fcb4777b189..7fb68d2dfb5 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2017, MariaDB Corporation + Copyright (c) 2009, 2020, MariaDB Corporation. 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 diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 22690c7e432..2a805605faa 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB Corporation. + Copyright (c) 2008, 2020, MariaDB Corporation. 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 @@ -608,6 +608,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) m_current_stage_key(0), in_sub_stmt(0), log_all_errors(0), binlog_unsafe_warning_flags(0), + current_stmt_binlog_format(BINLOG_FORMAT_MIXED), binlog_table_maps(0), bulk_param(0), table_map_for_update(0), diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 6bf43d3df5e..643b7ee898a 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2007, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2016, MariaDB + Copyright (c) 2008, 2020, 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 diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ffba46b4573..e5b9f74c5f3 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB + Copyright (c) 2008, 2020, 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 diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 99feb1006fb..539d8362050 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2958,8 +2958,12 @@ int JOIN::optimize_stage2() having_is_correlated= MY_TEST(having->used_tables() & OUTER_REF_TABLE_BIT); tmp_having= having; - if ((select_lex->options & OPTION_SCHEMA_TABLE)) - optimize_schema_tables_reads(this); + if ((select_lex->options & OPTION_SCHEMA_TABLE) && + optimize_schema_tables_reads(this)) + DBUG_RETURN(TRUE); + + if (unlikely(thd->is_error())) + DBUG_RETURN(TRUE); /* The loose index scan access method guarantees that all grouping or diff --git a/sql/sql_select.h b/sql/sql_select.h index b9043a851e7..d41fc3317a3 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -2,7 +2,7 @@ #define SQL_SELECT_INCLUDED /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2017, MariaDB Corporation. + Copyright (c) 2008, 2020, MariaDB Corporation. 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 @@ -1665,6 +1665,9 @@ public: void copy_ref_ptr_array(Ref_ptr_array dst_arr, Ref_ptr_array src_arr) { DBUG_ASSERT(dst_arr.size() >= src_arr.size()); + if (src_arr.size() == 0) + return; + void *dest= dst_arr.array(); const void *src= src_arr.array(); memcpy(dest, src, src_arr.size() * src_arr.element_size()); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 409574d4686..46d4685e0db 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -8765,7 +8765,6 @@ end: bool optimize_schema_tables_reads(JOIN *join) { THD *thd= join->thd; - bool result= 0; DBUG_ENTER("optimize_schema_tables_reads"); JOIN_TAB *tab; @@ -8800,11 +8799,11 @@ bool optimize_schema_tables_reads(JOIN *join) */ cond= tab->cache_select->cond; } - - optimize_for_get_all_tables(thd, table_list, cond); + if (optimize_for_get_all_tables(thd, table_list, cond)) + DBUG_RETURN(TRUE); // Handle OOM } } - DBUG_RETURN(result); + DBUG_RETURN(FALSE); } diff --git a/sql/sql_string.h b/sql/sql_string.h index aad5314a973..7d7d9f08748 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -3,7 +3,7 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB Corporation. + Copyright (c) 2008, 2020, MariaDB Corporation. 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 @@ -79,6 +79,10 @@ public: Well_formed_prefix(CHARSET_INFO *cs, const char *str, size_t length) :Well_formed_prefix_status(cs, str, str + length, length), m_str(str) { } + Well_formed_prefix(CHARSET_INFO *cs, LEX_STRING str, size_t nchars) + :Well_formed_prefix_status(cs, str.str, str.str + str.length, nchars), + m_str(str.str) + { } size_t length() const { return m_source_end_pos - m_str; } }; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 619c3fe2654..f46a7da09f5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB + Copyright (c) 2010, 2020, 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 @@ -4392,8 +4392,14 @@ bool validate_comment_length(THD *thd, LEX_CSTRING *comment, size_t max_len, uint err_code, const char *name) { DBUG_ENTER("validate_comment_length"); - size_t tmp_len= my_charpos(system_charset_info, comment->str, - comment->str + comment->length, max_len); + if (comment->length == 0) + DBUG_RETURN(false); + + if (max_len > comment->length) + max_len= comment->length; + + size_t tmp_len= + Well_formed_prefix(system_charset_info, comment->str, max_len).length(); if (tmp_len < comment->length) { if (thd->is_strict_mode()) |