diff options
author | Sergei Golubchik <serg@mariadb.org> | 2020-05-27 23:10:55 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2020-05-27 23:10:55 +0200 |
commit | c2a7dffc573f311029ed4696fb5bd88e5efba752 (patch) | |
tree | 9f04258d84a42954afb0b8e36486fd6f303cf90d /sql | |
parent | 520c3f69a6caed5524d3214a0339736d673c4c0c (diff) | |
parent | f20c63264ab4170fc8e45093042bd2e7272ce9fc (diff) | |
download | mariadb-git-10.0.tar.gz |
Merge tag 'mariadb-5.5.68' into 10.0bb-10.0-serg10.0
Diffstat (limited to 'sql')
-rw-r--r-- | sql/event_scheduler.cc | 4 | ||||
-rw-r--r-- | sql/opt_range.cc | 28 | ||||
-rw-r--r-- | sql/slave.cc | 34 | ||||
-rw-r--r-- | sql/sql_class.cc | 2 | ||||
-rw-r--r-- | sql/sql_lex.cc | 18 | ||||
-rw-r--r-- | sql/sql_parse.cc | 1 | ||||
-rw-r--r-- | sql/table.cc | 1 |
7 files changed, 41 insertions, 47 deletions
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index c865406e6f4..f6a9de9441b 100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2006, 2013, Oracle and/or its affiliates. +/* Copyright (c) 2006, 2019, Oracle and/or its affiliates. + 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 @@ -507,6 +508,7 @@ Event_scheduler::run(THD *thd) DBUG_PRINT("info", ("job_data is NULL, the thread was killed")); } DBUG_PRINT("info", ("state=%s", scheduler_states_names[state].str)); + free_root(thd->mem_root, MYF(0)); } LOCK_DATA(); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index d1ebb910448..078b0995d6a 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -958,7 +958,7 @@ QUICK_RANGE_SELECT *get_quick_select(PARAM *param,uint index, uint mrr_buf_size, MEM_ROOT *alloc); static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, bool index_read_must_be_used, - bool update_tbl_stats, + bool for_range_access, double read_time); static TRP_INDEX_INTERSECT *get_best_index_intersect(PARAM *param, SEL_TREE *tree, @@ -5291,6 +5291,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, sizeof(TRP_RANGE*)* n_child_scans))) DBUG_RETURN(NULL); + /* Collect best 'range' scan for each of disjuncts, and, while doing so, analyze possibility of ROR scans. Also calculate some values needed by @@ -5302,7 +5303,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, { DBUG_EXECUTE("info", print_sel_tree(param, *ptree, &(*ptree)->keys_map, "tree in SEL_IMERGE");); - if (!(*cur_child= get_key_scans_params(param, *ptree, TRUE, FALSE, read_time))) + if (!(*cur_child= get_key_scans_params(param, *ptree, TRUE, FALSE, + read_time))) { /* One of index scans in this index_merge is more expensive than entire @@ -5622,9 +5624,12 @@ TABLE_READ_PLAN *merge_same_index_scans(PARAM *param, SEL_IMERGE *imerge, a random order 2. the functions that estimate the cost of a range scan and an index merge retrievals are not well calibrated + + As the best range access has been already chosen it does not + make sense to evaluate the one obtained from a degenerated + index merge. */ - trp= get_key_scans_params(param, *imerge->trees, FALSE, TRUE, - read_time); + trp= 0; } DBUG_RETURN(trp); @@ -7341,6 +7346,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, tree make range select for this SEL_TREE index_read_must_be_used if TRUE, assume 'index only' option will be set (except for clustered PK indexes) + for_range_access if TRUE the function is called to get the best range + plan for range access, not for index merge access read_time don't create read plans with cost > read_time. RETURN Best range read plan @@ -7349,7 +7356,7 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, bool index_read_must_be_used, - bool update_tbl_stats, + bool for_range_access, double read_time) { uint idx; @@ -7394,9 +7401,16 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, (bool) param->table->covering_keys.is_set(keynr); found_records= check_quick_select(param, idx, read_index_only, *key, - update_tbl_stats, &mrr_flags, + for_range_access, &mrr_flags, &buf_size, &cost); + if (!for_range_access && !param->is_ror_scan && + !optimizer_flag(param->thd,OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION)) + { + /* The scan is not a ROR-scan, just skip it */ + continue; + } + if (found_records != HA_POS_ERROR && tree->index_scans && (index_scan= (INDEX_SCAN_INFO *)alloc_root(param->mem_root, sizeof(INDEX_SCAN_INFO)))) @@ -9482,7 +9496,7 @@ key_and(RANGE_OPT_PARAM *param, SEL_ARG *key1, SEL_ARG *key2, uint clone_flag) if (key2->next_key_part) { key1->use_count--; // Incremented in and_all_keys - return and_all_keys(param, key1, key2, clone_flag); + return and_all_keys(param, key1, key2->next_key_part, clone_flag); } key2->use_count--; // Key2 doesn't have a tree } diff --git a/sql/slave.cc b/sql/slave.cc index 39e630824df..9c05fa1a404 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3860,9 +3860,6 @@ pthread_handler_t handle_slave_io(void *arg) bool suppress_warnings; int ret; rpl_io_thread_info io_info; -#ifndef DBUG_OFF - uint retry_count_reg= 0, retry_count_dump= 0, retry_count_event= 0; -#endif // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff my_thread_init(); DBUG_ENTER("handle_slave_io"); @@ -4043,16 +4040,7 @@ connected: goto err; goto connected; } - DBUG_EXECUTE_IF("FORCE_SLAVE_TO_RECONNECT_REG", - if (!retry_count_reg) - { - retry_count_reg++; - sql_print_information("Forcing to reconnect slave I/O thread"); - if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings, - reconnect_messages[SLAVE_RECON_ACT_REG])) - goto err; - goto connected; - }); + DBUG_EXECUTE_IF("fail_com_register_slave", goto err;); } DBUG_PRINT("info",("Starting reading binary log from master")); @@ -4068,16 +4056,6 @@ connected: goto err; goto connected; } - DBUG_EXECUTE_IF("FORCE_SLAVE_TO_RECONNECT_DUMP", - if (!retry_count_dump) - { - retry_count_dump++; - sql_print_information("Forcing to reconnect slave I/O thread"); - if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings, - reconnect_messages[SLAVE_RECON_ACT_DUMP])) - goto err; - goto connected; - }); const char *event_buf; mi->slave_running= MYSQL_SLAVE_RUN_READING; @@ -4095,16 +4073,6 @@ connected: event_len= read_event(mysql, mi, &suppress_warnings); if (check_io_slave_killed(mi, NullS)) goto err; - DBUG_EXECUTE_IF("FORCE_SLAVE_TO_RECONNECT_EVENT", - if (!retry_count_event) - { - retry_count_event++; - sql_print_information("Forcing to reconnect slave I/O thread"); - if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings, - reconnect_messages[SLAVE_RECON_ACT_EVENT])) - goto err; - goto connected; - }); if (event_len == packet_error) { diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 997432e3af9..1ec2d8b3c9e 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -64,6 +64,7 @@ #include "sql_callback.h" #include "lock.h" #include "sql_connect.h" +#include "repl_failsafe.h" /* The following is used to initialise Table_ident with a internal @@ -1535,6 +1536,7 @@ THD::~THD() if (rgi_slave) rgi_slave->cleanup_after_session(); my_free(semisync_info); + unregister_slave(this, true, true); #endif free_root(&main_mem_root, MYF(0)); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 1b57c0f803b..4a523da0dad 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2018, MariaDB Corporation +/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. + 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 @@ -962,17 +962,27 @@ static inline uint int_token(const char *str,uint length) */ bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted) { + // only one level of nested comments are allowed + DBUG_ASSERT(remaining_recursions_permitted == 0 || + remaining_recursions_permitted == 1); reg1 uchar c; while (! lip->eof()) { c= lip->yyGet(); - if (remaining_recursions_permitted > 0) + if (remaining_recursions_permitted == 1) { if ((c == '/') && (lip->yyPeek() == '*')) { + lip->yyUnput('('); // Replace nested "/*..." with "(*..." + lip->yySkip(); // and skip "(" + lip->yySkip(); /* Eat asterisk */ - consume_comment(lip, remaining_recursions_permitted-1); + if (consume_comment(lip, 0)) + return true; + + lip->yyUnput(')'); // Replace "...*/" with "...*)" + lip->yySkip(); // and skip ")" continue; } } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 31ce44411ac..a27cbdf5962 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1530,7 +1530,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, general_log_print(thd, command, "Log: '%s' Pos: %lu", name, pos); if (nlen < FN_REFLEN) mysql_binlog_send(thd, thd->strmake(name, nlen), (my_off_t)pos, flags); - unregister_slave(thd,1,1); /* fake COM_QUIT -- if we get here, the thread needs to terminate */ error = TRUE; break; diff --git a/sql/table.cc b/sql/table.cc index cbddbacaf13..9488ad51afc 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3653,7 +3653,6 @@ bool check_column_name(const char *name) been opened. @param[in] table The table to check - @param[in] table_f_count Expected number of columns in the table @param[in] table_def Expected structure of the table (column name and type) |