mirror of
https://github.com/MariaDB/server.git
synced 2026-04-24 17:25:31 +02:00
Fix for BUG#49481 and BUG#49482.
BUG#49481: RBR: MyISAM and bit fields may cause slave to stop on delete:
cant find record
BUG#49482: RBR: Replication may break on deletes when MyISAM tables +
char field are used
When using MyISAM tables, despite the fact that the null bit is
set for some fields, their old value is still in the row. This
can cause the comparison of records to fail when the slave is
doing an index or range scan.
We fix this by avoiding memcmp for MyISAM tables when comparing
records. Additionally, when comparing field by field, we first
check if both fields are not null and if so, then we compare
them. If just one field is null we return failure immediately. If
both fields are null, we move on to the next field.
This commit is contained in:
parent
5ae7b3c996
commit
32aa612819
4 changed files with 153 additions and 2 deletions
|
|
@ -351,6 +351,24 @@ static bool record_compare(TABLE *table)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Check if we are using MyISAM.
|
||||
|
||||
If this is a myisam table, then we cannot do a memcmp
|
||||
right away because some NULL fields can still contain
|
||||
an old value in the row - they are not shown to the user
|
||||
because the null bit is set, however, the contents are
|
||||
not cleared. As such, plain memory comparison cannot be
|
||||
assured to work. See: BUG#49482 and BUG#49481.
|
||||
|
||||
On top of this, we do not store field contents for null
|
||||
fields in the binlog, so this is extra important when
|
||||
comparing records fetched from binlog and from storage
|
||||
engine.
|
||||
*/
|
||||
if (table->file->ht->db_type == DB_TYPE_MYISAM)
|
||||
goto record_compare_field_by_field;
|
||||
|
||||
if (table->s->blob_fields + table->s->varchar_fields == 0)
|
||||
{
|
||||
result= cmp_record(table,record[1]);
|
||||
|
|
@ -366,14 +384,33 @@ static bool record_compare(TABLE *table)
|
|||
goto record_compare_exit;
|
||||
}
|
||||
|
||||
record_compare_field_by_field:
|
||||
|
||||
/* Compare updated fields */
|
||||
for (Field **ptr=table->field ; *ptr ; ptr++)
|
||||
{
|
||||
if ((*ptr)->cmp_binary_offset(table->s->rec_buff_length))
|
||||
Field *f= *ptr;
|
||||
|
||||
/* if just one of the fields is null then there is no match */
|
||||
if ((f->is_null_in_record(table->record[0])) ==
|
||||
!(f->is_null_in_record(table->record[1])))
|
||||
{
|
||||
result= TRUE;
|
||||
goto record_compare_exit;
|
||||
}
|
||||
|
||||
/* if both fields are not null then we can compare */
|
||||
if (!(f->is_null_in_record(table->record[0])) &&
|
||||
!(f->is_null_in_record(table->record[1])))
|
||||
{
|
||||
if (f->cmp_binary_offset(table->s->rec_buff_length))
|
||||
{
|
||||
result= TRUE;
|
||||
goto record_compare_exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* if both fields are null then there is a match. compare next field */
|
||||
}
|
||||
|
||||
record_compare_exit:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue