[MDEV-19750] mysql command wrong encoding Created: 2019-06-13  Updated: 2020-08-25  Resolved: 2019-06-17

Status: Closed
Project: MariaDB Server
Component/s: Character Sets, Scripts & Clients
Affects Version/s: 10.2, 10.3, 10.4
Fix Version/s: 10.2.27, 10.3.17, 10.4.7

Type: Bug Priority: Critical
Reporter: Diego Dupin Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: None


 Description   

mysql console command doesn't detect console encoding like it was before 10.2.
When default-character-set is not set, the default value is 'auto'.
'auto' before 10.2 means rely on API "mysql_autodetect_character_set" that detect console encoding.
Since 10.2, regression is that 'auto' is not handled, defaulting to build option DEFAULT_CHARSET is was set, latin1 if not.

console client charset can then be wrong

Example on windows that default to cp850:

C:\Users\diego>"C:\Program Files\MariaDB 10.3\bin\mysql.exe" -udiego --host=192.168.0.45 --default-character-set=auto
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 124
Server version: 10.4.5-MariaDB-1:10.4.5+maria~bionic-log mariadb.org binary distribution
 
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> SELECT HEX('é'), HEX(CONVERT('é' USING utf8)), @@character_set_client;
+----------+------------------------------+------------------------+
| HEX('é') | HEX(CONVERT('é' USING utf8)) | @@character_set_client |
+----------+------------------------------+------------------------+
| 82       | E2809A                       | latin1                 |
+----------+------------------------------+------------------------+
1 row in set (0.006 sec)

good results would have been
C3A9 for HEX(CONVERT('é' USING utf8)) , cp850 for @@character_set_client



 Comments   
Comment by Anel Husakovic [ 2019-06-17 ]

Hi wlad
is it possible to apply MDEV-9883 here also for mysqldump?
There is a patch PR#739.

Comment by Vladislav Vaintroub [ 2019-06-17 ]

Not exactly same way that is in PR . Unfortunately, the auto is broken in C/C on Windows, for the console, since it does use GetACP(), rather that GetConsoleCP(). Those are 2 different things. There is no "os default encoding" on Windows, there is one for console , and another one for GUI, on historical reasons, and georg chose the one for GUI applications. georg also refused to fix it in C/C

Generated at Thu Feb 08 08:54:05 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.