From: Date: September 20 2006 4:26pm Subject: Connector/NET commit: r353 - in trunk: . TestSuite mysqlclient List-Archive: http://lists.mysql.com/commits/12277 X-Bug: 22400 Message-Id: <200609201426.k8KEQj7B010853@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: trunk/CHANGES trunk/TestSuite/Transactions.cs trunk/mysqlclient/Connection.cs trunk/mysqlclient/Resources.resx trunk/mysqlclient/transaction.cs Log: Bug #22400 Nested transactions fixed Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2006-09-19 21:43:48 UTC (rev 352) +++ trunk/CHANGES 2006-09-20 14:26:44 UTC (rev 353) @@ -72,7 +72,8 @@ Bug #20581 Null Reference Exception when closing reader after stored procedure. Bug #16884 Invalid DateTime Values from DataReader Bug #7248 There is already an open DataReader associated with this Connection which must - + Bug #22400 Nested transactions + Version 1.0.7 Bugs fixed or addressed Modified: trunk/TestSuite/Transactions.cs =================================================================== --- trunk/TestSuite/Transactions.cs 2006-09-19 21:43:48 UTC (rev 352) +++ trunk/TestSuite/Transactions.cs 2006-09-20 14:26:44 UTC (rev 353) @@ -197,6 +197,31 @@ } #endif + /// + /// Bug #22400 Nested transactions + /// + [Test] + public void NestedTransactions() + { + MySqlTransaction t1 = conn.BeginTransaction(); + try + { + MySqlTransaction t2 = conn.BeginTransaction(); + t2.Rollback(); + Assert.Fail("Exception should have been thrown"); + } + catch (NotSupportedException) + { + } + catch (Exception ex) + { + Assert.Fail(ex.Message); + } + finally + { + t1.Rollback(); + } + } } } Modified: trunk/mysqlclient/Connection.cs =================================================================== --- trunk/mysqlclient/Connection.cs 2006-09-19 21:43:48 UTC (rev 352) +++ trunk/mysqlclient/Connection.cs 2006-09-20 14:26:44 UTC (rev 353) @@ -48,6 +48,7 @@ private ProcedureCache procedureCache; private PerformanceMonitor perfMonitor; private MySqlPromotableTransaction currentTransaction; + internal MySqlTransaction activeLegacyTransaction; /// public event MySqlInfoMessageEventHandler InfoMessage; @@ -275,9 +276,12 @@ if (State != ConnectionState.Open) throw new InvalidOperationException(Resources.ConnectionNotOpen); + if (activeLegacyTransaction != null) + throw new NotSupportedException(Resources.NoNestedTransactions); + MySqlTransaction t = new MySqlTransaction(this, iso); - MySqlCommand cmd = new MySqlCommand( "", this); + MySqlCommand cmd = new MySqlCommand("", this); cmd.CommandText = "SET SESSION TRANSACTION ISOLATION LEVEL "; switch (iso) @@ -299,6 +303,7 @@ cmd.CommandText = "BEGIN"; cmd.ExecuteNonQuery(); + activeLegacyTransaction = t; return t; } Modified: trunk/mysqlclient/Resources.resx =================================================================== --- trunk/mysqlclient/Resources.resx 2006-09-19 21:43:48 UTC (rev 352) +++ trunk/mysqlclient/Resources.resx 2006-09-20 14:26:44 UTC (rev 353) @@ -267,4 +267,7 @@ Canceling an executing query requires MySQL 5.0 or higher. + + Nested transactions are not supported. + \ No newline at end of file Modified: trunk/mysqlclient/transaction.cs =================================================================== --- trunk/mysqlclient/transaction.cs 2006-09-19 21:43:48 UTC (rev 352) +++ trunk/mysqlclient/transaction.cs 2006-09-20 14:26:44 UTC (rev 353) @@ -84,16 +84,20 @@ throw new InvalidOperationException("Connection must be valid and open to commit transaction"); if (!open) throw new InvalidOperationException("Transaction has already been committed or is not pending"); - try - { - MySqlCommand cmd = new MySqlCommand( "COMMIT", conn ); - cmd.ExecuteNonQuery(); - open = false; - } - catch (MySqlException) - { - throw; - } + try + { + MySqlCommand cmd = new MySqlCommand("COMMIT", conn); + cmd.ExecuteNonQuery(); + open = false; + } + catch (MySqlException) + { + throw; + } + finally + { + conn.activeLegacyTransaction = null; + } } /// @@ -113,7 +117,11 @@ { throw; } - } + finally + { + conn.activeLegacyTransaction = null; + } + } } }