#At file:///D:/bzr-connector-net/6.0/ based on revid:reggie.burnett@stripped
800 Reggie Burnett 2010-03-10
- fixed bug in tokenization where a nonterminated string in sql will cause a CLR exception
rather than throwing a syntax exception (bug #51788)
modified:
CHANGES
MySql.Data/Provider/Source/common/MySqlTokenizer.cs
MySql.Data/Tests/Source/Syntax.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES 2010-03-08 21:15:52 +0000
+++ b/CHANGES 2010-03-10 19:14:18 +0000
@@ -24,6 +24,8 @@
- ScriptCompleted event handler now uses EventArgs.Empty instead of null
- fixed parsing bug that was caused by special characters being jammed up beside a quoted identifier (bug #51610)
- fixed bug in sql generation when using a negated binary fragment in EF (bug #49850)
+- fixed bug in tokenization where a nonterminated string in sql will cause a CLR exception
+ rather than throwing a syntax exception (bug #51788)
Version 6.0.5
- ensure that MySqlPacket always has a valid encoding. This prevents null reference exceptions in ReadString()
=== modified file 'MySql.Data/Provider/Source/common/MySqlTokenizer.cs'
--- a/MySql.Data/Provider/Source/common/MySqlTokenizer.cs 2010-03-03 23:36:25 +0000
+++ b/MySql.Data/Provider/Source/common/MySqlTokenizer.cs 2010-03-10 19:14:18 +0000
@@ -261,12 +261,16 @@
startIndex = pos-1;
bool escaped = false;
+ bool found = false;
while (pos < sql.Length)
{
char c = sql[pos];
if (c == quoteChar && !escaped)
+ {
+ found = true;
break;
+ }
if (escaped)
escaped = false;
@@ -274,8 +278,8 @@
escaped = true;
pos++;
}
- pos++;
- Quoted = true;
+ if (found) pos++;
+ Quoted = found;
stopIndex = pos;
}
=== modified file 'MySql.Data/Tests/Source/Syntax.cs'
--- a/MySql.Data/Tests/Source/Syntax.cs 2010-03-03 23:36:25 +0000
+++ b/MySql.Data/Tests/Source/Syntax.cs 2010-03-10 19:14:18 +0000
@@ -439,6 +439,34 @@
Assert.AreEqual("ABC", reader.GetString(0));
Assert.AreEqual(-1, reader.GetInt32(1));
}
+
+ cmd.CommandText = "SELECT 'test 2010-03-04 @ 10:14'";
+ using (MySqlDataReader reader = cmd.ExecuteReader())
+ {
+ reader.Read();
+ Assert.AreEqual("test 2010-03-04 @ 10:14", reader.GetString(0));
+ }
+
+ }
+
+ /// <summary>
+ /// Bug #51788 Error in SQL syntax not reported. A CLR exception was thrown instead,
+ /// </summary>
+ [Test]
+ public void NonTerminatedString()
+ {
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test(id INT, name1 VARCHAR(20), name2 VARCHAR(20))");
+
+ try
+ {
+ MySqlCommand cmd = new MySqlCommand(
+ "INSERT INTO test VALUES (1, 'test 2010-03-04 @ 10:14, name2=' joe')", conn);
+ cmd.ExecuteNonQuery();
+ }
+ catch (MySqlException)
+ {
+ }
}
}
}
Attachment: [text/bzr-bundle] bzr/reggie.burnett@sun.com-20100310191418-8j4iq8heg55g51ft.bundle
| Thread |
|---|
| • bzr commit into connector-net-6.0 branch (reggie.burnett:800) Bug#51788 | Reggie Burnett | 10 Mar |