Bug #47671 wrong character-set after upgrade from 5.1.34 to 5.1.39
Submitted: 28 Sep 2009 10:13 Modified: 12 Mar 2010 17:20
Reporter: Reto Galante Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.1.39 OS:Linux
Assigned to: Satya B CPU Architecture:Any
Tags: character-set, my.cnf, upgrade

[28 Sep 2009 10:13] Reto Galante
Description:
mysql-5.1.39 seems to ignore character-set defined in /etc/mysql/my.cnf.

Before upgrade:

mysql> status
--------------
mysql  Ver 14.14 Distrib 5.1.34, for pc-linux-gnu (i686) using readline 5.1
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    utf8
Conn.  characterset:    utf8

After:

mysql> status;
--------------
mysql  Ver 14.14 Distrib 5.1.39, for pc-linux-gnu (i686) using readline 5.1
Client characterset:    latin1
Server characterset:    latin1

Relevant content of "/etc/mysql/my.cnf":

character-set-server        = utf8
default-character-set       = utf8
character_set_server        = utf8
skip-character-set-client-handshake
default-collation=utf8_unicode_ci

("/etc/mysql/conf.d/" is empty)

How to repeat:
install mysql-5.1.39 over mysql-5.1.39
[28 Sep 2009 10:22] Valeriy Kravchuk
Thank you for the problem report. Please, send the results of:

find / -name "*my.cnf" -print 2>/dev/null
[28 Sep 2009 10:27] Reto Galante
# find / -name "*my.cnf" -print 2>/dev/null
/etc/mysql/my.cnf
[28 Sep 2009 10:35] Valeriy Kravchuk
Please, upload the entire /etc/mysql/my.cnf then, just to be sure...
[29 Oct 2009 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[29 Oct 2009 7:20] Reto Galante
no feedbak? 
indeed, i uploaded the whole configuration file and got no feedback!
[15 Nov 2009 10:44] Alexey Kishkin
Dear Reto, 

of course, no doubts,  feedback was provided. 'Bugs system' is just a bot, sometimes it makes mistakes. 

Sorry for inconvenience.
[18 Nov 2009 7:57] Sveta Smirnova
Thank you for the feedback.

Please send us output of SHOW VARIABLES LIKE '%char%';
[18 Nov 2009 8:09] Reto Galante
Funny stuff:

mysql> SHOW VARIABLES LIKE '%char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

mysql> status
--------------
mysql  Ver 14.14 Distrib 5.1.39, for pc-linux-gnu (i686) using readline 5.1

Connection id:          1
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.1.39 MySQL Community Server (GPL)
Protocol version:       10
Connection:             Localhost via UNIX socket
Client characterset:    latin1
Server characterset:    latin1
UNIX socket:            /var/run/mysqld/mysqld.sock
Uptime:                 1 min 4 sec
[18 Nov 2009 8:48] Sveta Smirnova
Thank you for the feedback.

Verified as described.

Problem is command line client, not server.

Workaround: use older client.

Proposed patch:

$bzr diff
=== modified file 'client/mysql.cc'
--- client/mysql.cc     2009-10-20 18:00:07 +0000
+++ client/mysql.cc     2009-11-18 08:35:38 +0000
@@ -4379,7 +4379,7 @@
     if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
       return 0;
   }
