mirror of
https://github.com/MariaDB/server.git
synced 2025-01-28 01:34:17 +01:00
MDEV-11675 fixup: GCC -Og -Wmaybe-uninitialized
save_restore_context_apply_event(): Because compilers cannot infer that ev->apply_event(rgi) will not affect ev->get_type_code(), let us test that condition only once and allow the compiler to emit a tail call. Also, replace a goto with an early return for error handling.
This commit is contained in:
parent
2b95c36b4b
commit
12f29a4bc0
1 changed files with 26 additions and 37 deletions
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2005, 2013, Oracle and/or its affiliates.
|
Copyright (c) 2005, 2013, Oracle and/or its affiliates.
|
||||||
|
Copyright (c) 2022, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -183,51 +184,39 @@ int binlog_defragment(THD *thd)
|
||||||
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
|
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
|
||||||
int save_restore_context_apply_event(Log_event *ev, rpl_group_info *rgi)
|
int save_restore_context_apply_event(Log_event *ev, rpl_group_info *rgi)
|
||||||
{
|
{
|
||||||
int err= 0;
|
if (ev->get_type_code() != QUERY_EVENT)
|
||||||
|
return ev->apply_event(rgi);
|
||||||
|
|
||||||
THD *thd= rgi->thd;
|
THD *thd= rgi->thd;
|
||||||
Relay_log_info *rli= thd->rli_fake;
|
Relay_log_info *rli= thd->rli_fake;
|
||||||
sql_digest_state *m_digest;
|
DBUG_ASSERT(!rli->mi);
|
||||||
PSI_statement_locker *m_statement_psi;
|
|
||||||
LEX_CSTRING save_db;
|
|
||||||
my_thread_id m_thread_id= 0;
|
|
||||||
LEX_CSTRING connection_name= { STRING_WITH_LEN("BINLOG_BASE64_EVENT") };
|
LEX_CSTRING connection_name= { STRING_WITH_LEN("BINLOG_BASE64_EVENT") };
|
||||||
|
|
||||||
DBUG_ASSERT(!rli->mi);
|
if (!(rli->mi= new Master_info(&connection_name, false)))
|
||||||
|
|
||||||
if (ev->get_type_code() == QUERY_EVENT)
|
|
||||||
{
|
{
|
||||||
m_digest= thd->m_digest;
|
my_error(ER_OUT_OF_RESOURCES, MYF(0));
|
||||||
m_statement_psi= thd->m_statement_psi;
|
return -1;
|
||||||
m_thread_id= thd->variables.pseudo_thread_id;
|
|
||||||
thd->system_thread_info.rpl_sql_info= NULL;
|
|
||||||
|
|
||||||
if ((rli->mi= new Master_info(&connection_name, false)))
|
|
||||||
{
|
|
||||||
save_db= thd->db;
|
|
||||||
thd->reset_db(&null_clex_str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
my_error(ER_OUT_OF_RESOURCES, MYF(0));
|
|
||||||
err= -1;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
thd->m_digest= NULL;
|
|
||||||
thd->m_statement_psi= NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err= ev->apply_event(rgi);
|
sql_digest_state *m_digest= thd->m_digest;
|
||||||
|
PSI_statement_locker *m_statement_psi= thd->m_statement_psi;;
|
||||||
|
LEX_CSTRING save_db= thd->db;
|
||||||
|
my_thread_id m_thread_id= thd->variables.pseudo_thread_id;
|
||||||
|
|
||||||
end:
|
thd->system_thread_info.rpl_sql_info= NULL;
|
||||||
if (ev->get_type_code() == QUERY_EVENT)
|
thd->reset_db(&null_clex_str);
|
||||||
{
|
|
||||||
thd->m_digest= m_digest;
|
thd->m_digest= NULL;
|
||||||
thd->m_statement_psi= m_statement_psi;
|
thd->m_statement_psi= NULL;
|
||||||
thd->variables.pseudo_thread_id= m_thread_id;
|
|
||||||
thd->reset_db(&save_db);
|
int err= ev->apply_event(rgi);
|
||||||
delete rli->mi;
|
|
||||||
rli->mi= NULL;
|
thd->m_digest= m_digest;
|
||||||
}
|
thd->m_statement_psi= m_statement_psi;
|
||||||
|
thd->variables.pseudo_thread_id= m_thread_id;
|
||||||
|
thd->reset_db(&save_db);
|
||||||
|
delete rli->mi;
|
||||||
|
rli->mi= NULL;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue