Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove SqlCommand code paths for context connections #2996

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1185,10 +1185,10 @@ private object CompleteExecuteScalar(SqlDataReader ds, bool returnLastResult)
return retResult;
}

private Task InternalExecuteNonQueryWithRetry(bool sendToPipe, int timeout, out bool usedCache, bool asyncWrite, bool inRetry, [CallerMemberName] string methodName = "")
private Task InternalExecuteNonQueryWithRetry(int timeout, out bool usedCache, bool asyncWrite, bool inRetry, [CallerMemberName] string methodName = "")
{
bool innerUsedCache = false;
Task result = RetryLogicProvider.Execute(this, () => InternalExecuteNonQuery(completion: null, sendToPipe, timeout, out innerUsedCache, asyncWrite, inRetry, methodName));
Task result = RetryLogicProvider.Execute(this, () => InternalExecuteNonQuery(completion: null, timeout, out innerUsedCache, asyncWrite, inRetry, methodName));
usedCache = innerUsedCache;
return result;
}
Expand All @@ -1214,11 +1214,11 @@ public override int ExecuteNonQuery()
WriteBeginExecuteEvent();
if (IsProviderRetriable)
{
InternalExecuteNonQueryWithRetry(sendToPipe: false, timeout: CommandTimeout, out _, asyncWrite: false, inRetry: false);
InternalExecuteNonQueryWithRetry(timeout: CommandTimeout, out _, asyncWrite: false, inRetry: false);
}
else
{
InternalExecuteNonQuery(completion: null, sendToPipe: false, timeout: CommandTimeout, out _);
InternalExecuteNonQuery(completion: null, timeout: CommandTimeout, out _);
}
success = true;
return _rowsAffected;
Expand Down Expand Up @@ -1283,7 +1283,7 @@ private IAsyncResult BeginExecuteNonQueryInternal(CommandBehavior behavior, Asyn
try
{
// InternalExecuteNonQuery already has reliability block, but if failure will not put stateObj back into pool.
Task execNQ = InternalExecuteNonQuery(localCompletion, false, timeout, out usedCache, asyncWrite, inRetry: inRetry, methodName: nameof(BeginExecuteNonQuery));
Task execNQ = InternalExecuteNonQuery(localCompletion, timeout, out usedCache, asyncWrite, inRetry: inRetry, methodName: nameof(BeginExecuteNonQuery));

if (execNQ != null)
{
Expand Down Expand Up @@ -1647,7 +1647,7 @@ private object InternalEndExecuteNonQuery(IAsyncResult asyncResult, bool isInter
return _rowsAffected;
}

private Task InternalExecuteNonQuery(TaskCompletionSource<object> completion, bool sendToPipe, int timeout, out bool usedCache, bool asyncWrite = false, bool inRetry = false, [CallerMemberName] string methodName = "")
private Task InternalExecuteNonQuery(TaskCompletionSource<object> completion, int timeout, out bool usedCache, bool asyncWrite = false, bool inRetry = false, [CallerMemberName] string methodName = "")
{
SqlClientEventSource.Log.TryTraceEvent("SqlCommand.InternalExecuteNonQuery | INFO | ObjectId {0}, Client Connection Id {1}, AsyncCommandInProgress={2}",
_activeConnection?.ObjectID, _activeConnection?.ClientConnectionId, _activeConnection?.AsyncCommandInProgress);
Expand All @@ -1670,10 +1670,8 @@ private Task InternalExecuteNonQuery(TaskCompletionSource<object> completion, bo

// Always Encrypted generally operates only on parameterized queries. However enclave based Always encrypted also supports unparameterized queries
// We skip this block for enclave based always encrypted so that we can make a call to SQL Server to get the encryption information
if (!ShouldUseEnclaveBasedWorkflow && !_batchRPCMode && (CommandType.Text == CommandType) && (0 == GetParameterCount(_parameters)))
if (!ShouldUseEnclaveBasedWorkflow && !_batchRPCMode && CommandType == CommandType.Text && GetParameterCount(_parameters) == 0)
{
Debug.Assert(!sendToPipe, "Trying to send non-context command to pipe");

if (statistics != null)
{
if (!IsDirty && IsPrepared)
Expand All @@ -1695,7 +1693,6 @@ private Task InternalExecuteNonQuery(TaskCompletionSource<object> completion, bo
else
{
// otherwise, use a full-fledged execute that can handle params and stored procs
Debug.Assert(!sendToPipe, "Trying to send non-context command to pipe");
SqlClientEventSource.Log.TryTraceEvent("SqlCommand.InternalExecuteNonQuery | INFO | Object Id {0}, RPC execute method name {1}, isAsync {2}, inRetry {3}", ObjectID, methodName, isAsync, inRetry);

SqlDataReader reader = RunExecuteReader(0, RunBehavior.UntilDone, false, completion, timeout, out task, out usedCache, asyncWrite, inRetry, methodName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,18 +830,13 @@
<Compile Include="Microsoft\Data\SqlClient\SqlBuffer.netfx.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlBulkCopy.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlClientPermission.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlClientWrapperSmiStream.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlClientWrapperSmiStreamChars.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlCommand.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlConnection.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlConnectionFactory.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlConnectionHelper.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlDataReader.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlDataReaderSmi.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlInternalConnectionSmi.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlInternalConnectionTds.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlSequentialStreamSmi.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlSequentialTextReaderSmi.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlTransaction.cs" />
<Compile Include="Microsoft\Data\SqlClient\TdsParser.cs" />
<Compile Include="Microsoft\Data\SqlClient\TdsParser.netfx.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ public SourceColumnMetadata(ValueMethod method, bool isSqlType, bool isDataFeed)

private object _rowSource;
private SqlDataReader _sqlDataReaderRowSource;
private bool _rowSourceIsSqlDataReaderSmi;
private DbDataReader _dbDataReaderRowSource;
private DataTable _dataTableSource;

Expand Down Expand Up @@ -1258,7 +1257,7 @@ private SourceColumnMetadata GetColumnMetadata(int ordinal)
}
}
// Check for data streams
else if ((_enableStreaming) && ((metadata.length == MAX_LENGTH) || metadata.metaType.SqlDbType == SqlDbTypeExtensions.Json) && (!_rowSourceIsSqlDataReaderSmi))
else if ((_enableStreaming) && ((metadata.length == MAX_LENGTH) || metadata.metaType.SqlDbType == SqlDbTypeExtensions.Json))
{
isSqlType = false;

Expand Down Expand Up @@ -1702,10 +1701,6 @@ public void WriteToServer(DbDataReader reader)
_dbDataReaderRowSource = reader;
_sqlDataReaderRowSource = reader as SqlDataReader;

if (_sqlDataReaderRowSource != null)
{
_rowSourceIsSqlDataReaderSmi = _sqlDataReaderRowSource is SqlDataReaderSmi;
}
_rowSourceType = ValueSourceType.DbDataReader;

WriteRowSourceToServerAsync(reader.FieldCount, CancellationToken.None); //It returns null since _isAsyncBulkCopy = false;
Expand Down Expand Up @@ -1738,10 +1733,6 @@ public void WriteToServer(IDataReader reader)
ResetWriteToServerGlobalVariables();
_rowSource = reader;
_sqlDataReaderRowSource = _rowSource as SqlDataReader;
if (_sqlDataReaderRowSource != null)
{
_rowSourceIsSqlDataReaderSmi = _sqlDataReaderRowSource is SqlDataReaderSmi;
}
_dbDataReaderRowSource = _rowSource as DbDataReader;
_rowSourceType = ValueSourceType.IDataReader;
WriteRowSourceToServerAsync(reader.FieldCount, CancellationToken.None); //It returns null since _isAsyncBulkCopy = false;
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading