Bug #25651 SELECT does not work properly when WHERE contains UTF-8 characters
Submitted: 16 Jan 2007 15:58 Modified: 23 Jan 2007 16:38
Reporter: Tomislav Ivancic
Status: Closed
Category:Connector/Net Severity:S2 (Serious)
Version:5.0.3 OS:Microsoft Windows (windows xp sp2)
Assigned to: Target Version:
Tags: characterset, Connector/Net

[16 Jan 2007 15:58] Tomislav Ivancic
Description:
Tested on:
MySql version: 5.0.24
Connector/Net 5.0.3
.Net 2.0
Windows XP SP2

SELECT does not work properly when WHERE contains UTF-8 string.

How to repeat:
string conString = "Database=test; Data Source=localhost;" +
"User Id=root;Password=;CharSet=utf8";
MySqlConnection con = new MySqlConnection(conString);
con.Open();

MySqlCommand command = new MySqlCommand("SELECT id FROM table1 WHERE value = ?parameter",
con);
command.Parameters.Add("?parameter", MySqlDbType.VarString);
command.Parameters[0].Value = "šđč枊ĐČĆŽ";

//throws NullReferenceException, should return 1 (id of šđč枊ĐČĆŽ):
MessageBox.Show(command.ExecuteScalar().ToString());
[16 Jan 2007 23:13] Reggie Burnett
Tomislav,

Are you using pooling?  If so, that can be it because we recently fixed a problem where
connections retrieved from the pool were not getting their encoding set back up properly
in some cases.  Try turning pooling off and see if that fixes it.    

The fix that I mentioned will be in 5.0.4

Reggie
[17 Jan 2007 0:47] Tomislav Ivancic
I added Pooling=false to my connection string (I think that is how I should turn the
pooling off). That did not solve the problem. I still get the same result.
The same code works fine with Connector/Net 1.0.7 and 1.0.8 (RC) with pooling on and
off.

Tomislav Ivancic
[17 Jan 2007 23:16] 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/18297
[17 Jan 2007 23:25] 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/18298
[17 Jan 2007 23:27] Reggie Burnett
fixed in 5.0.4 and 1.0.9
[23 Jan 2007 16:38] MC Brown
A note has been added to the 1.0.9 and 5.0.4 changelogs.