diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-04-22 18:18:51 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-04-22 18:18:51 +0300 |
commit | 88cf6f1c7ff5d56138c8b53a5adaca4c61752f86 (patch) | |
tree | eee8eed7e9388a575de4d9c948b0706e2356d694 /sql | |
parent | 498c5e2be1021569c1d5554bcb91f45090e30d4b (diff) | |
parent | 455cf6196c8c73f5a50004ac7f31a9be8ac14bbe (diff) | |
download | mariadb-git-88cf6f1c7ff5d56138c8b53a5adaca4c61752f86.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | sql/item.cc | 8 | ||||
-rw-r--r-- | sql/item.h | 10 | ||||
-rw-r--r-- | sql/item_subselect.cc | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 8 | ||||
-rw-r--r-- | sql/opt_range.cc | 19 |
6 files changed, 30 insertions, 19 deletions
diff --git a/sql/field.cc b/sql/field.cc index a9bd97d9844..5d946ef5d0c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9100,7 +9100,7 @@ int Field_geom::store(const char *from, size_t length, CHARSET_INFO *cs) my_error(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, MYF(0), Geometry::ci_collection[geom_type]->m_name.str, - wkt.c_ptr(), db, tab_name, field_name.str, + wkt.c_ptr_safe(), db, tab_name, field_name.str, (ulong) table->in_use->get_stmt_da()-> current_row_for_warning()); diff --git a/sql/item.cc b/sql/item.cc index 0d5c39086a6..69524cf8116 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -9245,8 +9245,10 @@ bool Item_default_value::fix_fields(THD *thd, Item **items) } if (!(def_field= (Field*) thd->alloc(field_arg->field->size_of()))) goto error; + cached_field= def_field; memcpy((void *)def_field, (void *)field_arg->field, field_arg->field->size_of()); + def_field->reset_fields(); // If non-constant default value expression if (def_field->default_value && def_field->default_value->flags) { @@ -9274,6 +9276,12 @@ error: return TRUE; } +void Item_default_value::cleanup() +{ + delete cached_field; // Free cached blob data + cached_field= 0; + Item_field::cleanup(); +} void Item_default_value::print(String *str, enum_query_type query_type) { diff --git a/sql/item.h b/sql/item.h index 990ca0ec887..54eaaaf8743 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2,7 +2,7 @@ #define SQL_ITEM_INCLUDED /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, 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 @@ -6254,21 +6254,23 @@ class Item_default_value : public Item_field void calculate(); public: Item *arg; + Field *cached_field; Item_default_value(THD *thd, Name_resolution_context *context_arg) :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL, &null_clex_str), - arg(NULL) {} + arg(NULL), cached_field(NULL) {} Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a) :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL, &null_clex_str), - arg(a) {} + arg(a), cached_field(NULL) {} Item_default_value(THD *thd, Name_resolution_context *context_arg, Field *a) :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL, &null_clex_str), - arg(NULL) {} + arg(NULL), cached_field(NULL) {} enum Type type() const { return DEFAULT_VALUE_ITEM; } bool eq(const Item *item, bool binary_cmp) const; bool fix_fields(THD *, Item **); + void cleanup(); void print(String *str, enum_query_type query_type); String *val_str(String *str); double val_real(); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 79dcf8ecfe8..736dfbd33b4 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -727,7 +727,7 @@ bool Item_subselect::exec() push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, ER_UNKNOWN_ERROR, "DBUG: Item_subselect::exec %.*s", - print.length(),print.ptr()); + print.length(),print.c_ptr()); ); /* Do not execute subselect in case of a fatal error diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6615cd01dcf..f758b7ed538 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1,5 +1,5 @@ /* 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 @@ -1933,11 +1933,7 @@ static void mysqld_exit(int exit_code) shutdown_performance_schema(); // we do it as late as possible #endif set_malloc_size_cb(NULL); - if (opt_endinfo && global_status_var.global_memory_used) - fprintf(stderr, "Warning: Memory not freed: %ld\n", - (long) global_status_var.global_memory_used); - if (!opt_debugging && !my_disable_leak_check && exit_code == 0 && - debug_assert_on_not_freed_memory) + if (global_status_var.global_memory_used) { #ifdef SAFEMALLOC sf_report_leaked_memory(0); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 899d1fc9782..312999ddc17 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -5044,8 +5044,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, double roru_index_costs; ha_rows roru_total_records; double roru_intersect_part= 1.0; - double limit_read_time= read_time; size_t n_child_scans; + double limit_read_time= read_time; THD *thd= param->thd; DBUG_ENTER("get_best_disjunct_quick"); DBUG_PRINT("info", ("Full table scan cost: %g", read_time)); @@ -5072,6 +5072,10 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, sizeof(TRP_RANGE*)* n_child_scans))) DBUG_RETURN(NULL); + + const bool only_ror_scans_required= !optimizer_flag(param->thd, + OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION); + Json_writer_object trace_best_disjunct(thd); Json_writer_array to_merge(thd, "indexes_to_merge"); /* @@ -5087,7 +5091,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, "tree in SEL_IMERGE");); Json_writer_object trace_idx(thd); if (!(*cur_child= get_key_scans_params(param, *ptree, TRUE, FALSE, - read_time, TRUE))) + read_time, + only_ror_scans_required))) { /* One of index scans in this index_merge is more expensive than entire @@ -5449,7 +5454,7 @@ TABLE_READ_PLAN *merge_same_index_scans(PARAM *param, SEL_IMERGE *imerge, index merge retrievals are not well calibrated */ trp= get_key_scans_params(param, *imerge->trees, FALSE, TRUE, - read_time, TRUE); + read_time, FALSE); } DBUG_RETURN(trp); @@ -7333,7 +7338,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, index_read_must_be_used if TRUE, assume 'index only' option will be set (except for clustered PK indexes) read_time don't create read plans with cost > read_time. - ror_scans_required set to TRUE for index merge + only_ror_scans_required set to TRUE when we are only interested + in ROR scan RETURN Best range read plan NULL if no plan found or error occurred @@ -7343,7 +7349,7 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, bool index_read_must_be_used, bool update_tbl_stats, double read_time, - bool ror_scans_required) + bool only_ror_scans_required) { uint idx, UNINIT_VAR(best_idx); SEL_ARG *key_to_read= NULL; @@ -7397,8 +7403,7 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, found_records= check_quick_select(param, idx, read_index_only, key, update_tbl_stats, &mrr_flags, &buf_size, &cost, &is_ror_scan); - if (ror_scans_required && !is_ror_scan && - !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION)) + if (only_ror_scans_required && !is_ror_scan) continue; if (found_records != HA_POS_ERROR && tree->index_scans && |