Bug #83918 RBR: Wrong field length in error message
Submitted: 22 Nov 2016 14:43 Modified: 31 Mar 2017 20:05
Reporter: Luis Soares Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Row Based Replication ( RBR ) Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[22 Nov 2016 14:43] Luis Soares
Description:
In row based replication, when replicating from a table with a field
with character set set to UTF8mb3 to the same table with the same
field set to character set UTF8mb4 I get a confusing error message:

  "Column 0 of table 'test.t1' cannot be converted from type
  'varchar(3)' to type 'varchar(1)'"

Even though RBR has a conversion framework in place for replicating
between different, but compatible types, it is stated in the
documentation that replication between columns with different character
sets is not supported (*). However the error message emitted seems
a bit inaccurate.

The binary log does not contain information about the character set of
the data in the fields it is replicating, thence it seems that:

 (a) the source field length is the plain length in bytes of the data
     transported, without considering the character encoding.

 (b) the destination field length is the actual length of the field in
     the destination table, considering the character encoding.

Thence there is inconsistency between (a) and (b).

(*) https://dev.mysql.com/doc/refman/5.7/en/replication-features-differing-tables.html

How to repeat:
1. Create a .test file and add the following test case to it:

--source include/master-slave.inc
--source include/have_binlog_format_row.inc

SET SQL_LOG_BIN=0;
CREATE TABLE t1 (c1 VARCHAR(1) CHARACTER SET 'utf8mb3');
SET SQL_LOG_BIN=1;

--source include/rpl_connection_slave.inc

SET SQL_LOG_BIN=0;
CREATE TABLE t1 (c1 VARCHAR(1) CHARACTER SET 'utf8mb4');
SET SQL_LOG_BIN=1;

--source include/rpl_connection_master.inc

INSERT INTO t1 VALUES ('a');

DROP TABLE t1;

--source include/sync_slave_sql_with_master.inc

--source include/rpl_end.inc

2. Run the test case:

   perl mysql-test-run.pl --mem rpl_x.test

3. Watch the test fail and look at the error message:

   [...]
   Last_Error	Column 0 of table 'test.t1' cannot be converted from type 'varchar(3)' to type 'varchar(1)'
   [...]
  

Suggested fix:
.
[22 Nov 2016 16:32] MySQL Verification Team
same as https://bugs.mysql.com/bug.php?id=83461 ?
[22 Nov 2016 17:34] Luis Soares
No. This one is about fixing the error message. The other one is about
replication breaking altogether.
[31 Mar 2017 20:05] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 5.7.18, 8.0.1 release, and here's the changelog entry:

In row-based replication, a message that incorrectly displayed field
lengths was returned when replicating from a table with a utf8mb3 column
to a table of the same definition where the column was defined with a
utf8mb4 character set.