diff options
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r-- | sql/sql_class.cc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b7d88eca89a..9445f092546 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -202,10 +202,10 @@ bool foreign_key_prefix(Key *a, Key *b) ** Thread specific functions ****************************************************************************/ -Open_tables_state::Open_tables_state(ulong version_arg) +Open_tables_state::Open_tables_state(THD *thd, ulong version_arg) :version(version_arg), state_flags(0U) { - reset_open_tables_state(); + reset_open_tables_state(thd); } /* @@ -440,7 +440,7 @@ bool Drop_table_error_handler::handle_condition(THD *thd, THD::THD() :Statement(&main_lex, &main_mem_root, CONVENTIONAL_EXECUTION, /* statement id */ 0), - Open_tables_state(refresh_version), rli_fake(0), + Open_tables_state(this, refresh_version), rli_fake(0), lock_id(&main_lock_id), user_time(0), in_sub_stmt(0), sql_log_bin_toplevel(false), @@ -468,7 +468,8 @@ THD::THD() #if defined(ENABLED_DEBUG_SYNC) debug_sync_control(0), #endif /* defined(ENABLED_DEBUG_SYNC) */ - main_warning_info(0) + main_warning_info(0), + mdl_el_root(NULL) { ulong tmp; @@ -573,6 +574,8 @@ THD::THD() thr_lock_owner_init(&main_lock_id, &lock_info); m_internal_handler= NULL; + + init_sql_alloc(&locked_tables_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0); } @@ -1051,6 +1054,9 @@ THD::~THD() if (!cleanup_done) cleanup(); + mdl_context_destroy(&mdl_context); + mdl_context_destroy(&handler_mdl_context); + ha_close_connection(this); plugin_thdvar_cleanup(this); @@ -1072,6 +1078,7 @@ THD::~THD() #endif free_root(&main_mem_root, MYF(0)); + free_root(&locked_tables_root, MYF(0)); DBUG_VOID_RETURN; } @@ -3014,7 +3021,7 @@ void THD::reset_n_backup_open_tables_state(Open_tables_state *backup) { DBUG_ENTER("reset_n_backup_open_tables_state"); backup->set_open_tables_state(this); - reset_open_tables_state(); + reset_open_tables_state(this); state_flags|= Open_tables_state::BACKUPS_AVAIL; DBUG_VOID_RETURN; } @@ -3032,6 +3039,9 @@ void THD::restore_backup_open_tables_state(Open_tables_state *backup) lock == 0 && locked_tables == 0 && prelocked_mode == NON_PRELOCKED && m_reprepare_observer == NULL); + mdl_context_destroy(&mdl_context); + mdl_context_destroy(&handler_mdl_context); + set_open_tables_state(backup); DBUG_VOID_RETURN; } |