diff options
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r-- | sql/sql_class.cc | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 74489139398..13d6ab7fec7 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2014, SkySQL Ab. + 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 it under the terms of the GNU General Public License as published by @@ -863,6 +863,7 @@ THD::THD(bool is_wsrep_applier) stmt_depends_on_first_successful_insert_id_in_prev_stmt(FALSE), m_examined_row_count(0), accessed_rows_and_keys(0), + m_digest(NULL), m_statement_psi(NULL), m_idle_psi(NULL), thread_id(0), @@ -870,7 +871,7 @@ THD::THD(bool is_wsrep_applier) failed_com_change_user(0), is_fatal_error(0), transaction_rollback_request(0), - is_fatal_sub_stmt_error(0), + is_fatal_sub_stmt_error(false), rand_used(0), time_zone_used(0), in_lock_tables(0), @@ -1063,6 +1064,13 @@ THD::THD(bool is_wsrep_applier) thr_lock_info_init(&lock_info); /* safety: will be reset after start */ lock_info.mysql_thd= (void *)this; + m_token_array= NULL; + if (max_digest_length > 0) + { + m_token_array= (unsigned char*) my_malloc(max_digest_length, + MYF(MY_WME|MY_THREAD_SPECIFIC)); + } + m_internal_handler= NULL; m_binlog_invoker= INVOKER_NONE; arena_for_cached_items= 0; @@ -1560,6 +1568,7 @@ void THD::cleanup(void) mysql_ha_cleanup(this); locked_tables_list.unlock_locked_tables(this); + delete_dynamic(&user_var_events); close_temporary_tables(this); transaction.xid_state.xa_state= XA_NOTR; @@ -1591,7 +1600,6 @@ void THD::cleanup(void) debug_sync_end_thread(this); #endif /* defined(ENABLED_DEBUG_SYNC) */ - delete_dynamic(&user_var_events); my_hash_free(&user_vars); sp_cache_clear(&sp_proc_cache); sp_cache_clear(&sp_func_cache); @@ -1672,6 +1680,7 @@ THD::~THD() #endif main_lex.free_set_stmt_mem_root(); free_root(&main_mem_root, MYF(0)); + my_free(m_token_array); main_da.free_memory(); if (tdc_hash_pins) lf_hash_put_pins(tdc_hash_pins); @@ -4649,7 +4658,8 @@ extern "C" int thd_binlog_format(const MYSQL_THD thd) extern "C" void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all) { - mark_transaction_to_rollback(thd, all); + DBUG_ASSERT(thd); + thd->mark_transaction_to_rollback(all); } extern "C" bool thd_binlog_filter_ok(const MYSQL_THD thd) @@ -4890,9 +4900,12 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup) If we've left sub-statement mode, reset the fatal error flag. Otherwise keep the current value, to propagate it up the sub-statement stack. + + NOTE: is_fatal_sub_stmt_error can be set only if we've been in the + sub-statement mode. */ if (!in_sub_stmt) - is_fatal_sub_stmt_error= FALSE; + is_fatal_sub_stmt_error= false; if ((variables.option_bits & OPTION_BIN_LOG) && is_update_query(lex->sql_command) && !is_current_stmt_binlog_format_row()) @@ -5134,17 +5147,18 @@ void THD::get_definer(LEX_USER *definer, bool role) /** Mark transaction to rollback and mark error as fatal to a sub-statement. - @param thd Thread handle @param all TRUE <=> rollback main transaction. */ -void mark_transaction_to_rollback(THD *thd, bool all) +void THD::mark_transaction_to_rollback(bool all) { - if (thd) - { - thd->is_fatal_sub_stmt_error= TRUE; - thd->transaction_rollback_request= all; - } + /* + There is no point in setting is_fatal_sub_stmt_error unless + we are actually in_sub_stmt. + */ + if (in_sub_stmt) + is_fatal_sub_stmt_error= true; + transaction_rollback_request= all; } /*************************************************************************** Handling of XA id cacheing |