cleanup: THD::change_user

This commit is contained in:
Sergei Golubchik 2025-02-21 20:55:54 +01:00
parent fa47c73561
commit 02b81afff8
2 changed files with 15 additions and 28 deletions

View File

@ -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 */
}
/**

View File

@ -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 */