MDEV-11636 Extra persistent columns on slave always gets NULL in RBR

Problem:- In replication if slave has extra persistent column then these
column are not computed while applying write-set from master.

Solution:- While applying row events from server, we will generate values
for extra persistent columns.
This commit is contained in:
Sachin Setiya 2016-12-27 14:13:32 +05:30
commit 11544334a2
4 changed files with 358 additions and 0 deletions

View file

@ -407,6 +407,12 @@ unpack_row(rpl_group_info *rgi,
}
}
/*
Add Extra slave persistent columns
*/
if ((error= fill_extra_persistent_columns(table, cols->n_bits)))
DBUG_RETURN(error);
/*
We should now have read all the null bytes, otherwise something is
really wrong.
@ -479,5 +485,30 @@ int prepare_record(TABLE *const table, const uint skip, const bool check)
DBUG_RETURN(0);
}
/**
Fills @c table->record[0] with computed values of extra persistent column which are present on slave but not on master.
@param table Table whose record[0] buffer is prepared.
@param master_cols No of columns on master
@returns 0 on success
*/
int fill_extra_persistent_columns(TABLE *table, int master_cols)
{
int error= 0;
Field **vfield_ptr, *vfield;
if (!table->vfield)
return 0;
for (vfield_ptr= table->vfield; *vfield_ptr; ++vfield_ptr)
{
vfield= *vfield_ptr;
if (vfield->field_index >= master_cols && vfield->stored_in_db)
{
/*Set bitmap for writing*/
bitmap_set_bit(table->vcol_set, vfield->field_index);
error= vfield->vcol_info->expr_item->save_in_field(vfield,0);
bitmap_clear_bit(table->vcol_set, vfield->field_index);
}
}
return error;
}
#endif // HAVE_REPLICATION

View file

@ -38,6 +38,7 @@ int unpack_row(rpl_group_info *rgi,
// Fill table's record[0] with default values.
int prepare_record(TABLE *const table, const uint skip, const bool check);
int fill_extra_persistent_columns(TABLE *table, int master_cols);
#endif
#endif