Modified:
branches/5.1/CHANGES
branches/5.1/Driver/Source/Connection.cs
branches/5.1/TestSuite/Source/ConnectionTests.cs
Log:
Fixed problem with attempting to use a command with a connection that is not open. The problem was caused by the introduction of the internal method SoftClosed that is used with transactions. (Bug #31262)
Modified: branches/5.1/CHANGES
===================================================================
--- branches/5.1/CHANGES 2007-10-23 19:50:24 UTC (rev 1039)
+++ branches/5.1/CHANGES 2007-10-23 20:27:36 UTC (rev 1040)
@@ -5,6 +5,9 @@
opened with CloseConnection would cause a object disposed exception to be thrown
- Fixed problem with installer where the installation would fail if the performance
counter categories had already been removed for some reason
+ - Fixed problem with attempting to use a command with a connection that is not open.
+ The problem was caused by the introduction of the internal method SoftClosed that is
+ used with transactions. (Bug #31262)
Version 5.1.3 - 9/19/2007
- Fixed problem with using a stored procedure that takes a parameter as a select routine
Modified: branches/5.1/Driver/Source/Connection.cs
===================================================================
--- branches/5.1/Driver/Source/Connection.cs 2007-10-23 19:50:24 UTC (rev 1039)
+++ branches/5.1/Driver/Source/Connection.cs 2007-10-23 20:27:36 UTC (rev 1040)
@@ -130,12 +130,15 @@
get { return isExecutingBuggyQuery; }
set { isExecutingBuggyQuery = value; }
}
+
internal bool SoftClosed
{
get
{
#if !CF
- return (State == ConnectionState.Closed) && driver.CurrentTransaction != null;
+ return (State == ConnectionState.Closed) &&
+ driver != null &&
+ driver.CurrentTransaction != null;
#else
return false;
#endif
Modified: branches/5.1/TestSuite/Source/ConnectionTests.cs
===================================================================
--- branches/5.1/TestSuite/Source/ConnectionTests.cs 2007-10-23 19:50:24 UTC (rev 1039)
+++ branches/5.1/TestSuite/Source/ConnectionTests.cs 2007-10-23 20:27:36 UTC (rev 1040)
@@ -422,5 +422,29 @@
Assert.AreEqual(1, o);
}
}
+
+ /// <summary>
+ /// Bug #31262 NullReferenceException in MySql.Data.MySqlClient.NativeDriver.ExecuteCommand
+ /// </summary>
+ [Test]
+ public void ConnectionNotOpenThrowningBadException()
+ {
+ MySqlConnection c2 = new MySqlConnection();
+ c2.ConnectionString = GetConnectionString(true); // "DataSource=localhost;Database=test;UserID=root;Password=********;PORT=3306;Allow Zero Datetime=True;logging=True;";
+ //conn.Open(); << REM
+ MySqlCommand command = new MySqlCommand();
+ command.Connection = c2;
+
+ MySqlCommand cmdCreateTable = new MySqlCommand("DROP TABLE IF EXISTS `test`.`contents_catalog`", c2);
+ cmdCreateTable.CommandType = CommandType.Text;
+ cmdCreateTable.CommandTimeout = 0;
+ try
+ {
+ cmdCreateTable.ExecuteNonQuery();
+ }
+ catch (InvalidOperationException)
+ {
+ }
+ }
}
}
| Thread |
|---|
| • Connector/NET commit: r1040 - in branches/5.1: . Driver/Source TestSuite/Source | rburnett | 23 Oct |