clean up Rows_log_event virtual methods

Modernize declaration to C++11.
Add missing const.
Convert TYPE_CODE to constexpr.
This commit is contained in:
Nikita Malyavin 2023-04-10 23:58:42 +03:00 committed by Sergei Golubchik
parent e1f5c58ac7
commit 2ce2440538
2 changed files with 47 additions and 61 deletions

View file

@ -4562,7 +4562,7 @@ public:
Log_event_type get_type_code() { return m_type; } /* Specific type (_V1 etc) */
enum_logged_status logged_status() { return LOGGED_ROW_EVENT; }
virtual Log_event_type get_general_type_code() = 0; /* General rows op type, no version */
virtual Log_event_type get_general_type_code() const = 0; /* General rows op type, no version */
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
virtual void pack_info(Protocol *protocol);
@ -4673,7 +4673,7 @@ public:
const uchar* get_extra_row_data() const { return m_extra_row_data; }
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
virtual uint8 get_trg_event_map()= 0;
virtual uint8 get_trg_event_map() const = 0;
inline bool do_invoke_trigger()
{
@ -4851,8 +4851,8 @@ private:
virtual int do_update_pos(rpl_group_info *rgi);
virtual enum_skip_reason do_shall_skip(rpl_group_info *rgi);
/*
Primitive to prepare for a sequence of row executions.
/**
@brief Primitive to prepare for a sequence of row executions.
DESCRIPTION
@ -4862,16 +4862,15 @@ private:
space for any buffers that are needed for the two member
functions mentioned above.
RETURN VALUE
@return
The member function will return 0 if all went OK, or a non-zero
error code otherwise.
*/
virtual
int do_before_row_operations(const rpl_group_info *) = 0;
/*
Primitive to clean up after a sequence of row executions.
/**
@brief Primitive to clean up after a sequence of row executions.
DESCRIPTION
@ -4884,11 +4883,10 @@ private:
function is successful, it should return the error code given in the argument.
*/
virtual
int do_after_row_operations(const Slave_reporting_capability *const log,
int error) = 0;
int do_after_row_operations(int error) = 0;
/*
Primitive to do the actual execution necessary for a row.
/**
@brief Primitive to do the actual execution necessary for a row.
DESCRIPTION
The member function will do the actual execution needed to handle a row.
@ -4896,7 +4894,7 @@ private:
m_curr_row_end should point at the next row (one byte after the end
of the current row).
RETURN VALUE
@return
0 if execution succeeded, 1 if execution failed.
*/
@ -4916,11 +4914,8 @@ private:
class Write_rows_log_event : public Rows_log_event
{
public:
enum
{
/* Support interface to THD::binlog_prepare_pending_rows_event */
TYPE_CODE = WRITE_ROWS_EVENT
};
/* Support interface to THD::binlog_prepare_pending_rows_event */
static constexpr Log_event_type TYPE_CODE = WRITE_ROWS_EVENT;
#if defined(MYSQL_SERVER)
Write_rows_log_event(THD*, TABLE*, ulong table_id,
@ -4946,20 +4941,20 @@ public:
#endif
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
uint8 get_trg_event_map();
uint8 get_trg_event_map() const override;
#endif
private:
virtual Log_event_type get_general_type_code() { return (Log_event_type)TYPE_CODE; }
Log_event_type get_general_type_code() const override { return TYPE_CODE; }
#ifdef MYSQL_CLIENT
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info);
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info) override;
#endif
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
virtual int do_before_row_operations(const rpl_group_info *);
virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
virtual int do_exec_row(rpl_group_info *);
int do_before_row_operations(const rpl_group_info *) override;
int do_after_row_operations(int) override;
int do_exec_row(rpl_group_info *) override;
#endif
};
@ -4977,7 +4972,7 @@ public:
#endif
private:
#if defined(MYSQL_CLIENT)
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info);
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info) override;
#endif
};
@ -4996,11 +4991,8 @@ private:
class Update_rows_log_event : public Rows_log_event
{
public:
enum
{
/* Support interface to THD::binlog_prepare_pending_rows_event */
TYPE_CODE = UPDATE_ROWS_EVENT
};
/* Support interface to THD::binlog_prepare_pending_rows_event */
static constexpr Log_event_type TYPE_CODE = UPDATE_ROWS_EVENT;
#ifdef MYSQL_SERVER
Update_rows_log_event(THD*, TABLE*, ulong table_id,
@ -5009,7 +5001,7 @@ public:
void init(MY_BITMAP const *cols);
#endif
virtual ~Update_rows_log_event();
~Update_rows_log_event() override;
#ifdef HAVE_REPLICATION
Update_rows_log_event(const uchar *buf, uint event_len,
@ -5030,26 +5022,26 @@ public:
}
#endif
virtual bool is_valid() const
bool is_valid() const override
{
return Rows_log_event::is_valid() && m_cols_ai.bitmap;
}
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
uint8 get_trg_event_map();
uint8 get_trg_event_map() const override;
#endif
protected:
virtual Log_event_type get_general_type_code() { return (Log_event_type)TYPE_CODE; }
Log_event_type get_general_type_code() const override { return TYPE_CODE; }
#ifdef MYSQL_CLIENT
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info);
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info) override;
#endif
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
virtual int do_before_row_operations(const rpl_group_info *);
virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
virtual int do_exec_row(rpl_group_info *);
int do_before_row_operations(const rpl_group_info *) override;
int do_after_row_operations(int) override;
int do_exec_row(rpl_group_info *) override;
#endif /* defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) */
};
@ -5067,7 +5059,7 @@ public:
#endif
private:
#if defined(MYSQL_CLIENT)
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info);
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info) override;
#endif
};
@ -5094,11 +5086,8 @@ private:
class Delete_rows_log_event : public Rows_log_event
{
public:
enum
{
/* Support interface to THD::binlog_prepare_pending_rows_event */
TYPE_CODE = DELETE_ROWS_EVENT
};
/* Support interface to THD::binlog_prepare_pending_rows_event */
static constexpr Log_event_type TYPE_CODE = DELETE_ROWS_EVENT;
#ifdef MYSQL_SERVER
Delete_rows_log_event(THD*, TABLE*, ulong, bool is_transactional);
@ -5123,20 +5112,20 @@ public:
#endif
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
uint8 get_trg_event_map();
uint8 get_trg_event_map() const override;
#endif
protected:
virtual Log_event_type get_general_type_code() { return (Log_event_type)TYPE_CODE; }
Log_event_type get_general_type_code() const override { return TYPE_CODE; }
#ifdef MYSQL_CLIENT
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info);
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info) override;
#endif
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
virtual int do_before_row_operations(const rpl_group_info *const);
virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
virtual int do_exec_row(rpl_group_info *);
int do_before_row_operations(const rpl_group_info *const) override;
int do_after_row_operations(int) override;
int do_exec_row(rpl_group_info *) override;
#endif
};
@ -5153,7 +5142,7 @@ public:
#endif
private:
#if defined(MYSQL_CLIENT)
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info);
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info) override;
#endif
};

