本文整理汇总了C#中System.Data.SqlClient.SqlInternalTransaction类的典型用法代码示例。如果您正苦于以下问题:C# SqlInternalTransaction类的具体用法?C# SqlInternalTransaction怎么用?C# SqlInternalTransaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlInternalTransaction类属于System.Data.SqlClient命名空间,在下文中一共展示了SqlInternalTransaction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SqlTransaction
internal SqlTransaction(SqlInternalConnection internalConnection, SqlConnection con, System.Data.IsolationLevel iso, SqlInternalTransaction internalTransaction)
{
this._isolationLevel = iso;
this._connection = con;
if (internalTransaction == null)
{
this._internalTransaction = new SqlInternalTransaction(internalConnection, TransactionType.LocalFromAPI, this);
}
else
{
this._internalTransaction = internalTransaction;
this._internalTransaction.InitParent(this);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:SqlTransaction.cs
示例2: SqlTransaction
internal SqlTransaction(SqlInternalConnection internalConnection, SqlConnection con,
IsolationLevel iso, SqlInternalTransaction internalTransaction) {
SqlConnection.VerifyExecutePermission();
_isolationLevel = iso;
_connection = con;
if (internalTransaction == null) {
_internalTransaction = new SqlInternalTransaction(internalConnection, TransactionType.LocalFromAPI, this);
}
else {
Debug.Assert(internalConnection.CurrentTransaction == internalTransaction, "Unexpected Parser.CurrentTransaction state!");
_internalTransaction = internalTransaction;
_internalTransaction.InitParent(this);
}
}
开发者ID:uQr,项目名称:referencesource,代码行数:16,代码来源:SqlTransaction.cs
示例3: AutomaticEnlistment
internal void AutomaticEnlistment()
{
Transaction currentTransaction = ADP.GetCurrentTransaction();
Transaction contextTransaction = this._smiContext.ContextTransaction;
long contextTransactionId = this._smiContext.ContextTransactionId;
if (Bid.AdvancedOn)
{
Bid.Trace("<sc.SqlInternalConnectionSmi.AutomaticEnlistment|ADV> %d#, contextTransactionId=0x%I64x, contextTransaction=%d#, currentSystemTransaction=%d#.\n", base.ObjectID, contextTransactionId, (null != contextTransaction) ? contextTransaction.GetHashCode() : 0, (null != currentTransaction) ? currentTransaction.GetHashCode() : 0);
}
if (0L != contextTransactionId)
{
if ((null != currentTransaction) && (contextTransaction != currentTransaction))
{
throw SQL.NestedTransactionScopesNotSupported();
}
if (Bid.AdvancedOn)
{
Bid.Trace("<sc.SqlInternalConnectionSmi.AutomaticEnlistment|ADV> %d#, using context transaction with transactionId=0x%I64x\n", base.ObjectID, contextTransactionId);
}
this._currentTransaction = new SqlInternalTransaction(this, TransactionType.Context, null, contextTransactionId);
this.ContextTransaction = contextTransaction;
}
else if (null == currentTransaction)
{
this._currentTransaction = null;
if (Bid.AdvancedOn)
{
Bid.Trace("<sc.SqlInternalConnectionSmi.AutomaticEnlistment|ADV> %d#, no transaction.\n", base.ObjectID);
}
}
else
{
if (Bid.AdvancedOn)
{
Bid.Trace("<sc.SqlInternalConnectionSmi.AutomaticEnlistment|ADV> %d#, using current System.Transaction.\n", base.ObjectID);
}
base.Enlist(currentTransaction);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:39,代码来源:SqlInternalConnectionSmi.cs
示例4: Initialize
public void Initialize()
{
SqlInternalConnection innerConnection = this._connection;
SqlConnection connection = innerConnection.Connection;
Bid.Trace("<sc.SqlDelegatedTransaction.Initialize|RES|CPOOL> %d#, Connection %d#, delegating transaction.\n", this.ObjectID, innerConnection.ObjectID);
RuntimeHelpers.PrepareConstrainedRegions();
try
{
if (innerConnection.IsEnlistedInTransaction)
{
Bid.Trace("<sc.SqlDelegatedTransaction.Initialize|RES|CPOOL> %d#, Connection %d#, was enlisted, now defecting.\n", this.ObjectID, innerConnection.ObjectID);
innerConnection.EnlistNull();
}
this._internalTransaction = new SqlInternalTransaction(innerConnection, TransactionType.Delegated, null);
innerConnection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Begin, null, this._isolationLevel, this._internalTransaction, true);
if (innerConnection.CurrentTransaction == null)
{
innerConnection.DoomThisConnection();
throw ADP.InternalError(ADP.InternalErrorCode.UnknownTransactionFailure);
}
this._active = true;
}
catch (OutOfMemoryException exception3)
{
connection.Abort(exception3);
throw;
}
catch (StackOverflowException exception2)
{
connection.Abort(exception2);
throw;
}
catch (ThreadAbortException exception)
{
connection.Abort(exception);
throw;
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:38,代码来源:SqlDelegatedTransaction.cs
示例5: WriteMarsHeaderData
// Write mars header data, not including the mars header length
private void WriteMarsHeaderData(TdsParserStateObject stateObj, SqlInternalTransaction transaction)
{
// Function to send over additional payload header data for Yukon and beyond only.
// These are not necessary - can have local started in distributed.
// Debug.Assert(!(null != sqlTransaction && null != distributedTransaction), "Error to have local (api started) and distributed transaction at the same time!");
// Debug.Assert(!(null != _userStartedLocalTransaction && null != distributedTransaction), "Error to have local (started outside of the api) and distributed transaction at the same time!");
// We may need to update the mars header length if mars header is changed in the future
WriteShort(TdsEnums.HEADERTYPE_MARS, stateObj);
if (null != transaction && SqlInternalTransaction.NullTransactionId != transaction.TransactionId)
{
WriteLong(transaction.TransactionId, stateObj);
WriteInt(stateObj.IncrementAndObtainOpenResultCount(transaction), stateObj);
}
else
{
WriteLong(SqlInternalTransaction.NullTransactionId, stateObj);
WriteInt(stateObj.IncrementAndObtainOpenResultCount(null), stateObj);
}
}
开发者ID:nnyamhon,项目名称:corefx,代码行数:24,代码来源:TdsParser.cs
示例6: TryRun
//.........这里部分代码省略.........
{
// ENVCHANGE must be processed synchronously (since it can modify the state of many objects)
stateObj._syncOverAsync = true;
SqlEnvChange[] env;
if (!TryProcessEnvChange(tokenLength, stateObj, out env))
{
return false;
}
for (int ii = 0; ii < env.Length; ii++)
{
if (env[ii] != null && !this.Connection.IgnoreEnvChange)
{
switch (env[ii].type)
{
case TdsEnums.ENV_BEGINTRAN:
// When we get notification from the server of a new
// transaction, we move any pending transaction over to
// the current transaction, then we store the token in it.
// if there isn't a pending transaction, then it's either
// a TSQL transaction or a distributed transaction.
Debug.Assert(null == _currentTransaction, "non-null current transaction with an ENV Change");
_currentTransaction = _pendingTransaction;
_pendingTransaction = null;
if (null != _currentTransaction)
{
_currentTransaction.TransactionId = env[ii].newLongValue; // this is defined as a ULongLong in the server and in the TDS Spec.
}
else
{
TransactionType transactionType = TransactionType.LocalFromTSQL;
_currentTransaction = new SqlInternalTransaction(_connHandler, transactionType, null, env[ii].newLongValue);
}
if (null != _statistics && !_statisticsIsInTransaction)
{
_statistics.SafeIncrement(ref _statistics._transactions);
}
_statisticsIsInTransaction = true;
break;
case TdsEnums.ENV_COMMITTRAN:
// SQLHOT 483
// Must clear the retain id if the server-side transaction ends by anything other
// than rollback.
goto case TdsEnums.ENV_ROLLBACKTRAN;
case TdsEnums.ENV_ROLLBACKTRAN:
// When we get notification of a completed transaction
// we null out the current transaction.
if (null != _currentTransaction)
{
#if DEBUG
// Check null for case where Begin and Rollback obtained in the same message.
if (SqlInternalTransaction.NullTransactionId != _currentTransaction.TransactionId)
{
Debug.Assert(_currentTransaction.TransactionId != env[ii].newLongValue, "transaction id's are not equal!");
}
#endif
if (TdsEnums.ENV_COMMITTRAN == env[ii].type)
{
_currentTransaction.Completed(TransactionState.Committed);
}
else if (TdsEnums.ENV_ROLLBACKTRAN == env[ii].type)
{
// Hold onto transaction id if distributed tran is rolled back. This must
开发者ID:nnyamhon,项目名称:corefx,代码行数:67,代码来源:TdsParser.cs
示例7: ExecuteTransactionPreYukon
// This function will not handle idle connection resiliency, as older servers will not support it
internal void ExecuteTransactionPreYukon(
TransactionRequest transactionRequest,
string transactionName,
IsolationLevel iso,
SqlInternalTransaction internalTransaction) {
StringBuilder sqlBatch = new StringBuilder();
switch (iso) {
case IsolationLevel.Unspecified:
break;
case IsolationLevel.ReadCommitted:
sqlBatch.Append(TdsEnums.TRANS_READ_COMMITTED);
sqlBatch.Append(";");
break;
case IsolationLevel.ReadUncommitted:
sqlBatch.Append(TdsEnums.TRANS_READ_UNCOMMITTED);
sqlBatch.Append(";");
break;
case IsolationLevel.RepeatableRead:
sqlBatch.Append(TdsEnums.TRANS_REPEATABLE_READ);
sqlBatch.Append(";");
break;
case IsolationLevel.Serializable:
sqlBatch.Append(TdsEnums.TRANS_SERIALIZABLE);
sqlBatch.Append(";");
break;
case IsolationLevel.Snapshot:
throw SQL.SnapshotNotSupported(IsolationLevel.Snapshot);
case IsolationLevel.Chaos:
throw SQL.NotSupportedIsolationLevel(iso);
default:
throw ADP.InvalidIsolationLevel(iso);
}
if (!ADP.IsEmpty(transactionName)) {
transactionName = " " + SqlConnection.FixupDatabaseTransactionName(transactionName);
}
switch (transactionRequest) {
case TransactionRequest.Begin:
sqlBatch.Append(TdsEnums.TRANS_BEGIN);
sqlBatch.Append(transactionName);
break;
case TransactionRequest.Promote:
Debug.Assert(false, "Promote called with transaction name or on pre-Yukon!");
break;
case TransactionRequest.Commit:
sqlBatch.Append(TdsEnums.TRANS_COMMIT);
sqlBatch.Append(transactionName);
break;
case TransactionRequest.Rollback:
sqlBatch.Append(TdsEnums.TRANS_ROLLBACK);
sqlBatch.Append(transactionName);
break;
case TransactionRequest.IfRollback:
sqlBatch.Append(TdsEnums.TRANS_IF_ROLLBACK);
sqlBatch.Append(transactionName);
break;
case TransactionRequest.Save:
sqlBatch.Append(TdsEnums.TRANS_SAVE);
sqlBatch.Append(transactionName);
break;
default:
Debug.Assert(false, "Unknown transaction type");
break;
}
Threading.Tasks.Task executeTask = _parser.TdsExecuteSQLBatch(sqlBatch.ToString(), ConnectionOptions.ConnectTimeout, null, _parser._physicalStateObj, sync: true);
Debug.Assert(executeTask == null, "Shouldn't get a task when doing sync writes");
_parser.Run(RunBehavior.UntilDone, null, null, null, _parser._physicalStateObj);
// Prior to Yukon, we didn't have any transaction tokens to manage,
// or any feedback to know when one was created, so we just presume
// that successful execution of the request caused the transaction
// to be created, and we set that on the parser.
if (TransactionRequest.Begin == transactionRequest) {
Debug.Assert(null != internalTransaction, "Begin Transaction request without internal transaction");
_parser.CurrentTransaction = internalTransaction;
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:83,代码来源:SqlInternalConnectionTds.cs
示例8: DisconnectTransaction
////////////////////////////////////////////////////////////////////////////////////////
// LOCAL TRANSACTION METHODS
////////////////////////////////////////////////////////////////////////////////////////
override internal void DisconnectTransaction(SqlInternalTransaction internalTransaction) {
TdsParser parser = Parser;
if (null != parser) {
parser.DisconnectTransaction(internalTransaction);
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:11,代码来源:SqlInternalConnectionTds.cs
示例9: IncrementAndObtainOpenResultCount
internal Int32 IncrementAndObtainOpenResultCount(SqlInternalTransaction transaction)
{
_hasOpenResult = true;
if (transaction == null)
{
// If we are not passed a transaction, we are not executing under a transaction
// and thus we should increment the global connection result count.
return _parser.IncrementNonTransactedOpenResultCount();
}
else
{
// If we are passed a transaction, we are executing under a transaction
// and thus we should increment the transaction's result count.
_executedUnderTransaction = transaction;
return transaction.IncrementAndObtainOpenResultCount();
}
}
开发者ID:nnyamhon,项目名称:corefx,代码行数:18,代码来源:TdsParserStateObject.cs
示例10: ExecuteTransaction
internal abstract void ExecuteTransaction(TransactionRequest transactionRequest, string name, System.Data.IsolationLevel iso, SqlInternalTransaction internalTransaction, bool isDelegateControlRequest);
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:1,代码来源:SqlInternalConnection.cs
示例11: ExecuteTransactionYukon
internal void ExecuteTransactionYukon(
TransactionRequest transactionRequest,
string transactionName,
IsolationLevel iso,
SqlInternalTransaction internalTransaction
)
{
TdsEnums.TransactionManagerRequestType requestType = TdsEnums.TransactionManagerRequestType.Begin;
TdsEnums.TransactionManagerIsolationLevel isoLevel = TdsEnums.TransactionManagerIsolationLevel.ReadCommitted;
switch (iso)
{
case IsolationLevel.Unspecified:
isoLevel = TdsEnums.TransactionManagerIsolationLevel.Unspecified;
break;
case IsolationLevel.ReadCommitted:
isoLevel = TdsEnums.TransactionManagerIsolationLevel.ReadCommitted;
break;
case IsolationLevel.ReadUncommitted:
isoLevel = TdsEnums.TransactionManagerIsolationLevel.ReadUncommitted;
break;
case IsolationLevel.RepeatableRead:
isoLevel = TdsEnums.TransactionManagerIsolationLevel.RepeatableRead;
break;
case IsolationLevel.Serializable:
isoLevel = TdsEnums.TransactionManagerIsolationLevel.Serializable;
break;
case IsolationLevel.Snapshot:
isoLevel = TdsEnums.TransactionManagerIsolationLevel.Snapshot;
break;
case IsolationLevel.Chaos:
throw SQL.NotSupportedIsolationLevel(iso);
default:
throw ADP.InvalidIsolationLevel(iso);
}
TdsParserStateObject stateObj = _parser._physicalStateObj;
TdsParser parser = _parser;
bool mustPutSession = false;
bool releaseConnectionLock = false;
Debug.Assert(!ThreadHasParserLockForClose || _parserLock.ThreadMayHaveLock(), "Thread claims to have parser lock, but lock is not taken");
if (!ThreadHasParserLockForClose)
{
_parserLock.Wait(canReleaseFromAnyThread: false);
ThreadHasParserLockForClose = true; // In case of error, let the connection know that we already own the parser lock
releaseConnectionLock = true;
}
try
{
switch (transactionRequest)
{
case TransactionRequest.Begin:
requestType = TdsEnums.TransactionManagerRequestType.Begin;
break;
case TransactionRequest.Commit:
requestType = TdsEnums.TransactionManagerRequestType.Commit;
break;
case TransactionRequest.IfRollback:
// Map IfRollback to Rollback since with Yukon and beyond we should never need
// the if since the server will inform us when transactions have completed
// as a result of an error on the server.
case TransactionRequest.Rollback:
requestType = TdsEnums.TransactionManagerRequestType.Rollback;
break;
case TransactionRequest.Save:
requestType = TdsEnums.TransactionManagerRequestType.Save;
break;
default:
Debug.Assert(false, "Unknown transaction type");
break;
}
// only restore if connection lock has been taken within the function
if (internalTransaction != null && internalTransaction.RestoreBrokenConnection && releaseConnectionLock)
{
Task reconnectTask = internalTransaction.Parent.Connection.ValidateAndReconnect(() =>
{
ThreadHasParserLockForClose = false;
_parserLock.Release();
releaseConnectionLock = false;
}, 0);
if (reconnectTask != null)
{
AsyncHelper.WaitForCompletion(reconnectTask, 0); // there is no specific timeout for BeginTransaction, uses ConnectTimeout
internalTransaction.ConnectionHasBeenRestored = true;
return;
}
}
// _parser may be nulled out during TdsExecuteTrannsactionManagerRequest.
// Only use local variable after this call.
_parser.TdsExecuteTransactionManagerRequest(null, requestType, transactionName, isoLevel,
ConnectionOptions.ConnectTimeout, internalTransaction, stateObj
);
}
finally
//.........这里部分代码省略.........
开发者ID:er0dr1guez,项目名称:corefx,代码行数:101,代码来源:SqlInternalConnectionTds.cs
示例12: ExecuteTransactionYukon
internal void ExecuteTransactionYukon(
TransactionRequest transactionRequest,
string transactionName,
IsolationLevel iso,
SqlInternalTransaction internalTransaction,
bool isDelegateControlRequest) {
TdsEnums.TransactionManagerRequestType requestType = TdsEnums.TransactionManagerRequestType.Begin;
TdsEnums.TransactionManagerIsolationLevel isoLevel = TdsEnums.TransactionManagerIsolationLevel.ReadCommitted;
switch (iso) {
case IsolationLevel.Unspecified:
isoLevel = TdsEnums.TransactionManagerIsolationLevel.Unspecified;
break;
case IsolationLevel.ReadCommitted:
isoLevel = TdsEnums.TransactionManagerIsolationLevel.ReadCommitted;
break;
case IsolationLevel.ReadUncommitted:
isoLevel = TdsEnums.TransactionManagerIsolationLevel.ReadUncommitted;
break;
case IsolationLevel.RepeatableRead:
isoLevel = TdsEnums.TransactionManagerIsolationLevel.RepeatableRead;
break;
case IsolationLevel.Serializable:
isoLevel = TdsEnums.TransactionManagerIsolationLevel.Serializable;
break;
case IsolationLevel.Snapshot:
isoLevel = TdsEnums.TransactionManagerIsolationLevel.Snapshot;
break;
case IsolationLevel.Chaos:
throw SQL.NotSupportedIsolationLevel(iso);
default:
throw ADP.InvalidIsolationLevel(iso);
}
TdsParserStateObject stateObj = _parser._physicalStateObj;
TdsParser parser = _parser;
bool mustPutSession = false;
bool releaseConnectionLock = false;
Debug.Assert(!ThreadHasParserLockForClose || _parserLock.ThreadMayHaveLock(), "Thread claims to have parser lock, but lock is not taken");
if (!ThreadHasParserLockForClose) {
_parserLock.Wait(canReleaseFromAnyThread:false);
ThreadHasParserLockForClose = true; // In case of error, let the connection know that we already own the parser lock
releaseConnectionLock = true;
}
try {
switch (transactionRequest) {
case TransactionRequest.Begin:
requestType = TdsEnums.TransactionManagerRequestType.Begin;
break;
case TransactionRequest.Promote:
requestType = TdsEnums.TransactionManagerRequestType.Promote;
break;
case TransactionRequest.Commit:
requestType = TdsEnums.TransactionManagerRequestType.Commit;
break;
case TransactionRequest.IfRollback:
// Map IfRollback to Rollback since with Yukon and beyond we should never need
// the if since the server will inform us when transactions have completed
// as a result of an error on the server.
case TransactionRequest.Rollback:
requestType = TdsEnums.TransactionManagerRequestType.Rollback;
break;
case TransactionRequest.Save:
requestType = TdsEnums.TransactionManagerRequestType.Save;
break;
default:
Debug.Assert(false, "Unknown transaction type");
break;
}
// only restore if connection lock has been taken within the function
if (internalTransaction != null && internalTransaction.RestoreBrokenConnection && releaseConnectionLock) {
Task reconnectTask = internalTransaction.Parent.Connection.ValidateAndReconnect(() => {
ThreadHasParserLockForClose = false;
_parserLock.Release();
releaseConnectionLock = false;
}, 0);
if (reconnectTask != null) {
AsyncHelper.WaitForCompletion(reconnectTask, 0); // there is no specific timeout for BeginTransaction, uses ConnectTimeout
internalTransaction.ConnectionHasBeenRestored = true;
return;
}
}
// SQLBUDT #20010853 - Promote, Commit and Rollback requests for
// delegated transactions often happen while there is an open result
// set, so we need to handle them by using a different MARS session,
// otherwise we'll write on the physical state objects while someone
// else is using it. When we don't have MARS enabled, we need to
// lock the physical state object to syncronize it's use at least
// until we increment the open results count. Once it's been
// incremented the delegated transaction requests will fail, so they
// won't stomp on anything.
//
// We need to keep this lock through the duration of the TM reqeuest
// so that we won't hijack a different request's data stream and a
// different request won't hijack ours, so we have a lock here on
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:SqlInternalConnectionTds.cs
示例13: ExecuteTransaction
override internal void ExecuteTransaction(TransactionRequest transactionRequest, string name, IsolationLevel iso, SqlInternalTransaction internalTransaction, bool isDelegateControlRequest) {
if (IsConnectionDoomed) { // doomed means we can't do anything else...
if (transactionRequest == TransactionRequest.Rollback
|| transactionRequest == TransactionRequest.IfRollback) {
return;
}
throw SQL.ConnectionDoomed();
}
if (transactionRequest == TransactionRequest.Commit
|| transactionRequest == TransactionRequest.Rollback
|| transactionRequest == TransactionRequest.IfRollback) {
if (!Parser.MARSOn && Parser._physicalStateObj.BcpLock) {
throw SQL.ConnectionLockedForBcpEvent();
}
}
string transactionName = (null == name) ? String.Empty : name;
if (!_parser.IsYukonOrNewer) {
ExecuteTransactionPreYukon(transactionRequest, transactionName, iso, internalTransaction);
}
else {
ExecuteTransactionYukon(transactionRequest, transactionName, iso, internalTransaction, isDelegateControlRequest);
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:26,代码来源:SqlInternalConnectionTds.cs
示例14: Initialize
public void Initialize() {
// if we get here, then we know for certain that we're the delegated
// transaction.
SqlInternalConnection connection = _connection;
SqlConnection usersConnection = connection.Connection;
Bid.Trace("<sc.SqlDelegatedTransaction.Initialize|RES|CPOOL> %d#, Connection %d#, delegating transaction.\n", ObjectID, connection.ObjectID);
RuntimeHelpers.PrepareConstrainedRegions();
try {
#if DEBUG
TdsParser.ReliabilitySection tdsReliabilitySection = new TdsParser.ReliabilitySection();
RuntimeHelpers.PrepareConstrainedRegions();
try {
tdsReliabilitySection.Start();
#else
{
#endif //DEBUG
if (connection.IsEnlistedInTransaction) { // defect first
Bid.Trace("<sc.SqlDelegatedTransaction.Initialize|RES|CPOOL> %d#, Connection %d#, was enlisted, now defecting.\n", ObjectID, connection.ObjectID);
connection.EnlistNull();
}
_internalTransaction = new SqlInternalTransaction(connection, TransactionType.Delegated, null);
connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Begin, null, _isolationLevel, _internalTransaction, true);
// Handle case where ExecuteTran didn't produce a new transaction, but also didn't throw.
if (null == connection.CurrentTransaction)
{
connection.DoomThisConnection();
throw ADP.InternalError(ADP.InternalErrorCode.UnknownTransactionFailure);
}
_active = true;
}
#if DEBUG
finally {
tdsReliabilitySection.Stop();
}
#endif //DEBUG
}
catch (System.OutOfMemoryException e) {
usersConnection.Abort(e);
throw;
}
catch (System.StackOverflowException e) {
usersConnection.Abort(e);
throw;
}
catch (System.Threading.ThreadAbortException e) {
usersConnection.Abort(e);
throw;
}
}
开发者ID:uQr,项目名称:referencesource,代码行数:56,代码来源:SqlDelegatedTransaction.cs
示例15: DisconnectTransaction
internal void DisconnectTransaction(SqlInternalTransaction internalTransaction)
{
Debug.Assert(_currentTransaction != null && _currentTransaction == internalTransaction, "disconnecting different transaction");
if (_currentTransaction != null && _currentTransaction == internalTransaction)
{
_currentTransaction = null;
}
}
开发者ID:nnyamhon,项目名称:corefx,代码行数:9,代码来源:TdsParser.cs
示例16: DisconnectTransaction
abstract internal void DisconnectTransaction(SqlInternalTransaction internalTransaction);
开发者ID:er0dr1guez,项目名称:corefx,代码行数:1,代码来源:SqlInternalConnection.cs
示例17: TdsExecuteTransactionManagerRequest
internal SqlDataReader TdsExecuteTransactionManagerRequest(
byte[] buffer,
TdsEnums.TransactionManagerRequestType request,
string transactionName,
TdsEnums.TransactionManagerIsolationLevel isoLevel,
int timeout,
SqlInternalTransaction transaction,
TdsParserStateObject stateObj
)
{
Debug.Assert(this == stateObj.Parser, "different parsers");
if (TdsParserState.Broken == State || TdsParserState.Closed == State)
{
return null;
}
// Promote, Commit and Rollback requests for
// delegated transactions often happen while there is an open result
// set, so we need to handle them by using a different MARS session,
// otherwise we'll write on the physical state objects while someone
// else is using it. When we don't have MARS enabled, we need to
// lock the physical state object to syncronize it's use at least
// until we increment the open results count. Once it's been
// incremented the delegated transaction requests will fail, so they
// won't stomp on anything.
Debug.Assert(!_connHandler.ThreadHasParserLockForClose || _connHandler._parserLock.ThreadMayHaveLock(), "Thread claims to have parser lock, but lock is not taken");
bool callerHasConnectionLock = _connHandler.ThreadHasParserLockForClose; // If the thread already claims to have the parser lock, then we will let the caller handle releasing it
if (!callerHasConnectionLock)
{
_connHandler._parserLock.Wait(canReleaseFromAnyThread: false);
_connHandler.ThreadHasParserLockForClose = true;
}
// Capture _asyncWrite (after taking lock) to restore it afterwards
bool hadAsyncWrites = _asyncWrite;
try
{
// Temprarily disable async writes
_asyncWrite = false;
stateObj._outputMessageType = TdsEnums.MT_TRANS; // set message type
stateObj.SetTimeoutSeconds(timeout);
stateObj.SniContext = SniContext.Snix_Execute;
const int marsHeaderSize = 18; // 4 + 2 + 8 + 4
const int totalHeaderLength = 22; // 4 + 4 + 2 + 8 + 4
Debug.Assert(stateObj._outBytesUsed == stateObj._outputHeaderLen, "Output bytes written before total header length");
// Write total header length
WriteInt(totalHeaderLength, stateObj);
// Write mars header length
WriteInt(marsHeaderSize, stateObj);
WriteMarsHeaderData(stateObj, _currentTransaction);
WriteShort((short)request, stateObj); // write TransactionManager Request type
bool returnReader = false;
switch (request)
{
case TdsEnums.TransactionManagerRequestType.Begin:
Debug.Assert(null != transaction, "Should have specified an internalTransaction when doing a BeginTransaction request!");
// Only assign the passed in transaction if it is not equal to the current transaction.
// And, if it is not equal, the current actually should be null. Anything else
// is a unexpected state. The concern here is mainly for the mixed use of
// T-SQL and API transactions.
// Expected states:
// 1) _pendingTransaction = null, _currentTransaction = null, non null transaction
// passed in on BeginTransaction API call.
// 2) _currentTransaction != null, _pendingTransaction = null, non null transaction
// passed in but equivalent to _currentTransaction.
// #1 will occur on standard BeginTransactionAPI call. #2 should only occur if
// t-sql transaction started followed by a call to SqlConnection.BeginTransaction.
// Any other state is unknown.
if (_currentTransaction != transaction)
{
Debug.Assert(_currentTransaction == null || true == _fResetConnection, "We should not have a current Tx at this point");
PendingTransaction = transaction;
}
stateObj.WriteByte((byte)isoLevel);
stateObj.WriteByte((byte)(transactionName.Length * 2)); // Write number of bytes (unicode string).
WriteString(transactionName, stateObj);
break;
case TdsEnums.TransactionManagerRequestType.Commit:
Debug.Assert(transactionName.Length == 0, "Should not have a transaction name on Commit");
stateObj.WriteByte((byte)0); // No xact name
stateObj.WriteByte(0); // No flags
Debug.Assert(isoLevel == TdsEnums.TransactionManagerIsolationLevel.Unspecified, "Should not have isolation level other than unspecified on Commit!");
// WriteByte((byte) 0, stateObj); // IsolationLevel
//.........这里部分代码省略.........
开发者ID:nnyamhon,项目名称:corefx,代码行数:101,代码来源:TdsParser.cs
示例18: ExecuteTransaction
abstract internal void ExecuteTransaction(TransactionRequest transactionRequest, string name, IsolationLevel iso, SqlInternalTransaction internalTransaction);
开发者ID:er0dr1guez,项目名称:corefx,代码行数:1,代码来源:SqlInternalConnection.cs
示例19: IncrementAndObtainOpenResultCount
internal int IncrementAndObtainOpenResultCount(SqlInternalTrans
|
请发表评论