Modified:
branches/1.0/TestSuite/Transactions.cs
branches/1.0/mysqlclient/Connection.cs
branches/1.0/mysqlclient/Resources.resx
branches/1.0/mysqlclient/transaction.cs
Log:
Bug #22400 Nested transactions
fixed
Modified: branches/1.0/TestSuite/Transactions.cs
===================================================================
--- branches/1.0/TestSuite/Transactions.cs 2006-09-20 14:26:44 UTC (rev 353)
+++ branches/1.0/TestSuite/Transactions.cs 2006-09-20 14:27:13 UTC (rev 354)
@@ -72,5 +72,31 @@
if (reader != null) reader.Close();
}
}
+
+ /// <summary>
+ /// Bug #22400 Nested transactions
+ /// </summary>
+ [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: branches/1.0/mysqlclient/Connection.cs
===================================================================
--- branches/1.0/mysqlclient/Connection.cs 2006-09-20 14:26:44 UTC (rev 353)
+++ branches/1.0/mysqlclient/Connection.cs 2006-09-20 14:27:13 UTC (rev 354)
@@ -40,6 +40,7 @@
private MySqlConnectionString settings;
private bool hasBeenOpen;
private ProcedureCache procedureCache;
+ internal MySqlTransaction activeLegacyTransaction;
/// <include file='docs/MySqlConnection.xml' path='docs/StateChange/*'/>
public event StateChangeEventHandler StateChange;
@@ -212,6 +213,9 @@
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);
@@ -236,6 +240,7 @@
cmd.CommandText = "BEGIN";
cmd.ExecuteNonQuery();
+ activeLegacyTransaction = t;
return t;
}
Modified: branches/1.0/mysqlclient/Resources.resx
===================================================================
--- branches/1.0/mysqlclient/Resources.resx 2006-09-20 14:26:44 UTC (rev 353)
+++ branches/1.0/mysqlclient/Resources.resx 2006-09-20 14:27:13 UTC (rev 354)
@@ -234,4 +234,7 @@
<data name="UnableToExecuteSP" xml:space="preserve">
<value>Unable to execute stored procedure '{0}'.</value>
</data>
+ <data name="NoNestedTransactions" xml:space="preserve">
+ <value>Nested transactions are not supported.</value>
+ </data>
</root>
\ No newline at end of file
Modified: branches/1.0/mysqlclient/transaction.cs
===================================================================
--- branches/1.0/mysqlclient/transaction.cs 2006-09-20 14:26:44 UTC (rev 353)
+++ branches/1.0/mysqlclient/transaction.cs 2006-09-20 14:27:13 UTC (rev 354)
@@ -87,16 +87,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;
+ }
}
/// <include file='docs/MySqlTransaction.xml' path='docs/Rollback/*'/>
@@ -116,6 +120,10 @@
{
throw;
}
- }
+ finally
+ {
+ conn.activeLegacyTransaction = null;
+ }
+ }
}
}
| Thread |
|---|
| • Connector/NET commit: r354 - in branches/1.0: TestSuite mysqlclient | rburnett | 20 Sep |