Skip to content
Merged
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 @@ -411,15 +411,9 @@
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ExtendedClrTypeCode.cs">
<Link>Microsoft\Data\SqlClient\Server\ExtendedClrTypeCode.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ITypedGetters.cs">
<Link>Microsoft\Data\SqlClient\Server\ITypedGetters.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ITypedGettersV3.cs">
<Link>Microsoft\Data\SqlClient\Server\ITypedGettersV3.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ITypedSetters.cs">
<Link>Microsoft\Data\SqlClient\Server\ITypedSetters.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ITypedSettersV3.cs">
<Link>Microsoft\Data\SqlClient\Server\ITypedSettersV3.cs</Link>
</Compile>
Expand All @@ -429,11 +423,8 @@
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\MetadataUtilsSmi.cs">
<Link>Microsoft\Data\SqlClient\Server\MetadataUtilsSmi.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiEventSink.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiEventSink_Default.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink_Default.Common.cs</Link>
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink_Default.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiGettersStream.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiGettersStream.cs</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,15 +522,9 @@
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ExtendedClrTypeCode.cs">
<Link>Microsoft\Data\SqlClient\Server\ExtendedClrTypeCode.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ITypedGetters.cs">
<Link>Microsoft\Data\SqlClient\Server\ITypedGetters.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ITypedGettersV3.cs">
<Link>Microsoft\Data\SqlClient\Server\ITypedGettersV3.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ITypedSetters.cs">
<Link>Microsoft\Data\SqlClient\Server\ITypedSetters.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ITypedSettersV3.cs">
<Link>Microsoft\Data\SqlClient\Server\ITypedSettersV3.cs</Link>
</Compile>
Expand All @@ -540,33 +534,12 @@
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\MetadataUtilsSmi.cs">
<Link>Microsoft\Data\SqlClient\Server\MetadataUtilsSmi.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiConnection.netfx.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiConnection.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiEventSink.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiEventSink_Default.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink_Default.Common.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiEventSink_Default.netfx.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink_Default.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiEventSink_DeferredProcessing.netfx.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink_DeferredProcessing.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiEventStream.netfx.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiEventStream.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiExecuteType.netfx.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiExecuteType.netfx.cs</Link>
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink_Default.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiGettersStream.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiGettersStream.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiLink.netfx.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiLink.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiMetaData.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiMetaData.cs</Link>
</Compile>
Expand All @@ -576,15 +549,9 @@
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiRecordBuffer.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiRecordBuffer.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiRequestExecutor.netfx.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiRequestExecutor.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiSettersStream.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiSettersStream.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiStream.netfx.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiStream.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiTypedGetterSetter.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiTypedGetterSetter.cs</Link>
</Compile>
Expand Down Expand Up @@ -615,9 +582,6 @@
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ValueUtilsSmi.cs">
<Link>Microsoft\Data\SqlClient\Server\ValueUtilsSmi.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ValueUtilsSmi.netfx.cs">
<Link>Microsoft\Data\SqlClient\Server\ValueUtilsSmi.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SqlSer.cs">
<Link>Microsoft\Data\SqlClient\Server\SqlSer.cs</Link>
</Compile>
Expand Down Expand Up @@ -953,11 +917,7 @@
<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\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\TdsParser.cs" />
<Compile Include="Microsoft\Data\SqlClient\TdsParser.netfx.cs" />
<Compile Include="Microsoft\Data\SqlClient\TdsParserStateObject.netfx.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,101 +420,6 @@ private CachedAsyncState cachedAsyncState
/// </summary>
internal bool CachingQueryMetadataPostponed { get; set; }

//
// Smi execution-specific stuff
//
sealed private class CommandEventSink : SmiEventSink_Default
{
private SqlCommand _command;

internal CommandEventSink(SqlCommand command) : base()
{
_command = command;
}

internal override void StatementCompleted(int rowsAffected)
{
SqlClientEventSource.Log.TryAdvancedTraceEvent("<sc.SqlCommand.CommandEventSink.StatementCompleted|ADV> {0}, rowsAffected={1}.", _command.ObjectID, rowsAffected);
_command.InternalRecordsAffected = rowsAffected;

// UNDONE: need to fire events back to user code, but this may be called
// while in a callback from the native server. Calling user code in
// this situation is BAAAAD, because the user code could call back to
// the server.
// _command.OnStatementCompleted( rowsAffected );
}

internal override void BatchCompleted()
{
SqlClientEventSource.Log.TryAdvancedTraceEvent("<sc.SqlCommand.CommandEventSink.BatchCompleted|ADV> {0}.", _command.ObjectID);
}

internal override void ParametersAvailable(SmiParameterMetaData[] metaData, ITypedGettersV3 parameterValues)
{
SqlClientEventSource.Log.TryAdvancedTraceEvent("<sc.SqlCommand.CommandEventSink.ParametersAvailable|ADV> {0} metaData.Length={1}.", _command.ObjectID, metaData?.Length);

if (SqlClientEventSource.Log.IsAdvancedTraceOn())
{
if (metaData != null)
{
for (int i = 0; i < metaData.Length; i++)
{
SqlClientEventSource.Log.AdvancedTraceEvent("<sc.SqlCommand.CommandEventSink.ParametersAvailable|ADV> {0}, metaData[{1}] is {2}{3}", _command.ObjectID, i, metaData[i].GetType(), metaData[i].TraceString());
}
}
}

Debug.Fail("NegotiatedSmiVersion will always throw (SmiContextFactory.Instance.NegotiatedSmiVersion >= SmiContextFactory.Sql2005Version)");
_command.OnParametersAvailableSmi(metaData, parameterValues);
}

internal override void ParameterAvailable(SmiParameterMetaData metaData, SmiTypedGetterSetter parameterValues, int ordinal)
{
if (SqlClientEventSource.Log.IsAdvancedTraceOn())
{
SqlClientEventSource.Log.AdvancedTraceEvent("<sc.SqlCommand.CommandEventSink.ParameterAvailable|ADV> {0}, metaData[{1}] is {2}{ 3}", _command.ObjectID, ordinal, metaData?.GetType(), metaData?.TraceString());
}

Debug.Fail("NegotiatedSmiVersion will always throw (SmiContextFactory.Instance.NegotiatedSmiVersion >= SmiContextFactory.Sql2008Version)");
_command.OnParameterAvailableSmi(metaData, parameterValues, ordinal);
}
}

