From d2d0995cf2beccac035bdd6f23860dec66fb2dcd Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Sun, 12 Dec 2021 11:41:14 +0300 Subject: [PATCH] MDEV-16329 [4/5] Refactor MYSQL_BIN_LOG: extract Event_log ancestor Event_log is supposed to be a basic logging class that can write events in a single file. MYSQL_BIN_LOG in comparison will have: * rotation support * index files * purging * gtid and transactional information handling. * is dedicated for a general-purpose binlog --- sql/handler.cc | 2 +- sql/handler.h | 4 +- sql/log.cc | 164 +++++++++++++++++++++++++++-------------------- sql/log.h | 97 ++++++++++++++++++++-------- sql/log_event.h | 6 +- sql/sql_class.cc | 10 +-- sql/sql_class.h | 7 +- sql/sql_table.cc | 2 +- 8 files changed, 180 insertions(+), 112 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 29c7f1528b7f1..b307574d5cef0 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7271,7 +7271,7 @@ int handler::binlog_log_row(TABLE *table, auto *cache= binlog_get_cache_data(cache_mngr, use_trans_cache(thd, is_trans)); - bool error= (*log_func)(thd, table, &mysql_bin_log, cache, + bool error= (*log_func)(thd, table, mysql_bin_log.as_event_log(), cache, is_trans, before_record, after_record); DBUG_RETURN(error ? HA_ERR_RBR_LOGGING_FAILED : 0); } diff --git a/sql/handler.h b/sql/handler.h index b30f24e1c220a..2858636c6dffa 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -655,9 +655,9 @@ given at all. */ typedef ulonglong alter_table_operations; -class MYSQL_BIN_LOG; +class Event_log; class binlog_cache_data; -typedef bool Log_func(THD*, TABLE*, MYSQL_BIN_LOG *, binlog_cache_data *, bool, +typedef bool Log_func(THD*, TABLE*, Event_log *, binlog_cache_data *, bool, const uchar*, const uchar*); /* diff --git a/sql/log.cc b/sql/log.cc index c432f13dec321..da7c6fa8a2dc1 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2408,7 +2408,7 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all) thd->reset_binlog_for_next_statement(); DBUG_RETURN(error); } - if (!wsrep_emulate_bin_log && MYSQL_BIN_LOG::check_write_error(thd)) + if (!wsrep_emulate_bin_log && Event_log::check_write_error(thd)) { /* "all == true" means that a "rollback statement" triggered the error and @@ -2473,7 +2473,7 @@ void binlog_reset_cache(THD *thd) } -void MYSQL_BIN_LOG::set_write_error(THD *thd, bool is_transactional) +void Event_log::set_write_error(THD *thd, bool is_transactional) { DBUG_ENTER("MYSQL_BIN_LOG::set_write_error"); @@ -2513,7 +2513,7 @@ void MYSQL_BIN_LOG::set_write_error(THD *thd, bool is_transactional) DBUG_VOID_RETURN; } -bool MYSQL_BIN_LOG::check_write_error(THD *thd) +bool Event_log::check_write_error(THD *thd) { DBUG_ENTER("MYSQL_BIN_LOG::check_write_error"); @@ -3666,7 +3666,7 @@ void MYSQL_BIN_LOG::init(ulong max_size_arg) void MYSQL_BIN_LOG::init_pthread_objects() { - MYSQL_LOG::init_pthread_objects(); + Event_log::init_pthread_objects(); mysql_mutex_init(m_key_LOCK_index, &LOCK_index, MY_MUTEX_INIT_SLOW); mysql_mutex_setflags(&LOCK_index, MYF_NO_DEADLOCK_DETECTION); mysql_mutex_init(key_BINLOG_LOCK_xid_list, @@ -3682,9 +3682,6 @@ void MYSQL_BIN_LOG::init_pthread_objects() &COND_binlog_background_thread, 0); mysql_cond_init(key_BINLOG_COND_binlog_background_thread_end, &COND_binlog_background_thread_end, 0); - - mysql_mutex_init(m_key_LOCK_binlog_end_pos, &LOCK_binlog_end_pos, - MY_MUTEX_INIT_SLOW); } @@ -3755,6 +3752,76 @@ bool MYSQL_BIN_LOG::open_index_file(const char *index_file_name_arg, } +bool Event_log::open(const char *log_name, enum_log_type log_type, + const char *new_name, ulong next_file_number, + enum cache_type io_cache_type_arg) +{ + bool error= MYSQL_LOG::open( +#ifdef HAVE_PSI_INTERFACE + 0, +#endif + log_name, log_type, new_name, next_file_number, io_cache_type_arg); + if (error) + return error; + + int bytes_written= write_description_event( + (enum_binlog_checksum_alg)binlog_checksum_options, + encrypt_binlog, false, false); + error= bytes_written < 0; + return error; +} + +int Event_log::write_description_event(enum_binlog_checksum_alg checksum_alg, + bool encrypt, bool dont_set_created, + bool is_relay_log) +{ + Format_description_log_event s(BINLOG_VERSION); + /* + don't set LOG_EVENT_BINLOG_IN_USE_F for SEQ_READ_APPEND io_cache + as we won't be able to reset it later + */ + if (io_cache_type == WRITE_CACHE) + s.flags |= LOG_EVENT_BINLOG_IN_USE_F; + s.checksum_alg= checksum_alg; + if (is_relay_log) + s.set_relay_log_event(); + + crypto.scheme = 0; + DBUG_ASSERT(s.checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF); + if (!s.is_valid()) + return -1; + s.dont_set_created= dont_set_created; + if (write_event(&s, 0, &log_file)) + return -1; + + if (encrypt) + { + uint key_version= encryption_key_get_latest_version(ENCRYPTION_KEY_SYSTEM_DATA); + if (key_version == ENCRYPTION_KEY_VERSION_INVALID) + { + sql_print_error("Failed to enable encryption of binary logs"); + return -1; + } + + if (key_version != ENCRYPTION_KEY_NOT_ENCRYPTED) + { + if (my_random_bytes(crypto.nonce, sizeof(crypto.nonce))) + return -1; + + Start_encryption_log_event sele(1, key_version, crypto.nonce); + sele.checksum_alg= s.checksum_alg; + if (write_event(&sele, 0, &log_file)) + return -1; + + // Start_encryption_log_event is written, enable the encryption + if (crypto.init(sele.crypto_scheme, key_version)) + return -1; + } + } + return s.data_written; +} + + /** Open a (new) binlog file. @@ -3881,17 +3948,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name, } { - /* - In 4.x we put Start event only in the first binlog. But from 5.0 we - want a Start event even if this is not the very first binlog. - */ - Format_description_log_event s(BINLOG_VERSION); - /* - don't set LOG_EVENT_BINLOG_IN_USE_F for SEQ_READ_APPEND io_cache - as we won't be able to reset it later - */ - if (io_cache_type == WRITE_CACHE) - s.flags |= LOG_EVENT_BINLOG_IN_USE_F; + enum_binlog_checksum_alg alg; if (is_relay_log) { @@ -3899,45 +3956,16 @@ bool MYSQL_BIN_LOG::open(const char *log_name, relay_log_checksum_alg= opt_slave_sql_verify_checksum ? (enum_binlog_checksum_alg) binlog_checksum_options : BINLOG_CHECKSUM_ALG_OFF; - s.checksum_alg= relay_log_checksum_alg; - s.set_relay_log_event(); + alg= relay_log_checksum_alg; } else - s.checksum_alg= (enum_binlog_checksum_alg)binlog_checksum_options; + alg= (enum_binlog_checksum_alg)binlog_checksum_options; - crypto.scheme = 0; - DBUG_ASSERT(s.checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF); - if (!s.is_valid()) + longlong written= write_description_event(alg, encrypt_binlog, + null_created_arg, is_relay_log); + if (written == -1) goto err; - s.dont_set_created= null_created_arg; - if (write_event(&s)) - goto err; - bytes_written+= s.data_written; - - if (encrypt_binlog) - { - uint key_version= encryption_key_get_latest_version(ENCRYPTION_KEY_SYSTEM_DATA); - if (key_version == ENCRYPTION_KEY_VERSION_INVALID) - { - sql_print_error("Failed to enable encryption of binary logs"); - goto err; - } - - if (key_version != ENCRYPTION_KEY_NOT_ENCRYPTED) - { - if (my_random_bytes(crypto.nonce, sizeof(crypto.nonce))) - goto err; - - Start_encryption_log_event sele(1, key_version, crypto.nonce); - sele.checksum_alg= s.checksum_alg; - if (write_event(&sele)) - goto err; - - // Start_encryption_log_event is written, enable the encryption - if (crypto.init(sele.crypto_scheme, key_version)) - goto err; - } - } + bytes_written+= written; if (!is_relay_log) { @@ -5626,7 +5654,7 @@ int MYSQL_BIN_LOG::new_file_impl() DBUG_RETURN(error); } -bool MYSQL_BIN_LOG::write_event(Log_event *ev, binlog_cache_data *cache_data, +bool Event_log::write_event(Log_event *ev, binlog_cache_data *cache_data, IO_CACHE *file) { Log_event_writer writer(file, 0, &crypto); @@ -6209,7 +6237,7 @@ bool THD::binlog_write_table_maps() } if (table->file->row_logging) { - if (binlog_write_table_map(table, with_annotate)) + if (mysql_bin_log.write_table_map(this, table, with_annotate)) DBUG_RETURN(1); with_annotate= 0; } @@ -6242,7 +6270,7 @@ bool THD::binlog_write_table_maps() nonzero if an error pops up when writing the table map event. */ -bool THD::binlog_write_table_map(TABLE *table, bool with_annotate) +bool MYSQL_BIN_LOG::write_table_map(THD *thd, TABLE *table, bool with_annotate) { int error= 1; bool is_transactional= table->file->row_logging_has_trans; @@ -6255,20 +6283,20 @@ bool THD::binlog_write_table_map(TABLE *table, bool with_annotate) DBUG_ASSERT(table->s->table_map_id != ULONG_MAX); /* Ensure that all events in a GTID group are in the same cache */ - if (variables.option_bits & OPTION_GTID_BEGIN) + if (thd->variables.option_bits & OPTION_GTID_BEGIN) is_transactional= 1; Table_map_log_event - the_event(this, table, table->s->table_map_id, is_transactional); + the_event(thd, table, table->s->table_map_id, is_transactional); - binlog_cache_mngr *const cache_mngr= binlog_get_cache_mngr(); + binlog_cache_mngr *const cache_mngr= thd->binlog_get_cache_mngr(); binlog_cache_data *cache_data= (cache_mngr-> get_binlog_cache_data(is_transactional)); IO_CACHE *file= &cache_data->cache_log; Log_event_writer writer(file, cache_data); if (with_annotate) - if (binlog_write_annotated_row(&writer)) + if (thd->binlog_write_annotated_row(&writer)) goto write_err; DBUG_EXECUTE_IF("table_map_write_error", @@ -6286,14 +6314,14 @@ bool THD::binlog_write_table_map(TABLE *table, bool with_annotate) DBUG_RETURN(0); write_err: - mysql_bin_log.set_write_error(this, is_transactional); + set_write_error(thd, is_transactional); /* For non-transactional engine or multi statement transaction with mixed engines, data is written to table but writing to binary log failed. In these scenarios rollback is not possible. Hence report an incident. */ - if (mysql_bin_log.check_write_error(this) && cache_data && - lex->stmt_accessed_table(LEX::STMT_WRITES_NON_TRANS_TABLE) && + if (check_write_error(thd) && cache_data && + thd->lex->stmt_accessed_table(LEX::STMT_WRITES_NON_TRANS_TABLE) && table->current_lock == F_WRLCK) cache_data->set_incident(); DBUG_RETURN(error); @@ -6337,7 +6365,7 @@ binlog_cache_data* binlog_get_cache_data(binlog_cache_mngr *cache_mngr, int binlog_flush_pending_rows_event(THD *thd, bool stmt_end, bool is_transactional, - MYSQL_BIN_LOG *bin_log, + Event_log *bin_log, binlog_cache_data *cache_data) { /* @@ -6395,7 +6423,7 @@ MYSQL_BIN_LOG::remove_pending_rows_event(THD *thd, binlog_cache_data *cache_data otherwise @c false a non-transactional. */ int -MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd, +Event_log::flush_and_set_pending_rows_event(THD *thd, Rows_log_event* event, binlog_cache_data *cache_data, bool is_transactional) @@ -6455,7 +6483,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd, */ Rows_log_event* -MYSQL_BIN_LOG::prepare_pending_rows_event(THD *thd, TABLE* table, +Event_log::prepare_pending_rows_event(THD *thd, TABLE* table, binlog_cache_data *cache_data, uint32 serv_id, size_t needed, bool is_transactional, @@ -7578,9 +7606,9 @@ class CacheWriter: public Log_event_writer events prior to fill in the binlog cache. */ -int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache) +int Event_log::write_cache(THD *thd, IO_CACHE *cache) { - DBUG_ENTER("MYSQL_BIN_LOG::write_cache"); + DBUG_ENTER("Event_log::write_cache"); mysql_mutex_assert_owner(&LOCK_log); if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0)) diff --git a/sql/log.h b/sql/log.h index c8cf8bdb27989..b84ccb6d791b6 100644 --- a/sql/log.h +++ b/sql/log.h @@ -326,6 +326,7 @@ class MYSQL_LOG bool strip_ext, char *buff); virtual int generate_new_name(char *new_name, const char *log_name, ulong next_log_number); + inline mysql_mutex_t* get_log_lock() { return &LOCK_log; } protected: /* LOCK_log is inited by init_pthread_objects() */ mysql_mutex_t LOCK_log; @@ -375,6 +376,63 @@ struct Rows_event_factory } }; +class Event_log: public MYSQL_LOG +{ +protected: + /* binlog encryption data */ + struct Binlog_crypt_data crypto; + + mysql_mutex_t LOCK_binlog_end_pos; + + /** The instrumentation key to use for LOCK_binlog_end_pos. */ + PSI_mutex_key m_key_LOCK_binlog_end_pos; + /** The instrumentation key to use for opening the log file. */ + PSI_file_key m_key_file_log, m_key_file_log_cache; +public: +#if !defined(MYSQL_CLIENT) + Rows_log_event* + 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); +#endif + int flush_and_set_pending_rows_event(THD *thd, Rows_log_event* event, + binlog_cache_data *cache_data, + bool is_transactional); + void set_write_error(THD *thd, bool is_transactional); + static bool check_write_error(THD *thd); + int write_cache(THD *thd, IO_CACHE *cache); + char* get_name() { return name; } + void cleanup() + { + if (inited) + mysql_mutex_destroy(&LOCK_binlog_end_pos); + + MYSQL_LOG::cleanup(); + } + void init_pthread_objects() + { + MYSQL_LOG::init_pthread_objects(); + + mysql_mutex_init(m_key_LOCK_binlog_end_pos, &LOCK_binlog_end_pos, + MY_MUTEX_INIT_SLOW); + } + + bool open( + const char *log_name, + enum_log_type log_type, + const char *new_name, ulong next_file_number, + enum cache_type io_cache_type_arg); + IO_CACHE *get_log_file() { return &log_file; } + + int write_description_event(enum_binlog_checksum_alg checksum_alg, + bool encrypt, bool dont_set_created, + bool is_relay_log); + + bool write_event(Log_event *ev, binlog_cache_data *data, IO_CACHE *file); +}; + /* Tell the io thread if we can delay the master info sync. */ #define SEMI_SYNC_SLAVE_DELAY_SYNC 1 /* Tell the io thread if the current event needs a ack. */ @@ -450,7 +508,7 @@ class binlog_cache_data; struct rpl_gtid; struct wait_for_commit; -class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG +class MYSQL_BIN_LOG: public TC_LOG, private Event_log { /** The instrumentation key to use for @ LOCK_index. */ PSI_mutex_key m_key_LOCK_index; @@ -458,14 +516,10 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG PSI_cond_key m_key_relay_log_update; /** The instrumentation key to use for @ COND_bin_log_updated */ PSI_cond_key m_key_bin_log_update; - /** The instrumentation key to use for opening the log file. */ - PSI_file_key m_key_file_log, m_key_file_log_cache; /** The instrumentation key to use for opening the log index file. */ PSI_file_key m_key_file_log_index, m_key_file_log_index_cache; PSI_cond_key m_key_COND_queue_busy; - /** The instrumentation key to use for LOCK_binlog_end_pos. */ - PSI_mutex_key m_key_LOCK_binlog_end_pos; struct group_commit_entry { @@ -518,7 +572,6 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG /* LOCK_log and LOCK_index are inited by init_pthread_objects() */ mysql_mutex_t LOCK_index; - mysql_mutex_t LOCK_binlog_end_pos; mysql_mutex_t LOCK_xid_list; mysql_cond_t COND_xid_list; mysql_cond_t COND_relay_log_updated, COND_bin_log_updated; @@ -568,9 +621,6 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG ulonglong group_commit_trigger_count, group_commit_trigger_timeout; ulonglong group_commit_trigger_lock_wait; - /* binlog encryption data */ - struct Binlog_crypt_data crypto; - /* pointer to the sync period variable, for binlog this will be sync_binlog_period, for relay log this will be sync_relay_log_period @@ -736,6 +786,11 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG } #endif + Event_log *as_event_log() + { + return this; + } + int open(const char *opt_name); void close(); virtual int generate_new_name(char *new_name, const char *log_name, @@ -749,17 +804,6 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG Format_description_log_event *fdle, bool do_xa); int do_binlog_recovery(const char *opt_name, bool do_xa_recovery); #if !defined(MYSQL_CLIENT) - Rows_log_event* - 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); - - int flush_and_set_pending_rows_event(THD *thd, Rows_log_event* event, - binlog_cache_data *cache_data, - bool is_transactional); - static int remove_pending_rows_event(THD *thd, binlog_cache_data *cache_data); #endif /* !defined(MYSQL_CLIENT) */ @@ -855,15 +899,13 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG bool write_incident_already_locked(THD *thd); bool write_incident(THD *thd); void write_binlog_checkpoint_event_already_locked(const char *name, uint len); - int write_cache(THD *thd, IO_CACHE *cache); - void set_write_error(THD *thd, bool is_transactional); - static bool check_write_error(THD *thd); - + bool write_table_map(THD *thd, TABLE *table, bool with_annotate); void start_union_events(THD *thd, query_id_t query_id_param); void stop_union_events(THD *thd); bool is_query_in_union(THD *thd, query_id_t query_id_param); - bool write_event(Log_event *ev, binlog_cache_data *data, IO_CACHE *file); + using Event_log::write_event; + bool write_event(Log_event *ev) { return write_event(ev, 0, &log_file); } bool write_event_buffer(uchar* buf,uint len); @@ -927,8 +969,7 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG uint next_file_id(); inline char* get_index_fname() { return index_file_name;} inline char* get_log_fname() { return log_file_name; } - inline char* get_name() { return name; } - inline mysql_mutex_t* get_log_lock() { return &LOCK_log; } + using MYSQL_LOG::get_log_lock; inline mysql_cond_t* get_bin_log_cond() { return &COND_bin_log_updated; } inline IO_CACHE* get_log_file() { return &log_file; } inline uint64 get_reset_master_count() { return reset_master_count; } @@ -1211,7 +1252,7 @@ void binlog_reset_cache(THD *thd); bool write_annotated_row(THD *thd); int binlog_flush_pending_rows_event(THD *thd, bool stmt_end, bool is_transactional, - MYSQL_BIN_LOG *bin_log, + Event_log *bin_log, binlog_cache_data *cache_data); Rows_log_event* binlog_get_pending_rows_event(binlog_cache_mngr *cache_mngr, bool use_trans_cache); diff --git a/sql/log_event.h b/sql/log_event.h index 142f3c44d4175..9095fc581b492 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -4926,7 +4926,7 @@ class Write_rows_log_event : public Rows_log_event #endif #if defined(MYSQL_SERVER) static bool binlog_row_logging_function(THD *thd, TABLE *table, - MYSQL_BIN_LOG *bin_log, + Event_log *bin_log, binlog_cache_data *cache_data, bool is_transactional, const uchar *before_record @@ -5012,7 +5012,7 @@ class Update_rows_log_event : public Rows_log_event #ifdef MYSQL_SERVER static bool binlog_row_logging_function(THD *thd, TABLE *table, - MYSQL_BIN_LOG *bin_log, + Event_log *bin_log, binlog_cache_data *cache_data, bool is_transactional, const uchar *before_record, @@ -5103,7 +5103,7 @@ class Delete_rows_log_event : public Rows_log_event #endif #ifdef MYSQL_SERVER static bool binlog_row_logging_function(THD *thd, TABLE *table, - MYSQL_BIN_LOG *bin_log, + Event_log *bin_log, binlog_cache_data *cache_data, bool is_transactional, const uchar *before_record, diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 86c113ae047c0..1f8579f8e68c4 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -7023,7 +7023,7 @@ CPP_UNNAMED_NS_START CPP_UNNAMED_NS_END -int THD::binlog_write_row(TABLE* table, MYSQL_BIN_LOG *bin_log, +int THD::binlog_write_row(TABLE* table, Event_log *bin_log, binlog_cache_data *cache_data, bool is_trans, uchar const *record) { @@ -7054,7 +7054,7 @@ int THD::binlog_write_row(TABLE* table, MYSQL_BIN_LOG *bin_log, return ev->add_row_data(row_data, len); } -int THD::binlog_update_row(TABLE* table, MYSQL_BIN_LOG *bin_log, +int THD::binlog_update_row(TABLE* table, Event_log *bin_log, binlog_cache_data *cache_data, bool is_trans, const uchar *before_record, const uchar *after_record) @@ -7123,7 +7123,7 @@ int THD::binlog_update_row(TABLE* table, MYSQL_BIN_LOG *bin_log, } -int THD::binlog_delete_row(TABLE* table, MYSQL_BIN_LOG *bin_log, +int THD::binlog_delete_row(TABLE* table, Event_log *bin_log, binlog_cache_data *cache_data, bool is_trans, uchar const *record) { @@ -7160,7 +7160,7 @@ int THD::binlog_delete_row(TABLE* table, MYSQL_BIN_LOG *bin_log, auto creator= binlog_should_compress(len) ? Rows_event_factory::get() : Rows_event_factory::get(); - auto *ev= mysql_bin_log.prepare_pending_rows_event(this, table, cache_data, + auto *ev= bin_log->prepare_pending_rows_event(this, table, cache_data, variables.server_id, len, is_trans, creator); @@ -7265,7 +7265,7 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end, bool is_transactional) int error= ::binlog_flush_pending_rows_event(this, stmt_end, is_transactional, - &mysql_bin_log, cache); + mysql_bin_log.as_event_log(), cache); DBUG_RETURN(error); } diff --git a/sql/sql_class.h b/sql/sql_class.h index bb62fe86109cc..a8c0ef841769d 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2946,20 +2946,19 @@ class THD: public THD_count, /* this must be first */ */ void binlog_start_trans_and_stmt(); void binlog_set_stmt_begin(); - int binlog_write_row(TABLE* table, MYSQL_BIN_LOG *bin_log, + int binlog_write_row(TABLE* table, Event_log *bin_log, binlog_cache_data *cache_data, bool is_transactional, const uchar *buf); - int binlog_delete_row(TABLE* table, MYSQL_BIN_LOG *bin_log, + int binlog_delete_row(TABLE* table, Event_log *bin_log, binlog_cache_data *cache_data, bool is_transactional, const uchar *buf); - int binlog_update_row(TABLE* table, MYSQL_BIN_LOG *bin_log, + int binlog_update_row(TABLE* table, Event_log *bin_log, binlog_cache_data *cache_data, bool is_transactional, const uchar *old_data, const uchar *new_data); bool prepare_handlers_for_update(uint flag); bool binlog_write_annotated_row(Log_event_writer *writer); void binlog_prepare_for_row_logging(); bool binlog_write_table_maps(); - bool binlog_write_table_map(TABLE *table, bool with_annotate); static void binlog_prepare_row_images(TABLE* table); void set_server_id(uint32 sid) { variables.server_id = sid; } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6ed7e9cbe75f0..440b926df94ea 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -11014,7 +11014,7 @@ do_continue:; binlog_as_create_select= 1; DBUG_ASSERT(new_table->file->row_logging); new_table->mark_columns_needed_for_insert(); - thd->binlog_write_table_map(new_table, 1); + mysql_bin_log.write_table_map(thd, new_table, 1); } if (copy_data_between_tables(thd, table, new_table, alter_info->create_list, ignore,