Modified:
branches/5.1/CHANGES
branches/5.1/Driver/Source/Connection.cs
branches/5.1/TestSuite/Source/ConnectionTests.cs
Log:
Fixed problem that prevented commands from being executed from the state change handler.
Not sure why you would want to do this but... (bug #30964)
Modified: branches/5.1/CHANGES
===================================================================
--- branches/5.1/CHANGES 2007-09-21 22:23:49 UTC (rev 1022)
+++ branches/5.1/CHANGES 2007-09-21 22:28:21 UTC (rev 1023)
@@ -72,7 +72,9 @@
- Changed from using Array.Copy to Buffer.BlockCopy in MySqlDataReader.GetBytes. This
helps with memory usage as we expect the source and destination arrays to not be
overlapping.
(Bug #31090)
-
+ - Fixed problem that prevented commands from being executed from the state change
+ handler. Not sure why you would want to do this but... (bug #30964)
+
Version 5.0.8 8/16/2007
Bug #28706 Log messages are truncated
- Fixed a problem with compression over a network. We were letting the inflate stream
read
Modified: branches/5.1/Driver/Source/Connection.cs
===================================================================
--- branches/5.1/Driver/Source/Connection.cs 2007-09-21 22:23:49 UTC (rev 1022)
+++ branches/5.1/Driver/Source/Connection.cs 2007-09-21 22:28:21 UTC (rev 1023)
@@ -402,13 +402,14 @@
this.database = database;
}
- internal void SetState(ConnectionState newConnectionState)
+ internal void SetState(ConnectionState newConnectionState, bool broadcast)
{
if (newConnectionState == connectionState)
return;
ConnectionState oldConnectionState = connectionState;
connectionState = newConnectionState;
- OnStateChange(new StateChangeEventArgs(oldConnectionState, connectionState));
+ if (broadcast)
+ OnStateChange(new StateChangeEventArgs(oldConnectionState, connectionState));
}
/// <summary>
@@ -419,7 +420,7 @@
{
bool result = driver.Ping();
if (!result)
- SetState(ConnectionState.Closed);
+ SetState(ConnectionState.Closed, true);
return result;
}
@@ -429,7 +430,7 @@
if (State == ConnectionState.Open)
throw new InvalidOperationException(Resources.ConnectionAlreadyOpen);
- SetState(ConnectionState.Connecting);
+ SetState(ConnectionState.Connecting, true);
#if !CF
// if we are auto enlisting in a current transaction, then we will be
@@ -460,7 +461,7 @@
}
catch (Exception)
{
- SetState(ConnectionState.Closed);
+ SetState(ConnectionState.Closed, true);
throw;
}
@@ -468,7 +469,7 @@
if (driver.Settings.UseOldSyntax)
Logger.LogWarning("You are using old syntax that will be removed in
future versions");
- SetState(ConnectionState.Open);
+ SetState(ConnectionState.Open, false);
driver.Configure(this);
if (settings.Database != null && settings.Database != String.Empty)
ChangeDatabase(settings.Database);
@@ -490,7 +491,8 @@
#endif
hasBeenOpen = true;
- }
+ SetState(ConnectionState.Open, true);
+ }
/// <include file='docs/MySqlConnection.xml' path='docs/CreateCommand/*'/>
public new MySqlCommand CreateCommand()
@@ -551,7 +553,7 @@
catch (Exception)
{
}
- SetState(ConnectionState.Closed);
+ SetState(ConnectionState.Closed, true);
}
internal void CloseFully()
@@ -588,7 +590,7 @@
driver.IsInActiveUse = false;
#endif
- SetState(ConnectionState.Closed);
+ SetState(ConnectionState.Closed, true);
}
internal string CurrentDatabase()
Modified: branches/5.1/TestSuite/Source/ConnectionTests.cs
===================================================================
--- branches/5.1/TestSuite/Source/ConnectionTests.cs 2007-09-21 22:23:49 UTC (rev 1022)
+++ branches/5.1/TestSuite/Source/ConnectionTests.cs 2007-09-21 22:28:21 UTC (rev 1023)
@@ -397,5 +397,30 @@
}
}
}
+
+ /// <summary>
+ /// Bug #30964 StateChange imperfection
+ /// </summary>
+ MySqlConnection rqConnection;
+ [Test]
+ public void RunningAQueryFromStateChangeHandler()
+ {
+ string connStr = GetConnectionString(true);
+ using (rqConnection = new MySqlConnection(connStr))
+ {
+ rqConnection.StateChange += new
StateChangeEventHandler(RunningQueryStateChangeHandler);
+ rqConnection.Open();
+ }
+ }
+
+ void RunningQueryStateChangeHandler(object sender, StateChangeEventArgs e)
+ {
+ if (e.CurrentState == ConnectionState.Open)
+ {
+ MySqlCommand cmd = new MySqlCommand("SELECT 1", rqConnection);
+ object o = cmd.ExecuteScalar();
+ Assert.AreEqual(1, o);
+ }
+ }
}
}
| Thread |
|---|
| • Connector/NET commit: r1023 - in branches/5.1: . Driver/Source TestSuite/Source | rburnett | 22 Sep |