Bug #32580 mysqlbinlog cannot read binlog event generated by user variable usage
Submitted: 21 Nov 2007 17:31 Modified: 6 Feb 2008 17:01
Reporter: Guilhem Bichot
Status: Closed
Category:Server: Replication Severity:S1 (Critical)
Version:5.1-bk OS:Linux
Assigned to: Mats Kindahl Target Version:5.1.23

[21 Nov 2007 17:31] Guilhem Bichot
Description:
In statement-based or mixed binlogging mode, when a user variable (@something) is used
inside an INSERT statement, a User_var binlog event is written to the binlog, and is
needed for the statement to replay properly.
Apparently in 5.1 this is broken:
on one installation I see mysqlbinlog print
SET @`r`:=%.14/*!*/;
which is not valid syntax, and on another installation mysqlbinlog segfaults.
This is S1 because it endangers recovery from backups, and so could even be P1 if I had
this power :)

How to repeat:
create t/bug.test:
-- source include/have_binlog_format_mixed_or_statement.inc
create table u(a int);
set @r=(rand()*1000-500);
insert into u values(@r);
select * from u;
show binlog events;

run that in 5.1 (./mtr --record bug): the result file will be correct, but mysqlbinlog on
this binlog will show incorrect results or crash.
[21 Nov 2007 17:42] Guilhem Bichot
verified with latest 5.1-rpl, by Sven
[21 Nov 2007 22:23] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38247

ChangeSet@1.2619, 2007-11-21 22:23:33+01:00, mats@kindahl-laptop.dnsalias.net +3 -0
  BUG#32580 (mysqlbinlog cannot read binlog event generated by user variable usage):
  
  The client program 'mysqlbinlog' crashed when trying to print a User_var_log_event
holding
  a floating-point value since the format specifier for my_b_printf() does not support
  floating-point format specifiers.
  
  This patch prints the floating-point number to an internal buffer, and then writes
  that buffer to the output instead.
[23 Nov 2007 12:26] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38348

ChangeSet@1.2619, 2007-11-23 12:26:20+01:00, mats@kindahl-laptop.dnsalias.net +3 -0
  BUG#32580 (mysqlbinlog cannot read binlog event generated by user variable usage):
  
  The client program 'mysqlbinlog' crashed when trying to print a User_var_log_event
holding
  a floating-point value since the format specifier for my_b_printf() does not support
  floating-point format specifiers.
  
  This patch prints the floating-point number to an internal buffer, and then writes
  that buffer to the output instead.
[23 Nov 2007 14:42] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38370

ChangeSet@1.2619, 2007-11-23 14:41:41+01:00, mats@kindahl-laptop.dnsalias.net +3 -0
  BUG#32580 (mysqlbinlog cannot read binlog event generated by user variable usage):
  
  The client program 'mysqlbinlog' crashed when trying to print a User_var_log_event
holding
  a floating-point value since the format specifier for my_b_printf() does not support
  floating-point format specifiers.
  
  This patch prints the floating-point number to an internal buffer, and then writes
  that buffer to the output instead.
[5 Feb 2008 14:03] Bugs System
Pushed into 5.1.24-rc
[5 Feb 2008 14:07] Bugs System
Pushed into 6.0.5-alpha
[6 Feb 2008 17:01] Jon Stephens
Documented in the 5.1.24 and 6.0.5 changelogs as follows:

        When a user variable was used inside an
        INSERT statement, the corresponding binlog
        event was not written to the binlog correctly.
[6 Mar 2008 14:39] Jon Stephens
Also documented for 5.1.23-ndb-6.2.14.
[31 Mar 2008 21:01] Jon Stephens
Also documented for 5.1.23-ndb-6.3.11.