enhanced binlog row verbose shown for the escape characters

Bug #949965 reported by Hui Liu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
Status tracked in 5.7
5.1
Won't Fix
Wishlist
Unassigned
5.5
Triaged
Wishlist
Unassigned
5.6
Triaged
Wishlist
Unassigned
5.7
Triaged
Wishlist
Unassigned

Bug Description

For mysqlbinlog client tool, when configured with -v (verbose) for row formatted binlog, the escape chars are shown with processed while not like the inserting buffer. Take examples below:

root@test 09:50:47>show create table tx;
+-------+---------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------+
| tx | CREATE TABLE `tx` (
  `a` varchar(5) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gbk |
+-------+---------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

root@test 09:50:58>insert into tx values('a\'b');
Query OK, 1 row affected (0.01 sec)

root@test 09:56:47>insert into tx values('a\tb');
Query OK, 1 row affected (0.00 sec)

root@test 10:06:01>insert into tx values('a\bb');
Query OK, 1 row affected (0.00 sec)

root@test 10:06:04>insert into tx values('a\0b');
Query OK, 1 row affected (0.00 sec)

$sudo mysqlbinlog --no-defaults /u01/mysqld/log/mysql-bin.000008 -v | grep ^'###'
### INSERT INTO test.tx
### SET
### @1='a'b'
### INSERT INTO test.tx
### SET
### @1='a\x09b'
### INSERT INTO test.tx
### SET
### @1='a\x08b'
### INSERT INTO test.tx
### SET
### @1='a\x00b'

While we changed the @1 value shown as below:

$sudo mysqlbinlog --no-defaults /u01/mysqld/log/mysql-bin.000008 -v | grep ^'###'
### INSERT INTO test.tx
### SET
### @1='a\'b'
### INSERT INTO test.tx
### SET
### @1='a\tb'
### INSERT INTO test.tx
### SET
### @1='a\bb'
### INSERT INTO test.tx
### SET
### @1='a\0b'

There is no problem for the first shown, while we expect the later shown for two reasons:
1. more readable of column values for mysqlbinlog -v
2. for some special usage (extra string from ###@1 for another usage, like constructing SQL and applying to mysqld)

We changed the verbose shown for the second usage, and everything works well.
All test case passed, as well as the newly added one.

Patch is attached for review.

Tags: contribution
Revision history for this message
Hui Liu (hickey) wrote :
Revision history for this message
Hui Liu (hickey) wrote :

Tweaked with another two issues:
1. malformed binlog: it does not contain any Format_description_log_event ...
It's a legal case while treated fatal error. detail could refer to #12354268

2. "(xxx)" for data type of bigint with negative numbers, which is unnecessary.

A compile switch is provided, that is BINLOG_ROW_VERBOSE_SHOW_LEGACY, which is undefined by default, therefore, the default behavior is making the patch enables.

Stewart Smith (stewart)
Changed in percona-server:
importance: Undecided → Wishlist
Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

The patch applies over PS bzr without any issues.

patch -Np1 < /tmp/binlog_row_verbose_show_escape.diff

patching file mysql-test/suite/binlog/t/binlog_row_verbose_escape.test
patching file sql/log_event.cc
Hunk #1 succeeded at 1503 (offset 17 lines).
Hunk #2 succeeded at 1589 (offset 17 lines).
Hunk #3 succeeded at 1682 (offset 17 lines).
Hunk #4 succeeded at 1765 (offset 17 lines).
patching file mysql-test/suite/binlog/r/binlog_row_verbose_escape.result
patching file client/mysqlbinlog.cc
Hunk #1 succeeded at 994 (offset 22 lines).
Hunk #2 succeeded at 1006 (offset 22 lines).

Here is the bzr diff - http://sprunge.us/EVON?c

Also, tested with binlog_row_verbose_escape.test and mysqlbinlog, and works as described.

Changed in percona-server:
status: New → Confirmed
tags: added: contribution
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-2369

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.