From: Date: March 22 2007 10:16pm Subject: Connector/NET commit: r647 - in branches/5.0: . Driver/Source TestSuite List-Archive: http://lists.mysql.com/commits/22707 X-Bug: 27289 Message-Id: <200703222116.l2MLGb3x028732@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/5.0/CHANGES branches/5.0/Driver/Source/Connection.cs branches/5.0/TestSuite/Transactions.cs Log: Bug #27289 Transaction is not rolledback when connection close Added code to rollback any pending txn inside Close() Modified: branches/5.0/CHANGES =================================================================== --- branches/5.0/CHANGES 2007-03-22 19:57:14 UTC (rev 646) +++ branches/5.0/CHANGES 2007-03-22 21:16:36 UTC (rev 647) @@ -3,6 +3,7 @@ Bugs fixed ---------- Bug #27269 MySqlConnection.Clone does not mimic SqlConnection.Clone behaviour + Bug #27289 Transaction is not rolledback when connection close Other changes ------------- Modified: branches/5.0/Driver/Source/Connection.cs =================================================================== --- branches/5.0/Driver/Source/Connection.cs 2007-03-22 19:57:14 UTC (rev 646) +++ branches/5.0/Driver/Source/Connection.cs 2007-03-22 21:16:36 UTC (rev 647) @@ -477,6 +477,12 @@ if (dataReader != null) dataReader.Close(); + if ((driver.ServerStatus & ServerStatusFlags.InTransaction) != 0) + { + MySqlTransaction t = new MySqlTransaction(this, IsolationLevel.Unspecified); + t.Rollback(); + } + if (settings.Pooling) MySqlPoolManager.ReleaseConnection(driver); else Modified: branches/5.0/TestSuite/Transactions.cs =================================================================== --- branches/5.0/TestSuite/Transactions.cs 2007-03-22 19:57:14 UTC (rev 646) +++ branches/5.0/TestSuite/Transactions.cs 2007-03-22 21:16:36 UTC (rev 647) @@ -143,6 +143,32 @@ #endif + /// + /// Bug #27289 Transaction is not rolledback when connection close + /// + [Test] + public void RollingBackOnClose() + { + execSQL("DROP TABLE IF EXISTS test"); + execSQL("CREATE TABLE test (id INT) TYPE=InnoDB"); + + string connStr = GetConnectionString(true) + ";pooling=true;"; + MySqlConnection c = new MySqlConnection(connStr); + c.Open(); + MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES (1)", c); + MySqlTransaction tx = c.BeginTransaction(); + cmd.ExecuteNonQuery(); + c.Close(); + + MySqlConnection c2 = new MySqlConnection(connStr); + c2.Open(); + MySqlCommand cmd2 = new MySqlCommand("SELECT COUNT(*) from test", c2); + MySqlTransaction tx2 = c2.BeginTransaction(); + object count = cmd2.ExecuteScalar(); + c2.Close(); + Assert.AreEqual(0, count); + } + ///