diff options
author | Sergei Golubchik <serg@mariadb.org> | 2022-05-24 21:11:48 +0200 |
---|---|---|
committer | Nikita Malyavin <nikitamalyavin@gmail.com> | 2022-10-17 15:24:44 +0300 |
commit | 776479dd5ade4cf9a574598c855b37799d6d5573 (patch) | |
tree | cb8d06fb86f7e03dcbc823e1e2d72cec5e4f05e2 | |
parent | d4e0712ea6cb6b227de6a4175402c74de75f81e7 (diff) | |
download | mariadb-git-776479dd5ade4cf9a574598c855b37799d6d5573.tar.gz |
cleanup
no functional changes here
-rw-r--r-- | sql/log.cc | 109 | ||||
-rw-r--r-- | sql/log.h | 9 | ||||
-rw-r--r-- | sql/rpl_rli.h | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 27 |
4 files changed, 49 insertions, 100 deletions
diff --git a/sql/log.cc b/sql/log.cc index aa99472b17b..1d62599adae 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -104,8 +104,8 @@ static int binlog_flush_cache(THD *thd, binlog_cache_mngr *cache_mngr, Log_event *end_ev, bool all, bool using_stmt, bool using_trx, bool is_ro_1pc); -int binlog_online_alter_commit(THD *thd, bool all); -void binlog_online_alter_rollback(THD *thd, bool all); +static int binlog_online_alter_commit(THD *thd, bool all); +static void binlog_online_alter_rollback(THD *thd, bool all); static const LEX_CSTRING write_error_msg= { STRING_WITH_LEN("error writing to the binary log") }; @@ -2237,12 +2237,11 @@ binlog_online_alter_cleanup(ilist<binlog_cache_mngr> &list, auto it= list.begin(); while (it != list.end()) { - auto &cache= *it; - it++; - list.remove(cache); + auto &cache= *it++; cache.~binlog_cache_mngr(); my_free(&cache); } + list.clear(); DBUG_ASSERT(list.empty()); } } @@ -2607,18 +2606,13 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv) Write ROLLBACK TO SAVEPOINT to the binlog cache if we have updated some non-transactional table. Otherwise, truncate the binlog cache starting from the SAVEPOINT command. - */ -#ifdef WITH_WSREP - /* for streaming replication, we must replicate savepoint rollback so that - slaves can maintain SR transactions + + For streaming replication, we must replicate savepoint rollback so that + slaves can maintain SR transactions */ - if (unlikely(thd->wsrep_trx().is_streaming() || - (trans_has_updated_non_trans_table(thd)) || - (thd->variables.option_bits & OPTION_BINLOG_THIS_TRX))) -#else - if (unlikely(trans_has_updated_non_trans_table(thd) || - (thd->variables.option_bits & OPTION_BINLOG_THIS_TRX))) -#endif /* WITH_WSREP */ + if (IF_WSREP(thd->wsrep_trx().is_streaming(),0) || + trans_has_updated_non_trans_table(thd) || + (thd->variables.option_bits & OPTION_BINLOG_THIS_TRX)) { char buf[1024]; String log_query(buf, sizeof(buf), &my_charset_bin); @@ -3732,40 +3726,20 @@ bool MYSQL_BIN_LOG::open_index_file(const char *index_file_name_arg, } -bool Event_log::open(const char *log_name, - const char *new_name, ulong next_file_number, - enum cache_type io_cache_type_arg) +bool Event_log::open(enum cache_type io_cache_type_arg) { - bool error= false; - if (log_name || new_name) - { - error= MYSQL_LOG::open( -#ifdef HAVE_PSI_INTERFACE - 0, -#endif - log_name, LOG_NORMAL, new_name, next_file_number, io_cache_type_arg); - } - else - { -#ifdef HAVE_PSI_INTERFACE - /* Keep the key for reopen */ - m_log_file_key= 0; -#endif - error= init_io_cache(&log_file, -1, LOG_BIN_IO_SIZE, - io_cache_type_arg, 0, 0, - MYF(MY_WME | MY_NABP | MY_WAIT_IF_FULL)); + bool error= init_io_cache(&log_file, -1, LOG_BIN_IO_SIZE, io_cache_type_arg, + 0, 0, MYF(MY_WME | MY_NABP | MY_WAIT_IF_FULL)); - log_state= LOG_OPENED; - inited= true; - } + log_state= LOG_OPENED; + inited= true; if (error) return error; longlong bytes_written= write_description_event( (enum_binlog_checksum_alg)binlog_checksum_options, - encrypt_binlog, false, false); - error= bytes_written < 0; - return error; + encrypt_binlog, true, false); + return bytes_written < 0; } longlong @@ -6390,11 +6364,7 @@ Rows_log_event* binlog_get_pending_rows_event(binlog_cache_mngr *cache_mngr, bool use_trans_cache) { DBUG_ASSERT(cache_mngr); - Rows_log_event* rows= NULL; - - if (cache_mngr) - rows= cache_mngr->get_binlog_cache_data(use_trans_cache)->pending(); - return rows; + return cache_mngr->get_binlog_cache_data(use_trans_cache)->pending(); } binlog_cache_data* binlog_get_cache_data(binlog_cache_mngr *cache_mngr, @@ -6408,14 +6378,14 @@ int binlog_flush_pending_rows_event(THD *thd, bool stmt_end, Event_log *bin_log, binlog_cache_data *cache_data) { - /* - Mark the event as the last event of a statement if the stmt_end - flag is set. - */ int error= 0; auto *pending= cache_data->pending(); if (pending) { + /* + Mark the event as the last event of a statement if the stmt_end + flag is set. + */ if (stmt_end) { pending->set_flags(Rows_log_event::STMT_END_F); @@ -6463,10 +6433,9 @@ MYSQL_BIN_LOG::remove_pending_rows_event(THD *thd, binlog_cache_data *cache_data otherwise @c false a non-transactional. */ int -Event_log::flush_and_set_pending_rows_event(THD *thd, - Rows_log_event* event, - binlog_cache_data *cache_data, - bool is_transactional) +Event_log::flush_and_set_pending_rows_event(THD *thd, Rows_log_event* event, + binlog_cache_data *cache_data, + bool is_transactional) { DBUG_ENTER("MYSQL_BIN_LOG::flush_and_set_pending_rows_event(event)"); DBUG_ASSERT(WSREP_EMULATE_BINLOG(thd) || is_open()); @@ -6524,10 +6493,10 @@ Event_log::flush_and_set_pending_rows_event(THD *thd, Rows_log_event* Event_log::prepare_pending_rows_event(THD *thd, TABLE* table, - binlog_cache_data *cache_data, - uint32 serv_id, size_t needed, - bool is_transactional, - Rows_event_factory event_factory) + binlog_cache_data *cache_data, + uint32 serv_id, size_t needed, + bool is_transactional, + Rows_event_factory event_factory) { DBUG_ENTER("MYSQL_BIN_LOG::prepare_pending_rows_event"); /* Pre-conditions */ @@ -7629,7 +7598,8 @@ private: bool first; }; -int cache_copy(IO_CACHE *to, IO_CACHE *from) +#ifdef HAVE_REPLICATION +static int cache_copy(IO_CACHE *to, IO_CACHE *from) { DBUG_ENTER("cache_copy"); if (reinit_io_cache(from, READ_CACHE, 0, 0, 0)) @@ -7648,10 +7618,11 @@ int cache_copy(IO_CACHE *to, IO_CACHE *from) DBUG_RETURN(0); } +#endif -int binlog_online_alter_commit(THD *thd, bool all) +static int binlog_online_alter_commit(THD *thd, bool all) { - DBUG_ENTER("online_alter_commit"); + DBUG_ENTER("binlog_online_alter_commit"); int error= 0; #ifdef HAVE_REPLICATION @@ -7665,14 +7636,8 @@ int binlog_online_alter_commit(THD *thd, bool all) auto *binlog= cache_mngr.share->online_alter_binlog; DBUG_ASSERT(binlog); - error= binlog_flush_pending_rows_event(thd, - /* - do not set STMT_END for last event - to leave table open in altering thd - */ - false, - true, - binlog, + // do not set STMT_END for last event to leave table open in altering thd + error= binlog_flush_pending_rows_event(thd, false, true, binlog, is_ending_transaction ? &cache_mngr.trx_cache : &cache_mngr.stmt_cache); @@ -7710,7 +7675,7 @@ int binlog_online_alter_commit(THD *thd, bool all) DBUG_RETURN(error); } -void binlog_online_alter_rollback(THD *thd, bool all) +static void binlog_online_alter_rollback(THD *thd, bool all) { #ifdef HAVE_REPLICATION bool is_ending_trans= ending_trans(thd, all); diff --git a/sql/log.h b/sql/log.h index 11dd8f2081b..c26727f2bf8 100644 --- a/sql/log.h +++ b/sql/log.h @@ -419,10 +419,7 @@ public: MY_MUTEX_INIT_SLOW); } - bool open( - const char *log_name, - const char *new_name, ulong next_file_number, - enum cache_type io_cache_type_arg); + bool open(enum cache_type io_cache_type_arg); virtual IO_CACHE *get_log_file() { return &log_file; } longlong write_description_event(enum_binlog_checksum_alg checksum_alg, @@ -445,7 +442,7 @@ public: TODO should be unnecessary after MDEV-24676 is done */ -class Cache_flip_event_log: public Event_log { +class Cache_flip_event_log: public Event_log, public Sql_alloc { IO_CACHE alt_buf; IO_CACHE *current, *alt; public: @@ -456,7 +453,7 @@ public: { log_file.dir= mysql_tmpdir; alt_buf.dir= log_file.dir; - bool res= Event_log::open(NULL, NULL, 0, io_cache_type_arg); + bool res= Event_log::open(io_cache_type_arg); if (res) return res; diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 6565ac55a86..f548b9c1665 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -950,8 +950,8 @@ struct rpl_group_info if (ptr->table == table_arg) { auto *rpl_table_list= static_cast<RPL_TABLE_LIST*>(ptr); - if (rpl_table_list->m_tabledef_valid) - *tabledef_var= &rpl_table_list->m_tabledef; + DBUG_ASSERT(rpl_table_list->m_tabledef_valid); + *tabledef_var= &rpl_table_list->m_tabledef; *conv_table_var= rpl_table_list->m_conv_table; *copy= rpl_table_list->m_online_alter_copy_fields; *copy_end= rpl_table_list->m_online_alter_copy_fields_end; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e26f25f53d3..6b0a3bef006 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2090,7 +2090,7 @@ bool log_drop_table(THD *thd, const LEX_CSTRING *db_name, in the binary log. We log this for non temporary tables, as the slave may use a filter to ignore queries for a specific database. */ - error= thd->binlog_query(THD::STMT_QUERY_TYPE, + error= thd->binlog_query(THD::STMT_QUERY_TYPE, query.ptr(), query.length(), FALSE, FALSE, temporary_table, 0) > 0; } @@ -10431,8 +10431,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, has been already processed. */ table_list->required_type= TABLE_TYPE_NORMAL; - - + if (alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_SHARED || alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_EXCLUSIVE || thd->locked_tables_mode == LTM_LOCK_TABLES @@ -10538,8 +10537,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, a new one if needed. */ table->s->tdc->flushed= 1; // Force close of all instances - if (thd->mdl_context.upgrade_shared_lock(mdl_ticket, - MDL_EXCLUSIVE, + if (thd->mdl_context.upgrade_shared_lock(mdl_ticket, MDL_EXCLUSIVE, thd->variables.lock_wait_timeout)) DBUG_RETURN(1); quick_rm_table(thd, table->file->ht, &table_list->db, @@ -10548,8 +10546,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, goto end_inplace; } if (!if_exists && - (table->file->partition_ht()->flags & - HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE)) + (table->file->partition_ht()->flags & HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE)) { /* Table is a shared table that may not exist on the slave. @@ -11976,9 +11973,7 @@ static void online_alter_cleanup_binlog(THD *thd, TABLE_SHARE *s) #ifdef HAVE_REPLICATION if (!s->online_alter_binlog) return; - // s->online_alter_binlog->reset_logs(thd, false, NULL, 0, 0); s->online_alter_binlog->cleanup(); - s->online_alter_binlog->~Cache_flip_event_log(); s->online_alter_binlog= NULL; #endif } @@ -12025,9 +12020,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, #ifdef HAVE_REPLICATION if (online) { - void *buf= alloc_root(thd->mem_root, sizeof (Cache_flip_event_log)); - - from->s->online_alter_binlog= new (buf) Cache_flip_event_log(); + from->s->online_alter_binlog= new (thd->mem_root) Cache_flip_event_log(); if (!from->s->online_alter_binlog) DBUG_RETURN(1); @@ -12035,8 +12028,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, error= from->s->online_alter_binlog->open(WRITE_CACHE); - DBUG_ASSERT(!error); - if (!error) { /* @@ -12381,10 +12372,8 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); #ifdef HAVE_REPLICATION - if (likely(online && error < 0)) + if (online && error < 0) { - Ha_trx_info *trx_info_save= thd->transaction->all.ha_list; - thd->transaction->all.ha_list = NULL; thd_progress_next_stage(thd); Table_map_log_event table_event(thd, from, from->s->table_map_id, from->file->has_transactions()); @@ -12421,10 +12410,8 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, thd_progress_next_stage(thd); error= online_alter_read_from_binlog(thd, &rgi, binlog); } - - thd->transaction->all.ha_list = trx_info_save; } - else if (unlikely(online)) // error was on copy stage + else if (online) // error was on copy stage { /* We need to issue a barrier to clean up gracefully. |