Description:
MySQL command line client display results in a well formed table
when using utf8, but a broken table when using gb18030 character set.
How to repeat:
Make sure to use *both* server and the command line client from
MySQL-5.7 (i.e. both server and client with gb18030 support).
1. Run a console in UTF8 mode.
For example, in gnome-terminal, make sure to do
"Terminal -> Set character encoding -> utf8".
Now run this command:
./mysql --default-character-set=utf8mb4 test --execute "select _gb18030 0x81398830 as a, _gb18030 0x81398831 as b, _gb18030 0x81308434 as c"
It displays a well formed table:
+-----+-----+----+
| a | b | c |
+-----+-----+----+
| ⻠ | ⻡ | ¢ |
+-----+-----+----+
All vertical bars are on good positions.
2. Now run a console in gb18030 mode.
For example, in gnome-terminal make sure to do:
"Terminal -> Set character encoding -> gb18030".
Run this command:
$ ./mysql --default-character-set=gb18030 test --execute "select _gb18030 0x81398830 as a, _gb18030 0x81398831 as b, _gb18030 0x81308434 as c"
Now the table is very broken:
+------+------+------+
| a | b | c |
+------+------+------+
| ⻠ | ⻡ | ¢ |
+------+------+------+
Notice, the vertical bars in the row with data are
printed on wrong positions.
Suggested fix:
Changing my_numcells_8bit to my_numcells_mb in
the definitions of my_charset_gb18030_handler
and my_charset_gb18030_uca_handler in ctype-gb18030.c
fixes the problem.