From a7d181a023ae51a3bef40c3740ef38de89e06adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= <vicentiu@mariadb.org> Date: Thu, 2 Apr 2015 19:31:51 +0300 Subject: [MDEV-6877] Added a bitmap compare function for binlog_row_image The function compares bitmaps according to the binlog_row_image variable setting. --- sql/log_event.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'sql/log_event.h') diff --git a/sql/log_event.h b/sql/log_event.h index b57ef35aad2..13d7242c98c 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -4264,9 +4264,58 @@ public: virtual int get_data_size(); MY_BITMAP const *get_cols() const { return &m_cols; } + MY_BITMAP const *get_cols_ai() const { return &m_cols_ai; } size_t get_width() const { return m_width; } ulong get_table_id() const { return m_table_id; } +#if defined(MYSQL_SERVER) + /* + This member function compares the table's read/write_set + with this event's m_cols and m_cols_ai. Comparison takes + into account what type of rows event is this: Delete, Write or + Update, therefore it uses the correct m_cols[_ai] according + to the event type code. + + Note that this member function should only be called for the + following events: + - Delete_rows_log_event + - Write_rows_log_event + - Update_rows_log_event + + @param[IN] table The table to compare this events bitmaps + against. + + @return TRUE if sets match, FALSE otherwise. (following + bitmap_cmp return logic). + + */ + virtual bool read_write_bitmaps_cmp(TABLE *table) + { + bool res= FALSE; + + switch (get_general_type_code()) + { + case DELETE_ROWS_EVENT: + res= bitmap_cmp(get_cols(), table->read_set); + break; + case UPDATE_ROWS_EVENT: + res= (bitmap_cmp(get_cols(), table->read_set) && + bitmap_cmp(get_cols_ai(), table->write_set)); + break; + case WRITE_ROWS_EVENT: + res= bitmap_cmp(get_cols(), table->write_set); + break; + default: + /* + We should just compare bitmaps for Delete, Write + or Update rows events. + */ + DBUG_ASSERT(0); + } + return res; + } +#endif + #ifdef MYSQL_SERVER virtual bool write_data_header(IO_CACHE *file); virtual bool write_data_body(IO_CACHE *file); -- cgit v1.2.1