Bug #35372 session character_set_client is different from global character_set_client
Submitted: 18 Mar 2008 6:54 Modified: 11 Jul 2008 16:20
Reporter: Rizwan Maredia Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.1.22 OS:Windows
Assigned to: Paul DuBois CPU Architecture:Any
Tags: character_set_client

[18 Mar 2008 6:54] Rizwan Maredia
Description:
session character_set_client is not the same as global character_set_client for new connection. This problem is also with character_set_database.

How to repeat:

Sample Code: 

SET @@global.character_set_client = utf8;
connect (con1,localhost,root,,,,);
connection con1;
SELECT @@global.character_set_client;
SELECT @@session.character_set_client;

Output:

SET @@global.character_set_client = utf8;
SELECT @@global.character_set_client;
@@global.character_set_client
utf8
SELECT @@session.character_set_client;
@@session.character_set_client
latin1

Here session character_set_client should have been utf8.

Suggested fix:
Session character_set_client should be the same as global character_set_client for every new connection.
[19 Mar 2008 7:59] Sveta Smirnova
Thank you for the report.

According to http://dev.mysql.com/doc/refman/5.1/en/charset-connection.html: "When a client connects, it sends to the server the name of the character set that it wants to use. The server uses the name to set the character_set_client, character_set_results, and character_set_connection system variables. In effect, the server performs a SET NAMES  operation using the character set name." So forcing use of client's default value of connection character set looks correct for me. But manual contains no word about purpose of global variable character_set_client. So I reclassify this bug as documentation.

About character_set_database read at http://dev.mysql.com/doc/refman/5.1/en/charset-database.html
[11 Jul 2008 16:20] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Updated the description for character_set_client:

The character set for statements that arrive from the client. The
session value of this variable is set using the character set
requested by the client when the client connects to the server. (Many
clients support a --default-character-set option to enable this
character set to be specified explicitly.) The global
value of the variable is used to set the session value in cases when
the client-requested value is unknown or not available, or the server
is configured to ignore client requests:

* The client is from a version of MySQL older than MySQL 4.1, and thus
does not request a character set.

* The client requests a character set not known to the server. For
example, a Japanese-enabled client requests sjis when connecting to a
server not configured with sjis support.

* mysqld was started with the --skip-character-set-client-handshake
option, which causes it to ignore client character set configuration.
This reproduces MySQL 4.0 behavior and is useful should you wish to
upgrade the server without upgrading all the clients.