diff options
Diffstat (limited to 'sql')
36 files changed, 177 insertions, 174 deletions
diff --git a/sql/init.cc b/sql/init.cc index 91b4b220bf3..8001e60b65e 100644 --- a/sql/init.cc +++ b/sql/init.cc @@ -42,9 +42,6 @@ void unireg_init(ulong options) current_pid=(ulong) getpid(); /* Save for later ref */ my_init_time(); /* Init time-functions (read zone) */ -#ifndef EMBEDDED_LIBRARY - my_abort_hook=unireg_abort; /* Abort with close of databases */ -#endif (void) strmov(reg_ext,".frm"); reg_ext_length= 4; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index c968ff6f65e..87be0f99e44 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2013, Monty Program Ab. + Copyright (c) 2009, 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 diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index e06d93f4b86..b7c51cd5178 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1,7 +1,7 @@ #ifndef ITEM_CMPFUNC_INCLUDED #define ITEM_CMPFUNC_INCLUDED -/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. - Copyright (c) 2009, 2011, Monty Program Ab. +/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. + Copyright (c) 2009, 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 diff --git a/sql/item_func.cc b/sql/item_func.cc index 235aec4a17e..52575a82e03 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. Copyright (c) 2009, 2015, MariaDB This program is free software; you can redistribute it and/or modify @@ -710,7 +710,7 @@ void Item_func::count_real_length() bool Item_func::count_string_result_length(enum_field_types field_type_arg, Item **items, uint nitems) { - if (agg_arg_charsets(collation, items, nitems, MY_COLL_ALLOW_CONV, 1)) + if (agg_arg_charsets_for_string_result(collation, items, nitems, 1)) return true; if (is_temporal_type(field_type_arg)) count_datetime_length(items, nitems); @@ -6216,9 +6216,7 @@ bool Item_func_match::fix_fields(THD *thd, Item **ref) table= 0; for (uint i=1 ; i < arg_count ; i++) { - item=args[i]; - if (item->type() == Item::REF_ITEM) - args[i]= item= *((Item_ref *)item)->ref; + item= args[i]= args[i]->real_item(); /* When running in PS mode, some Item_field's can already be replaced to Item_func_conv_charset during PREPARE time. This is possible @@ -6231,7 +6229,7 @@ bool Item_func_match::fix_fields(THD *thd, Item **ref) if (!thd->stmt_arena->is_stmt_execute() && item->type() != Item::FIELD_ITEM) { - my_error(ER_WRONG_ARGUMENTS, MYF(0), "AGAINST"); + my_error(ER_WRONG_ARGUMENTS, MYF(0), "MATCH"); return TRUE; } /* diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 04ddbf2c0f9..6c49c02f9aa 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -4486,6 +4486,8 @@ bool Item_func_dyncol_create::prepare_arguments(bool force_names_arg) case DYN_COL_DYNCOL: case DYN_COL_STRING: res= args[valpos]->val_str(&tmp); + if (res && defs[i].cs) + res->set_charset(defs[i].cs); if (res && (vals[i].x.string.value.str= sql_strmake(res->ptr(), res->length()))) { diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 3224362b7f7..d4e3e6c5e7a 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2002, 2012, Oracle and/or its affiliates. - Copyright (c) 2010, 2012, Monty Program Ab +/* Copyright (c) 2002, 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 diff --git a/sql/log_event.cc b/sql/log_event.cc index 81b72fe7787..ff2f9594922 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -4377,7 +4377,8 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, rgi->gtid_pending= false; gtid= rgi->current_gtid; - if (rpl_global_gtid_slave_state.record_gtid(thd, >id, sub_id, true, false)) + if (rpl_global_gtid_slave_state->record_gtid(thd, >id, sub_id, + true, false)) { int errcode= thd->get_stmt_da()->sql_errno(); if (!is_parallel_retry_error(rgi, errcode)) @@ -4587,7 +4588,7 @@ compare_errors: end: if (sub_id && !thd->is_slave_error) - rpl_global_gtid_slave_state.update_state_hash(sub_id, >id, rgi); + rpl_global_gtid_slave_state->update_state_hash(sub_id, >id, rgi); /* Probably we have set thd->query, thd->db, thd->catalog to point to places @@ -6427,7 +6428,7 @@ int Rotate_log_event::do_update_pos(rpl_group_info *rgi) rli->group_master_log_name, (ulong) rli->group_master_log_pos)); mysql_mutex_unlock(&rli->data_lock); - rpl_global_gtid_slave_state.record_and_update_gtid(thd, rgi); + rpl_global_gtid_slave_state->record_and_update_gtid(thd, rgi); flush_relay_log_info(rli); /* @@ -6932,7 +6933,7 @@ Gtid_list_log_event::Gtid_list_log_event(const char *buf, uint event_len, for (i= 0; i < count; ++i) { if (!(sub_id_list[i]= - rpl_global_gtid_slave_state.next_sub_id(list[i].domain_id))) + rpl_global_gtid_slave_state->next_sub_id(list[i].domain_id))) { my_free(list); my_free(sub_id_list); @@ -6987,7 +6988,7 @@ Gtid_list_log_event::Gtid_list_log_event(slave_connection_state *gtid_set, for (i= 0; i < count; ++i) { if (!(sub_id_list[i]= - rpl_global_gtid_slave_state.next_sub_id(list[i].domain_id))) + rpl_global_gtid_slave_state->next_sub_id(list[i].domain_id))) { my_free(list); my_free(sub_id_list); @@ -7059,11 +7060,11 @@ Gtid_list_log_event::do_apply_event(rpl_group_info *rgi) uint32 i; for (i= 0; i < count; ++i) { - if ((ret= rpl_global_gtid_slave_state.record_gtid(thd, &list[i], + if ((ret= rpl_global_gtid_slave_state->record_gtid(thd, &list[i], sub_id_list[i], false, false))) return ret; - rpl_global_gtid_slave_state.update_state_hash(sub_id_list[i], &list[i], + rpl_global_gtid_slave_state->update_state_hash(sub_id_list[i], &list[i], NULL); } } @@ -7562,7 +7563,8 @@ int Xid_log_event::do_apply_event(rpl_group_info *rgi) rgi->gtid_pending= false; gtid= rgi->current_gtid; - err= rpl_global_gtid_slave_state.record_gtid(thd, >id, sub_id, true, false); + err= rpl_global_gtid_slave_state->record_gtid(thd, >id, sub_id, true, + false); if (err) { int ec= thd->get_stmt_da()->sql_errno(); @@ -7595,7 +7597,7 @@ int Xid_log_event::do_apply_event(rpl_group_info *rgi) thd->mdl_context.release_transactional_locks(); if (!res && sub_id) - rpl_global_gtid_slave_state.update_state_hash(sub_id, >id, rgi); + rpl_global_gtid_slave_state->update_state_hash(sub_id, >id, rgi); /* Increment the global status commit count variable @@ -8212,7 +8214,7 @@ int Stop_log_event::do_update_pos(rpl_group_info *rgi) rgi->inc_event_relay_log_pos(); else if (!rgi->is_parallel_exec) { - rpl_global_gtid_slave_state.record_and_update_gtid(thd, rgi); + rpl_global_gtid_slave_state->record_and_update_gtid(thd, rgi); rli->inc_group_relay_log_pos(0, rgi); flush_relay_log_info(rli); } diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 50454f0f66a..9b4f45a9971 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -563,6 +563,10 @@ static int create_db_instance() if (!in) goto end; + if (setvbuf(in, NULL, _IONBF, 0)) + { + verbose("WARNING: Cannot disable buffering on mysqld's stdin"); + } if (fwrite("use mysql;\n",11,1, in) != 1) { verbose("ERROR: Cannot write to mysqld's stdin"); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index bdd6495015e..566d0ff9e04 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1021,7 +1021,7 @@ PSI_cond_key key_RELAYLOG_update_cond, key_COND_wakeup_ready, PSI_cond_key key_RELAYLOG_COND_queue_busy; PSI_cond_key key_TC_LOG_MMAP_COND_queue_busy; PSI_cond_key key_COND_rpl_thread_queue, key_COND_rpl_thread, - key_COND_rpl_thread_pool, + key_COND_rpl_thread_stop, key_COND_rpl_thread_pool, key_COND_parallel_entry, key_COND_group_commit_orderer, key_COND_prepare_ordered, key_COND_slave_init; PSI_cond_key key_COND_wait_gtid, key_COND_gtid_ignore_duplicates; @@ -1068,6 +1068,7 @@ static PSI_cond_info all_server_conds[]= { &key_COND_flush_thread_cache, "COND_flush_thread_cache", PSI_FLAG_GLOBAL}, { &key_COND_rpl_thread, "COND_rpl_thread", 0}, { &key_COND_rpl_thread_queue, "COND_rpl_thread_queue", 0}, + { &key_COND_rpl_thread_stop, "COND_rpl_thread_stop", 0}, { &key_COND_rpl_thread_pool, "COND_rpl_thread_pool", 0}, { &key_COND_parallel_entry, "COND_parallel_entry", 0}, { &key_COND_group_commit_orderer, "COND_group_commit_orderer", 0}, @@ -2115,14 +2116,9 @@ void clean_up(bool print_message) item_func_sleep_free(); lex_free(); /* Free some memory */ item_create_cleanup(); - if (!opt_noacl) - { -#ifdef HAVE_DLOPEN - udf_free(); -#endif - } tdc_start_shutdown(); plugin_shutdown(); + udf_free(); ha_end(); if (tc_log) tc_log->close(); @@ -5857,12 +5853,7 @@ int mysqld_main(int argc, char **argv) if (!opt_noacl) (void) grant_init(); - if (!opt_noacl) - { -#ifdef HAVE_DLOPEN - udf_init(); -#endif - } + udf_init(); if (opt_bootstrap) /* If running with bootstrap, do not start replication. */ opt_skip_slave_start= 1; diff --git a/sql/mysqld.h b/sql/mysqld.h index 081d89c48a4..1c1478f8a63 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. +/* 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 @@ -334,7 +335,7 @@ extern PSI_cond_key key_RELAYLOG_update_cond, key_COND_wakeup_ready, extern PSI_cond_key key_RELAYLOG_COND_queue_busy; extern PSI_cond_key key_TC_LOG_MMAP_COND_queue_busy; extern PSI_cond_key key_COND_rpl_thread, key_COND_rpl_thread_queue, - key_COND_rpl_thread_pool, + key_COND_rpl_thread_stop, key_COND_rpl_thread_pool, key_COND_parallel_entry, key_COND_group_commit_orderer; extern PSI_cond_key key_COND_wait_gtid, key_COND_gtid_ignore_duplicates; @@ -563,6 +564,7 @@ extern mysql_mutex_t LOCK_slave_init; extern MYSQL_PLUGIN_IMPORT mysql_mutex_t LOCK_thread_count; #ifdef HAVE_OPENSSL +extern char* des_key_file; extern mysql_mutex_t LOCK_des_key_file; #endif extern mysql_mutex_t LOCK_server_started; diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index 33cf78b6508..90d750c38ad 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -122,7 +122,7 @@ rpl_slave_state::check_duplicate_gtid(rpl_gtid *gtid, rpl_group_info *rgi) int res; bool did_enter_cond= false; PSI_stage_info old_stage; - THD *thd; + THD *UNINIT_VAR(thd); Relay_log_info *rli= rgi->rli; mysql_mutex_lock(&LOCK_slave_state); @@ -243,8 +243,10 @@ rpl_slave_state_free_element(void *arg) rpl_slave_state::rpl_slave_state() - : last_sub_id(0), inited(false), loaded(false) + : last_sub_id(0), loaded(false) { + mysql_mutex_init(key_LOCK_slave_state, &LOCK_slave_state, + MY_MUTEX_INIT_SLOW); my_hash_init(&hash, &my_charset_bin, 32, offsetof(element, domain_id), sizeof(uint32), NULL, rpl_slave_state_free_element, HASH_UNIQUE); my_init_dynamic_array(>id_sort_array, sizeof(rpl_gtid), 8, 8, MYF(0)); @@ -253,15 +255,10 @@ rpl_slave_state::rpl_slave_state() rpl_slave_state::~rpl_slave_state() { -} - - -void -rpl_slave_state::init() -{ - DBUG_ASSERT(!inited); - mysql_mutex_init(key_LOCK_slave_state, &LOCK_slave_state, MY_MUTEX_INIT_SLOW); - inited= true; + truncate_hash(); + my_hash_free(&hash); + delete_dynamic(>id_sort_array); + mysql_mutex_destroy(&LOCK_slave_state); } @@ -286,17 +283,6 @@ rpl_slave_state::truncate_hash() my_hash_reset(&hash); } -void -rpl_slave_state::deinit() -{ - if (!inited) - return; - truncate_hash(); - my_hash_free(&hash); - delete_dynamic(>id_sort_array); - mysql_mutex_destroy(&LOCK_slave_state); -} - int rpl_slave_state::update(uint32 domain_id, uint32 server_id, uint64 sub_id, @@ -2197,16 +2183,16 @@ gtid_waiting::wait_for_gtid(THD *thd, rpl_gtid *wait_gtid, uint64 wakeup_seq_no; queue_element *cur_waiter; - mysql_mutex_lock(&rpl_global_gtid_slave_state.LOCK_slave_state); + mysql_mutex_lock(&rpl_global_gtid_slave_state->LOCK_slave_state); /* The elements in the gtid_slave_state_hash are never re-allocated once they enter the hash, so we do not need to re-do the lookup after releasing and re-aquiring the lock. */ if (!slave_state_elem && - !(slave_state_elem= rpl_global_gtid_slave_state.get_element(domain_id))) + !(slave_state_elem= rpl_global_gtid_slave_state->get_element(domain_id))) { - mysql_mutex_unlock(&rpl_global_gtid_slave_state.LOCK_slave_state); + mysql_mutex_unlock(&rpl_global_gtid_slave_state->LOCK_slave_state); remove_from_wait_queue(he, &elem); promote_new_waiter(he); if (did_enter_cond) @@ -2223,7 +2209,7 @@ gtid_waiting::wait_for_gtid(THD *thd, rpl_gtid *wait_gtid, We do not have to wait. (We will be removed from the wait queue when we call process_wait_hash() below. */ - mysql_mutex_unlock(&rpl_global_gtid_slave_state.LOCK_slave_state); + mysql_mutex_unlock(&rpl_global_gtid_slave_state->LOCK_slave_state); } else if ((cur_waiter= slave_state_elem->gtid_waiter) && slave_state_elem->min_wait_seq_no <= seq_no) @@ -2235,7 +2221,7 @@ gtid_waiting::wait_for_gtid(THD *thd, rpl_gtid *wait_gtid, lock). */ elem.do_small_wait= false; - mysql_mutex_unlock(&rpl_global_gtid_slave_state.LOCK_slave_state); + mysql_mutex_unlock(&rpl_global_gtid_slave_state->LOCK_slave_state); } else { @@ -2260,7 +2246,7 @@ gtid_waiting::wait_for_gtid(THD *thd, rpl_gtid *wait_gtid, else mysql_mutex_unlock(&LOCK_gtid_waiting); thd->ENTER_COND(&slave_state_elem->COND_wait_gtid, - &rpl_global_gtid_slave_state.LOCK_slave_state, + &rpl_global_gtid_slave_state->LOCK_slave_state, &stage_master_gtid_wait_primary, &old_stage); do { @@ -2270,7 +2256,7 @@ gtid_waiting::wait_for_gtid(THD *thd, rpl_gtid *wait_gtid, { int err= mysql_cond_timedwait(&slave_state_elem->COND_wait_gtid, - &rpl_global_gtid_slave_state.LOCK_slave_state, + &rpl_global_gtid_slave_state->LOCK_slave_state, wait_until); if (err == ETIMEDOUT || err == ETIME) { @@ -2280,7 +2266,7 @@ gtid_waiting::wait_for_gtid(THD *thd, rpl_gtid *wait_gtid, } else mysql_cond_wait(&slave_state_elem->COND_wait_gtid, - &rpl_global_gtid_slave_state.LOCK_slave_state); + &rpl_global_gtid_slave_state->LOCK_slave_state); } while (slave_state_elem->gtid_waiter == &elem); wakeup_seq_no= slave_state_elem->highest_seq_no; /* diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h index 98f6c505dac..ece6effbef6 100644 --- a/sql/rpl_gtid.h +++ b/sql/rpl_gtid.h @@ -163,14 +163,11 @@ struct rpl_slave_state DYNAMIC_ARRAY gtid_sort_array; uint64 last_sub_id; - bool inited; bool loaded; rpl_slave_state(); ~rpl_slave_state(); - void init(); - void deinit(); void truncate_hash(); ulong count() const { return hash.records; } int update(uint32 domain_id, uint32 server_id, uint64 sub_id, diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 526c3ec7a92..b4e7b1a89dd 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -351,6 +351,7 @@ do_ftwrl_wait(rpl_group_info *rgi, THD *thd= rgi->thd; rpl_parallel_entry *entry= rgi->parallel_entry; uint64 sub_id= rgi->gtid_sub_id; + DBUG_ENTER("do_ftwrl_wait"); mysql_mutex_assert_owner(&entry->LOCK_parallel_entry); @@ -390,6 +391,8 @@ do_ftwrl_wait(rpl_group_info *rgi, if (sub_id > entry->largest_started_sub_id) entry->largest_started_sub_id= sub_id; + + DBUG_VOID_RETURN; } @@ -453,6 +456,7 @@ rpl_unpause_after_ftwrl(THD *thd) { uint32 i; rpl_parallel_thread_pool *pool= &global_rpl_thread_pool; + DBUG_ENTER("rpl_unpause_after_ftwrl"); DBUG_ASSERT(pool->busy); @@ -477,6 +481,7 @@ rpl_unpause_after_ftwrl(THD *thd) } pool_mark_not_busy(pool); + DBUG_VOID_RETURN; } @@ -491,6 +496,7 @@ rpl_pause_for_ftwrl(THD *thd) uint32 i; rpl_parallel_thread_pool *pool= &global_rpl_thread_pool; int err; + DBUG_ENTER("rpl_pause_for_ftwrl"); /* While the count_pending_pause_for_ftwrl counter is non-zero, the pool @@ -501,7 +507,7 @@ rpl_pause_for_ftwrl(THD *thd) as this can deadlock against release_thread()). */ if ((err= pool_mark_busy(pool, thd))) - return err; + DBUG_RETURN(err); for (i= 0; i < pool->count; ++i) { @@ -548,7 +554,7 @@ rpl_pause_for_ftwrl(THD *thd) if (err) rpl_unpause_after_ftwrl(thd); - return err; + DBUG_RETURN(err); } @@ -1134,7 +1140,7 @@ handle_rpl_parallel_thread(void *arg) if (opt_gtid_ignore_duplicates) { int res= - rpl_global_gtid_slave_state.check_duplicate_gtid(&rgi->current_gtid, + rpl_global_gtid_slave_state->check_duplicate_gtid(&rgi->current_gtid, rgi); if (res < 0) { @@ -1311,8 +1317,9 @@ handle_rpl_parallel_thread(void *arg) */ mysql_mutex_lock(&rpt->current_entry->LOCK_parallel_entry); mysql_mutex_unlock(&rpt->LOCK_rpl_thread); - mysql_cond_wait(&rpt->current_entry->COND_parallel_entry, - &rpt->current_entry->LOCK_parallel_entry); + if (rpt->pause_for_ftwrl) + mysql_cond_wait(&rpt->current_entry->COND_parallel_entry, + &rpt->current_entry->LOCK_parallel_entry); mysql_mutex_unlock(&rpt->current_entry->LOCK_parallel_entry); mysql_mutex_lock(&rpt->LOCK_rpl_thread); /* @@ -1349,7 +1356,7 @@ handle_rpl_parallel_thread(void *arg) /* Tell wait_for_done() that we are done, if it is waiting. */ if (likely(rpt->current_entry) && unlikely(rpt->current_entry->force_abort)) - mysql_cond_broadcast(&rpt->current_entry->COND_parallel_entry); + mysql_cond_broadcast(&rpt->COND_rpl_thread_stop); rpt->current_entry= NULL; if (!rpt->stop) rpt->pool->release_thread(rpt); @@ -1430,6 +1437,8 @@ rpl_parallel_change_thread_count(rpl_parallel_thread_pool *pool, mysql_cond_init(key_COND_rpl_thread, &new_list[i]->COND_rpl_thread, NULL); mysql_cond_init(key_COND_rpl_thread_queue, &new_list[i]->COND_rpl_thread_queue, NULL); + mysql_cond_init(key_COND_rpl_thread_stop, + &new_list[i]->COND_rpl_thread_stop, NULL); new_list[i]->pool= pool; if (mysql_thread_create(key_rpl_parallel_thread, &th, &connection_attrib, handle_rpl_parallel_thread, new_list[i])) @@ -2143,7 +2152,7 @@ rpl_parallel::wait_for_done(THD *thd, Relay_log_info *rli) { mysql_mutex_lock(&rpt->LOCK_rpl_thread); while (rpt->current_owner == &e->rpl_threads[j]) - mysql_cond_wait(&e->COND_parallel_entry, &rpt->LOCK_rpl_thread); + mysql_cond_wait(&rpt->COND_rpl_thread_stop, &rpt->LOCK_rpl_thread); mysql_mutex_unlock(&rpt->LOCK_rpl_thread); } } diff --git a/sql/rpl_parallel.h b/sql/rpl_parallel.h index 6c1a650429b..9bb37f77dbd 100644 --- a/sql/rpl_parallel.h +++ b/sql/rpl_parallel.h @@ -97,6 +97,7 @@ struct rpl_parallel_thread { mysql_mutex_t LOCK_rpl_thread; mysql_cond_t COND_rpl_thread; mysql_cond_t COND_rpl_thread_queue; + mysql_cond_t COND_rpl_thread_stop; struct rpl_parallel_thread *next; /* For free list. */ struct rpl_parallel_thread_pool *pool; THD *thd; diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 7bdd9c1861f..987e011d5eb 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -37,7 +37,7 @@ static int count_relay_log_space(Relay_log_info* rli); Current replication state (hash of last GTID executed, per replication domain). */ -rpl_slave_state rpl_global_gtid_slave_state; +rpl_slave_state *rpl_global_gtid_slave_state; /* Object used for MASTER_GTID_WAIT(). */ gtid_waiting rpl_global_gtid_waiting; @@ -1325,7 +1325,7 @@ void Relay_log_info::stmt_done(my_off_t event_master_log_pos, THD *thd, else { inc_group_relay_log_pos(event_master_log_pos, rgi); - if (rpl_global_gtid_slave_state.record_and_update_gtid(thd, rgi)) + if (rpl_global_gtid_slave_state->record_and_update_gtid(thd, rgi)) { report(WARNING_LEVEL, ER_CANNOT_UPDATE_GTID_STATE, rgi->gtid_info(), "Failed to update GTID state in %s.%s, slave state may become " @@ -1449,9 +1449,9 @@ rpl_load_gtid_slave_state(THD *thd) uint32 i; DBUG_ENTER("rpl_load_gtid_slave_state"); - mysql_mutex_lock(&rpl_global_gtid_slave_state.LOCK_slave_state); - bool loaded= rpl_global_gtid_slave_state.loaded; - mysql_mutex_unlock(&rpl_global_gtid_slave_state.LOCK_slave_state); + mysql_mutex_lock(&rpl_global_gtid_slave_state->LOCK_slave_state); + bool loaded= rpl_global_gtid_slave_state->loaded; + mysql_mutex_unlock(&rpl_global_gtid_slave_state->LOCK_slave_state); if (loaded) DBUG_RETURN(0); @@ -1551,23 +1551,23 @@ rpl_load_gtid_slave_state(THD *thd) } } - mysql_mutex_lock(&rpl_global_gtid_slave_state.LOCK_slave_state); - if (rpl_global_gtid_slave_state.loaded) + mysql_mutex_lock(&rpl_global_gtid_slave_state->LOCK_slave_state); + if (rpl_global_gtid_slave_state->loaded) { - mysql_mutex_unlock(&rpl_global_gtid_slave_state.LOCK_slave_state); + mysql_mutex_unlock(&rpl_global_gtid_slave_state->LOCK_slave_state); goto end; } for (i= 0; i < array.elements; ++i) { get_dynamic(&array, (uchar *)&tmp_entry, i); - if ((err= rpl_global_gtid_slave_state.update(tmp_entry.gtid.domain_id, + if ((err= rpl_global_gtid_slave_state->update(tmp_entry.gtid.domain_id, tmp_entry.gtid.server_id, tmp_entry.sub_id, tmp_entry.gtid.seq_no, NULL))) { - mysql_mutex_unlock(&rpl_global_gtid_slave_state.LOCK_slave_state); + mysql_mutex_unlock(&rpl_global_gtid_slave_state->LOCK_slave_state); my_error(ER_OUT_OF_RESOURCES, MYF(0)); goto end; } @@ -1580,14 +1580,14 @@ rpl_load_gtid_slave_state(THD *thd) mysql_bin_log.bump_seq_no_counter_if_needed(entry->gtid.domain_id, entry->gtid.seq_no)) { - mysql_mutex_unlock(&rpl_global_gtid_slave_state.LOCK_slave_state); + mysql_mutex_unlock(&rpl_global_gtid_slave_state->LOCK_slave_state); my_error(ER_OUT_OF_RESOURCES, MYF(0)); goto end; } } - rpl_global_gtid_slave_state.loaded= true; - mysql_mutex_unlock(&rpl_global_gtid_slave_state.LOCK_slave_state); + rpl_global_gtid_slave_state->loaded= true; + mysql_mutex_unlock(&rpl_global_gtid_slave_state->LOCK_slave_state); err= 0; /* Clear HA_ERR_END_OF_FILE */ @@ -1657,7 +1657,7 @@ rpl_group_info::~rpl_group_info() int event_group_new_gtid(rpl_group_info *rgi, Gtid_log_event *gev) { - uint64 sub_id= rpl_global_gtid_slave_state.next_sub_id(gev->domain_id); + uint64 sub_id= rpl_global_gtid_slave_state->next_sub_id(gev->domain_id); if (!sub_id) { /* Out of memory caused hash insertion to fail. */ @@ -1772,7 +1772,7 @@ void rpl_group_info::cleanup_context(THD *thd, bool error) --gtid-ignore-duplicates. */ if (gtid_ignore_duplicate_state != GTID_DUPLICATE_NULL) - rpl_global_gtid_slave_state.release_domain_owner(this); + rpl_global_gtid_slave_state->release_domain_owner(this); } /* diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 23ab1664a7b..e896c189a8e 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -745,7 +745,7 @@ struct rpl_group_info /** Save pointer to Annotate_rows event and switch on the binlog_annotate_row_events for this sql thread. - To be called when sql thread recieves an Annotate_rows event. + To be called when sql thread receives an Annotate_rows event. */ inline void set_annotate_event(Annotate_rows_log_event *event) { @@ -873,7 +873,7 @@ public: int init_relay_log_info(Relay_log_info* rli, const char* info_fname); -extern struct rpl_slave_state rpl_global_gtid_slave_state; +extern struct rpl_slave_state *rpl_global_gtid_slave_state; extern gtid_waiting rpl_global_gtid_waiting; int rpl_load_gtid_slave_state(THD *thd); diff --git a/sql/scheduler.cc b/sql/scheduler.cc index a9b253e478a..bc3166210b5 100644 --- a/sql/scheduler.cc +++ b/sql/scheduler.cc @@ -135,7 +135,7 @@ void one_thread_per_connection_scheduler(scheduler_functions *func, #endif /* - Initailize scheduler for --thread-handling=no-threads + Initialize scheduler for --thread-handling=no-threads */ void one_thread_scheduler(scheduler_functions *func) diff --git a/sql/slave.cc b/sql/slave.cc index 895a8c2167e..8512fc229c1 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2190,8 +2190,8 @@ after_set_capability: (master_row= mysql_fetch_row(master_res)) && (master_row[0] != NULL)) { - rpl_global_gtid_slave_state.load(mi->io_thd, master_row[0], - strlen(master_row[0]), false, false); + rpl_global_gtid_slave_state->load(mi->io_thd, master_row[0], + strlen(master_row[0]), false, false); } else if (check_io_slave_killed(mi, NULL)) goto slave_killed_err; @@ -2498,7 +2498,7 @@ bool show_master_info(THD *thd, Master_info *mi, bool full) DBUG_ENTER("show_master_info"); String gtid_pos; - if (full && rpl_global_gtid_slave_state.tostring(>id_pos, NULL, 0)) + if (full && rpl_global_gtid_slave_state->tostring(>id_pos, NULL, 0)) DBUG_RETURN(TRUE); if (send_show_master_info_header(thd, full, gtid_pos.length())) DBUG_RETURN(TRUE); @@ -3679,7 +3679,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, if (opt_gtid_ignore_duplicates) { - int res= rpl_global_gtid_slave_state.check_duplicate_gtid + int res= rpl_global_gtid_slave_state->check_duplicate_gtid (&serial_rgi->current_gtid, serial_rgi); if (res < 0) { @@ -4614,7 +4614,7 @@ pthread_handler_t handle_slave_sql(void *arg) It will then be updated as required by GTID and GTID_LIST events found while applying events read from relay logs. */ - rli->relay_log_state.load(&rpl_global_gtid_slave_state); + rli->relay_log_state.load(rpl_global_gtid_slave_state); } rli->gtid_skip_flag = GTID_SKIP_NOT; if (init_relay_log_pos(rli, @@ -4860,9 +4860,9 @@ pthread_handler_t handle_slave_sql(void *arg) To handle this when we restart the SQL thread, mark the current per-domain position in the Relay_log_info. */ - mysql_mutex_lock(&rpl_global_gtid_slave_state.LOCK_slave_state); - domain_count= rpl_global_gtid_slave_state.count(); - mysql_mutex_unlock(&rpl_global_gtid_slave_state.LOCK_slave_state); + mysql_mutex_lock(&rpl_global_gtid_slave_state->LOCK_slave_state); + domain_count= rpl_global_gtid_slave_state->count(); + mysql_mutex_unlock(&rpl_global_gtid_slave_state->LOCK_slave_state); if (domain_count > 1) { inuse_relaylog *ir; @@ -4873,7 +4873,7 @@ pthread_handler_t handle_slave_sql(void *arg) the relay log back to a known safe place to start (prior to any not yet applied transaction in any domain). */ - rli->restart_gtid_pos.load(&rpl_global_gtid_slave_state, NULL, 0); + rli->restart_gtid_pos.load(rpl_global_gtid_slave_state, NULL, 0); if ((ir= rli->inuse_relaylog_list)) { rpl_gtid *gtid= ir->relay_log_state; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 1240d5d35b2..cdfd731ffcb 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -10270,6 +10270,8 @@ acl_check_proxy_grant_access(THD *thd, const char *host, const char *user, DBUG_RETURN(FALSE); } + mysql_mutex_lock(&acl_cache->lock); + /* check for matching WITH PROXY rights */ for (uint i=0; i < acl_proxy_users.elements; i++) { @@ -10282,10 +10284,12 @@ acl_check_proxy_grant_access(THD *thd, const char *host, const char *user, proxy->get_with_grant()) { DBUG_PRINT("info", ("found")); + mysql_mutex_unlock(&acl_cache->lock); DBUG_RETURN(FALSE); } } + mysql_mutex_unlock(&acl_cache->lock); my_error(ER_ACCESS_DENIED_NO_PASSWORD_ERROR, MYF(0), thd->security_ctx->user, thd->security_ctx->host_or_ip); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 7a0a114971d..a04cbb573e1 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2031,7 +2031,7 @@ public: */ MDL_request grl_protection; - Delayed_insert() + Delayed_insert(SELECT_LEX *current_select) :locks_in_memory(0), table(0),tables_in_use(0),stacked_inserts(0), status(0), handler_thread_initialized(FALSE), group_count(0) { @@ -2041,7 +2041,7 @@ public: strmake_buf(thd.security_ctx->priv_user, thd.security_ctx->user); thd.current_tablenr=0; thd.set_command(COM_DELAYED_INSERT); - thd.lex->current_select= 0; // for my_message_sql + thd.lex->current_select= current_select; thd.lex->sql_command= SQLCOM_INSERT; // For innodb::store_lock() /* Prevent changes to global.lock_wait_timeout from affecting @@ -2218,7 +2218,7 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request, */ if (! (di= find_handler(thd, table_list))) { - if (!(di= new Delayed_insert())) + if (!(di= new Delayed_insert(thd->lex->current_select))) goto end_create; thread_safe_increment32(&thread_count); @@ -2870,6 +2870,16 @@ pthread_handler_t handle_delayed_insert(void *arg) if (di->open_and_lock_table()) goto err; + /* + INSERT DELAYED generally expects thd->lex->current_select to be NULL, + since this is not an attribute of the current thread. This can lead to + problems if the thread that spawned the current one disconnects. + current_select will then point to freed memory. But current_select is + required to resolve the partition function. So, after fulfilling that + requirement, we set the current_select to 0. + */ + thd->lex->current_select= NULL; + /* Tell client that the thread is initialized */ mysql_cond_signal(&di->cond_client); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index de5b9ac01e3..0158ab7d206 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1831,7 +1831,6 @@ static void plugin_load(MEM_ROOT *tmp_root) table->m_needs_reopen= TRUE; // Force close to free memory close_mysql_tables(new_thd); end: - /* Remember that we don't have a THD */ delete new_thd; DBUG_VOID_RETURN; } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index dfe6d1c2117..55f05c3762c 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2002, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2014, Monty Program Ab +/* Copyright (c) 2002, 2015, Oracle and/or its affiliates. + Copyright (c) 2008, 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 @@ -3866,8 +3866,8 @@ Prepared_statement::swap_prepared_statement(Prepared_statement *copy) swap_variables(LEX_STRING, name, copy->name); /* Ditto */ swap_variables(char *, db, copy->db); + swap_variables(size_t, db_length, copy->db_length); - DBUG_ASSERT(db_length == copy->db_length); DBUG_ASSERT(param_count == copy->param_count); DBUG_ASSERT(thd == copy->thd); last_error[0]= '\0'; diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 7f2cf987f0e..1796d4549c7 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. 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 @@ -28,7 +28,7 @@ #include "rpl_mi.h" // Master_info::data_lock #include "sql_show.h" #include "debug_sync.h" -#include "rpl_mi.h" +#include "des_key_file.h" static void disable_checkpoints(THD *thd); @@ -342,7 +342,7 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, } } #endif -#ifdef OPENSSL +#ifdef HAVE_OPENSSL if (options & REFRESH_DES_KEY_FILE) { if (des_key_file && load_des_key_file(des_key_file)) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index aa36afcf995..e524153ad15 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1064,8 +1064,8 @@ check_slave_start_position(binlog_send_info *info, const char **errormsg, rpl_gtid master_replication_gtid; rpl_gtid start_gtid; bool start_at_own_slave_pos= - rpl_global_gtid_slave_state.domain_to_gtid(slave_gtid->domain_id, - &master_replication_gtid) && + rpl_global_gtid_slave_state->domain_to_gtid(slave_gtid->domain_id, + &master_replication_gtid) && slave_gtid->server_id == master_replication_gtid.server_id && slave_gtid->seq_no == master_replication_gtid.seq_no; @@ -4309,14 +4309,14 @@ ret: void rpl_init_gtid_slave_state() { - rpl_global_gtid_slave_state.init(); + rpl_global_gtid_slave_state= new rpl_slave_state; } void rpl_deinit_gtid_slave_state() { - rpl_global_gtid_slave_state.deinit(); + delete rpl_global_gtid_slave_state; } @@ -4352,7 +4352,7 @@ rpl_append_gtid_state(String *dest, bool use_binlog) (err= mysql_bin_log.get_most_recent_gtid_list(>id_list, &num_gtids))) return err; - err= rpl_global_gtid_slave_state.tostring(dest, gtid_list, num_gtids); + err= rpl_global_gtid_slave_state->tostring(dest, gtid_list, num_gtids); my_free(gtid_list); return err; @@ -4377,7 +4377,7 @@ rpl_load_gtid_state(slave_connection_state *state, bool use_binlog) (err= mysql_bin_log.get_most_recent_gtid_list(>id_list, &num_gtids))) return err; - err= state->load(&rpl_global_gtid_slave_state, gtid_list, num_gtids); + err= state->load(rpl_global_gtid_slave_state, gtid_list, num_gtids); my_free(gtid_list); return err; @@ -4474,7 +4474,7 @@ rpl_gtid_pos_check(THD *thd, char *str, size_t len) bool rpl_gtid_pos_update(THD *thd, char *str, size_t len) { - if (rpl_global_gtid_slave_state.load(thd, str, len, true, true)) + if (rpl_global_gtid_slave_state->load(thd, str, len, true, true)) { my_error(ER_FAILED_GTID_STATE_INIT, MYF(0)); return true; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f086a184b96..28a2c8df606 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3392,11 +3392,6 @@ mysql_select(THD *thd, Item ***rref_pointer_array, { if (select_lex->linkage != GLOBAL_OPTIONS_TYPE) { - //here is EXPLAIN of subselect or derived table - if (join->change_result(result, NULL)) - { - DBUG_RETURN(TRUE); - } /* Original join tabs might be overwritten at first subselect execution. So we need to restore them. @@ -7466,7 +7461,7 @@ double table_multi_eq_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, { double curr_eq_fld_sel; Field *fld= fi.get_curr_field(); - if (!fld->table->map & ~(table_bit | rem_tables)) + if (!(fld->table->map & ~(table_bit | rem_tables))) continue; curr_eq_fld_sel= get_column_avg_frequency(fld) / fld->table->stat_records(); @@ -16213,8 +16208,8 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, uint temp_pool_slot=MY_BIT_NONE; uint fieldnr= 0; ulong reclength, string_total_length; - bool using_unique_constraint= 0; - bool use_packed_rows= 0; + bool using_unique_constraint= false; + bool use_packed_rows= false; bool not_all_columns= !(select_options & TMP_TABLE_ALL_COLUMNS); char *tmpname,path[FN_REFLEN]; uchar *pos, *group_buff, *bitmaps; @@ -16287,10 +16282,10 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, */ (*tmp->item)->marker=4; // Store null in key if ((*tmp->item)->too_big_for_varchar()) - using_unique_constraint=1; + using_unique_constraint= true; } if (param->group_length >= MAX_BLOB_WIDTH) - using_unique_constraint=1; + using_unique_constraint= true; if (group) distinct=0; // Can't use distinct } @@ -16546,12 +16541,14 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, *blob_field++= fieldnr; blob_count++; } + if (new_field->real_type() == MYSQL_TYPE_STRING || new_field->real_type() == MYSQL_TYPE_VARCHAR) { string_count++; string_total_length+= new_field->pack_length(); } + if (item->marker == 4 && item->maybe_null) { group_null_items++; @@ -16604,7 +16601,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, if (group && (param->group_parts > table->file->max_key_parts() || param->group_length > table->file->max_key_length())) - using_unique_constraint=1; + using_unique_constraint= true; } else { @@ -17541,7 +17538,10 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, start_recinfo, share->uniques, &uniquedef, &create_info, - HA_CREATE_TMP_TABLE | HA_CREATE_INTERNAL_TABLE))) + HA_CREATE_TMP_TABLE | HA_CREATE_INTERNAL_TABLE | + ((share->db_create_options & HA_OPTION_PACK_RECORD) ? + HA_PACK_RECORD : 0) + ))) { table->file->print_error(error,MYF(0)); /* purecov: inspected */ table->db_stat=0; @@ -20484,6 +20484,7 @@ uint find_shortest_key(TABLE *table, const key_map *usable_keys) min_cost= cost; best=nr; } + DBUG_ASSERT(best < MAX_KEY); } } } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 10d8ed23a46..9914099c3ad 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1830,7 +1830,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet, For string types dump collation name only if collation is not primary for the given charset */ - if (!(field->charset()->state & MY_CS_PRIMARY)) + if (!(field->charset()->state & MY_CS_PRIMARY) && !field->vcol_info) { packet->append(STRING_WITH_LEN(" COLLATE ")); packet->append(field->charset()->name); @@ -7485,11 +7485,12 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) tmp_table_param->field_count= field_count; tmp_table_param->schema_table= 1; SELECT_LEX *select_lex= thd->lex->current_select; + bool keep_row_order= sql_command_flags[thd->lex->sql_command] & CF_STATUS_COMMAND; if (!(table= create_tmp_table(thd, tmp_table_param, field_list, (ORDER*) 0, 0, 0, (select_lex->options | thd->variables.option_bits | - TMP_TABLE_ALL_COLUMNS), - HA_POS_ERROR, table_list->alias))) + TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR, + table_list->alias, false, keep_row_order))) DBUG_RETURN(0); my_bitmap_map* bitmaps= (my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count)); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ccd6c705c32..80d4ec049d8 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3162,13 +3162,14 @@ static void check_duplicate_key(THD *thd, // Report a warning if we have two identical keys. + DBUG_ASSERT(thd->lex->query_tables->alias); if (all_columns_are_identical) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, ER_DUP_INDEX, ER_THD(thd, ER_DUP_INDEX), key_info->name, thd->lex->query_tables->db, - thd->lex->query_tables->table_name); + thd->lex->query_tables->alias); break; } } @@ -3297,9 +3298,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->interval_list); List_iterator<String> int_it(sql_field->interval_list); String conv, *tmp; - char comma_buf[4]; /* 4 bytes for utf32 */ + char comma_buf[5]; /* 5 bytes for 'filename' charset */ + DBUG_ASSERT(sizeof(comma_buf) >= cs->mbmaxlen); int comma_length= cs->cset->wc_mb(cs, ',', (uchar*) comma_buf, - (uchar*) comma_buf + + (uchar*) comma_buf + sizeof(comma_buf)); DBUG_ASSERT(comma_length > 0); for (uint i= 0; (tmp= int_it++); i++) @@ -4640,8 +4642,8 @@ int create_table_impl(THD *thd, bool frm_only= create_table_mode == C_ALTER_TABLE_FRM_ONLY; bool internal_tmp_table= create_table_mode == C_ALTER_TABLE || frm_only; DBUG_ENTER("mysql_create_table_no_lock"); - DBUG_PRINT("enter", ("db: '%s' table: '%s' tmp: %d", - db, table_name, internal_tmp_table)); + DBUG_PRINT("enter", ("db: '%s' table: '%s' tmp: %d path: %s", + db, table_name, internal_tmp_table, path)); if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE) { diff --git a/sql/sql_time.cc b/sql/sql_time.cc index 9785a1691af..eddf14bfbf3 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -1359,7 +1359,7 @@ time_to_datetime_with_warn(THD *thd, only in the old mode. */ if (time_to_datetime(thd, from, to) || - ((thd->variables.old_behavior && OLD_MODE_ZERO_DATE_TIME_CAST) && + ((thd->variables.old_behavior & OLD_MODE_ZERO_DATE_TIME_CAST) && check_date(to, fuzzydate, &warn))) { ErrConvTime str(from); diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index d962df6257d..0b294b5af8c 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -144,7 +144,7 @@ void udf_init() DBUG_ENTER("ufd_init"); char db[]= "mysql"; /* A subject to casednstr, can't be constant */ - if (initialized) + if (initialized || opt_noacl) DBUG_VOID_RETURN; #ifdef HAVE_PSI_INTERFACE @@ -268,6 +268,8 @@ void udf_free() { /* close all shared libraries */ DBUG_ENTER("udf_free"); + if (opt_noacl) + DBUG_VOID_RETURN; for (uint idx=0 ; idx < udf_hash.records ; idx++) { udf_func *udf=(udf_func*) my_hash_element(&udf_hash,idx); diff --git a/sql/sql_udf.h b/sql/sql_udf.h index a42fe686637..d3ec1cc1f95 100644 --- a/sql/sql_udf.h +++ b/sql/sql_udf.h @@ -141,5 +141,8 @@ udf_func *find_udf(const char *name, uint len=0,bool mark_used=0); void free_udf(udf_func *udf); int mysql_create_function(THD *thd,udf_func *udf); int mysql_drop_function(THD *thd,const LEX_STRING *name); +#else +static inline void udf_init(void) { } +static inline void udf_free(void) { } #endif #endif /* SQL_UDF_INCLUDED */ diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index b3900dd5208..8c7204330e4 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1650,7 +1650,7 @@ Sys_var_gtid_slave_pos::global_value_ptr(THD *thd, const LEX_STRING *base) But if the table is not loaded (eg. missing mysql_upgrade_db or some such), then the slave state must be empty anyway. */ - if ((rpl_global_gtid_slave_state.loaded && + if ((rpl_global_gtid_slave_state->loaded && rpl_append_gtid_state(&str, false)) || !(p= thd->strmake(str.ptr(), str.length()))) { diff --git a/sql/table.cc b/sql/table.cc index 6dedd2f8acc..a90eb2eee15 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. Copyright (c) 2008, 2015, MariaDB This program is free software; you can redistribute it and/or modify @@ -2661,21 +2661,6 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share, outparam->record[1]= outparam->record[0]; // Safety } -#ifdef HAVE_valgrind - /* - We need this because when we read var-length rows, we are not updating - bytes after end of varchar - */ - if (records > 1) - { - memcpy(outparam->record[0], share->default_values, share->rec_buff_length); - memcpy(outparam->record[1], share->default_values, share->null_bytes); - if (records > 2) - memcpy(outparam->record[1], share->default_values, - share->rec_buff_length); - } -#endif - if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root, (uint) ((share->fields+1)* sizeof(Field*))))) diff --git a/sql/threadpool.h b/sql/threadpool.h index 50dee35511b..7b62d2cb70a 100644 --- a/sql/threadpool.h +++ b/sql/threadpool.h @@ -27,6 +27,7 @@ extern uint threadpool_oversubscribe; /* Maximum active threads in group */ /* Common thread pool routines, suitable for different implementations */ +extern void threadpool_cleanup_connection(THD *thd); extern void threadpool_remove_connection(THD *thd); extern int threadpool_process_request(THD *thd); extern int threadpool_add_connection(THD *thd); diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 9e0cb07b86c..5bcea767aae 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -168,22 +168,28 @@ int threadpool_add_connection(THD *thd) return retval; } +/* + threadpool_cleanup_connection() does the bulk of connection shutdown work. + Usually called from threadpool_remove_connection(), but rarely it might + be called also in the main polling thread if connection initialization fails. +*/ +void threadpool_cleanup_connection(THD *thd) +{ + thd->net.reading_or_writing = 0; + end_connection(thd); + close_connection(thd, 0); + unlink_thd(thd); + mysql_cond_broadcast(&COND_thread_count); +} + void threadpool_remove_connection(THD *thd) { - Worker_thread_context worker_context; worker_context.save(); - thread_attach(thd); - thd->net.reading_or_writing= 0; - - end_connection(thd); - close_connection(thd, 0); - - unlink_thd(thd); - mysql_cond_broadcast(&COND_thread_count); + threadpool_cleanup_connection(thd); /* Free resources associated with this connection: mysys thread_var and PSI thread. diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc index e720e43498a..89a2036cb10 100644 --- a/sql/threadpool_unix.cc +++ b/sql/threadpool_unix.cc @@ -1255,7 +1255,7 @@ void tp_add_connection(THD *thd) else { /* Allocation failed */ - threadpool_remove_connection(thd); + threadpool_cleanup_connection(thd); } DBUG_VOID_RETURN; } diff --git a/sql/threadpool_win.cc b/sql/threadpool_win.cc index 9cef1af272c..4be51f3d6e9 100644 --- a/sql/threadpool_win.cc +++ b/sql/threadpool_win.cc @@ -667,7 +667,7 @@ void tp_add_connection(THD *thd) if(!con) { tp_log_warning("Allocation failed", "tp_add_connection"); - threadpool_remove_connection(thd); + threadpool_cleanup_connection(thd); return; } @@ -685,7 +685,7 @@ void tp_add_connection(THD *thd) else { /* Likely memory pressure */ - login_callback(NULL, con, NULL); /* deletes connection if something goes wrong */ + threadpool_cleanup_connection(thd); } } |