Modified:
branches/1.0/CHANGES
branches/1.0/TestSuite/ParameterTests.cs
branches/1.0/mysqlclient/Types/MySqlString.cs
Log:
fixed problem where string parameters who have their size set after their value could
cause exceptions (Bug #32094)
Modified: branches/1.0/CHANGES
===================================================================
--- branches/1.0/CHANGES 2007-11-05 17:11:38 UTC (rev 1061)
+++ branches/1.0/CHANGES 2007-11-05 18:05:36 UTC (rev 1062)
@@ -8,7 +8,9 @@
handler. Not sure why you would want to do this but... (bug #30964)
- Removed code that set the Fetching state so that running a query from the state
change handler would work in the case that the new state is open
-
+ - fixed problem where string parameters who have their size set after their value could
cause exceptions
+ (Bug #32094)
+
Version 1.0.10
Bugs
----
Modified: branches/1.0/TestSuite/ParameterTests.cs
===================================================================
--- branches/1.0/TestSuite/ParameterTests.cs 2007-11-05 17:11:38 UTC (rev 1061)
+++ branches/1.0/TestSuite/ParameterTests.cs 2007-11-05 18:05:36 UTC (rev 1062)
@@ -482,5 +482,36 @@
}
c.Close();
}
- }
+
+ /// <summary>
+ /// Bug #32094 Size property on string parameter throws an exception
+ /// </summary>
+ [Test]
+ public void StringParameterSizeSetAfterValue()
+ {
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (v VARCHAR(10))");
+
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?p1)", conn);
+ cmd.Parameters.Add("?p1", MySqlDbType.VarChar);
+ cmd.Parameters[0].Value = "123";
+ cmd.Parameters[0].Size = 10;
+ cmd.ExecuteNonQuery();
+
+ MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
+ DataTable dt = new DataTable();
+ da.Fill(dt);
+ Assert.AreEqual("123", dt.Rows[0][0]);
+
+ cmd.Parameters.Clear();
+ cmd.Parameters.Add("?p1", MySqlDbType.VarChar);
+ cmd.Parameters[0].Value = "123456789012345";
+ cmd.Parameters[0].Size = 10;
+ cmd.ExecuteNonQuery();
+
+ dt.Clear();
+ da.Fill(dt);
+ Assert.AreEqual("1234567890", dt.Rows[1][0]);
+ }
+ }
}
Modified: branches/1.0/mysqlclient/Types/MySqlString.cs
===================================================================
--- branches/1.0/mysqlclient/Types/MySqlString.cs 2007-11-05 17:11:38 UTC (rev 1061)
+++ branches/1.0/mysqlclient/Types/MySqlString.cs 2007-11-05 18:05:36 UTC (rev 1062)
@@ -49,7 +49,10 @@
{
string v = value.ToString();
if (length > 0)
+ {
+ length = Math.Min(length, v.Length);
v = v.Substring(0, length);
+ }
if (binary)
writer.WriteLenString( v );
| Thread |
|---|
| • Connector/NET commit: r1062 - in branches/1.0: . TestSuite mysqlclient/Types | rburnett | 5 Nov |