-  if (mysql_store_result_for_lazy(&result))
+  if (!mysql_store_result_for_lazy(&result))
   {
     MYSQL_ROW cur=mysql_fetch_row(result);
     if (cur)
[19 Nov 2009 17:44] MySQL Verification Team
Sveta,

Can you check one detail.

my.cnf in question has this option set:

skip-character-set-client-handshake

Is it possible that 5.1.34 has ignored the option and 5.1.39 is honouring it ???

Thanks in advance !!!
[19 Nov 2009 19:43] Sveta Smirnova
Sinisa,

I checked: not, problem is in the code I pasted.
[25 Nov 2009 6:55] Satya B
Sveta is right that we use don't properly use the mysql_store_lazy_result() return values in com_status() in msyql client.

Submitting a patch with testcase.
[25 Nov 2009 6:56] 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/commits/91538

3219 Satya B	2009-11-25
      Fix for BUG#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
      
      mysql client displays wrong character-set of server. When a user changes the
      charset of a server, mysql client 'status' command displays wrong charset but
      the command "SHOW VARIABLES LIKE "%charset%" displayed correct charset results.
      The problem is only with the mysql client's 'status' command output.
      
      In mysql client, the method mysql_store_lazy_result() returns 0 for
      success and non-zero for failure. The method com_status() was using this method
      wrongly. Fixed all such instances according to return value of the method 
      mysql_store_lazy_result().
     @ client/mysql.cc
        Fix for BUG#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
        
        Fix com_status() method to use mysql_store_lazy_result() properly.
     @ mysql-test/r/bug47671.result
        Fix for BUG#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
        
        Testcase for BUG#47671
     @ mysql-test/t/bug47671-master.opt
        Fix for BUG#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
        
        Testcase for BUG#47671
     @ mysql-test/t/bug47671.test
        Fix for BUG#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
        
        Testcase for BUG#47671
[26 Nov 2009 7:59] Satya B
patch queued to mysql-5.1-bugteam & mysql-pe
[30 Nov 2009 5:24] 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/commits/92019

3211 Satya B	2009-11-30
      Additional Fix for BUG#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
      
      Fix for failure on windows PB2 because of the result content mismatch.
      In windows additional information about TCP port was causing failures.
      Added to regex.
[2 Dec 2009 8:03] Bugs System
Pushed into 5.1.42 (revid:joro@sun.com-20091202080033-mndu4sxwx19lz2zs) (version source revid:satya.bn@sun.com-20091130052426-5m6j8bf0ofir0e57) (merge vers: 5.1.42) (pib:13)
[15 Dec 2009 2:49] Paul DuBois
Noted in 5.1.42 changelog.

The mysql client status command displayed an incorrect value for the
server character set.

Setting report to NDI pending push to 5.5.x+.
[16 Dec 2009 8:39] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091216083311-xorsasf5kopjxshf) (version source revid:alik@sun.com-20091214191830-wznm8245ku8xo702) (merge vers: 6.0.14-alpha) (pib:14)
[16 Dec 2009 8:46] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091216082430-s0gtzibcgkv4pqul) (version source revid:alexey.kopytov@sun.com-20091201145844-39gy4wmejbisbxac) (merge vers: 5.5.0-beta) (pib:14)
[16 Dec 2009 8:52] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20091216083231-rp8ecpnvkkbhtb27) (version source revid:alik@sun.com-20091212203859-fx4rx5uab47wwuzd) (merge vers: 5.6.0-beta) (pib:14)
[18 Dec 2009 1:43] Paul DuBois
Noted in 5.5.1, 6.0.14 changelogs.
[12 Mar 2010 14:13] Bugs System
Pushed into 5.1.44-ndb-7.0.14 (revid:jonas@mysql.com-20100312135944-t0z8s1da2orvl66x) (version source revid:jonas@mysql.com-20100312115609-woou0te4a6s4ae9y) (merge vers: 5.1.44-ndb-7.0.14) (pib:16)
[12 Mar 2010 14:29] Bugs System
Pushed into 5.1.44-ndb-6.2.19 (revid:jonas@mysql.com-20100312134846-tuqhd9w3tv4xgl3d) (version source revid:jonas@mysql.com-20100312060623-mx6407w2vx76h3by) (merge vers: 5.1.44-ndb-6.2.19) (pib:16)
[12 Mar 2010 14:45] Bugs System
Pushed into 5.1.44-ndb-6.3.33 (revid:jonas@mysql.com-20100312135724-xcw8vw2lu3mijrhn) (version source revid:jonas@mysql.com-20100312103652-snkltsd197l7q2yg) (merge vers: 5.1.44-ndb-6.3.33) (pib:16)