Commit ca276729 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

[MDEV-6877] Fixed Update_rows_log_event to correctly apply update log events

Update_rows_log_event must make use of the after image bitmap when
detecting which columns to update.
parent 8a1b7c9c
......@@ -9855,12 +9855,19 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
longer if slave has extra columns.
*/
DBUG_PRINT_BITSET("debug", "Setting table's write_set from: %s", &m_cols);
DBUG_PRINT_BITSET("debug", "Setting table's read_set from: %s", &m_cols);
bitmap_set_all(table->read_set);
if (get_general_type_code() == DELETE_ROWS_EVENT ||
get_general_type_code() == UPDATE_ROWS_EVENT)
bitmap_intersect(table->read_set,&m_cols);
bitmap_set_all(table->write_set);
if (!get_flags(COMPLETE_ROWS_F))
bitmap_intersect(table->write_set,&m_cols);
/* WRITE ROWS EVENTS store the bitmap in m_cols instead of m_cols_ai */
MY_BITMAP *after_image= ((get_general_type_code() == UPDATE_ROWS_EVENT) ?
&m_cols_ai : &m_cols);
bitmap_intersect(table->write_set, after_image);
this->slave_exec_mode= slave_exec_mode_options; // fix the mode
......@@ -12396,7 +12403,7 @@ Update_rows_log_event::do_exec_row(rpl_group_info *rgi)
/* this also updates m_curr_row_end */
thd_proc_info(thd, message);
if ((error= unpack_current_row(rgi)))
if ((error= unpack_current_row(rgi, &m_cols_ai)))
goto err;
/*
......@@ -12429,9 +12436,15 @@ Update_rows_log_event::do_exec_row(rpl_group_info *rgi)
goto err;
}
// Temporary fix to find out why it fails [/Matz]
memcpy(m_table->read_set->bitmap, m_cols.bitmap, (m_table->read_set->n_bits + 7) / 8);
memcpy(m_table->write_set->bitmap, m_cols_ai.bitmap, (m_table->write_set->n_bits + 7) / 8);
m_table->mark_columns_per_binlog_row_image();
error= m_table->file->ha_update_row(m_table->record[1], m_table->record[0]);
if (error == HA_ERR_RECORD_IS_THE_SAME)
error= 0;
m_table->default_column_bitmaps();
if (invoke_triggers && !error &&
process_triggers(TRG_EVENT_UPDATE, TRG_ACTION_AFTER, TRUE))
......
......@@ -4410,6 +4410,14 @@ protected:
int write_row(rpl_group_info *, const bool);
// Unpack the current row into m_table->record[0]
int unpack_current_row(rpl_group_info *rgi, MY_BITMAP const *cols)
{
DBUG_ASSERT(m_table);
ASSERT_OR_RETURN_ERROR(m_curr_row < m_rows_end, HA_ERR_CORRUPT_EVENT);
return ::unpack_row(rgi, m_table, m_width, m_curr_row, cols,
&m_curr_row_end, &m_master_reclength, m_rows_end);
}
int unpack_current_row(rpl_group_info *rgi)
{
DBUG_ASSERT(m_table);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment