Bug #31185 columns names are incorrect when using the 'AS' clause and name with accents
Submitted: 25 Sep 2007 13:37 Modified: 13 Nov 2007 11:38
Reporter: Ken Dionne Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:5.1.2 OS:Windows (XP sp2, french version (CF))
Assigned to: CPU Architecture:Any
Tags: encoding, utf8

[25 Sep 2007 13:37] Ken Dionne
Description:
I run a query like this one : "select distinct digits_dialed as 'Numéro' from calls_2"

Problem : the column name in the datagridview is : 'Numéro' instead of 'Numéro' 

Additionnal detail :

All the data and the columns name are in plain english in the database.

versions :

mysql ADO .net driver version : 5.1.2.2
runtime version : v2.0.50727
mysql Server version 5.0.20

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/ |
+--------------------------+----------------------------+ 

database calls_2 : InnoDB; all interclassment are in utf8_bin

How to repeat:
This a sample program in C# that show the problem.

the program only contain a dataGridView and a button with that code :
--------------------------------------------------
private void button1_Click(object sender, EventArgs e)
{
string myConnectionString;
MySqlConnection myConnection;
MySqlDataAdapter myDataAdapter;
DataTable matable;
string Query;
matable = new DataTable();
myConnectionString = "Database='dbname';Data Source='hostname';User Id='username';Password='passwd';CharSet='utf8';";
myConnection = new MySqlConnection(myConnectionString);
try
{
myConnection.Open();
}
catch
{
MessageBox.Show("Base de données non connectée", "Erreur");
Application.Exit();
}
Query = "select distinct digits_dialed as 'Numéro' from calls_2";
myDataAdapter = new MySqlDataAdapter();
try
{
myDataAdapter.SelectCommand = new MySqlCommand(Query, myConnection);
}
catch
{
MessageBox.Show("Erreur dans la query SQL", "Erreur");
Application.Exit();
}
myDataAdapter.Fill(matable);
dataGridView1.DataSource = matable;
myDataAdapter.Dispose();
}

Suggested fix:
heu.. encoding the columns name with the correct encoding ?
[26 Sep 2007 13:19] Ken Dionne
I tested with the new version 5.1.3 and I got the same behaviour.
Windows XP have all patches.

Microsoft Visual Studio 2005
Version 8.0.50727.762  (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727

Édition installée : C# Express

Mysql server is on Linux, fedora core 4.
[9 Oct 2007 20:34] 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/35234
[9 Oct 2007 20:39] 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/35235
[9 Oct 2007 20:39] Reggie Burnett
Fixed in 5.0.9, 5.1.4, and 5.2+
[9 Oct 2007 20:40] 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/35236
[13 Nov 2007 11:38] MC Brown
A note has been added to the 5.0.9, 5.1.4 and 5.2.0 changelog: 

Column name metadata was not using the character set as deifned
        within the connection string being used.