Bug #30040 GROUP_CONCAT() truncates character set
Submitted: 25 Jul 2007 13:42 Modified: 9 Aug 2007 17:39
Reporter: Marc Gutt Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:4.1.22 OS:Any
Assigned to: CPU Architecture:Any
Tags: concat, GROUP, group_concat, umlaut, umlaute, umlauts, utf8

[25 Jul 2007 13:42] Marc Gutt
Description:
similar to:
http://bugs.mysql.com/bug.php?id=12829

How to repeat:
<?php
    // 1.
    $sql = 'SELECT GROUP_CONCAT(group_name) AS gcusername
                FROM users
                WHERE gender = 0
            GROUP BY uid
            LIMIT 5';
    $result = $db->sql_query($sql, false, __LINE__, __FILE__);
    while ( $row = $db->sql_fetchrow($result) )
    {
    echo($row['gcusername'] . '<br />');
    }
    // 2.
    $sql = 'SELECT GROUP_CONCAT(g.group_name) AS gcusername
                FROM users u, users g
                WHERE u.uid = g.group_owner
            GROUP BY u.uid
            LIMIT 5';
    $result = $db->sql_query($sql, false, __LINE__, __FILE__);
    while ( $row = $db->sql_fetchrow($result) )
    {
    echo($row['gcusername'] . '<br />');
    }
?>

--------------------------------------------------------------------------------

1.) returns
Grüppchen

2.) returns:
Grüppchen
[25 Jul 2007 15:48] Andy Bang
This is a bug in the server, not in the Monitoring and Advisory Service.
[26 Jul 2007 6:57] Sveta Smirnova
Thank you for the report.

Please provide output from SHOW CREATE TABLE users and SELECT group_name, uid, group_owner FROM users.
[26 Jul 2007 13:03] Marc Gutt
SHOW CREATE TABLE:
Array
(
    [Table] => users
    [Create Table] => CREATE TABLE `users` (
  `uid` int(11) unsigned NOT NULL auto_increment,
  `gender` tinyint(1) unsigned NOT NULL default '0',
  `group_name` varchar(255) NOT NULL default '',
  `group_owner` int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (`uid`),
  FULLTEXT KEY `fulltext_search` (`group_name`)
) ENGINE=MyISAM AUTO_INCREMENT=44 DEFAULT CHARSET=utf8
)

SELECT:
Array
(
    [group_name] => Grüppchen
    [uid] => 35
    [group_owner] => 1
)
[26 Jul 2007 13:05] Marc Gutt
SELECT WITH uid = 1:
Array
(
    [group_name] => 
    [uid] => 1
    [group_owner] => 0
)
[27 Jul 2007 9:11] Sveta Smirnova
Thank yo for the feedback.

Can you repeat same behaviour using mysql command line client and not PHP script?
[3 Aug 2007 23:18] Marc Gutt
No.
[9 Aug 2007 17:39] Sveta Smirnova
Thank you for the feedback.

Further analysis showed this is duplicate of Bug #29850