From 3ae0b329fb7edac102f97815f6a16166b593085a Mon Sep 17 00:00:00 2001 From: jrahnama Date: Wed, 12 Jun 2024 11:37:40 -0700 Subject: [PATCH] Addressing conflict --- .../Data/ProviderBase/DbConnectionClosed.cs | 8 +-- .../Data/ProviderBase/DbConnectionInternal.cs | 50 ++++++++--------- .../Data/ProviderBase/DbConnectionPool.cs | 31 +++++------ .../Microsoft/Data/SqlClient/SqlCommand.cs | 6 +- .../Data/SqlClient/SqlConnectionHelper.cs | 13 ++--- .../Data/SqlClient/SqlDelegatedTransaction.cs | 55 +++++++++---------- .../SqlClient/SqlInternalConnectionSmi.cs | 18 +++--- .../SqlClient/SqlInternalConnectionTds.cs | 52 +++++++++--------- 8 files changed, 115 insertions(+), 118 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs index ad48b3fa30..99ad6029de 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs @@ -9,7 +9,7 @@ namespace Microsoft.Data.ProviderBase using System.Diagnostics; using System.Threading.Tasks; using Microsoft.Data.Common; - using SysTx = System.Transactions; + using System.Transactions; abstract internal class DbConnectionClosed : DbConnectionInternal { @@ -26,12 +26,12 @@ override public string ServerVersion } } - override protected void Activate(SysTx.Transaction transaction) + override protected void Activate(Transaction transaction) { throw ADP.ClosedConnectionError(); } - override public DbTransaction BeginTransaction(IsolationLevel il) + override public DbTransaction BeginTransaction(System.Data.IsolationLevel il) { throw ADP.ClosedConnectionError(); } @@ -51,7 +51,7 @@ override protected void Deactivate() throw ADP.ClosedConnectionError(); } - override public void EnlistTransaction(SysTx.Transaction transaction) + override public void EnlistTransaction(Transaction transaction) { throw ADP.ClosedConnectionError(); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs index 06b1e04712..b2e4f7d04e 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs @@ -15,13 +15,13 @@ namespace Microsoft.Data.ProviderBase using System.Threading.Tasks; using Microsoft.Data.Common; using Microsoft.Data.SqlClient; - using SysTx = System.Transactions; + using System.Transactions; internal abstract class DbConnectionInternal { private static int _objectTypeCount; internal readonly int _objectID = Interlocked.Increment(ref _objectTypeCount); - private SysTx.TransactionCompletedEventHandler _transactionCompletedEventHandler = null; + private TransactionCompletedEventHandler _transactionCompletedEventHandler = null; internal static readonly StateChangeEventArgs StateChangeClosed = new StateChangeEventArgs(ConnectionState.Open, ConnectionState.Closed); internal static readonly StateChangeEventArgs StateChangeOpen = new StateChangeEventArgs(ConnectionState.Closed, ConnectionState.Open); @@ -43,13 +43,13 @@ internal abstract class DbConnectionInternal private DateTime _createTime; // when the connection was created. - private SysTx.Transaction _enlistedTransaction; // [usage must be thread-safe] the transaction that we're enlisted in, either manually or automatically + private Transaction _enlistedTransaction; // [usage must be thread-safe] the transaction that we're enlisted in, either manually or automatically // _enlistedTransaction is a clone, so that transaction information can be queried even if the original transaction object is disposed. // However, there are times when we need to know if the original transaction object was disposed, so we keep a reference to it here. // This field should only be assigned a value at the same time _enlistedTransaction is updated. // Also, this reference should not be disposed, since we aren't taking ownership of it. - private SysTx.Transaction _enlistedTransactionOriginal; + private Transaction _enlistedTransactionOriginal; #if DEBUG private int _activateCount; // debug only counter to verify activate/deactivates are in sync. @@ -83,7 +83,7 @@ internal bool CanBePooled } } - protected internal SysTx.Transaction EnlistedTransaction + protected internal Transaction EnlistedTransaction { get { @@ -91,7 +91,7 @@ protected internal SysTx.Transaction EnlistedTransaction } set { - SysTx.Transaction currentEnlistedTransaction = _enlistedTransaction; + Transaction currentEnlistedTransaction = _enlistedTransaction; if (((null == currentEnlistedTransaction) && (null != value)) || ((null != currentEnlistedTransaction) && !currentEnlistedTransaction.Equals(value))) { // WebData 20000024 @@ -104,8 +104,8 @@ protected internal SysTx.Transaction EnlistedTransaction // SQLBUDT #230558 we need to use a clone of the transaction // when we store it, or we'll end up keeping it past the // duration of the using block of the TransactionScope - SysTx.Transaction valueClone = null; - SysTx.Transaction previousTransactionClone = null; + Transaction valueClone = null; + Transaction previousTransactionClone = null; try { if (null != value) @@ -188,7 +188,7 @@ protected bool EnlistedTransactionDisposed { bool disposed; - SysTx.Transaction currentEnlistedTransactionOriginal = _enlistedTransactionOriginal; + Transaction currentEnlistedTransactionOriginal = _enlistedTransactionOriginal; if (currentEnlistedTransactionOriginal != null) { disposed = currentEnlistedTransactionOriginal.TransactionInformation == null; @@ -385,9 +385,9 @@ public ConnectionState State internal virtual bool IsAccessTokenExpired => false; - abstract protected void Activate(SysTx.Transaction transaction); + abstract protected void Activate(Transaction transaction); - internal void ActivateConnection(SysTx.Transaction transaction) + internal void ActivateConnection(Transaction transaction) { // Internal method called from the connection pooler so we don't expose // the Activate method publicly. @@ -415,7 +415,7 @@ internal void AddWeakReference(object value, int tag) _referenceCollection.Add(value, tag); } - abstract public DbTransaction BeginTransaction(IsolationLevel il); + abstract public DbTransaction BeginTransaction(System.Data.IsolationLevel il); virtual public void ChangeDatabase(string value) { @@ -654,7 +654,7 @@ public virtual void Dispose() // Dispose of the _enlistedTransaction since it is a clone // of the original reference. // VSDD 780271 - _enlistedTransaction can be changed by another thread (TX end event) - SysTx.Transaction enlistedTransaction = Interlocked.Exchange(ref _enlistedTransaction, null); + Transaction enlistedTransaction = Interlocked.Exchange(ref _enlistedTransaction, null); if (enlistedTransaction != null) { enlistedTransaction.Dispose(); @@ -681,7 +681,7 @@ protected internal void UnDoomThisConnection() _connectionIsDoomed = false; } - abstract public void EnlistTransaction(SysTx.Transaction transaction); + abstract public void EnlistTransaction(Transaction transaction); virtual protected internal DataTable GetSchema(DbConnectionFactory factory, DbConnectionPoolGroup poolGroup, DbConnection outerConnection, string collectionName, string[] restrictions) { @@ -865,21 +865,21 @@ internal void RemoveWeakReference(object value) // Cleanup connection's transaction-specific structures (currently used by Delegated transaction). // This is a separate method because cleanup can be triggered in multiple ways for a delegated // transaction. - virtual protected void CleanupTransactionOnCompletion(SysTx.Transaction transaction) + virtual protected void CleanupTransactionOnCompletion(Transaction transaction) { } internal void DetachCurrentTransactionIfEnded() { - SysTx.Transaction enlistedTransaction = EnlistedTransaction; + Transaction enlistedTransaction = EnlistedTransaction; if (enlistedTransaction != null) { bool transactionIsDead; try { - transactionIsDead = (SysTx.TransactionStatus.Active != enlistedTransaction.TransactionInformation.Status); + transactionIsDead = (TransactionStatus.Active != enlistedTransaction.TransactionInformation.Status); } - catch (SysTx.TransactionException) + catch (TransactionException) { // If the transaction is being processed (i.e. is part way through a rollback\commit\etc then TransactionInformation.Status will throw an exception) transactionIsDead = true; @@ -892,7 +892,7 @@ internal void DetachCurrentTransactionIfEnded() } // Detach transaction from connection. - internal void DetachTransaction(SysTx.Transaction transaction, bool isExplicitlyReleasing) + internal void DetachTransaction(Transaction transaction, bool isExplicitlyReleasing) { SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Transaction Completed. (pooledCount={1})", ObjectID, _pooledCount); @@ -906,7 +906,7 @@ internal void DetachTransaction(SysTx.Transaction transaction, bool isExplicitly DbConnection owner = Owner; if (isExplicitlyReleasing || UnbindOnTransactionCompletion || owner is null) { - SysTx.Transaction currentEnlistedTransaction = _enlistedTransaction; + Transaction currentEnlistedTransaction = _enlistedTransaction; if (currentEnlistedTransaction != null && transaction.Equals(currentEnlistedTransaction)) { // We need to remove the transaction completed event handler to cease listening for the transaction to end. @@ -924,7 +924,7 @@ internal void DetachTransaction(SysTx.Transaction transaction, bool isExplicitly } // Handle transaction detach, pool cleanup and other post-transaction cleanup tasks associated with - internal void CleanupConnectionOnTransactionCompletion(SysTx.Transaction transaction) + internal void CleanupConnectionOnTransactionCompletion(Transaction transaction) { DetachTransaction(transaction, false); @@ -935,9 +935,9 @@ internal void CleanupConnectionOnTransactionCompletion(SysTx.Transaction transac } } - void TransactionCompletedEvent(object sender, SysTx.TransactionEventArgs e) + void TransactionCompletedEvent(object sender, TransactionEventArgs e) { - SysTx.Transaction transaction = e.Transaction; + Transaction transaction = e.Transaction; SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Transaction Completed. (pooledCount = {1})", ObjectID, _pooledCount); CleanupTransactionOnCompletion(transaction); @@ -947,9 +947,9 @@ void TransactionCompletedEvent(object sender, SysTx.TransactionEventArgs e) // TODO: Review whether we need the unmanaged code permission when we have the new object model available. [SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)] - private void TransactionOutcomeEnlist(SysTx.Transaction transaction) + private void TransactionOutcomeEnlist(Transaction transaction) { - _transactionCompletedEventHandler ??= new SysTx.TransactionCompletedEventHandler(TransactionCompletedEvent); + _transactionCompletedEventHandler ??= new TransactionCompletedEventHandler(TransactionCompletedEvent); transaction.TransactionCompleted += _transactionCompletedEventHandler; } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs index f39be43eee..62fb98df2a 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs @@ -19,8 +19,7 @@ namespace Microsoft.Data.ProviderBase using System.Threading.Tasks; using Microsoft.Data.Common; using Microsoft.Data.SqlClient; - - using SysTx = System.Transactions; + using System.Transactions; sealed internal class DbConnectionPool { @@ -36,8 +35,8 @@ private enum State // copy as part of the value. sealed private class TransactedConnectionList : List { - private SysTx.Transaction _transaction; - internal TransactedConnectionList(int initialAllocation, SysTx.Transaction tx) : base(initialAllocation) + private Transaction _transaction; + internal TransactedConnectionList(int initialAllocation, Transaction tx) : base(initialAllocation) { _transaction = tx; } @@ -69,7 +68,7 @@ public PendingGetConnection(long dueTime, DbConnection owner, TaskCompletionSour sealed private class TransactedConnectionPool { - Dictionary _transactedCxns; + Dictionary _transactedCxns; DbConnectionPool _pool; @@ -80,7 +79,7 @@ internal TransactedConnectionPool(DbConnectionPool pool) { Debug.Assert(null != pool, "null pool?"); _pool = pool; - _transactedCxns = new Dictionary(); + _transactedCxns = new Dictionary(); SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Constructed for connection pool {1}", ObjectID, _pool.ObjectID); } @@ -100,7 +99,7 @@ internal DbConnectionPool Pool } } - internal DbConnectionInternal GetTransactedObject(SysTx.Transaction transaction) + internal DbConnectionInternal GetTransactedObject(Transaction transaction) { Debug.Assert(null != transaction, "null transaction?"); @@ -145,7 +144,7 @@ internal DbConnectionInternal GetTransactedObject(SysTx.Transaction transaction) return transactedObject; } - internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInternal transactedObject) + internal void PutTransactedObject(Transaction transaction, DbConnectionInternal transactedObject) { Debug.Assert(null != transaction, "null transaction?"); Debug.Assert(null != transactedObject, "null transactedObject?"); @@ -179,7 +178,7 @@ internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInt { // create the transacted pool, making sure to clone the associated transaction // for use as a key in our internal dictionary of transactions and connections - SysTx.Transaction transactionClone = null; + Transaction transactionClone = null; TransactedConnectionList newConnections = null; try @@ -243,7 +242,7 @@ internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInt } - internal void TransactionEnded(SysTx.Transaction transaction, DbConnectionInternal transactedObject) + internal void TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject) { SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Transaction Completed", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); TransactedConnectionList connections; @@ -1014,7 +1013,7 @@ private void DeactivateObject(DbConnectionInternal obj) // the transaction asynchronously completing on a second // thread. - SysTx.Transaction transaction = obj.EnlistedTransaction; + Transaction transaction = obj.EnlistedTransaction; if (null != transaction) { // NOTE: we're not locking on _state, so it's possible that its @@ -1212,7 +1211,7 @@ void WaitForPendingOpen() bool allowCreate = true; bool onlyOneCheckConnection = false; - ADP.SetCurrentTransaction(next.Completion.Task.AsyncState as System.Transactions.Transaction); + ADP.SetCurrentTransaction(next.Completion.Task.AsyncState as Transaction); timeout = !TryGetConnection(next.Owner, delay, allowCreate, onlyOneCheckConnection, next.UserOptions, out connection); } #if DEBUG @@ -1336,7 +1335,7 @@ internal bool TryGetConnection(DbConnection owningObject, TaskCompletionSource {0}, Getting connection.", ObjectID); @@ -1554,7 +1553,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj return true; } - private void PrepareConnection(DbConnection owningObject, DbConnectionInternal obj, SysTx.Transaction transaction) + private void PrepareConnection(DbConnection owningObject, DbConnectionInternal obj, Transaction transaction) { lock (obj) { // Protect against Clear and ReclaimEmancipatedObjects, which call IsEmancipated, which is affected by PrePush and PostPop @@ -1631,7 +1630,7 @@ private DbConnectionInternal GetFromGeneralPool() return (obj); } - private DbConnectionInternal GetFromTransactedPool(out SysTx.Transaction transaction) + private DbConnectionInternal GetFromTransactedPool(out Transaction transaction) { transaction = ADP.GetCurrentTransaction(); DbConnectionInternal obj = null; @@ -1973,7 +1972,7 @@ internal void Shutdown() // that is implemented inside DbConnectionPool. This method's counterpart (PutTransactedObject) should // only be called from DbConnectionPool.DeactivateObject and thus the plumbing to provide access to // other objects is unnecessary (hence the asymmetry of Ended but no Begin) - internal void TransactionEnded(SysTx.Transaction transaction, DbConnectionInternal transactedObject) + internal void TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject) { Debug.Assert(null != transaction, "null transaction?"); Debug.Assert(null != transactedObject, "null transactedObject?"); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs index 94cd927c1d..30338925cc 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs @@ -22,7 +22,7 @@ using Microsoft.Data.Common; using Microsoft.Data.Sql; using Microsoft.Data.SqlClient.Server; -using SysTx = System.Transactions; +using System.Transactions; using System.Collections.Concurrent; // NOTE: The current Microsoft.VSDesigner editor attributes are implemented for System.Data.SqlClient, and are not publicly available. @@ -4046,7 +4046,7 @@ private void RunExecuteNonQuerySmi(bool sendToPipe) try { long transactionId; - SysTx.Transaction transaction; + Transaction transaction; innerConnection.GetCurrentTransactionPair(out transactionId, out transaction); SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, innerConnection={1}, transactionId=0x{2}, cmdBehavior={3}.", ObjectID, innerConnection.ObjectID, transactionId, (int)CommandBehavior.Default); @@ -5696,7 +5696,7 @@ private SqlDataReader RunExecuteReaderSmi(CommandBehavior cmdBehavior, RunBehavi requestExecutor = SetUpSmiRequest(innerConnection); long transactionId; - SysTx.Transaction transaction; + Transaction transaction; innerConnection.GetCurrentTransactionPair(out transactionId, out transaction); SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, innerConnection={1}, transactionId=0x{2}, commandBehavior={(int)cmdBehavior}.", ObjectID, innerConnection.ObjectID, transactionId); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs index 07d44f020c..dcbd0738cb 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs @@ -12,8 +12,7 @@ namespace Microsoft.Data.SqlClient using System.Threading; using Microsoft.Data.Common; using Microsoft.Data.ProviderBase; - - using SysTx = System.Transactions; + using System.Transactions; public sealed partial class SqlConnection : DbConnection { @@ -242,11 +241,11 @@ private void EnlistDistributedTransactionHelper(System.EnterpriseServices.ITrans permissionSet.Demand(); SqlClientEventSource.Log.TryTraceEvent(" {0}, Connection enlisting in a transaction.", ObjectID); - SysTx.Transaction indigoTransaction = null; + Transaction indigoTransaction = null; if (null != transaction) { - indigoTransaction = SysTx.TransactionInterop.GetTransactionFromDtcTransaction((SysTx.IDtcTransaction)transaction); + indigoTransaction = TransactionInterop.GetTransactionFromDtcTransaction((IDtcTransaction)transaction); } RepairInnerConnection(); @@ -263,7 +262,7 @@ private void EnlistDistributedTransactionHelper(System.EnterpriseServices.ITrans } /// - override public void EnlistTransaction(SysTx.Transaction transaction) + override public void EnlistTransaction(Transaction transaction) { SqlConnection.ExecutePermission.Demand(); SqlClientEventSource.Log.TryTraceEvent(" {0}, Connection enlisting in a transaction.", ObjectID); @@ -277,7 +276,7 @@ override public void EnlistTransaction(SysTx.Transaction transaction) // NOTE: since transaction enlistment involves round trips to the // server, we don't want to lock here, we'll handle the race conditions // elsewhere. - SysTx.Transaction enlistedTransaction = innerConnection.EnlistedTransaction; + Transaction enlistedTransaction = innerConnection.EnlistedTransaction; if (enlistedTransaction != null) { // Allow calling enlist if already enlisted (no-op) @@ -287,7 +286,7 @@ override public void EnlistTransaction(SysTx.Transaction transaction) } // Allow enlisting in a different transaction if the enlisted transaction has completed. - if (enlistedTransaction.TransactionInformation.Status == SysTx.TransactionStatus.Active) + if (enlistedTransaction.TransactionInformation.Status == TransactionStatus.Active) { throw ADP.TransactionPresent(); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs index e11ec36e79..ffe44e328c 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs @@ -8,13 +8,12 @@ using System.Runtime.CompilerServices; using System.Threading; using Microsoft.Data.Common; - -using SysTx = System.Transactions; +using System.Transactions; namespace Microsoft.Data.SqlClient { - sealed internal class SqlDelegatedTransaction : SysTx.IPromotableSinglePhaseNotification + sealed internal class SqlDelegatedTransaction : IPromotableSinglePhaseNotification { private static int _objectTypeCount; private readonly int _objectID = Interlocked.Increment(ref _objectTypeCount); @@ -34,19 +33,19 @@ internal int ObjectID // may be initiated here AFTER the connection lock is released, but should NOT fall under this class's locking strategy. private SqlInternalConnection _connection; // the internal connection that is the root of the transaction - private IsolationLevel _isolationLevel; // the IsolationLevel of the transaction we delegated to the server + private System.Data.IsolationLevel _isolationLevel; // the IsolationLevel of the transaction we delegated to the server private SqlInternalTransaction _internalTransaction; // the SQL Server transaction we're delegating to - private SysTx.Transaction _atomicTransaction; + private Transaction _atomicTransaction; private bool _active; // Is the transaction active? - internal SqlDelegatedTransaction(SqlInternalConnection connection, SysTx.Transaction tx) + internal SqlDelegatedTransaction(SqlInternalConnection connection, Transaction tx) { Debug.Assert(null != connection, "null connection?"); _connection = connection; _atomicTransaction = tx; _active = false; - SysTx.IsolationLevel systxIsolationLevel = tx.IsolationLevel; + System.Transactions.IsolationLevel systxIsolationLevel = tx.IsolationLevel; // We need to map the System.Transactions IsolationLevel to the one // that System.Data uses and communicates to SqlServer. We could @@ -57,27 +56,27 @@ internal SqlDelegatedTransaction(SqlInternalConnection connection, SysTx.Transac // place. switch (systxIsolationLevel) { - case SysTx.IsolationLevel.ReadCommitted: - _isolationLevel = IsolationLevel.ReadCommitted; + case System.Transactions.IsolationLevel.ReadCommitted: + _isolationLevel = System.Data.IsolationLevel.ReadCommitted; break; - case SysTx.IsolationLevel.ReadUncommitted: - _isolationLevel = IsolationLevel.ReadUncommitted; + case System.Transactions.IsolationLevel.ReadUncommitted: + _isolationLevel = System.Data.IsolationLevel.ReadUncommitted; break; - case SysTx.IsolationLevel.RepeatableRead: - _isolationLevel = IsolationLevel.RepeatableRead; + case System.Transactions.IsolationLevel.RepeatableRead: + _isolationLevel = System.Data.IsolationLevel.RepeatableRead; break; - case SysTx.IsolationLevel.Serializable: - _isolationLevel = IsolationLevel.Serializable; + case System.Transactions.IsolationLevel.Serializable: + _isolationLevel = System.Data.IsolationLevel.Serializable; break; - case SysTx.IsolationLevel.Snapshot: - _isolationLevel = IsolationLevel.Snapshot; + case System.Transactions.IsolationLevel.Snapshot: + _isolationLevel = System.Data.IsolationLevel.Snapshot; break; default: throw SQL.UnknownSysTxIsolationLevel(systxIsolationLevel); } } - internal SysTx.Transaction Transaction + internal Transaction Transaction { get { return _atomicTransaction; } } @@ -191,7 +190,7 @@ public Byte[] Promote() // Now that we've acquired the lock, make sure we still have valid state for this operation. ValidateActiveOnConnection(connection); - connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Promote, null, IsolationLevel.Unspecified, _internalTransaction, true); + connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Promote, null, System.Data.IsolationLevel.Unspecified, _internalTransaction, true); returnValue = connection.PromotedDTCToken; // For Global Transactions, we need to set the Transaction Id since we use a Non-MSDTC Promoter type. @@ -260,12 +259,12 @@ public Byte[] Promote() try { // Safely access Transction status - as it's possible Transaction is not in right state. - if(Transaction?.TransactionInformation?.Status == SysTx.TransactionStatus.Aborted) + if(Transaction?.TransactionInformation?.Status == System.Transactions.TransactionStatus.Aborted) { throw SQL.PromotionFailed(promoteException); } } - catch(SysTx.TransactionException te) + catch(TransactionException te) { SqlClientEventSource.Log.TryTraceEvent("SqlDelegatedTransaction.Promote | RES | CPOOL | Object Id {0}, Client Connection Id {1}, Transaction exception occurred: {2}.", ObjectID, usersConnection?.ClientConnectionId, te.Message); // Throw promote exception if transaction state is unknown. @@ -287,7 +286,7 @@ public Byte[] Promote() } // Called by transaction to initiate abort sequence - public void Rollback(SysTx.SinglePhaseEnlistment enlistment) + public void Rollback(SinglePhaseEnlistment enlistment) { Debug.Assert(null != enlistment, "null enlistment?"); SqlInternalConnection connection = GetValidConnection(); @@ -315,7 +314,7 @@ public void Rollback(SysTx.SinglePhaseEnlistment enlistment) // If we haven't already rolled back (or aborted) then tell the SQL Server to roll back if (!_internalTransaction.IsAborted) { - connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Rollback, null, IsolationLevel.Unspecified, _internalTransaction, true); + connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Rollback, null, System.Data.IsolationLevel.Unspecified, _internalTransaction, true); } } catch (SqlException e) @@ -382,7 +381,7 @@ public void Rollback(SysTx.SinglePhaseEnlistment enlistment) } // Called by the transaction to initiate commit sequence - public void SinglePhaseCommit(SysTx.SinglePhaseEnlistment enlistment) + public void SinglePhaseCommit(SinglePhaseEnlistment enlistment) { Debug.Assert(null != enlistment, "null enlistment?"); SqlInternalConnection connection = GetValidConnection(); @@ -428,7 +427,7 @@ public void SinglePhaseCommit(SysTx.SinglePhaseEnlistment enlistment) _active = false; // set to inactive first, doesn't matter how the rest completes, this transaction is done. _connection = null; // Set prior to ExecuteTransaction call in case this initiates a TransactionEnd event - connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Commit, null, IsolationLevel.Unspecified, _internalTransaction, true); + connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Commit, null, System.Data.IsolationLevel.Unspecified, _internalTransaction, true); commitException = null; } catch (SqlException e) @@ -461,7 +460,7 @@ public void SinglePhaseCommit(SysTx.SinglePhaseEnlistment enlistment) else if (_internalTransaction.IsAborted) { // The transaction was aborted, report that to - // SysTx. + // System.Transactions. enlistment.Aborted(commitException); } else @@ -520,7 +519,7 @@ public void SinglePhaseCommit(SysTx.SinglePhaseEnlistment enlistment) // ended event via the internal connection. If it occurs without a prior Rollback or SinglePhaseCommit call, // it indicates the transaction was ended externally (generally that one the the DTC participants aborted // the transaction). - internal void TransactionEnded(SysTx.Transaction transaction) + internal void TransactionEnded(Transaction transaction) { SqlInternalConnection connection = _connection; @@ -547,7 +546,7 @@ internal void TransactionEnded(SysTx.Transaction transaction) private SqlInternalConnection GetValidConnection() { SqlInternalConnection connection = _connection; - if (null == connection && _atomicTransaction.TransactionInformation.Status != SysTx.TransactionStatus.Aborted) + if (null == connection && _atomicTransaction.TransactionInformation.Status != TransactionStatus.Aborted) { throw ADP.ObjectDisposed(this); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs index aa1a766861..88b9aa2430 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs @@ -8,7 +8,7 @@ using System.Diagnostics; using Microsoft.Data.Common; using Microsoft.Data.SqlClient.Server; -using SysTx = System.Transactions; +using System.Transactions; namespace Microsoft.Data.SqlClient { @@ -222,20 +222,20 @@ protected override bool UnbindOnTransactionCompletion // Context transactions SHOULD be considered enlisted. // This works for now only because we can't unenlist from the context transaction // DON'T START USING THIS ANYWHERE EXCEPT IN InternalTransaction and in InternalConnectionSmi!!! - private SysTx.Transaction ContextTransaction + private Transaction ContextTransaction { get; set; } - private SysTx.Transaction InternalEnlistedTransaction + private Transaction InternalEnlistedTransaction { get { // Workaround to access context transaction without rewriting connection pool & internalconnections properly. // This SHOULD be a simple wrapper around EnlistedTransaction. // This works for now only because we can't unenlist from the context transaction - SysTx.Transaction tx = EnlistedTransaction; + Transaction tx = EnlistedTransaction; if (null == tx) { @@ -246,7 +246,7 @@ private SysTx.Transaction InternalEnlistedTransaction } } - override protected void Activate(SysTx.Transaction transaction) + override protected void Activate(Transaction transaction) { Debug.Assert(false, "Activating an internal SMI connection?"); // we should never be activating, because that would indicate we're being pooled. } @@ -266,8 +266,8 @@ internal void Activate() internal void AutomaticEnlistment() { - SysTx.Transaction currentSystemTransaction = ADP.GetCurrentTransaction(); // NOTE: Must be first to ensure _smiContext.ContextTransaction is set! - SysTx.Transaction contextTransaction = _smiContext.ContextTransaction; // returns the transaction that was handed to SysTx that wraps the ContextTransactionId. + Transaction currentSystemTransaction = ADP.GetCurrentTransaction(); // NOTE: Must be first to ensure _smiContext.ContextTransaction is set! + Transaction contextTransaction = _smiContext.ContextTransaction; // returns the transaction that was handed to SysTx that wraps the ContextTransactionId. long contextTransactionId = _smiContext.ContextTransactionId; SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, contextTransactionId=0x{1}, contextTransaction={2}, currentSystemTransaction={3}.", ObjectID, contextTransactionId, (null != contextTransaction) ? contextTransaction.GetHashCode() : 0, (null != currentSystemTransaction) ? currentSystemTransaction.GetHashCode() : 0); @@ -357,7 +357,7 @@ override public void Dispose() override internal void ExecuteTransaction( TransactionRequest transactionRequest, string transactionName, - IsolationLevel iso, + System.Data.IsolationLevel iso, SqlInternalTransaction internalTransaction, bool isDelegateControlRequest) { @@ -429,7 +429,7 @@ override protected byte[] GetDTCAddress() return whereAbouts; } - internal void GetCurrentTransactionPair(out long transactionId, out SysTx.Transaction transaction) + internal void GetCurrentTransactionPair(out long transactionId, out Transaction transaction) { // SQLBU 214740: Transaction state could change between obtaining tranid and transaction // due to background SqlDelegatedTransaction processing. Lock the connection to prevent that. diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs index 612aab532e..cc80af6767 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs @@ -18,7 +18,7 @@ using Microsoft.Data.Common; using Microsoft.Data.ProviderBase; using Microsoft.Identity.Client; -using SysTx = System.Transactions; +using System.Transactions; namespace Microsoft.Data.SqlClient @@ -952,7 +952,7 @@ internal void CheckEnlistedTransactionBinding() { // If we are enlisted in a transaction, check that transaction is active. // When using explicit transaction unbinding, also verify that the enlisted transaction is the current transaction. - SysTx.Transaction enlistedTransaction = EnlistedTransaction; + Transaction enlistedTransaction = EnlistedTransaction; if (enlistedTransaction != null) { @@ -960,16 +960,16 @@ internal void CheckEnlistedTransactionBinding() if (requireExplicitTransactionUnbind) { - SysTx.Transaction currentTransaction = SysTx.Transaction.Current; + Transaction currentTransaction = Transaction.Current; - if (SysTx.TransactionStatus.Active != enlistedTransaction.TransactionInformation.Status || !enlistedTransaction.Equals(currentTransaction)) + if (TransactionStatus.Active != enlistedTransaction.TransactionInformation.Status || !enlistedTransaction.Equals(currentTransaction)) { throw ADP.TransactionConnectionMismatch(); } } else // implicit transaction unbind { - if (SysTx.TransactionStatus.Active != enlistedTransaction.TransactionInformation.Status) + if (TransactionStatus.Active != enlistedTransaction.TransactionInformation.Status) { if (EnlistedTransactionDisposed) { @@ -1012,7 +1012,7 @@ internal override bool IsConnectionAlive(bool throwOnException) // POOLING METHODS //////////////////////////////////////////////////////////////////////////////////////// - override protected void Activate(SysTx.Transaction transaction) + override protected void Activate(Transaction transaction) { FailoverPermissionDemand(); // Demand for unspecified failover pooled connections @@ -1146,12 +1146,12 @@ override internal void DisconnectTransaction(SqlInternalTransaction internalTran } } - internal void ExecuteTransaction(TransactionRequest transactionRequest, string name, IsolationLevel iso) + internal void ExecuteTransaction(TransactionRequest transactionRequest, string name, System.Data.IsolationLevel iso) { ExecuteTransaction(transactionRequest, name, iso, null, false); } - override internal void ExecuteTransaction(TransactionRequest transactionRequest, string name, IsolationLevel iso, SqlInternalTransaction internalTransaction, bool isDelegateControlRequest) + override internal void ExecuteTransaction(TransactionRequest transactionRequest, string name, System.Data.IsolationLevel iso, SqlInternalTransaction internalTransaction, bool isDelegateControlRequest) { if (IsConnectionDoomed) { // doomed means we can't do anything else... @@ -1189,35 +1189,35 @@ override internal void ExecuteTransaction(TransactionRequest transactionRequest, internal void ExecuteTransactionPre2005( TransactionRequest transactionRequest, string transactionName, - IsolationLevel iso, + System.Data.IsolationLevel iso, SqlInternalTransaction internalTransaction) { StringBuilder sqlBatch = new StringBuilder(); switch (iso) { - case IsolationLevel.Unspecified: + case System.Data.IsolationLevel.Unspecified: break; - case IsolationLevel.ReadCommitted: + case System.Data.IsolationLevel.ReadCommitted: sqlBatch.Append(TdsEnums.TRANS_READ_COMMITTED); sqlBatch.Append(";"); break; - case IsolationLevel.ReadUncommitted: + case System.Data.IsolationLevel.ReadUncommitted: sqlBatch.Append(TdsEnums.TRANS_READ_UNCOMMITTED); sqlBatch.Append(";"); break; - case IsolationLevel.RepeatableRead: + case System.Data.IsolationLevel.RepeatableRead: sqlBatch.Append(TdsEnums.TRANS_REPEATABLE_READ); sqlBatch.Append(";"); break; - case IsolationLevel.Serializable: + case System.Data.IsolationLevel.Serializable: sqlBatch.Append(TdsEnums.TRANS_SERIALIZABLE); sqlBatch.Append(";"); break; - case IsolationLevel.Snapshot: - throw SQL.SnapshotNotSupported(IsolationLevel.Snapshot); + case System.Data.IsolationLevel.Snapshot: + throw SQL.SnapshotNotSupported(System.Data.IsolationLevel.Snapshot); - case IsolationLevel.Chaos: + case System.Data.IsolationLevel.Chaos: throw SQL.NotSupportedIsolationLevel(iso); default: @@ -1278,7 +1278,7 @@ internal void ExecuteTransactionPre2005( internal void ExecuteTransaction2005( TransactionRequest transactionRequest, string transactionName, - IsolationLevel iso, + System.Data.IsolationLevel iso, SqlInternalTransaction internalTransaction, bool isDelegateControlRequest) { @@ -1287,25 +1287,25 @@ internal void ExecuteTransaction2005( switch (iso) { - case IsolationLevel.Unspecified: + case System.Data.IsolationLevel.Unspecified: isoLevel = TdsEnums.TransactionManagerIsolationLevel.Unspecified; break; - case IsolationLevel.ReadCommitted: + case System.Data.IsolationLevel.ReadCommitted: isoLevel = TdsEnums.TransactionManagerIsolationLevel.ReadCommitted; break; - case IsolationLevel.ReadUncommitted: + case System.Data.IsolationLevel.ReadUncommitted: isoLevel = TdsEnums.TransactionManagerIsolationLevel.ReadUncommitted; break; - case IsolationLevel.RepeatableRead: + case System.Data.IsolationLevel.RepeatableRead: isoLevel = TdsEnums.TransactionManagerIsolationLevel.RepeatableRead; break; - case IsolationLevel.Serializable: + case System.Data.IsolationLevel.Serializable: isoLevel = TdsEnums.TransactionManagerIsolationLevel.Serializable; break; - case IsolationLevel.Snapshot: + case System.Data.IsolationLevel.Snapshot: isoLevel = TdsEnums.TransactionManagerIsolationLevel.Snapshot; break; - case IsolationLevel.Chaos: + case System.Data.IsolationLevel.Chaos: throw SQL.NotSupportedIsolationLevel(iso); default: throw ADP.InvalidIsolationLevel(iso); @@ -1508,7 +1508,7 @@ private void CompleteLogin(bool enlistOK) if (enlistOK && ConnectionOptions.Enlist && _routingInfo == null) { _parser._physicalStateObj.SniContext = SniContext.Snix_AutoEnlist; - SysTx.Transaction tx = ADP.GetCurrentTransaction(); + Transaction tx = ADP.GetCurrentTransaction(); Enlist(tx); } _parser._physicalStateObj.SniContext = SniContext.Snix_Login;