diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-02-02 11:30:16 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-02-02 11:30:16 +0200 |
commit | 12f29a4bc03b9c01ec04be15d8f4e9ecf3fd7805 (patch) | |
tree | 0b6bd76865f6d624bb149d340f50fde797047e4c /sql/sql_binlog.cc | |
parent | 2b95c36b4bf452e6d7b143827f481f58fda04b75 (diff) | |
download | mariadb-git-12f29a4bc03b9c01ec04be15d8f4e9ecf3fd7805.tar.gz |
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.
Diffstat (limited to 'sql/sql_binlog.cc')
-rw-r--r-- | sql/sql_binlog.cc | 63 |
1 files changed, 26 insertions, 37 deletions
diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index baba60e9b6a..c229655e915 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -1,5 +1,6 @@ /* 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 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) 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; Relay_log_info *rli= thd->rli_fake; - sql_digest_state *m_digest; - 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") }; - DBUG_ASSERT(!rli->mi); + LEX_CSTRING connection_name= { STRING_WITH_LEN("BINLOG_BASE64_EVENT") }; - if (ev->get_type_code() == QUERY_EVENT) + if (!(rli->mi= new Master_info(&connection_name, false))) { - m_digest= thd->m_digest; - m_statement_psi= thd->m_statement_psi; - 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; + my_error(ER_OUT_OF_RESOURCES, MYF(0)); + return -1; } - 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: - if (ev->get_type_code() == QUERY_EVENT) - { - 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; - } + thd->system_thread_info.rpl_sql_info= NULL; + thd->reset_db(&null_clex_str); + + thd->m_digest= NULL; + thd->m_statement_psi= NULL; + + int err= ev->apply_event(rgi); + + 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; } |