Skip to content

Commit

Permalink
clean up Rows_log_event virtual methods
Browse files Browse the repository at this point in the history
Modernize declaration to C++11.
Add missing const.
Convert TYPE_CODE to constexpr.
  • Loading branch information
FooBarrior authored and vuvova committed Aug 15, 2023
1 parent e1f5c58 commit 2ce2440
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 61 deletions.
91 changes: 40 additions & 51 deletions sql/log_event.h
Expand Up @@ -4562,7 +4562,7 @@ class Rows_log_event : public Log_event

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);
Expand Down Expand Up @@ -4673,7 +4673,7 @@ class Rows_log_event : public Log_event
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()
{
Expand Down Expand Up @@ -4851,8 +4851,8 @@ class Rows_log_event : public Log_event
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
Expand All @@ -4862,16 +4862,15 @@ class Rows_log_event : public Log_event
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
Expand All @@ -4884,19 +4883,18 @@ class Rows_log_event : public Log_event
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.
The row is located at m_curr_row. When the function returns,
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.
*/
Expand All @@ -4916,11 +4914,8 @@ class Rows_log_event : public Log_event
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,
Expand All @@ -4946,20 +4941,20 @@ class Write_rows_log_event : public Rows_log_event
#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
};

Expand All @@ -4977,7 +4972,7 @@ class Write_rows_compressed_log_event : public Write_rows_log_event
#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
};

Expand All @@ -4996,11 +4991,8 @@ class Write_rows_compressed_log_event : public Write_rows_log_event
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,
Expand All @@ -5009,7 +5001,7 @@ class Update_rows_log_event : public Rows_log_event
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,
Expand All @@ -5030,26 +5022,26 @@ class Update_rows_log_event : public Rows_log_event
}
#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) */
};

Expand All @@ -5067,7 +5059,7 @@ class Update_rows_compressed_log_event : public Update_rows_log_event
#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
};

Expand All @@ -5094,11 +5086,8 @@ class Update_rows_compressed_log_event : public Update_rows_log_event
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);
Expand All @@ -5123,20 +5112,20 @@ class Delete_rows_log_event : public Rows_log_event
#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
};

Expand All @@ -5153,7 +5142,7 @@ class Delete_rows_compressed_log_event : public Delete_rows_log_event
#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
};

Expand Down
17 changes: 7 additions & 10 deletions sql/log_event_server.cc
Expand Up @@ -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)))
{

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -8038,7 +8035,7 @@ Update_rows_log_event::do_exec_row(rpl_group_info *rgi)


#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);
}
Expand Down

0 comments on commit 2ce2440

Please sign in to comment.