Bug #34386 mysqlbinlog --hexdump prints last row of hexdump incorrectly
Submitted: 7 Feb 2008 17:59 Modified: 15 Dec 2011 10:57
Reporter: Sven Sandberg Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.0, 5.1 OS:Any
Assigned to: Sven Sandberg CPU Architecture:Any
Tags: hexdump, mysqlbinlog

[7 Feb 2008 17:59] Sven Sandberg
Description:
When mysqlbinlog --hexdump prints events, it prints the last row of the hexdump incorrectly, in two ways:

1. if the last row has eight bytes, the end of the second last row is copied to the end of the last row, padding the last row to full length.

2. if the last row has less than sixteen bytes, the textual representation is not aligned with previous rows.

How to repeat:
$ cat <<EOF > mysql-test/suite/rpl/t/rpl_bug.test
--source include/master-slave.inc
use test;
create table t1 (a enum('one', 'two', 'three'));
insert into t1 values ('two');
EOF

$ cd mysql-test

$ ./mtr rpl_bug

$ ../client/mysqlbinlog --hexdump var/log/master-bin.000001 | tail -n 27
# at 216
# at 259
#080207 18:49:34 server id 1  end_log_pos 259 
# Position  Timestamp   Type   Master ID        Size      Master Pos    Flags 
#       d8 ae 44 ab 47   13   01 00 00 00   2b 00 00 00   03 01 00 00   00 00
#       eb 10 00 00 00 00 00 00 00  04 74 65 73 74 00 02 74 |.........test..t|
#       fb 31 00 01 fe 02 f7 01 01  04 74 65 73 74 00 02 74 |1.......|
#       Table_map: `test`.`t1` mapped to number 16
#080207 18:49:34 server id 1  end_log_pos 290 
# Position  Timestamp   Type   Master ID        Size      Master Pos    Flags 
#      103 ae 44 ab 47   17   01 00 00 00   1f 00 00 00   22 01 00 00   10 00
#      116 10 00 00 00 00 00 01 00  01 ff fe 02  |............|
#       Write_rows: table id 16 flags: STMT_END_F

BINLOG '
rkSrRxMBAAAAKwAAAAMBAAAAABAAAAAAAAAABHRlc3QAAnQxAAH+AvcBAQ==
rkSrRxcBAAAAHwAAACIBAAAQABAAAAAAAAEAAf/+Ag==
'/*!*/;
# at 290
#080207 18:49:36 server id 1  end_log_pos 309 
# Position  Timestamp   Type   Master ID        Size      Master Pos    Flags 
#      122 b0 44 ab 47   03   01 00 00 00   13 00 00 00   35 01 00 00   00 00
#       Stop
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

The end of the Table_map_log_event shows defect 1 and the end of the Write_rows_log_event shows defect 2.
[7 Feb 2008 18:02] Sven Sandberg
The bug is in log_event.cc, member function:

void Log_event::print_header(IO_CACHE* file,
                             PRINT_EVENT_INFO* print_event_info,
                             bool is_more)
[12 Feb 2008 15:42] Susanne Ebrecht
Verified as described
[15 Dec 2011 10:57] Jon Stephens
Doxumented fix in the 5.6.4 changelog, as follows:

        mysqlbinlog --hexdump printed the last row of the hex dump
        incorrectly, in two ways:

            1. If the length of the last row was eight bytes, the end of
            the previous row was copied to the end of the last row,
            padding the last row to full length.

            2. If the length of the last row was less than sixteen bytes,
            its textual representation was not aligned with that of
            previous rows.

Closed.
[15 Dec 2011 10:57] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html