Bug #96815 wbcopytables still uses utf8 hardcoded - prevents migration of 4byte characters
Submitted: 10 Sep 2019 7:04 Modified: 11 Sep 2019 7:02
Reporter: Simon Scheib Email Updates:
Status: Duplicate Impact on me:
Category:MySQL Workbench Severity:S4 (Feature request)
Version:8.0.17 OS:Any
Assigned to: CPU Architecture:x86
Tags: charset, utf8, utf8mb4, wbcopytables

[10 Sep 2019 7:04] Simon Scheib
wbcopytables uses hardcoded "SET NAMES = utf8". This prevents migration of tables containing 4-byte characters. 

Affecting code is in copytable.cpp Line 1238 and 1491:
std::string q = "SET NAMES 'utf8'";

Found a similar bug where version 6.3 was affected, but bug still persists: https://bugs.mysql.com/bug.php?id=87593

How to repeat:
Create database with charset utf8mb4 and collation utf8mb4_bin.
Create table with charset utf8mb4

Migrate any table containing a 4byte character. Even if the target schema and table have been created using utf8mb4, options in mysqld have been set to be utf8mb4, and Target collation in MySQL Workbench has been set to utf8mb4

Following error is thrown: Error Code: 1366. Incorrect string value: '\xF0\x9F\x98\x80' for column

Suggested fix:
Make the charset configurable in MySQL Workbench. Hardcoded to utf8 is not usable anymore in modern times. 

1) Remove lines 1238 and 1491 in copytable.cpp and rely on the default charset (which can be configured within my.cnf)

2) replace hardcoded charset with configuration parameter 
   e.g. --charset utf8mb4
[11 Sep 2019 7:02] MySQL Verification Team
Hello Simon Scheib,

Thank you for the report.
This is duplicate of Bug #87593, and describes this very problem. 
Even if you feel that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments to the original bug instead.

Thank you for your interest in MySQL.