Bug #72573 Broken table in mysql command line client when using gb18030

Submitted: 8 May 2014 13:09 Modified: 10 Jun 2014 0:01
Reporter: Alexander Barkov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Charsets Severity:S3 (Non-critical)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any

[8 May 2014 13:09] Alexander Barkov
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.
[8 May 2014 15:24] MySQL Verification Team
Thank you for the bug report.
[10 Jun 2014 0:01] Paul DuBois
Noted in 5.7.5 changelog.

The mysql client displayed gb18030 data incorrectly.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.371 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.