Bug #9948 changed client-charset behavior in 4.1.x libmysql, which issue BC prob
Submitted: 16 Apr 2005 3:23 Modified: 13 Sep 2005 22:54
Reporter: xuefer tinys Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.11 OS:Linux (redhat)
Assigned to: Alexander Barkov CPU Architecture:Any

[16 Apr 2005 3:23] xuefer tinys
Description:
before 4.1:
1. mysql_options() my.ini default-character-set
2. or fallback to serverside default-character-set (mysql->server_language?)
3. or fallback to default_charset_info (configure option in libmysql which is HARD to change)

in 4.1:
1. mysql_option my.ini default-character-set
2. or fallback to default_charset_info

IMHO, server-side default-character-set is really important, cuz default_charset_info in libmysql stands 0 bit of the need of the author who write the client-application. they don't configure/compile libmysql.
there's so many old application which didn't aware of 4.1 charset, most of which don't use mysql_options to read my.ini on connect(e.g.: php4 has NO mysql_options())
but they're fine with 4.0libmysql cuz the end user can always set default-character-set in server side

How to repeat:
connect mysql4.1 in php4, linked with libmysql4.1.x
echo mysql_client_encoding(); <- give you latin1, not server-side default charset

Suggested fix:
just change back to 4.0 behavior
[31 Aug 2005 8:06] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/29083
[5 Sep 2005 15:05] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/29334
[6 Sep 2005 9:45] Alexander Barkov
Pushed into 4.1.15 and 5.0.13.

A new command line argument was added to mysqld to ignore
client character set sent during handshake, use server side
settrings instead, and thus reproduce 4.0 behaviour:

mysqld --skip-character-set-client-handshake
[13 Sep 2005 22:54] Mike Hillyer
Documented in 4.1.15 and 5.0.13 changelogs:

<listitem>
        <para>
          A new command line argument was added to mysqld to ignore
          client character set information sent during handshake, and use server side
          settings instead, to reproduce 4.0 behaviour (Bug #9948):
          
          <programlisting>mysqld --skip-character-set-client-handshake</programlisting>
        </para>
      </listitem>
[23 Jan 2006 16:35] [ name withheld ]
4.1 client can can also be made to use server's character set by default using an option in server's my.cnf:

[mysqld]
...
character_set_client=@@character_set_server
# or: character_set_client=<default_client_character_set>

i found that this works witn 4.1.15+, but doesn't work with 4.1.14 and earlier - server refuses to start, saying:
[ERROR] /usr/sbin/mysqld: unknown variable 'character_set_client=utf8'

so you need 4.1.15+ to make this work.
[5 Mar 2006 23:56] [ name withheld ]
Now, MySQL attaches charset information to almost everything - it's worse than before: it tries to perform charset conversion at every opportunity if you aren't watching , and unless everything is configured perfectly (or latin1), there's a good chance your data will be mangled.