Skip to content

Commit

Permalink
FB8-92: Checking for NULL while preparing write set according to binl…
Browse files Browse the repository at this point in the history
…og_row_image (facebook#990) (facebook#990)

Summary:
Jira issue: https://jira.percona.com/browse/FB8-92

Reference Patch: facebook@f3dc487

Field::cmp_binary_offset returns 0 when comparing a NULL text
field and an empty string leading to the field not being logged when the
value is changed from NULL to empty string. This fix first checks if
both AI and BI fields are not NULL before comparing them.

Originally Reviewed By: santoshbanda

Pull Request resolved: facebook#990

Differential Revision: D14652424 (facebook@b6a8e1d)

fbshipit-source-id: 61a8844cc3a
  • Loading branch information
abhinav04sharma authored and inikep committed Jul 16, 2021
1 parent 22d6884 commit 25fc8cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion mysql-test/suite/rpl/t/rpl_row_img_sanity.test
Expand Up @@ -394,6 +394,7 @@ while (`SELECT HEX(@img_types) != HEX('')`)
-- connection master
CREATE TABLE t (c1 int, c2 int, c3 blob, primary key(c1));
INSERT INTO t VALUES (1,2,"a");
INSERT INTO t VALUES (2,4,NULL);


--source include/sync_slave_sql_with_master.inc
Expand All @@ -412,7 +413,7 @@ while (`SELECT HEX(@img_types) != HEX('')`)
-- let $row_img_expected_slave = $row_img_expected_master
-- source include/rpl_row_img_parts_master_slave.inc

-- let $row_img_query= INSERT INTO t VALUES (1, 4, "a") ON DUPLICATE KEY UPDATE c2 = c2 + 2, c3 = c3;
-- let $row_img_query= INSERT INTO t VALUES (1, 4, "a") AS alias ON DUPLICATE KEY UPDATE c2 = alias.c2 + 2, c3 = alias.c3;
if (`SELECT @@binlog_row_image = "MINIMAL"`)
{
-- let $row_img_expected_master= 1:1 | 2:6
Expand All @@ -424,6 +425,18 @@ while (`SELECT HEX(@img_types) != HEX('')`)
-- let $row_img_expected_slave = $row_img_expected_master
-- source include/rpl_row_img_parts_master_slave.inc

-- let $row_img_query= INSERT INTO t VALUES (2, 4, "") AS alias ON DUPLICATE KEY UPDATE c2 = alias.c2, c3 = alias.c3;
if (`SELECT @@binlog_row_image = "MINIMAL"`)
{
-- let $row_img_expected_master= 1:2 | 3:''
}
if (`SELECT @@binlog_row_image = "COMPLETE"`)
{
-- let $row_img_expected_master= 1:2 2:4 3:NULL | 3:''
}
-- let $row_img_expected_slave = $row_img_expected_master
-- source include/rpl_row_img_parts_master_slave.inc

-- connection master
DROP TABLE t;
--source include/sync_slave_sql_with_master.inc
Expand Down
1 change: 1 addition & 0 deletions sql/binlog.cc
Expand Up @@ -11658,6 +11658,7 @@ void binlog_prepare_row_images(const THD *thd, TABLE *table, bool is_update) {

/* compare content, only if fields are not set to NULL */
else if (!field->is_null() &&
!field->is_null_in_record(table->record[1]) &&
!field->cmp_binary_offset(table->s->rec_buff_length))
bitmap_clear_bit(&table->tmp_write_set, field->field_index());
}
Expand Down

0 comments on commit 25fc8cd

Please sign in to comment.