From 02b81afff8f17e2ac1b944e263e3c5277776fc46 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 21 Feb 2025 20:55:54 +0100 Subject: [PATCH] cleanup: THD::change_user --- sql/sql_class.cc | 15 +++++++++++++++ sql/sql_parse.cc | 28 ---------------------------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4f723b9f016..f87e2417bfb 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1546,6 +1546,14 @@ void THD::init_for_queries() void THD::change_user(void) { +#ifdef WITH_WSREP + bool pause_wsrep= wsrep_cs().state() != wsrep::client_state::s_none; + if (pause_wsrep) + { + wsrep_after_command_ignore_result(this); + wsrep_close(this); + } +#endif /* WITH_WSREP */ if (!status_in_global) // Reset in init() add_status_to_global(); @@ -1575,6 +1583,13 @@ void THD::change_user(void) sp_caches_clear(); statement_rcontext_reinit(); opt_trace.delete_traces(); +#ifdef WITH_WSREP + if (pause_wsrep) + { + wsrep_open(this); + wsrep_before_command(this); + } +#endif /* WITH_WSREP */ } /** diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e8bd0ab9002..f665fee8037 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1713,22 +1713,8 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD * case COM_RESET_CONNECTION: { thd->status_var.com_other++; -#ifdef WITH_WSREP - if (unlikely(wsrep_service_started)) - { - wsrep_after_command_ignore_result(thd); - wsrep_close(thd); - } -#endif /* WITH_WSREP */ thd->change_user(); thd->clear_error(); // if errors from rollback -#ifdef WITH_WSREP - if (unlikely(wsrep_service_started)) - { - wsrep_open(thd); - wsrep_before_command(thd); - } -#endif /* WITH_WSREP */ /* Restore original charset from client authentication packet.*/ if(thd->org_charset) thd->update_charset(thd->org_charset,thd->org_charset,thd->org_charset); @@ -1740,21 +1726,7 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD * int auth_rc; status_var_increment(thd->status_var.com_other); -#ifdef WITH_WSREP - if (unlikely(wsrep_service_started)) - { - wsrep_after_command_ignore_result(thd); - wsrep_close(thd); - } -#endif /* WITH_WSREP */ thd->change_user(); -#ifdef WITH_WSREP - if (unlikely(wsrep_service_started)) - { - wsrep_open(thd); - wsrep_before_command(thd); - } -#endif /* WITH_WSREP */ thd->clear_error(); // if errors from rollback /* acl_authenticate() takes the data from net->read_pos */