From 89685d55d7329065607df5a5f19b641e5947e22f Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 7 Apr 2016 19:51:40 +0300 Subject: Reuse THD for new user connections - To ensure that mallocs are marked for the correct THD, even if it's allocated in another thread, I added the thread_id to the THD constructor - Added st_my_thread_var to thr_lock_info_init() to avoid a call to my_thread_var - Moved things from THD::THD() to THD::init() - Moved some things to THD::cleanup() - Added THD::free_connection() and THD::reset_for_reuse() - Added THD to CONNECT::create_thd() - Added THD::thread_dbug_id and st_my_thread_var->dbug_id. These are needed to ensure that we have a constant thread_id used for debugging with a THD, even if it changes thread_id (=connection_id) - Set variables.pseudo_thread_id in constructor. Removed not needed sets. --- sql/sql_profile.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'sql/sql_profile.cc') diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index a169823e25e..f3b62991c5c 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -328,14 +328,28 @@ PROFILING::PROFILING() } PROFILING::~PROFILING() +{ + restart(); +} + +/* + Restart profiling from scratch +*/ + +void PROFILING::restart() { while (! history.is_empty()) delete history.pop(); if (current != NULL) delete current; + /* Ensure that profiling object can be reused */ + profile_id_counter= 1; + current= NULL; + last= NULL; } + /** Throw away the current profile, because it's useless or unwanted or corrupted. @@ -675,6 +689,6 @@ int PROFILING::fill_statistics_info(THD *thd_arg, TABLE_LIST *tables, Item *cond void PROFILING::reset() { - enabled= thd->variables.option_bits & OPTION_PROFILING; + enabled= (thd->variables.option_bits & OPTION_PROFILING) != 0; } #endif /* ENABLED_PROFILING */ -- cgit v1.2.1