private CommandEventSink _smiEventSink;
private SmiEventSink_DeferredProcessing _outParamEventSink;

private CommandEventSink EventSink
{
get
{
if (_smiEventSink == null)
{
_smiEventSink = new CommandEventSink(this);
}

_smiEventSink.Parent = InternalSmiConnection.CurrentEventSink;
return _smiEventSink;
}
}

private SmiEventSink_DeferredProcessing OutParamEventSink
{
get
{
if (_outParamEventSink == null)
{
_outParamEventSink = new SmiEventSink_DeferredProcessing(EventSink);
}
else
{
_outParamEventSink.Parent = EventSink;
}

return _outParamEventSink;
}
}


/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/ctor[@name="default"]/*'/>
public SqlCommand() : base()
{
Expand Down Expand Up @@ -655,14 +560,6 @@ protected override DbConnection DbConnection
}
}

private SqlInternalConnectionSmi InternalSmiConnection
{
get
{
return (SqlInternalConnectionSmi)_activeConnection.InnerConnection;
}
}

private SqlInternalConnectionTds InternalTdsConnection
{
get
Expand Down Expand Up @@ -6137,66 +6034,6 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
return;
}

internal void OnParametersAvailableSmi(SmiParameterMetaData[] paramMetaData, ITypedGettersV3 parameterValues)
{
Debug.Assert(paramMetaData != null);

for (int index = 0; index < paramMetaData.Length; index++)
{
OnParameterAvailableSmi(paramMetaData[index], parameterValues, index);
}
}

internal void OnParameterAvailableSmi(SmiParameterMetaData metaData, ITypedGettersV3 parameterValues, int ordinal)
{
if (ParameterDirection.Input != metaData.Direction)
{
string name = null;
if (ParameterDirection.ReturnValue != metaData.Direction)
{
name = metaData.Name;
}

SqlParameterCollection parameters = GetCurrentParameterCollection();
int count = GetParameterCount(parameters);
SqlParameter param = GetParameterForOutputValueExtraction(parameters, name, count);

if (param != null)
{
param.LocaleId = (int)metaData.LocaleId;
param.CompareInfo = metaData.CompareOptions;
SqlBuffer buffer = new SqlBuffer();
object result;
if (_activeConnection.Is2008OrNewer)
{
result = ValueUtilsSmi.GetOutputParameterV200Smi(
OutParamEventSink,
(SmiTypedGetterSetter)parameterValues,
ordinal,
metaData,
buffer);
}
else
{
result = ValueUtilsSmi.GetOutputParameterV3Smi(
OutParamEventSink,
parameterValues,
ordinal,
metaData,
buffer);
}
if (result != null)
{
param.Value = result;
}
else
{
param.SetSqlBuffer(buffer);
}
}
}
}

private SqlParameterCollection GetCurrentParameterCollection()
{
if (_batchRPCMode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1906,33 +1906,24 @@ private bool TryOpenInner(TaskCompletionSource<DbConnectionInternal> retry)
// GetBestEffortCleanup must happen AFTER OpenConnection to get the correct target.
bestEffortCleanupTarget = SqlInternalConnection.GetBestEffortCleanupTarget(this);

var tdsInnerConnection = (InnerConnection as SqlInternalConnectionTds);
if (tdsInnerConnection == null)
var tdsInnerConnection = (SqlInternalConnectionTds)InnerConnection;
Debug.Assert(tdsInnerConnection.Parser != null, "Where's the parser?");

if (!tdsInnerConnection.ConnectionOptions.Pooling)
{
// For non-pooled connections, we need to make sure that the finalizer does actually run to avoid leaking SNI handles
GC.ReRegisterForFinalize(this);
}

if (StatisticsEnabled)
{
// @TODO: This branch can't be called, because it'll automatically break. But I can't prove it isn't just yet....
SqlInternalConnectionSmi innerConnection = (InnerConnection as SqlInternalConnectionSmi);
innerConnection.AutomaticEnlistment();
_statistics._openTimestamp = ADP.TimerCurrent();
tdsInnerConnection.Parser.Statistics = _statistics;
}
else
{
Debug.Assert(tdsInnerConnection.Parser != null, "Where's the parser?");

if (!tdsInnerConnection.ConnectionOptions.Pooling)
{
// For non-pooled connections, we need to make sure that the finalizer does actually run to avoid leaking SNI handles
GC.ReRegisterForFinalize(this);
}

if (StatisticsEnabled)
{
_statistics._openTimestamp = ADP.TimerCurrent();
tdsInnerConnection.Parser.Statistics = _statistics;
}
else
{
tdsInnerConnection.Parser.Statistics = null;
_statistics = null; // in case of previous Open/Close/reset_CollectStats sequence
}
tdsInnerConnection.Parser.Statistics = null;
_statistics = null; // in case of previous Open/Close/reset_CollectStats sequence
}
}
catch (System.OutOfMemoryException e)
Expand Down
Loading
Loading