Bug #93450 mysqldump does not wrap SET NAMES into mysql-extension comment
Submitted: 3 Dec 2018 13:20 Modified: 9 Apr 2019 16:39
Reporter: Mattias Jonsson (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S3 (Non-critical)
Version:8.0, 8.0.13 OS:Any
Assigned to: CPU Architecture:Any

[3 Dec 2018 13:20] Mattias Jonsson
Description:
In WL#10353 there was a change in the output of mysqldump, no longer wrapping SET NAMES in an mysql-extension comment, breaking its compatibility with other imports (like vitess).

Commit with changes (including result files) that:
https://github.com/mysql/mysql-server/commit/ebaff9fffc958030a57d8ea7f1f2d527cac1df64

I cannot see any reason or comments on why the the wrapping was removed.

How to repeat:
See: https://github.com/mysql/mysql-server/commit/ebaff9fffc958030a57d8ea7f1f2d527cac1df64#diff...

Where it is clear that:
/*!40101 SET character_set_client = utf8 */;
was changed to:
 SET character_set_client = utf8mb4 ;
without any mysql-extension comment protecting it from being parsed by a non mysql-extension aware parser.

Suggested fix:
Wrap the 'SET NAMES = <character_set>' command in mysqldump like:
/*50503 SET NAMES = utf8mb4 */;

So non mysql-extension aware parsers can still parse the dump.
I assume utf8mb4 was added by 5.5.3:
https://dev.mysql.com/doc/relnotes/mysql/5.5/en/news-5-5-3.html
[4 Dec 2018 4:00] MySQL Verification Team
Hello Mattias,

Thank you for the report and feedback!

regards,
Umesh
[9 Apr 2019 16:39] Paul DuBois
Posted by developer:
 
Fixed in 8.0.17.

mysqldump failed to wrap SET NAMES utf8mb4 and SET
character_set_client = utf8mb4 statements within version-specific
comments, which could cause compatibility problems.
[27 Jan 2020 16:22] Rick James
Related:  https://dba.stackexchange.com/questions/257749/how-to-force-mysqldump-to-produce-40101-set...