Modified:
branches/1.0/CHANGES
branches/1.0/TestSuite/DateTimeTests.cs
branches/1.0/mysqlclient/Types/MySqlDateTime.cs
Log:
Bug #17736 Selecting a row with with empty date '0000-00-00' results in Read() hanging.
Fixed. The problem was that when using prepared statements, the MySqlDateTime class was
not properly deserializing a zero datetime off the wire. It was assuming that the value
is always at least 4 bytes long. A date value of '0000-00-00' will have zero length.
DateTimeTests.cs - Added test case
mysqlclient/Types/MySqlDateTime.cs - Handled the case where the date component could come
back as zero length
Modified: branches/1.0/CHANGES
===================================================================
--- branches/1.0/CHANGES 2006-06-01 18:18:59 UTC (rev 246)
+++ branches/1.0/CHANGES 2006-06-01 21:41:17 UTC (rev 247)
@@ -15,6 +15,7 @@
Bug #19017 GetBytes Error [fixed]
Bug #19936 DataReader already open exception [fixed]
Bug #17106 MySql.Data.MySqlClient.CharSetMap.GetEncoding thread synchronization issue
[fixed]
+ Bug #17736 Selecting a row with with empty date '0000-00-00' results in Read()
hanging. [fixed]
x-xx-05 - Version 1.0.7
Modified: branches/1.0/TestSuite/DateTimeTests.cs
===================================================================
--- branches/1.0/TestSuite/DateTimeTests.cs 2006-06-01 18:18:59 UTC (rev 246)
+++ branches/1.0/TestSuite/DateTimeTests.cs 2006-06-01 21:41:17 UTC (rev 247)
@@ -48,7 +48,7 @@
Close();
}
- [Test()]
+ [Test]
public void ConvertZeroDateTime()
{
execSQL("INSERT INTO Test VALUES(1, '0000-00-00', '0000-00-00', '00:00:00', NULL)");
@@ -81,7 +81,7 @@
}
}
- [Test()]
+ [Test]
public void TestNotAllowZerDateAndTime()
{
execSQL("INSERT INTO Test VALUES(1, 'Test', '0000-00-00', '0000-00-00', '00:00:00')");
@@ -264,7 +264,7 @@
}
}
- [Test()]
+ [Test]
public void TestZeroDateTimeException()
{
execSQL("INSERT INTO Test (id, d, dt) VALUES (1, '0000-00-00', '0000-00-00
00:00:00')");
@@ -376,6 +376,33 @@
da.Fill(dataSet);
}
+ /// <summary>
+ /// Bug #17736 Selecting a row with with empty date '0000-00-00' results in
Read() hanging.
+ /// </summary>
+ [Category("4.1")]
+ [Test]
+ public void PreparedZeroDateTime()
+ {
+ execSQL("INSERT INTO test VALUES(1, Now(), '0000-00-00', NULL, NULL)");
+ MySqlCommand cmd = new MySqlCommand("SELECT d FROM test WHERE id=?id", conn);
+ cmd.Parameters.Add("?id", 1);
+ cmd.Prepare();
+ MySqlDataReader reader = null;
+ try
+ {
+ reader = cmd.ExecuteReader();
+ reader.Read();
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null)
+ reader.Close();
+ }
+ }
}
}
Modified: branches/1.0/mysqlclient/Types/MySqlDateTime.cs
===================================================================
--- branches/1.0/mysqlclient/Types/MySqlDateTime.cs 2006-06-01 18:18:59 UTC (rev 246)
+++ branches/1.0/mysqlclient/Types/MySqlDateTime.cs 2006-06-01 21:41:17 UTC (rev 247)
@@ -302,12 +302,16 @@
}
long bufLength = reader.ReadByte();
+ int year = 0, month = 0, day = 0;
+ int hour = 0, minute = 0, second = 0;
+
+ if (bufLength >= 4)
+ {
+ year = reader.ReadInteger(2);
+ month = reader.ReadByte();
+ day = reader.ReadByte();
+ }
- int year = reader.ReadInteger(2);
- int month = reader.ReadByte();
- int day = reader.ReadByte();
- int hour = 0, minute = 0, second = 0;
-
if (bufLength > 4)
{
hour = reader.ReadByte();
| Thread |
|---|
| • Connector/NET commit: r247 - in branches/1.0: . TestSuite mysqlclient/Types | rburnett | 1 Jun |