diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-04-25 09:05:52 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-04-25 09:05:52 +0300 |
commit | acf6f92aa936fbfe7524617ae57d011ab8f1f96d (patch) | |
tree | e7fc2258c06a0fdab1cce115de4d71a091d82d28 /sql | |
parent | 765ae6e82165d1bc4cf6cc9f0d556d66a5e172d1 (diff) | |
parent | bc145193c164b895a52b943e73fff53952d48a60 (diff) | |
download | mariadb-git-acf6f92aa936fbfe7524617ae57d011ab8f1f96d.tar.gz |
Merge 10.2 into 10.3
Diffstat (limited to 'sql')
-rw-r--r-- | sql/gcalc_slicescan.cc | 2 | ||||
-rw-r--r-- | sql/handler.cc | 1 | ||||
-rw-r--r-- | sql/item_func.cc | 2 | ||||
-rw-r--r-- | sql/sp_head.cc | 3 | ||||
-rw-r--r-- | sql/sql_class.h | 3 | ||||
-rw-r--r-- | sql/sql_parse.cc | 15 | ||||
-rw-r--r-- | sql/sql_select.cc | 3 | ||||
-rw-r--r-- | sql/sql_show.cc | 5 | ||||
-rw-r--r-- | sql/sql_statistics.cc | 6 | ||||
-rw-r--r-- | sql/sql_string.h | 5 | ||||
-rw-r--r-- | sql/sql_update.cc | 3 | ||||
-rw-r--r-- | sql/sql_window.cc | 16 |
12 files changed, 46 insertions, 18 deletions
diff --git a/sql/gcalc_slicescan.cc b/sql/gcalc_slicescan.cc index 9127bb95aeb..3a5dc6410a8 100644 --- a/sql/gcalc_slicescan.cc +++ b/sql/gcalc_slicescan.cc @@ -993,6 +993,8 @@ void Gcalc_heap::reset() { if (m_n_points) { + if (m_hook) + *m_hook= NULL; free_list(m_first); m_n_points= 0; } diff --git a/sql/handler.cc b/sql/handler.cc index f2ea9365974..6329774668f 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2048,6 +2048,7 @@ int ha_recover(HASH *commit_list) for (info.len= MAX_XID_LIST_SIZE ; info.list==0 && info.len > MIN_XID_LIST_SIZE; info.len/=2) { + DBUG_EXECUTE_IF("min_xa_len", info.len = 16;); info.list=(XID *)my_malloc(info.len*sizeof(XID), MYF(0)); } if (!info.list) diff --git a/sql/item_func.cc b/sql/item_func.cc index 5b34b6d5f34..0a7693daaae 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2009, 2017, MariaDB + Copyright (c) 2009, 2019, 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/sp_head.cc b/sql/sp_head.cc index 3c57a29105d..924fd04007e 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -203,6 +203,7 @@ sp_get_flags_for_command(LEX *lex) case SQLCOM_SHOW_EXPLAIN: case SQLCOM_SHOW_FIELDS: case SQLCOM_SHOW_FUNC_CODE: + case SQLCOM_SHOW_GENERIC: case SQLCOM_SHOW_GRANTS: case SQLCOM_SHOW_ENGINE_STATUS: case SQLCOM_SHOW_ENGINE_LOGS: @@ -3209,7 +3210,7 @@ sp_head::show_routine_code(THD *thd) const char *format= "Instruction at position %u has m_ip=%u"; char tmp[sizeof(format) + 2*SP_INSTR_UINT_MAXLEN + 1]; - sprintf(tmp, format, ip, i->m_ip); + my_snprintf(tmp, sizeof(tmp), format, ip, i->m_ip); /* Since this is for debugging purposes only, we don't bother to introduce a special error code for it. diff --git a/sql/sql_class.h b/sql/sql_class.h index 1ac422f40b3..e1119757957 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2443,6 +2443,9 @@ public: */ bool create_tmp_table_for_derived; + /* The flag to force reading statistics from EITS tables */ + bool force_read_stats; + bool save_prep_leaf_list; /* container for handler's private per-connection data */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 33a1fa8a291..a0aaec9927a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2964,15 +2964,14 @@ static bool do_execute_sp(THD *thd, sp_head *sp) my_error(ER_SP_BADSELECT, MYF(0), ErrConvDQName(sp).ptr()); return 1; } - /* - If SERVER_MORE_RESULTS_EXISTS is not set, - then remember that it should be cleared - */ - bits_to_be_cleared= (~thd->server_status & - SERVER_MORE_RESULTS_EXISTS); - thd->server_status|= SERVER_MORE_RESULTS_EXISTS; } - + /* + If SERVER_MORE_RESULTS_EXISTS is not set, + then remember that it should be cleared + */ + bits_to_be_cleared= (~thd->server_status & + SERVER_MORE_RESULTS_EXISTS); + thd->server_status|= SERVER_MORE_RESULTS_EXISTS; ha_rows select_limit= thd->variables.select_limit; thd->variables.select_limit= HA_POS_ERROR; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1c9bfa397d2..1ecc964c04b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3399,7 +3399,8 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields, if (setup_sum_funcs(thd, sum_funcs)) goto err; - if (!group_list && !table->distinct && order && simple_order) + if (!group_list && !table->distinct && order && simple_order && + tab == join_tab + const_tables) { DBUG_PRINT("info",("Sorting for order")); THD_STAGE_INFO(thd, stage_sorting_for_order); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 3f40384ab72..cded8fbaf23 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2009, 2017, MariaDB + Copyright (c) 2009, 2019, 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 @@ -4606,7 +4606,10 @@ fill_schema_table_by_open(THD *thd, MEM_ROOT *mem_root, } DBUG_ASSERT(thd->lex == lex); + thd->force_read_stats= get_schema_table_idx(schema_table) == SCH_STATISTICS; result= open_tables_only_view_structure(thd, table_list, can_deadlock); + (void) read_statistics_for_tables_if_needed(thd, table_list); + thd->force_read_stats= false; DEBUG_SYNC(thd, "after_open_table_ignore_flush"); diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 11fd7765e03..c751b079147 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -2185,7 +2185,10 @@ inline bool statistics_for_command_is_needed(THD *thd) { if (thd->bootstrap || thd->variables.use_stat_tables == NEVER) return FALSE; - + + if (thd->force_read_stats) + return TRUE; + switch(thd->lex->sql_command) { case SQLCOM_SELECT: case SQLCOM_INSERT: @@ -4081,6 +4084,7 @@ bool is_eits_usable(Field *field) partition list of a table. We assume the selecticivity for such columns would be handled during partition pruning. */ + DBUG_ASSERT(field->table->stats_is_read); Column_statistics* col_stats= field->read_stats; return col_stats && !col_stats->no_stat_values_provided() && //(1) field->type() != MYSQL_TYPE_GEOMETRY && //(2) diff --git a/sql/sql_string.h b/sql/sql_string.h index 7c920cafc4f..4302f458436 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -738,11 +738,6 @@ public: { length(0); } - StringBuffer(const char *str, size_t length_arg, CHARSET_INFO *cs) - : String(buff, buff_sz, cs) - { - set(str, length_arg, cs); - } }; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 5e5b6644377..0d02e9e6fee 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -355,6 +355,8 @@ int mysql_update(THD *thd, if (lock_tables(thd, table_list, table_count, 0)) DBUG_RETURN(1); + (void) read_statistics_for_tables_if_needed(thd, table_list); + THD_STAGE_INFO(thd, stage_init_update); if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT)) DBUG_RETURN(1); @@ -1688,6 +1690,7 @@ int mysql_multi_update_prepare(THD *thd) { DBUG_RETURN(TRUE); } + (void) read_statistics_for_tables_if_needed(thd, table_list); /* @todo: downgrade the metadata locks here. */ /* diff --git a/sql/sql_window.cc b/sql/sql_window.cc index dcc6a7bac1c..86c40b5f58f 100644 --- a/sql/sql_window.cc +++ b/sql/sql_window.cc @@ -455,6 +455,22 @@ int compare_order_lists(SQL_I_List<ORDER> *part_list1, for ( ; elem1 && elem2; elem1= elem1->next, elem2= elem2->next) { int cmp; + // remove all constants as we don't need them for comparision + while(elem1 && ((*elem1->item)->real_item())->const_item()) + { + elem1= elem1->next; + continue; + } + + while(elem2 && ((*elem2->item)->real_item())->const_item()) + { + elem2= elem2->next; + continue; + } + + if (!elem1 || !elem2) + break; + if ((cmp= compare_order_elements(elem1, elem2))) return cmp; } |