Bug #7491 MySQL client doesn't allow typing of 8-bit characters
Submitted: 22 Dec 2004 17:21 Modified: 7 Feb 2005 15:48
Reporter: David L Lambert Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:14.6 (distrib 4.1.4-gamma), also 11.16 OS:Linux (Linux Debian)
Assigned to: CPU Architecture:Any

[22 Dec 2004 17:21] David L Lambert
Description:
Using a vt100 emulator that displays latin1 characters,  it's still not possible to type them in queries using the MySQL client,  either by using a suitably configured keyboard or by cut-and-paste from a freetext document.

How to repeat:
I'm trying to use the mysql client running in a TeraTerm window on a Windows ME box,  with the keyboard set to "US-International", to enter data possibly containing Latin1 characters in a MySQL database.  Here is what happens:

O davidl, who worketh in /usr/local/mysql on ramoth,
I await thy bidding $ echo $LOCALE
EN_us.iso8859-1
O davidl, who worketh in /usr/local/mysql on ramoth,
I await thy bidding $ cat
hablo alemán
hablo alemán
O davidl, who worketh in /usr/local/mysql on ramoth,
I await thy bidding $ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 356 to server version: 4.1.4-gamma-standard-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SELECT "hablo alen";
+------------+
| hablo alen |
+------------+
| hablo alen |
+------------+
1 row in set (0.09 sec)

mysql> SHOW VARIABLES LIKE "char%";
+--------------------------+---------------------------------------------------------------------------+
| Variable_name            | Value                                                                     |
+--------------------------+---------------------------------------------------------------------------+
| character_set_client     | latin1                                                                    |
| character_set_connection | latin1                                                                    |
| character_set_database   | latin1                                                                    |
| character_set_results    | latin1                                                                    |
| character_set_server     | latin1                                                                    |
| character_set_system     | utf8                                                                      |
| character_sets_dir       | /usr/local/mysql-standard-4.1.4-gamma-pc-linux-i686/share/mysql/charsets/ |
+--------------------------+---------------------------------------------------------------------------+
7 rows in set (0.00 sec)

mysql> Bye

When using MySQL,  I typed the exact same sequence of keys as when using cat.  

Suggested fix:
When LOCALE is set to something 8-bit,  disable META-key recognition in readline() and pass 8-bit characters permitted by the locale literally.  Note that the cursor keys and Control-* would still work,  because they use the 7-bit ASCII cltrol characters to send theselves.

When LOCALE is a utf8 locale (including "EN_us.utf8"),  readline() should return a valid utf8 string, and mysql should set he connection character set to UTF8.  readline() could assume that non-UTF8 eight-bit sequences are iso8859-* according to the current locale and convert them appropriately; this would allow cut-and-paste from an 8-bit text document to still work.
[7 Feb 2005 15:48] Aleksey Kishkin
Hi.
I installed teraterm web 3.1 on win2003 (EE) and tried to connect over ssh session to linux computer with mysql. I was able to type and see any characters (I attached a screenshot in 'Files' section). So, I believe it's not a bug and the point is in your settings. If you have ideas how to reproduce this error, please let us know.
[7 Feb 2005 15:50] Aleksey Kishkin
screenshot  of session with 8 bit characters

Attachment: bug7491.jpg (image/jpeg, text), 83.85 KiB.

[27 Mar 2005 12:10] David L Lambert
The original report used TeraTerm Pro 2.3 under Windows ME,  and TeraTerm does not seem to run on Windows 2000, 2003 or XP.  It's quite possible that TeraTerm is at fault here,  although it seemed to display the characters fine with "cat".

The mysql client accepts latin1 characters in queries just fine when run under PuTTY (tested with 0.56) on a Linux host.