danfengcao / binlog2sql

Parse MySQL binlog to SQL you want
GNU General Public License v3.0
3.31k stars 1.04k forks source link

Generated wrong SQL when `binlog_row_image = MINIMAL` #71

Open auntyellow opened 4 years ago

auntyellow commented 4 years ago

I have a table test with column id (PK) and val.

I got the correct SQL without additional binlog_row_image set (default is FULL):

UPDATE `test` SET `id`=1, `val`='2' WHERE `id`=1 AND `val`='2' LIMIT 1

But when I set binlog_row_image = MINIMAL, I got the wrong SQL:

UPDATE `test` SET `id`=NULL, `val`='2' WHERE `id`=1 AND `val` IS NULL LIMIT 1

Should be:

UPDATE `test` SET `val`='2' WHERE `id`=1 LIMIT 1

This is because id is omitted in after image and val is omitted in before image.

auntyellow commented 4 years ago

My MySQL version is 8.0.19