Bug #11089 Certain unicode characters in data cause connector to declare SQL format error
Submitted: 3 Jun 2005 22:36 Modified: 4 Jun 2005 6:47
Reporter: Mark Modrall Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:1.0 OS:Windows (Windows)
Assigned to: CPU Architecture:Any

[3 Jun 2005 22:36] Mark Modrall
Description:
Possibly related to bug 10870, but I've found using the MySQL .Net connector, not only do many unicode values get mashed down to the ? character in the database, certain unicode characters cause parameterized queries to simply blow up.  Executing the command causes a "Bad SQL Format error" to be thrown.  I believe the number at the front of the .Net Exception was 42000.

How to repeat:
MySqlConnection conn = new MySqlConnection ("server=svr;user
id=user;password=pass;database=test;pooling=false" );
conn.Open();

MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "create table if not exists temp3 (\n"+
		"query TEXT NOT NULL\n" +
		") CHARACTER SET UTF8;";
cmd.ExecuteNonQuery();

// works fine
cmd.CommandText = "insert into temp3 (query) VALUES (?query)";
cmd.Parameters.Clear();
cmd.Parameters.Add (new MySqlParameter ("?query", "abc"));
cmd.ExecuteNonQuery();

// doesn't work - not sure which causes it, but it declares a bad sql error
// some characters have trouble rendering in browsers, so I have to use convoluted
// methods to express them here.  The characters are ѱ ۺ 
// and ʹ
cmd.Parameters.Clear();
string qval = "...";
Int32 code = 1137;
qval[0] = code.ToChar(); 
code = 1786;
qval[1] = code.ToChar();
code = 697; 
qval[2] = code.ToChar();
cmd.Parameters.Add (new MySqlParameter ("?query", qval));
cmd.ExecuteNonQuery();

Suggested fix:
don't have one
[4 Jun 2005 6:47] Vasily Kishkin
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the original bug instead.

Thank you for your interest in MySQL.
[6 Jun 2005 12:33] Mark Modrall
Duplicate of which other incident?  I didn't see it when I did a search.  I know it may be related to the other bug I filed on unicode mishandling, but the manifestation was very different.  For most unicode characters, it just sends up the wrong character, but in this case certain unicode characters actually manage to crash .Net, which seems quite different.
[6 Jun 2005 14:09] Mark Modrall
My apologies...  The "crashing .Net" was actually from another bug I filed against the MyOdbc; I've filed a bunch in the last week or two and they're all starting to run together.

I still don't know what this is a duplicate of.  It's not directly a duplicate of the other one I filed (10870) and I didn't find another in search that seemed on point.
[11 Sep 2006 18:46] Bryan Livingston
Since this was marked duplicate incorrectly and never reopened I have posted a new bug at http://bugs.mysql.com/22243

The new bug report contains something of workaround.