Bug #53313 libmysql reports and uses wrong character set/missing functionality in the proto
Submitted: 30 Apr 2010 12:02 Modified: 6 May 2010 7:00
Reporter: Andrey Hristov Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:5.1, probably others OS:Any
Assigned to: CPU Architecture:Any
Tags: mysql_change_user

[30 Apr 2010 12:02] Andrey Hristov
Description:
Programs can set the character set to be used with a connection by calling mysql_options() with parameter MYSQL_SET_CHARSET_NAME, before calling mysql_real_connect(). In the protocol there is a support for setting the charset during connection establishment. However, when mysql_change_user() (COM_CHANGE_USER) is used there is no such possibility. After COM_CHANGE_USER the server sets the connection character set to its default. However, the C API doesn't check that and continues to think that the character set from the session before COM_CHANGE_USER is in effect - mysql_character_set_name() delivers wrong data. In situations where this field is used from transcoding this will break the data being transcoded, if the user uses character set different than server ones.

It would be nice if COM_CHANGE_USER supported setting of character set, but this is not available and probably will never be.

How to repeat:
Check the sources of the C API : mysql_change_user(). Then you will see that charset is not updated after successful COM_CHANGE_USER.
[6 May 2010 7:00] Susanne Ebrecht
You are right.

Verified as described.