View file

@ -5206,7 +5206,7 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
const_cast<Relay_log_info*>(rli)->abort_slave= 1;);
}
if (unlikely(error= do_after_row_operations(rli, error)) &&
if (unlikely(error= do_after_row_operations(error)) &&
ignored_error_code(convert_handler_error(error, thd, table)))
{
@ -6538,8 +6538,7 @@ Write_rows_log_event::do_before_row_operations(const rpl_group_info *)
}
int
Write_rows_log_event::do_after_row_operations(const Slave_reporting_capability *const,
int error)
Write_rows_log_event::do_after_row_operations(int error)
{
int local_error= 0;
@ -7016,7 +7015,7 @@ Write_rows_log_event::do_exec_row(rpl_group_info *rgi)
#if defined(HAVE_REPLICATION)
uint8 Write_rows_log_event::get_trg_event_map()
uint8 Write_rows_log_event::get_trg_event_map() const
{
return trg2bit(TRG_EVENT_INSERT) | trg2bit(TRG_EVENT_UPDATE) |
trg2bit(TRG_EVENT_DELETE);
@ -7735,8 +7734,7 @@ Delete_rows_log_event::do_before_row_operations(const rpl_group_info *rgi)
}
int
Delete_rows_log_event::do_after_row_operations(const Slave_reporting_capability *const,
int error)
Delete_rows_log_event::do_after_row_operations(int error)
{
m_table->file->ha_index_or_rnd_end();
my_free(m_key);
@ -7821,7 +7819,7 @@ int Delete_rows_log_event::do_exec_row(rpl_group_info *rgi)
#endif /* defined(HAVE_REPLICATION) */
#if defined(HAVE_REPLICATION)
uint8 Delete_rows_log_event::get_trg_event_map()
uint8 Delete_rows_log_event::get_trg_event_map() const
{
return trg2bit(TRG_EVENT_DELETE);
}
@ -7895,8 +7893,7 @@ Update_rows_log_event::do_before_row_operations(const rpl_group_info *rgi)
}
int
Update_rows_log_event::do_after_row_operations(const Slave_reporting_capability *const,
int error)
Update_rows_log_event::do_after_row_operations(int error)
{
/*error= ToDo:find out what this should really be, this triggers close_scan in nbd, returning error?*/
m_table->file->ha_index_or_rnd_end();
@ -8038,7 +8035,7 @@ err:
#if defined(HAVE_REPLICATION)
uint8 Update_rows_log_event::get_trg_event_map()
uint8 Update_rows_log_event::get_trg_event_map() const
{
return trg2bit(TRG_EVENT_UPDATE);
}