diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
index af0db1e61f..c3b8693734 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -411,15 +411,9 @@
Microsoft\Data\SqlClient\Server\ExtendedClrTypeCode.cs
-
- Microsoft\Data\SqlClient\Server\ITypedGetters.cs
-
Microsoft\Data\SqlClient\Server\ITypedGettersV3.cs
-
- Microsoft\Data\SqlClient\Server\ITypedSetters.cs
-
Microsoft\Data\SqlClient\Server\ITypedSettersV3.cs
@@ -429,11 +423,8 @@
Microsoft\Data\SqlClient\Server\MetadataUtilsSmi.cs
-
- Microsoft\Data\SqlClient\Server\SmiEventSink.cs
-
- Microsoft\Data\SqlClient\Server\SmiEventSink_Default.Common.cs
+ Microsoft\Data\SqlClient\Server\SmiEventSink_Default.cs
Microsoft\Data\SqlClient\Server\SmiGettersStream.cs
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
index 1fb9fce27e..e0f690bdf2 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
@@ -522,15 +522,9 @@
Microsoft\Data\SqlClient\Server\ExtendedClrTypeCode.cs
-
- Microsoft\Data\SqlClient\Server\ITypedGetters.cs
-
Microsoft\Data\SqlClient\Server\ITypedGettersV3.cs
-
- Microsoft\Data\SqlClient\Server\ITypedSetters.cs
-
Microsoft\Data\SqlClient\Server\ITypedSettersV3.cs
@@ -540,33 +534,12 @@
Microsoft\Data\SqlClient\Server\MetadataUtilsSmi.cs
-
- Microsoft\Data\SqlClient\Server\SmiConnection.netfx.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiEventSink.cs
-
- Microsoft\Data\SqlClient\Server\SmiEventSink_Default.Common.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiEventSink_Default.netfx.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiEventSink_DeferredProcessing.netfx.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiEventStream.netfx.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiExecuteType.netfx.cs
+ Microsoft\Data\SqlClient\Server\SmiEventSink_Default.cs
Microsoft\Data\SqlClient\Server\SmiGettersStream.cs
-
- Microsoft\Data\SqlClient\Server\SmiLink.netfx.cs
-
Microsoft\Data\SqlClient\Server\SmiMetaData.cs
@@ -576,15 +549,9 @@
Microsoft\Data\SqlClient\Server\SmiRecordBuffer.cs
-
- Microsoft\Data\SqlClient\Server\SmiRequestExecutor.netfx.cs
-
Microsoft\Data\SqlClient\Server\SmiSettersStream.cs
-
- Microsoft\Data\SqlClient\Server\SmiStream.netfx.cs
-
Microsoft\Data\SqlClient\Server\SmiTypedGetterSetter.cs
@@ -615,9 +582,6 @@
Microsoft\Data\SqlClient\Server\ValueUtilsSmi.cs
-
- Microsoft\Data\SqlClient\Server\ValueUtilsSmi.netfx.cs
-
Microsoft\Data\SqlClient\Server\SqlSer.cs
@@ -953,11 +917,7 @@
-
-
-
-
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 a5851c023d..b40e3dbfa2 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
@@ -420,101 +420,6 @@ private CachedAsyncState cachedAsyncState
///
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(" {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(" {0}.", _command.ObjectID);
- }
-
- internal override void ParametersAvailable(SmiParameterMetaData[] metaData, ITypedGettersV3 parameterValues)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {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(" {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(" {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;
- }
- }
-
-
///
public SqlCommand() : base()
{
@@ -655,14 +560,6 @@ protected override DbConnection DbConnection
}
}
- private SqlInternalConnectionSmi InternalSmiConnection
- {
- get
- {
- return (SqlInternalConnectionSmi)_activeConnection.InnerConnection;
- }
- }
-
private SqlInternalConnectionTds InternalTdsConnection
{
get
@@ -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)
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs
index 9681a6a3ae..46800b4140 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs
@@ -1906,33 +1906,24 @@ private bool TryOpenInner(TaskCompletionSource 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)
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs
deleted file mode 100644
index 187ff89d17..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs
+++ /dev/null
@@ -1,1358 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Data;
-using System.Data.Common;
-using System.Data.SqlTypes;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.Runtime.CompilerServices;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Xml;
-using Microsoft.Data.Common;
-using Microsoft.Data.ProviderBase;
-using Microsoft.Data.SqlClient.Server;
-
-
-using Microsoft.Data.SqlTypes;
-
-namespace Microsoft.Data.SqlClient
-{
- // SqlServer provider's implementation of ISqlReader.
- // Supports ISqlReader and ISqlResultSet objects.
- //
- // User should never be able to create one of these themselves, nor subclass.
- // This is accomplished by having no public override constructors.
- internal sealed class SqlDataReaderSmi : SqlDataReader
- {
- //
- // IDBRecord properties
- //
- public override int FieldCount
- {
- get
- {
- ThrowIfClosed();
- return InternalFieldCount;
- }
- }
-
- public override int VisibleFieldCount
- {
- get
- {
- ThrowIfClosed();
-
- if (FNotInResults())
- {
- return 0;
- }
-
- return _visibleColumnCount;
- }
- }
-
- //
- // IDBRecord Metadata Methods
- //
- public override string GetName(int ordinal)
- {
- EnsureCanGetMetaData();
- return _currentMetaData[ordinal].Name;
- }
-
- public override string GetDataTypeName(int ordinal)
- {
- EnsureCanGetMetaData();
- SmiExtendedMetaData md = _currentMetaData[ordinal];
- if (SqlDbType.Udt == md.SqlDbType)
- {
- return md.TypeSpecificNamePart1 + "." + md.TypeSpecificNamePart2 + "." + md.TypeSpecificNamePart3;
- }
- else
- {
- return md.TypeName;
- }
- }
-
- public override Type GetFieldType(int ordinal)
- {
- EnsureCanGetMetaData();
- if (_currentMetaData[ordinal].SqlDbType == SqlDbType.Udt)
- {
- return _currentMetaData[ordinal].Type;
- }
- else
- {
- return MetaType.GetMetaTypeFromSqlDbType(_currentMetaData[ordinal].SqlDbType, _currentMetaData[ordinal].IsMultiValued).ClassType;
- }
- }
-
- override public Type GetProviderSpecificFieldType(int ordinal)
- {
- EnsureCanGetMetaData();
-
- if (SqlDbType.Udt == _currentMetaData[ordinal].SqlDbType)
- {
- return _currentMetaData[ordinal].Type;
- }
- else
- {
- return MetaType.GetMetaTypeFromSqlDbType(_currentMetaData[ordinal].SqlDbType, _currentMetaData[ordinal].IsMultiValued).SqlType;
- }
- }
-
- public override int Depth
- {
- get
- {
- ThrowIfClosed();
- return 0;
- }
- } // UNDONE: (alazela 10/14/2001) Multi-level reader not impl.
-
- public override object GetValue(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- SmiQueryMetaData metaData = _currentMetaData[ordinal];
- if (_currentConnection.Is2008OrNewer)
- {
- return ValueUtilsSmi.GetValue200(
- _readerEventSink,
- (SmiTypedGetterSetter)_currentColumnValuesV3,
- ordinal,
- metaData);
- }
- else
- {
- return ValueUtilsSmi.GetValue(_readerEventSink, _currentColumnValuesV3, ordinal, metaData);
- }
- }
-
- public override T GetFieldValue(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- SmiQueryMetaData metaData = _currentMetaData[ordinal];
-
- if (typeof(INullable).IsAssignableFrom(typeof(T)))
- {
- // If its a SQL Type or Nullable UDT
- if (_currentConnection.Is2008OrNewer)
- {
- return (T)ValueUtilsSmi.GetSqlValue200(
- _readerEventSink,
- (SmiTypedGetterSetter)_currentColumnValuesV3,
- ordinal,
- metaData);
- }
- else
- {
- return (T)ValueUtilsSmi.GetSqlValue(_readerEventSink, _currentColumnValuesV3, ordinal, metaData);
- }
- }
- else
- {
- // Otherwise It's a CLR or non-Nullable UDT
- if (_currentConnection.Is2008OrNewer)
- {
- return (T)ValueUtilsSmi.GetValue200(
- _readerEventSink,
- (SmiTypedGetterSetter)_currentColumnValuesV3,
- ordinal,
- metaData);
- }
- else
- {
- return (T)ValueUtilsSmi.GetValue(_readerEventSink, _currentColumnValuesV3, ordinal, metaData);
- }
- }
- }
-
- public override Task GetFieldValueAsync(int ordinal, CancellationToken cancellationToken)
- {
- // As per Async spec, Context Connections do not support async
- return ADP.CreatedTaskWithException(ADP.ExceptionWithStackTrace(SQL.NotAvailableOnContextConnection()));
- }
-
- override internal SqlBuffer.StorageType GetVariantInternalStorageType(int ordinal)
- {
- Debug.Assert(_currentColumnValuesV3 != null, "Attempting to get variant internal storage type without calling GetValue first");
- if (IsDBNull(ordinal))
- {
- return SqlBuffer.StorageType.Empty;
- }
-
- SmiMetaData valueMetaData = _currentColumnValuesV3.GetVariantType(_readerEventSink, ordinal);
- if (valueMetaData == null)
- {
- return SqlBuffer.StorageType.Empty;
- }
- else
- {
- return ValueUtilsSmi.SqlDbTypeToStorageType(valueMetaData.SqlDbType);
- }
- }
-
- public override int GetValues(object[] values)
- {
- EnsureCanGetCol(0);
- if (values == null)
- {
- throw ADP.ArgumentNull(nameof(values));
- }
-
- int copyLength = (values.Length < _visibleColumnCount) ? values.Length : _visibleColumnCount;
- for (int i = 0; i < copyLength; i++)
- {
- values[_indexMap[i]] = GetValue(i);
- }
- return copyLength;
- }
-
- public override int GetOrdinal(string name)
- {
- EnsureCanGetMetaData();
- if (_fieldNameLookup == null)
- {
- _fieldNameLookup = new FieldNameLookup((IDataReader)this, -1); // TODO: Need to support DefaultLCID for name comparisons
- }
- return _fieldNameLookup.GetOrdinal(name); // MDAC 71470
- }
-
- // Generic array access by column index (accesses column value)
- public override object this[int ordinal] => GetValue(ordinal);
-
- // Generic array access by column name (accesses column value)
- public override object this[string strName] => GetValue(GetOrdinal(strName));
-
- //
- // IDataRecord Data Access methods
- //
- public override bool IsDBNull(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.IsDBNull(_readerEventSink, _currentColumnValuesV3, ordinal);
- }
-
- public override Task IsDBNullAsync(int ordinal, CancellationToken cancellationToken)
- {
- // As per Async spec, Context Connections do not support async
- return ADP.CreatedTaskWithException(ADP.ExceptionWithStackTrace(SQL.NotAvailableOnContextConnection()));
- }
-
- public override bool GetBoolean(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetBoolean(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override byte GetByte(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetByte(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override long GetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetBytes(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal], fieldOffset, buffer, bufferOffset, length, true);
- }
-
- // XmlReader support code calls this method.
- internal override long GetBytesInternal(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetBytesInternal(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal], fieldOffset, buffer, bufferOffset, length, false);
- }
-
- public override char GetChar(int ordinal) => throw ADP.NotSupported();
-
- public override long GetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
- {
- EnsureCanGetCol(ordinal);
- SmiExtendedMetaData metaData = _currentMetaData[ordinal];
- if (IsCommandBehavior(CommandBehavior.SequentialAccess))
- {
- if (metaData.SqlDbType == SqlDbType.Xml)
- {
- return GetStreamingXmlChars(ordinal, fieldOffset, buffer, bufferOffset, length);
- }
- }
- return ValueUtilsSmi.GetChars(_readerEventSink, _currentColumnValuesV3, ordinal, metaData, fieldOffset, buffer, bufferOffset, length);
- }
-
- public override Guid GetGuid(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetGuid(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override short GetInt16(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetInt16(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override int GetInt32(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetInt32(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override long GetInt64(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetInt64(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override float GetFloat(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSingle(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override double GetDouble(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetDouble(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override string GetString(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetString(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override decimal GetDecimal(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetDecimal(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override DateTime GetDateTime(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetDateTime(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- //
- // IDataReader properties
- //
- // Logically closed test. I.e. is this object closed as far as external access is concerned?
- public override bool IsClosed => IsReallyClosed();
-
- public override int RecordsAffected => Command.InternalRecordsAffected;
-
- //
- // IDataReader methods
- //
- internal override void CloseReaderFromConnection()
- {
- // Context Connections do not support async - so there is no threading issues with closing from the connection
- CloseInternal(closeConnection: false);
- }
-
- public override void Close()
- {
- // Connection should be open at this point, so we can do multiple checks of HasEvents, and we may need to close the connection afterwards
- CloseInternal(closeConnection: IsCommandBehavior(CommandBehavior.CloseConnection));
- }
-
- private void CloseInternal(bool closeConnection)
- {
- using (TryEventScope.Create(" {0}", ObjectID))
- {
- bool processFinallyBlock = true;
- try
- {
- if (!IsClosed)
- {
- _hasRows = false;
-
- // Process the remaining events. This makes sure that environment changes are applied and any errors are picked up.
- while (_eventStream.HasEvents)
- {
- _eventStream.ProcessEvent(_readerEventSink);
- _readerEventSink.ProcessMessagesAndThrow(true);
- }
-
- // Close the request executor
- _requestExecutor.Close(_readerEventSink);
- _readerEventSink.ProcessMessagesAndThrow(true);
- }
- }
- catch (Exception e)
- {
- processFinallyBlock = ADP.IsCatchableExceptionType(e);
- throw;
- }
- finally
- {
- if (processFinallyBlock)
- {
- _isOpen = false;
-
- if ((closeConnection) && (Connection != null))
- {
- Connection.Close();
- }
- }
- }
- }
- }
-
- // Move to the next resultset
- public override unsafe bool NextResult()
- {
- ThrowIfClosed();
-
- bool hasAnotherResult = InternalNextResult(false);
-
- return hasAnotherResult;
- }
-
- public override Task NextResultAsync(CancellationToken cancellationToken)
- {
- // Async not supported on Context Connections
- return ADP.CreatedTaskWithException(ADP.ExceptionWithStackTrace(SQL.NotAvailableOnContextConnection()));
- }
-
- internal unsafe bool InternalNextResult(bool ignoreNonFatalMessages)
- {
- long scopeID = SqlClientEventSource.Log.TryAdvancedScopeEnterEvent(" {0}", ObjectID);
- try
- {
- _hasRows = false;
-
- if (PositionState.AfterResults != _currentPosition)
- {
- // Consume any remaning rows in the current result.
-
- while (InternalRead(ignoreNonFatalMessages))
- {
- // This space intentionally left blank
- }
-
- // reset resultset metadata - it will be created again if there is a pending resultset
- ResetResultSet();
-
- // Process the events until metadata is found or all of the
- // available events have been consumed. If there is another
- // result, the metadata for it will be available after the last
- // read on the prior result.
-
- while (_currentMetaData == null && _eventStream.HasEvents)
- {
- _eventStream.ProcessEvent(_readerEventSink);
- _readerEventSink.ProcessMessagesAndThrow(ignoreNonFatalMessages);
- }
- }
-
- return PositionState.AfterResults != _currentPosition;
- }
- finally
- {
- SqlClientEventSource.Log.TryAdvanceScopeLeave(scopeID);
- }
- }
-
- public override bool Read()
- {
- ThrowIfClosed();
- bool hasAnotherRow = InternalRead(false);
-
- return hasAnotherRow;
- }
-
- public override Task ReadAsync(CancellationToken cancellationToken)
- {
- // Async not supported on Context Connections
- return ADP.CreatedTaskWithException(ADP.ExceptionWithStackTrace(SQL.NotAvailableOnContextConnection()));
- }
-
- internal unsafe bool InternalRead(bool ignoreNonFatalErrors)
- {
- long scopeID = SqlClientEventSource.Log.TryAdvancedScopeEnterEvent(" {0}", ObjectID);
- try
- {
- // Don't move unless currently in results.
- if (FInResults())
- {
-
- // Set current row to null so we can see if we get a new one
- _currentColumnValues = null;
- _currentColumnValuesV3 = null;
-
- // Reset blobs
- if (_currentStream != null)
- {
- _currentStream.SetClosed();
- _currentStream = null;
- }
- if (_currentTextReader != null)
- {
- _currentTextReader.SetClosed();
- _currentTextReader = null;
- }
-
- // NOTE: SQLBUDT #386118 -- may indicate that we want to break this loop when we get a MessagePosted callback, but we can't prove that.
- while (_currentColumnValues == null && // Did we find a row?
- _currentColumnValuesV3 == null && // Did we find a V3 row?
- FInResults() && // Was the batch terminated due to a serious error?
- PositionState.AfterRows != _currentPosition && // Have we seen a statement completed event?
- _eventStream.HasEvents)
- { // Have we processed all events?
- _eventStream.ProcessEvent(_readerEventSink);
- _readerEventSink.ProcessMessagesAndThrow(ignoreNonFatalErrors);
- }
- }
-
- return PositionState.OnRow == _currentPosition;
- }
- finally
- {
- SqlClientEventSource.Log.TryAdvanceScopeLeave(scopeID);
- }
- }
-
- public override DataTable GetSchemaTable()
- {
- ThrowIfClosed();
-
- if (_schemaTable == null && FInResults())
- {
-
- DataTable schemaTable = new DataTable("SchemaTable")
- {
- Locale = System.Globalization.CultureInfo.InvariantCulture,
- MinimumCapacity = InternalFieldCount
- };
-
- DataColumn ColumnName = new DataColumn(SchemaTableColumn.ColumnName, typeof(string));
- DataColumn Ordinal = new DataColumn(SchemaTableColumn.ColumnOrdinal, typeof(int));
- DataColumn Size = new DataColumn(SchemaTableColumn.ColumnSize, typeof(int));
- DataColumn Precision = new DataColumn(SchemaTableColumn.NumericPrecision, typeof(short));
- DataColumn Scale = new DataColumn(SchemaTableColumn.NumericScale, typeof(short));
-
- DataColumn DataType = new DataColumn(SchemaTableColumn.DataType, typeof(Type));
- DataColumn ProviderSpecificDataType = new DataColumn(SchemaTableOptionalColumn.ProviderSpecificDataType, typeof(Type));
- DataColumn ProviderType = new DataColumn(SchemaTableColumn.ProviderType, typeof(int));
- DataColumn NonVersionedProviderType = new DataColumn(SchemaTableColumn.NonVersionedProviderType, typeof(int));
-
- DataColumn IsLong = new DataColumn(SchemaTableColumn.IsLong, typeof(bool));
- DataColumn AllowDBNull = new DataColumn(SchemaTableColumn.AllowDBNull, typeof(bool));
- DataColumn IsReadOnly = new DataColumn(SchemaTableOptionalColumn.IsReadOnly, typeof(bool));
- DataColumn IsRowVersion = new DataColumn(SchemaTableOptionalColumn.IsRowVersion, typeof(bool));
-
- DataColumn IsUnique = new DataColumn(SchemaTableColumn.IsUnique, typeof(bool));
- DataColumn IsKey = new DataColumn(SchemaTableColumn.IsKey, typeof(bool));
- DataColumn IsAutoIncrement = new DataColumn(SchemaTableOptionalColumn.IsAutoIncrement, typeof(bool));
- DataColumn IsHidden = new DataColumn(SchemaTableOptionalColumn.IsHidden, typeof(bool));
-
- DataColumn BaseCatalogName = new DataColumn(SchemaTableOptionalColumn.BaseCatalogName, typeof(string));
- DataColumn BaseSchemaName = new DataColumn(SchemaTableColumn.BaseSchemaName, typeof(string));
- DataColumn BaseTableName = new DataColumn(SchemaTableColumn.BaseTableName, typeof(string));
- DataColumn BaseColumnName = new DataColumn(SchemaTableColumn.BaseColumnName, typeof(string));
-
- // unique to SqlClient
- DataColumn BaseServerName = new DataColumn(SchemaTableOptionalColumn.BaseServerName, typeof(string));
- DataColumn IsAliased = new DataColumn(SchemaTableColumn.IsAliased, typeof(bool));
- DataColumn IsExpression = new DataColumn(SchemaTableColumn.IsExpression, typeof(bool));
- DataColumn IsIdentity = new DataColumn("IsIdentity", typeof(bool));
- // UDT specific. Holds UDT typename ONLY if the type of the column is UDT, otherwise the data type
- DataColumn DataTypeName = new DataColumn("DataTypeName", typeof(string));
- DataColumn UdtAssemblyQualifiedName = new DataColumn("UdtAssemblyQualifiedName", typeof(string));
- // Xml metadata specific
- DataColumn XmlSchemaCollectionDatabase = new DataColumn("XmlSchemaCollectionDatabase", typeof(string));
- DataColumn XmlSchemaCollectionOwningSchema = new DataColumn("XmlSchemaCollectionOwningSchema", typeof(string));
- DataColumn XmlSchemaCollectionName = new DataColumn("XmlSchemaCollectionName", typeof(string));
- // SparseColumnSet
- DataColumn IsColumnSet = new DataColumn("IsColumnSet", typeof(bool));
-
- Ordinal.DefaultValue = 0;
- IsLong.DefaultValue = false;
-
- DataColumnCollection columns = schemaTable.Columns;
-
- // must maintain order for backward compatibility
- columns.Add(ColumnName);
- columns.Add(Ordinal);
- columns.Add(Size);
- columns.Add(Precision);
- columns.Add(Scale);
- columns.Add(IsUnique);
- columns.Add(IsKey);
- columns.Add(BaseServerName);
- columns.Add(BaseCatalogName);
- columns.Add(BaseColumnName);
- columns.Add(BaseSchemaName);
- columns.Add(BaseTableName);
- columns.Add(DataType);
- columns.Add(AllowDBNull);
- columns.Add(ProviderType);
- columns.Add(IsAliased);
- columns.Add(IsExpression);
- columns.Add(IsIdentity);
- columns.Add(IsAutoIncrement);
- columns.Add(IsRowVersion);
- columns.Add(IsHidden);
- columns.Add(IsLong);
- columns.Add(IsReadOnly);
- columns.Add(ProviderSpecificDataType);
- columns.Add(DataTypeName);
- columns.Add(XmlSchemaCollectionDatabase);
- columns.Add(XmlSchemaCollectionOwningSchema);
- columns.Add(XmlSchemaCollectionName);
- columns.Add(UdtAssemblyQualifiedName);
- columns.Add(NonVersionedProviderType);
- columns.Add(IsColumnSet);
-
- for (int i = 0; i < InternalFieldCount; i++)
- {
- SmiQueryMetaData colMetaData = _currentMetaData[i];
-
- long maxLength = colMetaData.MaxLength;
-
- MetaType metaType = MetaType.GetMetaTypeFromSqlDbType(colMetaData.SqlDbType, colMetaData.IsMultiValued);
- if (SmiMetaData.UnlimitedMaxLengthIndicator == maxLength)
- {
- metaType = MetaType.GetMaxMetaTypeFromMetaType(metaType);
- maxLength = (metaType.IsSizeInCharacters && !metaType.IsPlp) ? (0x7fffffff / 2) : 0x7fffffff;
- }
-
- DataRow schemaRow = schemaTable.NewRow();
-
- // NOTE: there is an impedence mismatch here - the server always
- // treats numeric data as variable length and sends a maxLength
- // based upon the precision, whereas TDS always sends 17 for
- // the max length; rather than push this logic into the server,
- // I've elected to make a fixup here instead.
- if (SqlDbType.Decimal == colMetaData.SqlDbType)
- {
- // TODO: Consider moving this into SmiMetaData itself...
- maxLength = TdsEnums.MAX_NUMERIC_LEN; // SQLBUDT 339686
- }
- else if (SqlDbType.Variant == colMetaData.SqlDbType)
- {
- // TODO: Consider moving this into SmiMetaData itself...
- maxLength = 8009; // SQLBUDT 340726
- }
-
- schemaRow[ColumnName] = colMetaData.Name;
- schemaRow[Ordinal] = i;
- schemaRow[Size] = maxLength;
-
- schemaRow[ProviderType] = (int)colMetaData.SqlDbType; // SqlDbType
- schemaRow[NonVersionedProviderType] = (int)colMetaData.SqlDbType; // SqlDbType
-
- if (colMetaData.SqlDbType != SqlDbType.Udt)
- {
- schemaRow[DataType] = metaType.ClassType; // com+ type
- schemaRow[ProviderSpecificDataType] = metaType.SqlType;
- }
- else
- {
- schemaRow[UdtAssemblyQualifiedName] = colMetaData.Type.AssemblyQualifiedName;
- schemaRow[DataType] = colMetaData.Type;
- schemaRow[ProviderSpecificDataType] = colMetaData.Type;
- }
-
- // NOTE: there is also an impedence mismatch here - the server
- // has different ideas about what the precision value should be
- // than does the client bits. I tried fixing up the default
- // meta data values in SmiMetaData, however, it caused the
- // server suites to fall over dead. Rather than attempt to
- // bake it into the server, I'm fixing it up in the client.
- byte precision; // default for everything, except certain numeric types.
-
- // TODO: Consider moving this into SmiMetaData itself...
- switch (colMetaData.SqlDbType)
- {
- case SqlDbType.BigInt:
- case SqlDbType.DateTime:
- case SqlDbType.Decimal:
- case SqlDbType.Int:
- case SqlDbType.Money:
- case SqlDbType.SmallDateTime:
- case SqlDbType.SmallInt:
- case SqlDbType.SmallMoney:
- case SqlDbType.TinyInt:
- precision = colMetaData.Precision;
- break;
- case SqlDbType.Float:
- precision = 15;
- break;
- case SqlDbType.Real:
- precision = 7;
- break;
- default:
- precision = 0xff; // everything else is unknown;
- break;
- }
-
- schemaRow[Precision] = precision;
-
- // TODO: Consider moving this to a utitlity class if we end up with a bunch more of this stuff...
- if (SqlDbType.Decimal == colMetaData.SqlDbType ||
- SqlDbType.Time == colMetaData.SqlDbType ||
- SqlDbType.DateTime2 == colMetaData.SqlDbType ||
- SqlDbType.DateTimeOffset == colMetaData.SqlDbType)
- {
- schemaRow[Scale] = colMetaData.Scale;
- }
- else
- {
- schemaRow[Scale] = MetaType.GetMetaTypeFromSqlDbType(colMetaData.SqlDbType, colMetaData.IsMultiValued).Scale;
- }
-
- schemaRow[AllowDBNull] = colMetaData.AllowsDBNull;
- if (!(colMetaData.IsAliased.IsNull))
- {
- schemaRow[IsAliased] = colMetaData.IsAliased.Value;
- }
-
- if (!(colMetaData.IsKey.IsNull))
- {
- schemaRow[IsKey] = colMetaData.IsKey.Value;
- }
-
- if (!(colMetaData.IsHidden.IsNull))
- {
- schemaRow[IsHidden] = colMetaData.IsHidden.Value;
- }
-
- if (!(colMetaData.IsExpression.IsNull))
- {
- schemaRow[IsExpression] = colMetaData.IsExpression.Value;
- }
-
- schemaRow[IsReadOnly] = colMetaData.IsReadOnly;
- schemaRow[IsIdentity] = colMetaData.IsIdentity;
- schemaRow[IsColumnSet] = colMetaData.IsColumnSet;
- schemaRow[IsAutoIncrement] = colMetaData.IsIdentity;
- schemaRow[IsLong] = metaType.IsLong;
-
- // mark unique for timestamp columns
- if (SqlDbType.Timestamp == colMetaData.SqlDbType)
- {
- schemaRow[IsUnique] = true;
- schemaRow[IsRowVersion] = true;
- }
- else
- {
- schemaRow[IsUnique] = false;
- schemaRow[IsRowVersion] = false;
- }
-
- if (!string.IsNullOrEmpty(colMetaData.ColumnName))
- {
- schemaRow[BaseColumnName] = colMetaData.ColumnName;
- }
- else if (!string.IsNullOrEmpty(colMetaData.Name))
- {
- // Use projection name if base column name is not present
- schemaRow[BaseColumnName] = colMetaData.Name;
- }
-
- if (!string.IsNullOrEmpty(colMetaData.TableName))
- {
- schemaRow[BaseTableName] = colMetaData.TableName;
- }
-
- if (!string.IsNullOrEmpty(colMetaData.SchemaName))
- {
- schemaRow[BaseSchemaName] = colMetaData.SchemaName;
- }
-
- if (!string.IsNullOrEmpty(colMetaData.CatalogName))
- {
- schemaRow[BaseCatalogName] = colMetaData.CatalogName;
- }
-
- if (!string.IsNullOrEmpty(colMetaData.ServerName))
- {
- schemaRow[BaseServerName] = colMetaData.ServerName;
- }
-
- if (SqlDbType.Udt == colMetaData.SqlDbType)
- {
- schemaRow[DataTypeName] = colMetaData.TypeSpecificNamePart1 + "." + colMetaData.TypeSpecificNamePart2 + "." + colMetaData.TypeSpecificNamePart3;
- }
- else
- {
- schemaRow[DataTypeName] = metaType.TypeName;
- }
-
- // Add Xml metadata
- if (SqlDbType.Xml == colMetaData.SqlDbType)
- {
- schemaRow[XmlSchemaCollectionDatabase] = colMetaData.TypeSpecificNamePart1;
- schemaRow[XmlSchemaCollectionOwningSchema] = colMetaData.TypeSpecificNamePart2;
- schemaRow[XmlSchemaCollectionName] = colMetaData.TypeSpecificNamePart3;
- }
-
- schemaTable.Rows.Add(schemaRow);
- schemaRow.AcceptChanges();
- }
-
- // mark all columns as readonly
- foreach (DataColumn column in columns)
- {
- column.ReadOnly = true; // MDAC 70943
- }
-
- _schemaTable = schemaTable;
- }
-
- return _schemaTable;
- }
-
- //
- // ISqlRecord methods
- //
- public override SqlBinary GetSqlBinary(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlBinary(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlBoolean GetSqlBoolean(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlBoolean(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlByte GetSqlByte(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlByte(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlInt16 GetSqlInt16(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlInt16(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlInt32 GetSqlInt32(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlInt32(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlInt64 GetSqlInt64(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlInt64(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlSingle GetSqlSingle(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlSingle(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlDouble GetSqlDouble(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlDouble(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlMoney GetSqlMoney(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlMoney(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlDateTime GetSqlDateTime(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlDateTime(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
-
- public override SqlDecimal GetSqlDecimal(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlDecimal(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlString GetSqlString(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlString(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlGuid GetSqlGuid(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlGuid(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlChars GetSqlChars(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlChars(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlBytes GetSqlBytes(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlBytes(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override SqlXml GetSqlXml(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetSqlXml(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal]);
- }
-
- public override TimeSpan GetTimeSpan(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetTimeSpan(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal], _currentConnection.Is2008OrNewer);
- }
-
- public override DateTimeOffset GetDateTimeOffset(int ordinal)
- {
- EnsureCanGetCol(ordinal);
- return ValueUtilsSmi.GetDateTimeOffset(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal], _currentConnection.Is2008OrNewer);
- }
-
- public override object GetSqlValue(int ordinal)
- {
- EnsureCanGetCol(ordinal);
-
- SmiMetaData metaData = _currentMetaData[ordinal];
- if (_currentConnection.Is2008OrNewer)
- {
- return ValueUtilsSmi.GetSqlValue200(
- _readerEventSink,
- (SmiTypedGetterSetter)_currentColumnValuesV3,
- ordinal,
- metaData);
- }
-
- return ValueUtilsSmi.GetSqlValue(_readerEventSink, _currentColumnValuesV3, ordinal, metaData);
- }
-
- public override int GetSqlValues(object[] values)
- {
- EnsureCanGetCol(0);
-
- if (values == null)
- {
- throw ADP.ArgumentNull(nameof(values));
- }
-
- int copyLength = (values.Length < _visibleColumnCount) ? values.Length : _visibleColumnCount;
- for (int i = 0; i < copyLength; i++)
- {
- values[_indexMap[i]] = GetSqlValue(i);
- }
-
- return copyLength;
- }
-
- //
- // ISqlReader methods/properties
- //
- public override bool HasRows
- {
- get { return _hasRows; }
- }
-
- //
- // SqlDataReader method/properties
- //
- public override Stream GetStream(int ordinal)
- {
- EnsureCanGetCol(ordinal);
-
- SmiQueryMetaData metaData = _currentMetaData[ordinal];
-
- // For non-null, non-variant types with sequential access, we support proper streaming
- if ((metaData.SqlDbType != SqlDbType.Variant) && (IsCommandBehavior(CommandBehavior.SequentialAccess)) && (!ValueUtilsSmi.IsDBNull(_readerEventSink, _currentColumnValuesV3, ordinal)))
- {
- if (HasActiveStreamOrTextReaderOnColumn(ordinal))
- {
- throw ADP.NonSequentialColumnAccess(ordinal, ordinal + 1);
- }
- _currentStream = ValueUtilsSmi.GetSequentialStream(_readerEventSink, _currentColumnValuesV3, ordinal, metaData);
- return _currentStream;
- }
- else
- {
- return ValueUtilsSmi.GetStream(_readerEventSink, _currentColumnValuesV3, ordinal, metaData);
- }
- }
-
- public override TextReader GetTextReader(int ordinal)
- {
- EnsureCanGetCol(ordinal);
-
- SmiQueryMetaData metaData = _currentMetaData[ordinal];
-
- // For non-variant types with sequential access, we support proper streaming
- if ((metaData.SqlDbType != SqlDbType.Variant) && (IsCommandBehavior(CommandBehavior.SequentialAccess)) && (!ValueUtilsSmi.IsDBNull(_readerEventSink, _currentColumnValuesV3, ordinal)))
- {
- if (HasActiveStreamOrTextReaderOnColumn(ordinal))
- {
- throw ADP.NonSequentialColumnAccess(ordinal, ordinal + 1);
- }
- _currentTextReader = ValueUtilsSmi.GetSequentialTextReader(_readerEventSink, _currentColumnValuesV3, ordinal, metaData);
- return _currentTextReader;
- }
- else
- {
- return ValueUtilsSmi.GetTextReader(_readerEventSink, _currentColumnValuesV3, ordinal, metaData);
- }
- }
-
- public override XmlReader GetXmlReader(int ordinal)
- {
- // NOTE: sql_variant can not contain a XML data type: http://msdn.microsoft.com/en-us/library/ms173829.aspx
-
- EnsureCanGetCol(ordinal);
- if (_currentMetaData[ordinal].SqlDbType != SqlDbType.Xml)
- {
- throw ADP.InvalidCast();
- }
-
- Stream stream;
- if ((IsCommandBehavior(CommandBehavior.SequentialAccess)) && (!ValueUtilsSmi.IsDBNull(_readerEventSink, _currentColumnValuesV3, ordinal)))
- {
- if (HasActiveStreamOrTextReaderOnColumn(ordinal))
- {
- throw ADP.NonSequentialColumnAccess(ordinal, ordinal + 1);
- }
- // Need to bypass the type check since streams are not usually allowed on XML types
- _currentStream = ValueUtilsSmi.GetSequentialStream(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal], bypassTypeCheck: true);
- stream = _currentStream;
- }
- else
- {
- stream = ValueUtilsSmi.GetStream(_readerEventSink, _currentColumnValuesV3, ordinal, _currentMetaData[ordinal], bypassTypeCheck: true);
- }
-
- return SqlTypeWorkarounds.SqlXmlCreateSqlXmlReader(stream, closeInput: false, async: false);
- }
-
- //
- // Internal reader state
- //
-
- // Logical state of reader/resultset as viewed by the client
- // Does not necessarily match up with server state.
- internal enum PositionState
- {
- BeforeResults, // Before all resultset in request
- BeforeRows, // Before all rows in current resultset
- OnRow, // On a valid row in the current resultset
- AfterRows, // After all rows in current resultset
- AfterResults // After all resultsets in request
- }
-
- private PositionState _currentPosition; // Where is the reader relative to incoming results?
- private bool _isOpen; // Is the reader open?
- private SmiQueryMetaData[] _currentMetaData; // Metadata for current resultset
- private int[] _indexMap; // map of indices for visible column
- private int _visibleColumnCount; // number of visible columns
- private DataTable _schemaTable; // Cache of user-visible extended metadata while in results.
- private ITypedGetters _currentColumnValues; // Unmanaged-managed data marshalers/cache
- private ITypedGettersV3 _currentColumnValuesV3; // Unmanaged-managed data marshalers/cache for SMI V3
- private bool _hasRows; // Are there any rows in the current resultset? Must be able to say before moving to first row.
- private SmiEventStream _eventStream; // The event buffer that receives the events from the execution engine.
- private SmiRequestExecutor _requestExecutor; // The used to request actions from the execution engine.
- private SqlInternalConnectionSmi _currentConnection;
- private ReaderEventSink _readerEventSink; // The event sink that will process events from the event buffer.
- private FieldNameLookup _fieldNameLookup; // cached lookup object to improve access time based on field name
- private SqlSequentialStreamSmi _currentStream; // The stream on the current column (if any)
- private SqlSequentialTextReaderSmi _currentTextReader; // The text reader on the current column (if any)
-
- // @TODO: No longer used -- delete!
- // Assumes that if there were any results, the first chunk of them are in the data stream
- // (up to the first actual row or the end of the resultsets).
- unsafe internal SqlDataReaderSmi(
- SmiEventStream eventStream, // the event stream that receives the events from the execution engine
- SqlCommand parent, // command that owns reader
- CommandBehavior behavior, // behavior specified for this execution
- SqlInternalConnectionSmi connection, // connection that owns everybody
- SmiEventSink parentSink, // Event sink of parent command
- SmiRequestExecutor requestExecutor
- ) : base(parent, behavior)
- { // UNDONE: handle other command behaviors
- _eventStream = eventStream;
- _currentConnection = connection;
- _readerEventSink = new ReaderEventSink(this, parentSink);
- _currentPosition = PositionState.BeforeResults;
- _isOpen = true;
- _indexMap = null;
- _visibleColumnCount = 0;
- _currentStream = null;
- _currentTextReader = null;
- _requestExecutor = requestExecutor;
- }
-
- internal override SmiExtendedMetaData[] GetInternalSmiMetaData()
- {
- if (_currentMetaData == null || _visibleColumnCount == InternalFieldCount)
- {
- return _currentMetaData;
- }
- else
- {
-#if DEBUG
- // DEVNOTE: Interpretation of returned array currently depends on hidden columns
- // always appearing at the end, since there currently is no access to the index map
- // outside of this class. In Debug code, we check this assumption.
- bool sawHiddenColumn = false;
-#endif
- SmiExtendedMetaData[] visibleMetaData = new SmiExtendedMetaData[_visibleColumnCount];
- for (int i = 0; i < _visibleColumnCount; i++)
- {
-#if DEBUG
- if (_currentMetaData[_indexMap[i]].IsHidden.IsTrue)
- {
- sawHiddenColumn = true;
- }
- else
- {
- Debug.Assert(!sawHiddenColumn);
- }
-#endif
- visibleMetaData[i] = _currentMetaData[_indexMap[i]];
- }
-
- return visibleMetaData;
- }
- }
-
- internal override int GetLocaleId(int ordinal)
- {
- EnsureCanGetMetaData();
- return (int)_currentMetaData[ordinal].LocaleId;
- }
- private int InternalFieldCount
- {
- get
- {
- if (FNotInResults())
- {
- return 0;
- }
- else
- {
- return _currentMetaData.Length;
- }
- }
- }
-
- // Have we cleaned up internal resources?
- private bool IsReallyClosed() => !_isOpen;
-
- // Central checkpoint for closed recordset.
- // Any code that requires an open recordset should call this method first!
- // Especially any code that accesses unmanaged memory structures whose lifetime
- // matches the lifetime of the unmanaged recordset.
- internal void ThrowIfClosed([CallerMemberName] string operationName = null)
- {
- if (IsClosed)
- {
- throw ADP.DataReaderClosed(operationName);
- }
- }
-
- // Central checkpoint to ensure the requested column can be accessed.
- // Calling this function serves to notify that it has been accessed by the user.
- private void EnsureCanGetCol(int ordinal, [CallerMemberName] string operationName = null)
- {
- EnsureOnRow(operationName);
- }
-
- internal void EnsureOnRow(string operationName)
- {
- ThrowIfClosed(operationName);
- if (_currentPosition != PositionState.OnRow)
- {
- throw SQL.InvalidRead();
- }
- }
-
- internal void EnsureCanGetMetaData([CallerMemberName] string operationName = null)
- {
- ThrowIfClosed(operationName);
- if (FNotInResults())
- {
- throw SQL.InvalidRead(); // UNDONE: Shouldn't this be a bit more descriptive?
- }
- }
-
- private bool FInResults()
- {
- return !FNotInResults();
- }
-
- private bool FNotInResults()
- {
- return (PositionState.AfterResults == _currentPosition || PositionState.BeforeResults == _currentPosition);
- }
-
- private void MetaDataAvailable(SmiQueryMetaData[] md, bool nextEventIsRow)
- {
- Debug.Assert(_currentPosition != PositionState.AfterResults);
-
- _currentMetaData = md;
- _hasRows = nextEventIsRow;
- _fieldNameLookup = null;
- _schemaTable = null; // will be rebuilt based on new metadata
- _currentPosition = PositionState.BeforeRows;
-
- // calculate visible column indices
- _indexMap = new int[_currentMetaData.Length];
- int i;
- int visibleCount = 0;
- for (i = 0; i < _currentMetaData.Length; i++)
- {
- if (!_currentMetaData[i].IsHidden.IsTrue)
- {
- _indexMap[visibleCount] = i;
- visibleCount++;
- }
- }
- _visibleColumnCount = visibleCount;
- }
-
- private bool HasActiveStreamOrTextReaderOnColumn(int columnIndex)
- {
- bool active = false;
-
- active |= (_currentStream != null) && (_currentStream.ColumnIndex == columnIndex);
- active |= (_currentTextReader != null) && (_currentTextReader.ColumnIndex == columnIndex);
-
- return active;
- }
-
- // Obsolete V2- method
- private void RowAvailable(ITypedGetters row)
- {
- Debug.Assert(_currentPosition != PositionState.AfterResults);
-
- _currentColumnValues = row;
- _currentPosition = PositionState.OnRow;
- }
-
- private void RowAvailable(ITypedGettersV3 row)
- {
- Debug.Assert(_currentPosition != PositionState.AfterResults);
-
- _currentColumnValuesV3 = row;
- _currentPosition = PositionState.OnRow;
- }
-
- private void StatementCompleted()
- {
- Debug.Assert(_currentPosition != PositionState.AfterResults);
-
- _currentPosition = PositionState.AfterRows;
- }
-
- private void ResetResultSet()
- {
- _currentMetaData = null;
- _visibleColumnCount = 0;
- _schemaTable = null;
- }
-
- private void BatchCompleted()
- {
- Debug.Assert(_currentPosition != PositionState.AfterResults);
-
- ResetResultSet();
-
- _currentPosition = PositionState.AfterResults;
- _eventStream.Close(_readerEventSink);
- }
-
- // An implementation of the IEventSink interface that either performs
- // the required enviornment changes or forwards the events on to the
- // corresponding reader instance. Having the event sink be a separate
- // class keeps the IEventSink methods out of SqlDataReader's inteface.
-
- private sealed class ReaderEventSink : SmiEventSink_Default
- {
- private readonly SqlDataReaderSmi _reader;
-
- internal ReaderEventSink(SqlDataReaderSmi reader, SmiEventSink parent)
- : base(parent)
- {
- _reader = reader;
- }
-
- internal override void MetaDataAvailable(SmiQueryMetaData[] md, bool nextEventIsRow)
- {
- var mdLength = (md != null) ? md.Length : -1;
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, md.Length={1} nextEventIsRow={2}.", _reader.ObjectID, mdLength, nextEventIsRow);
-
- if (SqlClientEventSource.Log.IsAdvancedTraceOn())
- {
- if (md != null)
- {
- for (int i = 0; i < md.Length; i++)
- {
- SqlClientEventSource.Log.TraceEvent(" {0}, metaData[{1}] is {2}{3}", _reader.ObjectID, i, md[i].GetType(), md[i].TraceString());
- }
- }
- }
- _reader.MetaDataAvailable(md, nextEventIsRow);
- }
-
- // Obsolete V2- method
- internal override void RowAvailable(ITypedGetters row)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0} (v2).", _reader.ObjectID);
- _reader.RowAvailable(row);
- }
-
- internal override void RowAvailable(ITypedGettersV3 row)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0} (ITypedGettersV3).", _reader.ObjectID);
- _reader.RowAvailable(row);
- }
-
- internal override void RowAvailable(SmiTypedGetterSetter rowData)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0} (SmiTypedGetterSetter).", _reader.ObjectID);
- _reader.RowAvailable(rowData);
- }
-
- internal override void StatementCompleted(int recordsAffected)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0} recordsAffected= {1}.", _reader.ObjectID, recordsAffected);
-
- // devnote: relies on SmiEventSink_Default to pass event to parent
- // Both command and reader care about StatementCompleted, but for different reasons.
- base.StatementCompleted(recordsAffected);
- _reader.StatementCompleted();
- }
-
- internal override void BatchCompleted()
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}.", _reader.ObjectID);
-
- // devnote: relies on SmiEventSink_Default to pass event to parent
- // parent's callback *MUST* come before reader's BatchCompleted, since
- // reader will close the event stream during this call, and parent wants
- // to extract parameter values before that happens.
- base.BatchCompleted();
- _reader.BatchCompleted();
- }
- }
-
- }
-}
-
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
deleted file mode 100644
index c663ddbd09..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs
+++ /dev/null
@@ -1,531 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Data;
-using System.Data.Common;
-using System.Diagnostics;
-using Microsoft.Data.Common;
-using Microsoft.Data.SqlClient.Server;
-using System.Transactions;
-
-namespace Microsoft.Data.SqlClient
-{
- sealed internal class SqlInternalConnectionSmi : SqlInternalConnection
- {
- private SmiConnection _smiConnection;
- private SmiEventSink_Default _smiEventSink;
- private int _isInUse; // 1 = Connected to open outer connection, 0 = not connected
-
- private SqlInternalTransaction _pendingTransaction; // transaction awaiting event signalling that it is active
- private SqlInternalTransaction _currentTransaction; // currently active non-context transaction.
-
- sealed private class EventSink : SmiEventSink_Default
- {
-
- SqlInternalConnectionSmi _connection;
-
- override internal string ServerVersion
- {
- // @TODO: Will always throw
- get => throw SQL.ContextUnavailableOutOfProc();
- }
-
- override protected void DispatchMessages(bool ignoreNonFatalMessages)
- {
- // Override this on the Connection event sink, since we can deal
- // with info messages here.
- SqlException exception = ProcessMessages(false, ignoreNonFatalMessages);
-
- if (exception != null)
- {
- // SQLBUVSTS 225982, query for connection once to avoid race condition between GC (that may collect the connection) and the user thread
- SqlConnection connection = _connection.Connection;
- if (connection != null && connection.FireInfoMessageEventOnUserErrors)
- {
- connection.OnInfoMessage(new SqlInfoMessageEventArgs(exception));
- }
- else
- {
- _connection.OnError(exception, false); // we can't really ever break the direct connection, can we?
- }
- }
- }
-
- internal EventSink(SqlInternalConnectionSmi connection)
- {
- Debug.Assert(connection != null, "null connection?");
- _connection = connection;
- }
-
- internal override void DefaultDatabaseChanged(string databaseName)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, databaseName='{1}'.", _connection.ObjectID, databaseName);
- _connection.CurrentDatabase = databaseName;
- }
-
- internal override void TransactionCommitted(long transactionId)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, transactionId=0x{1}.", _connection.ObjectID, transactionId);
- _connection.TransactionEnded(transactionId, TransactionState.Committed);
- }
-
- internal override void TransactionDefected(long transactionId)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, transactionId=0x{1}.", _connection.ObjectID, transactionId);
- _connection.TransactionEnded(transactionId, TransactionState.Unknown);
- }
-
- internal override void TransactionEnlisted(long transactionId)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, transactionId=0x{1}.", _connection.ObjectID, transactionId);
- _connection.TransactionStarted(transactionId, true); // distributed;
- }
-
- internal override void TransactionEnded(long transactionId)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, transactionId=0x{1}.", _connection.ObjectID, transactionId);
- _connection.TransactionEndedByServer(transactionId, TransactionState.Unknown);
- }
-
- internal override void TransactionRolledBack(long transactionId)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, transactionId=0x{1}.", _connection.ObjectID, transactionId);
-
- // Dev11 1066: ensure delegated transaction is rolled back
- _connection.TransactionEndedByServer(transactionId, TransactionState.Aborted);
- }
-
- internal override void TransactionStarted(long transactionId)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, transactionId=0x{1}.", _connection.ObjectID, transactionId);
- _connection.TransactionStarted(transactionId, false); // not distributed;
- }
- }
-
- // @TODO: No longer used -- delete!
- internal SqlInternalConnectionSmi(SqlConnectionString connectionOptions) : base(connectionOptions)
- {
- _smiConnection = null;
- Debug.Assert(_smiConnection != null, "null SmiContext.ContextConnection?");
-
- _smiEventSink = new EventSink(this);
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, constructed new SMI internal connection", ObjectID);
- }
-
- internal SmiEventSink CurrentEventSink
- {
- get
- {
- return _smiEventSink;
- }
- }
-
- override internal SqlInternalTransaction CurrentTransaction
- {
- get
- {
- return _currentTransaction;
- }
- }
-
- override internal bool IsLockedForBulkCopy
- {
- get
- {
- return false; // no bulk copy in the Direct connection case.
- }
- }
-
- override internal bool Is2008OrNewer
- {
- // @TODO: Will always throw
- get => throw SQL.ContextUnavailableOutOfProc();
- }
-
- override internal SqlInternalTransaction PendingTransaction
- {
- get
- {
- return CurrentTransaction; // there are no differences between pending and current in proc.
- }
- }
-
- override public string ServerVersion
- {
- // @TODO: Will always throw
- get => throw SQL.ContextUnavailableOutOfProc();
- }
-
- ///
- /// Get boolean that specifies whether an enlisted transaction can be unbound from
- /// the connection when that transaction completes.
- ///
- ///
- /// True if the connection string property "TransactionBinding" is set to TransactionBindingEnum.ImplicitUnbind;
- /// otherwise, false.
- ///
- protected override bool UnbindOnTransactionCompletion
- {
- get
- {
- return ConnectionOptions.TransactionBinding == SqlConnectionString.TransactionBindingEnum.ImplicitUnbind;
- }
- }
-
- // Workaround to access context transaction without rewriting connection pool & internalconnections properly.
- // 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 Transaction ContextTransaction
- {
- get;
- set;
- }
-
- 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
- Transaction tx = EnlistedTransaction;
-
- if (tx == null)
- {
- tx = ContextTransaction;
- }
-
- return tx;
- }
- }
-
- 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.
- }
-
- // @TODO: No longer used -- delete
- internal void Activate()
- {
- int wasInUse = System.Threading.Interlocked.Exchange(ref _isInUse, 1);
- if (0 != wasInUse)
- {
- throw SQL.ContextConnectionIsInUse();
- }
-
- CurrentDatabase = _smiConnection.GetCurrentDatabase(_smiEventSink);
-
- _smiEventSink.ProcessMessagesAndThrow();
- }
-
- internal void AutomaticEnlistment()
- {
- Transaction currentSystemTransaction = ADP.GetCurrentTransaction(); // NOTE: Must be first to ensure _smiContext.ContextTransaction is set!
- // @TODO: These referenced _sqlContext so they'd definitely break, but I can't prove this method isn't being used yet...
- Transaction contextTransaction = null; // returns the transaction that was handed to SysTx that wraps the ContextTransactionId.
- long contextTransactionId = 0;
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, contextTransactionId=0x{1}, contextTransaction={2}, currentSystemTransaction={3}.",
- ObjectID,
- contextTransactionId,
- contextTransaction != null ? contextTransaction.GetHashCode() : 0,
- currentSystemTransaction != null ? currentSystemTransaction.GetHashCode() : 0);
-
- if (SqlInternalTransaction.NullTransactionId != contextTransactionId)
- {
- if (currentSystemTransaction != null && contextTransaction != currentSystemTransaction)
- {
- throw SQL.NestedTransactionScopesNotSupported(); // can't use TransactionScope(RequiresNew) inside a Sql Transaction.
- }
-
- SqlClientEventSource.Log.TryTraceEvent(" {0}, using context transaction with transactionId=0x{1}", ObjectID, contextTransactionId);
- _currentTransaction = new SqlInternalTransaction(this, TransactionType.Context, null, contextTransactionId);
- ContextTransaction = contextTransaction;
- }
- else if (currentSystemTransaction == null)
- {
- _currentTransaction = null; // there really isn't a transaction.
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, no transaction.", ObjectID);
- }
- else
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, using current System.Transaction.", ObjectID);
- base.Enlist(currentSystemTransaction);
- }
- }
-
- override protected void ChangeDatabaseInternal(string database)
- {
- _smiConnection.SetCurrentDatabase(database, _smiEventSink);
- _smiEventSink.ProcessMessagesAndThrow();
- }
-
- override protected void InternalDeactivate()
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, Deactivating.", ObjectID);
-
- // When we put this to bed, we should not hold on to the transaction
- // or any activity (commit/rollback) may cause it to stop responding.
- if (!IsNonPoolableTransactionRoot)
- {
- base.Enlist(null);
- }
-
- if (_currentTransaction != null)
- {
- if (_currentTransaction.IsContext)
- {
- _currentTransaction = null;
- }
- else if (_currentTransaction.IsLocal)
- {
- _currentTransaction.CloseFromConnection();
- }
- }
-
- ContextTransaction = null;
-
- _isInUse = 0; // don't need compare-exchange.
- }
-
- override internal void DelegatedTransactionEnded()
- {
- base.DelegatedTransactionEnded();
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, cleaning up after Delegated Transaction Completion", ObjectID);
- _currentTransaction = null; // clean up our current transaction too
- }
-
- override internal void DisconnectTransaction(SqlInternalTransaction internalTransaction)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, Disconnecting Transaction {1}.", ObjectID, internalTransaction.ObjectID);
-
- // VSTS 215465/15029: allow _currentTransaction to be null - it can be cleared before by server's callback
- Debug.Assert(_currentTransaction == null || _currentTransaction == internalTransaction, "disconnecting different transaction");
-
- if (_currentTransaction != null && _currentTransaction == internalTransaction)
- {
- _currentTransaction = null;
- }
- }
-
- override internal void ExecuteTransaction(
- TransactionRequest transactionRequest,
- string transactionName,
- System.Data.IsolationLevel iso,
- SqlInternalTransaction internalTransaction,
- bool isDelegateControlRequest)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(
- " {0}, transactionRequest={1}, " +
- "transactionName='{2}', isolationLevel={3}, internalTransaction=#{4} transactionId=0x{5}.",
- ObjectID,
- transactionRequest,
- transactionName,
- iso,
- internalTransaction != null ? internalTransaction.ObjectID : 0,
- internalTransaction != null ? internalTransaction.TransactionId : SqlInternalTransaction.NullTransactionId);
-
- switch (transactionRequest)
- {
- case TransactionRequest.Begin:
- try
- {
- _pendingTransaction = internalTransaction; // store this for the time being.
-
- _smiConnection.BeginTransaction(transactionName, iso, _smiEventSink);
- }
- finally
- {
- _pendingTransaction = null;
- }
-
- Debug.Assert(_smiEventSink.HasMessages || _currentTransaction != null, "begin transaction without TransactionStarted event?");
- break;
-
- case TransactionRequest.Commit:
- Debug.Assert(_currentTransaction != null, "commit transaction without TransactionStarted event?");
-
- _smiConnection.CommitTransaction(_currentTransaction.TransactionId, _smiEventSink);
- break;
-
- case TransactionRequest.Promote:
- Debug.Assert(_currentTransaction != null, "promote transaction without TransactionStarted event?");
- PromotedDTCToken = _smiConnection.PromoteTransaction(_currentTransaction.TransactionId, _smiEventSink);
- break;
-
- case TransactionRequest.Rollback:
- case TransactionRequest.IfRollback:
- Debug.Assert(_currentTransaction != null, "rollback/ifrollback transaction without TransactionStarted event?");
- _smiConnection.RollbackTransaction(_currentTransaction.TransactionId, transactionName, _smiEventSink);
- break;
-
- case TransactionRequest.Save:
- Debug.Assert(_currentTransaction != null, "save transaction without TransactionStarted event?");
- _smiConnection.CreateTransactionSavePoint(_currentTransaction.TransactionId, transactionName, _smiEventSink);
- break;
-
- default:
- Debug.Assert(false, "unhandled case for TransactionRequest");
- break;
- }
-
- _smiEventSink.ProcessMessagesAndThrow();
- }
-
- override protected byte[] GetDTCAddress()
- {
- byte[] whereAbouts = _smiConnection.GetDTCAddress(_smiEventSink); // might want to store this on the SmiLink because it doesn't change, but we want to be compatible with TDS which doesn't have a link yet.
-
- _smiEventSink.ProcessMessagesAndThrow();
-
- if (whereAbouts != null)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" whereAbouts = {0}, Length = {1}", whereAbouts, (ushort)whereAbouts.Length);
- }
- else
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" whereAbouts=null");
- }
-
- return whereAbouts;
- }
-
- // @TODO: No longer used -- delete!
- 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.
- lock (this)
- {
- transactionId = CurrentTransaction != null ? CurrentTransaction.TransactionId : 0;
- transaction = null;
- if (0 != transactionId)
- {
- transaction = InternalEnlistedTransaction;
- }
- }
- }
-
- private void OnOutOfScope(object s, EventArgs e)
- {
- // Called whenever the context goes out of scope, we need to make
- // sure that we close the connection, or the next person that uses
- // the context may appear to have the connection in use.
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0} context is out of scope", ObjectID);
-
- // TODO: This is suspect to me -- if I go out of scope, who will commit the transaction?
- DelegatedTransaction = null; // we don't want to hold this over to the next usage; it will automatically be reused as the context transaction...
-
- DbConnection owningObject = (DbConnection)Owner;
-
- try
- {
- if (owningObject != null && 1 == _isInUse)
- {
- // SQLBU 369953
- // for various reasons, the owning object may no longer be connection to this
- // so call close on the owner, rather than trying to bypass to use internal close logic.
- owningObject.Close();
- }
- }
- finally
- {
- // Now make sure this object is not left in an in-use state
- // this is safe, because no user code should be accessing the connection by this time
- ContextTransaction = null;
- _isInUse = 0;
- }
- }
-
- override protected void PropagateTransactionCookie(byte[] transactionCookie)
- {
-
- if (transactionCookie != null)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" transactionCookie", transactionCookie, (UInt16)transactionCookie.Length);
- }
- else
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" null");
- }
-
- // Propagate the transaction cookie to the server
- _smiConnection.EnlistTransaction(transactionCookie, _smiEventSink);
- _smiEventSink.ProcessMessagesAndThrow();
- }
-
- private void TransactionEndedByServer(long transactionId, TransactionState transactionState)
- {
- // Some extra steps required when the server initiates the ending of a transaction unilaterally
- // as opposed to the client initiating it.
- // Basically, we have to make the delegated transaction (if there is one) aware of the situation.
-
- SqlDelegatedTransaction delegatedTransaction = DelegatedTransaction;
- if (delegatedTransaction != null)
- {
- delegatedTransaction.Transaction.Rollback(); // just to make sure...
- DelegatedTransaction = null; // He's dead, Jim.
- }
-
- // Now handle the standard transaction-ended stuff.
- TransactionEnded(transactionId, transactionState);
- }
-
- private void TransactionEnded(long transactionId, TransactionState transactionState)
- {
- // When we get notification of a completed transaction
- // we null out the current transaction.
-
- if (_currentTransaction != null)
- {
-#if DEBUG
- // Check null for case where Begin and Rollback obtained in the same message.
- if (0 != _currentTransaction.TransactionId)
- {
- Debug.Assert(_currentTransaction.TransactionId == transactionId, "transaction id's are not equal!");
- }
-#endif
- _currentTransaction.Completed(transactionState);
- _currentTransaction = null;
- }
- }
-
- private void TransactionStarted(long transactionId, bool isDistributed)
- {
- // 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(_currentTransaction == null, "non-null current transaction with an env change");
- _currentTransaction = _pendingTransaction;
- _pendingTransaction = null;
-
- if (_currentTransaction != null)
- {
- _currentTransaction.TransactionId = transactionId; // this is defined as a ULongLong in the server and in the TDS Spec.
- }
- else
- {
- TransactionType transactionType = (isDistributed) ? TransactionType.Distributed : TransactionType.LocalFromTSQL;
- _currentTransaction = new SqlInternalTransaction(this, transactionType, null, transactionId);
- }
- _currentTransaction.Activate(); // SQLBUDT #376531 -- ensure this is activated to prevent asserts later.
- }
-
- override internal void ValidateConnectionForExecute(SqlCommand command)
- {
- SqlDataReader reader = FindLiveReader(null);
- if (reader != null)
- {
- // if MARS is on, then a datareader associated with the command exists
- // or if MARS is off, then a datareader exists
- TdsParser parser = command.Connection.Parser;
- throw ADP.OpenReaderExists(parser.MARSOn); // MDAC 66411
- }
- }
- }
-}
-
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlSequentialStreamSmi.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlSequentialStreamSmi.cs
deleted file mode 100644
index 9705d32abc..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlSequentialStreamSmi.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using Microsoft.Data.Common;
-using Microsoft.Data.SqlClient.Server;
-
-namespace Microsoft.Data.SqlClient
-{
- sealed internal class SqlSequentialStreamSmi : System.IO.Stream
- {
- private SmiEventSink_Default _sink;
- private ITypedGettersV3 _getters;
- private int _columnIndex; // The index of out column in the table
- private long _position; // Current position in the stream
- private long _length; // Total length of the stream
-
- internal SqlSequentialStreamSmi(SmiEventSink_Default sink, ITypedGettersV3 getters, int columnIndex, long length)
- {
- _sink = sink;
- _getters = getters;
- _columnIndex = columnIndex;
- _length = length;
- _position = 0;
- }
-
- public override bool CanRead
- {
- get { return ((_sink != null) && (_getters != null)); }
- }
-
- public override bool CanSeek
- {
- get { return false; }
- }
-
- public override bool CanWrite
- {
- get { return false; }
- }
-
- public override void Flush()
- { }
-
- public override long Length
- {
- get { throw ADP.NotSupported(); }
- }
-
- public override long Position
- {
- get { throw ADP.NotSupported(); }
- set { throw ADP.NotSupported(); }
- }
-
- internal int ColumnIndex
- {
- get { return _columnIndex; }
- }
-
- public override int Read(byte[] buffer, int offset, int count)
- {
- SqlSequentialStream.ValidateReadParameters(buffer, offset, count);
- if (!CanRead)
- {
- throw ADP.ObjectDisposed(this);
- }
-
- try
- {
- // Read whichever is less: however much the user asked for, or however much we have
- // NOTE: It is safe to do this since count <= Int32.MaxValue, therefore the Math.Min should always result in an int
- int bytesNeeded = (int)Math.Min((long)count, _length - _position);
- int bytesRead = 0;
- if (bytesNeeded > 0)
- {
- bytesRead = ValueUtilsSmi.GetBytes_Unchecked(_sink, _getters, _columnIndex, _position, buffer, offset, bytesNeeded);
- _position += bytesRead;
- }
- return bytesRead;
- }
- catch (SqlException ex)
- {
- // Stream.Read() can't throw a SqlException - so wrap it in an IOException
- throw ADP.ErrorReadingFromStream(ex);
- }
- }
-
- public override long Seek(long offset, System.IO.SeekOrigin origin)
- {
- throw ADP.NotSupported();
- }
-
- public override void SetLength(long value)
- {
- throw ADP.NotSupported();
- }
-
- public override void Write(byte[] buffer, int offset, int count)
- {
- throw ADP.NotSupported();
- }
-
- ///
- /// Forces the stream to act as if it was closed (i.e. CanRead=false and Read() throws)
- /// This does not actually close the stream, read off the rest of the data or dispose this
- ///
- internal void SetClosed()
- {
- _sink = null;
- _getters = null;
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- SetClosed();
- }
-
- base.Dispose(disposing);
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlSequentialTextReaderSmi.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlSequentialTextReaderSmi.cs
deleted file mode 100644
index 7adbb67f21..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlSequentialTextReaderSmi.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Diagnostics;
-using Microsoft.Data.Common;
-using Microsoft.Data.SqlClient.Server;
-
-namespace Microsoft.Data.SqlClient
-{
- sealed internal class SqlSequentialTextReaderSmi : System.IO.TextReader
- {
- private SmiEventSink_Default _sink;
- private ITypedGettersV3 _getters;
- private int _columnIndex; // The index of out column in the table
- private long _position; // Current position in the stream
- private long _length; // Total length of the stream
- private int _peekedChar; // Current peeked character (if any)
-
- internal SqlSequentialTextReaderSmi(SmiEventSink_Default sink, ITypedGettersV3 getters, int columnIndex, long length)
- {
- _sink = sink;
- _getters = getters;
- _columnIndex = columnIndex;
- _length = length;
- _position = 0;
- _peekedChar = -1;
- }
-
- internal int ColumnIndex
- {
- get { return _columnIndex; }
- }
-
- public override int Peek()
- {
- if (!HasPeekedChar)
- {
- _peekedChar = Read();
- }
-
- Debug.Assert(_peekedChar == -1 || ((_peekedChar >= char.MinValue) && (_peekedChar <= char.MaxValue)), string.Format("Bad peeked character: {0}", _peekedChar));
- return _peekedChar;
- }
-
- public override int Read()
- {
- if (IsClosed)
- {
- throw ADP.ObjectDisposed(this);
- }
-
- int readChar = -1;
-
- // If there is already a peeked char, then return it
- if (HasPeekedChar)
- {
- readChar = _peekedChar;
- _peekedChar = -1;
- }
- // If there is data available try to read a char
- else if (_position < _length)
- {
- char[] tempBuffer = new char[1];
- int charsRead = ValueUtilsSmi.GetChars_Unchecked(_sink, _getters, _columnIndex, _position, tempBuffer, 0, 1);
- if (charsRead == 1)
- {
- readChar = tempBuffer[0];
- _position++;
- }
- }
-
- Debug.Assert(readChar == -1 || ((readChar >= char.MinValue) && (readChar <= char.MaxValue)), string.Format("Bad read character: {0}", readChar));
- return readChar;
- }
-
- public override int Read(char[] buffer, int index, int count)
- {
- SqlSequentialTextReader.ValidateReadParameters(buffer, index, count);
- if (IsClosed)
- {
- throw ADP.ObjectDisposed(this);
- }
-
- int charsRead = 0;
- // Load in peeked char
- if ((count > 0) && (HasPeekedChar))
- {
- Debug.Assert((_peekedChar >= char.MinValue) && (_peekedChar <= char.MaxValue), string.Format("Bad peeked character: {0}", _peekedChar));
- buffer[index + charsRead] = (char)_peekedChar;
- charsRead++;
- _peekedChar = -1;
- }
-
- // Read whichever is less: however much the user asked for, or however much we have
- // NOTE: It is safe to do this since count <= Int32.MaxValue, therefore the Math.Min should always result in an int
- int charsNeeded = (int)Math.Min((long)(count - charsRead), _length - _position);
- // If we need more data and there is data avaiable, read
- if (charsNeeded > 0)
- {
- int newCharsRead = ValueUtilsSmi.GetChars_Unchecked(_sink, _getters, _columnIndex, _position, buffer, index + charsRead, charsNeeded);
- _position += newCharsRead;
- charsRead += newCharsRead;
- }
-
- return charsRead;
- }
-
- ///
- /// Forces the TextReader to act as if it was closed
- /// This does not actually close the stream, read off the rest of the data or dispose this
- ///
- internal void SetClosed()
- {
- _sink = null;
- _getters = null;
- _peekedChar = -1;
- }
-
- ///
- /// True if this TextReader is supposed to be closed
- ///
- private bool IsClosed
- {
- get { return ((_sink == null) || (_getters == null)); }
- }
-
- ///
- /// True if there is a peeked character available
- ///
- private bool HasPeekedChar
- {
- get { return (_peekedChar >= char.MinValue); }
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedGetters.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedGetters.cs
deleted file mode 100644
index 406784f2d9..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedGetters.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Data;
-using System.Data.SqlTypes;
-
-namespace Microsoft.Data.SqlClient.Server
-{
- // Interface for strongly-typed value getters
- internal interface ITypedGetters
- {
- // Null test
- bool IsDBNull(int ordinal);
-
- // Check what type current sql_variant value is
- SqlDbType GetVariantType(int ordinal);
-
- // By value accessors (data copy across the interface boundary implied)
- bool GetBoolean(int ordinal);
-
- byte GetByte(int ordinal);
-
- long GetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length);
-
- char GetChar(int ordinal);
-
- long GetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length);
-
- short GetInt16(int ordinal);
-
- int GetInt32(int ordinal);
-
- long GetInt64(int ordinal);
-
- float GetFloat(int ordinal);
-
- double GetDouble(int ordinal);
-
- string GetString(int ordinal);
-
- decimal GetDecimal(int ordinal);
-
- DateTime GetDateTime(int ordinal);
-
- Guid GetGuid(int ordinal);
-
- SqlBoolean GetSqlBoolean(int ordinal);
-
- SqlByte GetSqlByte(int ordinal);
-
- SqlInt16 GetSqlInt16(int ordinal);
-
- SqlInt32 GetSqlInt32(int ordinal);
-
- SqlInt64 GetSqlInt64(int ordinal);
-
- SqlSingle GetSqlSingle(int ordinal);
-
- SqlDouble GetSqlDouble(int ordinal);
-
- SqlMoney GetSqlMoney(int ordinal);
-
- SqlDateTime GetSqlDateTime(int ordinal);
-
- SqlDecimal GetSqlDecimal(int ordinal);
-
- SqlString GetSqlString(int ordinal);
-
- SqlBinary GetSqlBinary(int ordinal);
-
- SqlGuid GetSqlGuid(int ordinal);
-
- SqlChars GetSqlChars(int ordinal);
-
- SqlBytes GetSqlBytes(int ordinal);
-
- SqlXml GetSqlXml(int ordinal);
-
-
- // "By reference" accessors
- // May hook to buffer.
- // Semantics guarantee is that as long as the object exposing the accessor is not logically
- // moved to a new set of values and the overall state (open/closed) isn't changed, it will not
- // change the underlying value returned and continue to allow access to it.
- //
- // Example: GetSqlCharsRef called on an event stream value. The back-end optimizes by re-using
- // the buffer wrapped by the returned SqlChars on the next row event, but guarantees that it
- // won't change the value until the next event is consumed.
- //
- // Simplest way to guarantee this behavior is to simply call the corresponding by-value accessor.
- SqlBytes GetSqlBytesRef(int ordinal);
-
- SqlChars GetSqlCharsRef(int ordinal);
-
- SqlXml GetSqlXmlRef(int ordinal);
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedGettersV3.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedGettersV3.cs
index 1203e0a6ac..056d89d722 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedGettersV3.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedGettersV3.cs
@@ -12,11 +12,11 @@ internal interface ITypedGettersV3
{
// Null test
// valid for all types
- bool IsDBNull(SmiEventSink sink, int ordinal);
+ bool IsDBNull(int ordinal);
// Check what type current sql_variant value is
// valid for SqlDbType.Variant
- SmiMetaData GetVariantType(SmiEventSink sink, int ordinal);
+ SmiMetaData GetVariantType(int ordinal);
//
// Actual value accessors
@@ -25,44 +25,44 @@ internal interface ITypedGettersV3
//
// valid for SqlDbType.Bit
- bool GetBoolean(SmiEventSink sink, int ordinal);
+ bool GetBoolean(int ordinal);
// valid for SqlDbType.TinyInt
- byte GetByte(SmiEventSink sink, int ordinal);
+ byte GetByte(int ordinal);
// valid for SqlDbTypes: Binary, VarBinary, Image, Udt, Xml, Char, VarChar, Text, NChar, NVarChar, NText
// (Character type support needed for ExecuteXmlReader handling)
- long GetBytesLength(SmiEventSink sink, int ordinal);
- int GetBytes(SmiEventSink sink, int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length);
+ long GetBytesLength(int ordinal);
+ int GetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length);
// valid for character types: Char, VarChar, Text, NChar, NVarChar, NText
- long GetCharsLength(SmiEventSink sink, int ordinal);
- int GetChars(SmiEventSink sink, int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length);
- string GetString(SmiEventSink sink, int ordinal);
+ long GetCharsLength(int ordinal);
+ int GetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length);
+ string GetString(int ordinal);
// valid for SqlDbType.SmallInt
- short GetInt16(SmiEventSink sink, int ordinal);
+ short GetInt16(int ordinal);
// valid for SqlDbType.Int
- int GetInt32(SmiEventSink sink, int ordinal);
+ int GetInt32(int ordinal);
// valid for SqlDbType.BigInt, SqlDbType.Money, SqlDbType.SmallMoney
- long GetInt64(SmiEventSink sink, int ordinal);
+ long GetInt64(int ordinal);
// valid for SqlDbType.Real
- float GetSingle(SmiEventSink sink, int ordinal);
+ float GetSingle(int ordinal);
// valid for SqlDbType.Float
- double GetDouble(SmiEventSink sink, int ordinal);
+ double GetDouble(int ordinal);
// valid for SqlDbType.Numeric (uses SqlDecimal since Decimal cannot hold full range)
- SqlDecimal GetSqlDecimal(SmiEventSink sink, int ordinal);
+ SqlDecimal GetSqlDecimal(int ordinal);
// valid for DateTime & SmallDateTime
- DateTime GetDateTime(SmiEventSink sink, int ordinal);
+ DateTime GetDateTime(int ordinal);
// valid for UniqueIdentifier
- Guid GetGuid(SmiEventSink sink, int ordinal);
+ Guid GetGuid(int ordinal);
}
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedSetters.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedSetters.cs
deleted file mode 100644
index b294c6b347..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedSetters.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Data.SqlTypes;
-
-namespace Microsoft.Data.SqlClient.Server
-{
- // interface for strongly-typed value setters
- internal interface ITypedSetters
- {
- // By value setters (data copy across the interface boundary implied)
- void SetDBNull(int ordinal);
-
- void SetBoolean(int ordinal, bool value);
-
- void SetByte(int ordinal, byte value);
-
- void SetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length);
-
- void SetChar(int ordinal, char value);
-
- void SetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length);
-
- void SetInt16(int ordinal, short value);
-
- void SetInt32(int ordinal, int value);
-
- void SetInt64(int ordinal, long value);
-
- void SetFloat(int ordinal, float value);
-
- void SetDouble(int ordinal, double value);
-
- [ObsoleteAttribute("Not supported as of SMI v2. Will be removed when v1 support dropped. Use setter with offset.")]
- void SetString(int ordinal, string value);
-
- // Method introduced as of SMI V2
- void SetString(int ordinal, string value, int offset);
-
- void SetDecimal(int ordinal, decimal value);
-
- void SetDateTime(int ordinal, DateTime value);
-
- void SetGuid(int ordinal, Guid value);
-
- void SetSqlBoolean(int ordinal, SqlBoolean value);
-
- void SetSqlByte(int ordinal, SqlByte value);
-
- void SetSqlInt16(int ordinal, SqlInt16 value);
-
- void SetSqlInt32(int ordinal, SqlInt32 value);
-
- void SetSqlInt64(int ordinal, SqlInt64 value);
-
- void SetSqlSingle(int ordinal, SqlSingle value);
-
- void SetSqlDouble(int ordinal, SqlDouble value);
-
- void SetSqlMoney(int ordinal, SqlMoney value);
-
- void SetSqlDateTime(int ordinal, SqlDateTime value);
-
- void SetSqlDecimal(int ordinal, SqlDecimal value);
-
- [ObsoleteAttribute("Not supported as of SMI v2. Will be removed when v1 support dropped. Use setter with offset.")]
- void SetSqlString(int ordinal, SqlString value);
-
- // Method introduced as of SMI V2
- void SetSqlString(int ordinal, SqlString value, int offset);
-
- [ObsoleteAttribute("Not supported as of SMI v2. Will be removed when v1 support dropped. Use setter with offset.")]
- void SetSqlBinary(int ordinal, SqlBinary value);
-
- // Method introduced as of SMI V2
- void SetSqlBinary(int ordinal, SqlBinary value, int offset);
-
- void SetSqlGuid(int ordinal, SqlGuid value);
-
- [ObsoleteAttribute("Not supported as of SMI v2. Will be removed when v1 support dropped. Use setter with offset.")]
- void SetSqlChars(int ordinal, SqlChars value);
-
- // Method introduced as of SMI V2
- void SetSqlChars(int ordinal, SqlChars value, int offset);
-
- [ObsoleteAttribute("Not supported as of SMI v2. Will be removed when v1 support dropped. Use setter with offset.")]
- void SetSqlBytes(int ordinal, SqlBytes value);
-
- // Method introduced as of SMI V2
- void SetSqlBytes(int ordinal, SqlBytes value, int offset);
-
- void SetSqlXml(int ordinal, SqlXml value);
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedSettersV3.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedSettersV3.cs
index 6108e787b7..4ae70725ae 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedSettersV3.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ITypedSettersV3.cs
@@ -21,58 +21,58 @@ internal interface ITypedSettersV3
// the following pairs are the only setters/sqldbtypes that need this call:
// NVarChar/VarChar + SetString (needed only for non-global collation, i.e. SqlString)
// Money/SmallMoney + SetInt64
- void SetVariantMetaData(SmiEventSink sink, int ordinal, SmiMetaData metaData);
+ void SetVariantMetaData(int ordinal, SmiMetaData metaData);
// Set value to null
// valid for all types
- void SetDBNull(SmiEventSink sink, int ordinal);
+ void SetDBNull(int ordinal);
// valid for SqlDbType.Bit
- void SetBoolean(SmiEventSink sink, int ordinal, bool value);
+ void SetBoolean(int ordinal, bool value);
// valid for SqlDbType.TinyInt
- void SetByte(SmiEventSink sink, int ordinal, byte value);
+ void SetByte(int ordinal, byte value);
// Semantics for SetBytes are to modify existing value, not overwrite
// Use in combination with SetLength to ensure overwriting when necessary
// valid for SqlDbTypes: Binary, VarBinary, Image, Udt, Xml
// (VarBinary assumed for variants)
- int SetBytes(SmiEventSink sink, int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length);
- void SetBytesLength(SmiEventSink sink, int ordinal, long length);
+ int SetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length);
+ void SetBytesLength(int ordinal, long length);
// Semantics for SetChars are to modify existing value, not overwrite
// Use in combination with SetLength to ensure overwriting when necessary
// valid for character types: Char, VarChar, Text, NChar, NVarChar, NText
// (NVarChar and global clr collation assumed for variants)
- int SetChars(SmiEventSink sink, int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length);
- void SetCharsLength(SmiEventSink sink, int ordinal, long length);
+ int SetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length);
+ void SetCharsLength(int ordinal, long length);
// valid for character types: Char, VarChar, Text, NChar, NVarChar, NText
- void SetString(SmiEventSink sink, int ordinal, string value, int offset, int length);
+ void SetString(int ordinal, string value, int offset, int length);
// valid for SqlDbType.SmallInt
- void SetInt16(SmiEventSink sink, int ordinal, short value);
+ void SetInt16(int ordinal, short value);
// valid for SqlDbType.Int
- void SetInt32(SmiEventSink sink, int ordinal, int value);
+ void SetInt32(int ordinal, int value);
// valid for SqlDbType.BigInt, SqlDbType.Money, SqlDbType.SmallMoney
- void SetInt64(SmiEventSink sink, int ordinal, long value);
+ void SetInt64(int ordinal, long value);
// valid for SqlDbType.Real
- void SetSingle(SmiEventSink sink, int ordinal, float value);
+ void SetSingle(int ordinal, float value);
// valid for SqlDbType.Float
- void SetDouble(SmiEventSink sink, int ordinal, double value);
+ void SetDouble(int ordinal, double value);
// valid for SqlDbType.Numeric (uses SqlDecimal since Decimal cannot hold full range)
- void SetSqlDecimal(SmiEventSink sink, int ordinal, SqlDecimal value);
+ void SetSqlDecimal(int ordinal, SqlDecimal value);
// valid for DateTime & SmallDateTime
- void SetDateTime(SmiEventSink sink, int ordinal, DateTime value);
+ void SetDateTime(int ordinal, DateTime value);
// valid for UniqueIdentifier
- void SetGuid(SmiEventSink sink, int ordinal, Guid value);
+ void SetGuid(int ordinal, Guid value);
}
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MemoryRecordBuffer.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MemoryRecordBuffer.cs
index 1daf6b225c..12dda06c9f 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MemoryRecordBuffer.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MemoryRecordBuffer.cs
@@ -28,132 +28,133 @@ internal MemoryRecordBuffer(SmiMetaData[] metaData)
#region Getters
// Null test
// valid for all types
- public override bool IsDBNull(SmiEventSink sink, int ordinal)
+ public override bool IsDBNull(int ordinal)
{
return _buffer[ordinal].IsNull;
}
// Check what type current sql_variant value is
// valid for SqlDbType.Variant
- public override SmiMetaData GetVariantType(SmiEventSink sink, int ordinal)
+ public override SmiMetaData GetVariantType(int ordinal)
{
return _buffer[ordinal].VariantType;
}
// valid for SqlDbType.Bit
- public override bool GetBoolean(SmiEventSink sink, int ordinal)
+ public override bool GetBoolean(int ordinal)
{
return _buffer[ordinal].Boolean;
}
// valid for SqlDbType.TinyInt
- public override byte GetByte(SmiEventSink sink, int ordinal)
+ public override byte GetByte(int ordinal)
{
return _buffer[ordinal].Byte;
}
// valid for SqlDbTypes: Binary, VarBinary, Image, Udt, Xml, Char, VarChar, Text, NChar, NVarChar, NText
// (Character type support needed for ExecuteXmlReader handling)
- public override long GetBytesLength(SmiEventSink sink, int ordinal)
+ public override long GetBytesLength(int ordinal)
{
return _buffer[ordinal].BytesLength;
}
- public override int GetBytes(SmiEventSink sink, int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
+ public override int GetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
{
return _buffer[ordinal].GetBytes(fieldOffset, buffer, bufferOffset, length);
}
// valid for character types: Char, VarChar, Text, NChar, NVarChar, NText
- public override long GetCharsLength(SmiEventSink sink, int ordinal)
+ public override long GetCharsLength(int ordinal)
{
return _buffer[ordinal].CharsLength;
}
- public override int GetChars(SmiEventSink sink, int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
+ public override int GetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
{
return _buffer[ordinal].GetChars(fieldOffset, buffer, bufferOffset, length);
}
- public override string GetString(SmiEventSink sink, int ordinal)
+ public override string GetString(int ordinal)
{
return _buffer[ordinal].String;
}
// valid for SqlDbType.SmallInt
- public override short GetInt16(SmiEventSink sink, int ordinal)
+ public override short GetInt16(int ordinal)
{
return _buffer[ordinal].Int16;
}
// valid for SqlDbType.Int
- public override int GetInt32(SmiEventSink sink, int ordinal)
+ public override int GetInt32(int ordinal)
{
return _buffer[ordinal].Int32;
}
// valid for SqlDbType.BigInt, SqlDbType.Money, SqlDbType.SmallMoney
- public override long GetInt64(SmiEventSink sink, int ordinal)
+ public override long GetInt64(int ordinal)
{
return _buffer[ordinal].Int64;
}
// valid for SqlDbType.Real
- public override float GetSingle(SmiEventSink sink, int ordinal)
+ public override float GetSingle(int ordinal)
{
return _buffer[ordinal].Single;
}
// valid for SqlDbType.Float
- public override double GetDouble(SmiEventSink sink, int ordinal)
+ public override double GetDouble(int ordinal)
{
return _buffer[ordinal].Double;
}
// valid for SqlDbType.Numeric (uses SqlDecimal since Decimal cannot hold full range)
- public override SqlDecimal GetSqlDecimal(SmiEventSink sink, int ordinal)
+ public override SqlDecimal GetSqlDecimal(int ordinal)
{
return _buffer[ordinal].SqlDecimal;
}
// valid for DateTime, SmallDateTime, Date, and DateTime2
- public override DateTime GetDateTime(SmiEventSink sink, int ordinal)
+ public override DateTime GetDateTime(int ordinal)
{
return _buffer[ordinal].DateTime;
}
// valid for UniqueIdentifier
- public override Guid GetGuid(SmiEventSink sink, int ordinal)
+ public override Guid GetGuid(int ordinal)
{
return _buffer[ordinal].Guid;
}
// valid for SqlDbType.Time
- public override TimeSpan GetTimeSpan(SmiEventSink sink, int ordinal)
+ public override TimeSpan GetTimeSpan(int ordinal)
{
return _buffer[ordinal].TimeSpan;
}
// valid for DateTimeOffset
- public override DateTimeOffset GetDateTimeOffset(SmiEventSink sink, int ordinal)
+ public override DateTimeOffset GetDateTimeOffset(int ordinal)
{
return _buffer[ordinal].DateTimeOffset;
}
#endregion
#region Setters
+
// Set value to null
// valid for all types
- public override void SetDBNull(SmiEventSink sink, int ordinal)
+ public override void SetDBNull(int ordinal)
{
_buffer[ordinal].SetNull();
}
// valid for SqlDbType.Bit
- public override void SetBoolean(SmiEventSink sink, int ordinal, bool value)
+ public override void SetBoolean(int ordinal, bool value)
{
_buffer[ordinal].Boolean = value;
}
// valid for SqlDbType.TinyInt
- public override void SetByte(SmiEventSink sink, int ordinal, byte value)
+ public override void SetByte(int ordinal, byte value)
{
_buffer[ordinal].Byte = value;
}
@@ -162,11 +163,11 @@ public override void SetByte(SmiEventSink sink, int ordinal, byte value)
// Use in combination with SetLength to ensure overwriting when necessary
// valid for SqlDbTypes: Binary, VarBinary, Image, Udt, Xml
// (VarBinary assumed for variants)
- public override int SetBytes(SmiEventSink sink, int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
+ public override int SetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
{
return _buffer[ordinal].SetBytes(fieldOffset, buffer, bufferOffset, length);
}
- public override void SetBytesLength(SmiEventSink sink, int ordinal, long length)
+ public override void SetBytesLength(int ordinal, long length)
{
_buffer[ordinal].BytesLength = length;
}
@@ -175,17 +176,17 @@ public override void SetBytesLength(SmiEventSink sink, int ordinal, long length)
// Use in combination with SetLength to ensure overwriting when necessary
// valid for character types: Char, VarChar, Text, NChar, NVarChar, NText
// (NVarChar and global clr collation assumed for variants)
- public override int SetChars(SmiEventSink sink, int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
+ public override int SetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
{
return _buffer[ordinal].SetChars(fieldOffset, buffer, bufferOffset, length);
}
- public override void SetCharsLength(SmiEventSink sink, int ordinal, long length)
+ public override void SetCharsLength(int ordinal, long length)
{
_buffer[ordinal].CharsLength = length;
}
// valid for character types: Char, VarChar, Text, NChar, NVarChar, NText
- public override void SetString(SmiEventSink sink, int ordinal, string value, int offset, int length)
+ public override void SetString(int ordinal, string value, int offset, int length)
{
Debug.Assert(offset == 0 && length <= value.Length, "Invalid string length or offset"); // for sqlvariant, length could be less than value.Length
@@ -193,67 +194,67 @@ public override void SetString(SmiEventSink sink, int ordinal, string value, int
}
// valid for SqlDbType.SmallInt
- public override void SetInt16(SmiEventSink sink, int ordinal, short value)
+ public override void SetInt16(int ordinal, short value)
{
_buffer[ordinal].Int16 = value;
}
// valid for SqlDbType.Int
- public override void SetInt32(SmiEventSink sink, int ordinal, int value)
+ public override void SetInt32(int ordinal, int value)
{
_buffer[ordinal].Int32 = value;
}
// valid for SqlDbType.BigInt, SqlDbType.Money, SqlDbType.SmallMoney
- public override void SetInt64(SmiEventSink sink, int ordinal, long value)
+ public override void SetInt64(int ordinal, long value)
{
_buffer[ordinal].Int64 = value;
}
// valid for SqlDbType.Real
- public override void SetSingle(SmiEventSink sink, int ordinal, float value)
+ public override void SetSingle(int ordinal, float value)
{
_buffer[ordinal].Single = value;
}
// valid for SqlDbType.Float
- public override void SetDouble(SmiEventSink sink, int ordinal, double value)
+ public override void SetDouble(int ordinal, double value)
{
_buffer[ordinal].Double = value;
}
// valid for SqlDbType.Numeric (uses SqlDecimal since Decimal cannot hold full range)
- public override void SetSqlDecimal(SmiEventSink sink, int ordinal, SqlDecimal value)
+ public override void SetSqlDecimal(int ordinal, SqlDecimal value)
{
_buffer[ordinal].SqlDecimal = value;
}
// valid for DateTime, SmallDateTime, Date, and DateTime2
- public override void SetDateTime(SmiEventSink sink, int ordinal, DateTime value)
+ public override void SetDateTime(int ordinal, DateTime value)
{
_buffer[ordinal].DateTime = value;
}
// valid for UniqueIdentifier
- public override void SetGuid(SmiEventSink sink, int ordinal, Guid value)
+ public override void SetGuid(int ordinal, Guid value)
{
_buffer[ordinal].Guid = value;
}
// SqlDbType.Time
- public override void SetTimeSpan(SmiEventSink sink, int ordinal, TimeSpan value)
+ public override void SetTimeSpan(int ordinal, TimeSpan value)
{
_buffer[ordinal].TimeSpan = value;
}
// DateTimeOffset
- public override void SetDateTimeOffset(SmiEventSink sink, int ordinal, DateTimeOffset value)
+ public override void SetDateTimeOffset(int ordinal, DateTimeOffset value)
{
_buffer[ordinal].DateTimeOffset = value;
}
// valid for SqlDbType.Variant
- public override void SetVariantMetaData(SmiEventSink sink, int ordinal, SmiMetaData metaData)
+ public override void SetVariantMetaData(int ordinal, SmiMetaData metaData)
{
_buffer[ordinal].VariantType = metaData;
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MetadataUtilsSmi.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MetadataUtilsSmi.cs
index 9000fb6ff9..eeda678834 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MetadataUtilsSmi.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MetadataUtilsSmi.cs
@@ -19,7 +19,7 @@ namespace Microsoft.Data.SqlClient.Server
/// These are all based off of knowing the clr type of the value
/// as an ExtendedClrTypeCode enum for rapid access.
///
- internal class MetaDataUtilsSmi
+ internal static class MetaDataUtilsSmi
{
internal const SqlDbType InvalidSqlDbType = (SqlDbType)(-1);
internal const long InvalidMaxLength = -2;
@@ -163,10 +163,6 @@ internal static bool IsAnsiType(SqlDbType type) => type == SqlDbType.Char ||
type == SqlDbType.VarChar ||
type == SqlDbType.Text;
- internal static bool IsBinaryType(SqlDbType type) => type == SqlDbType.Binary ||
- type == SqlDbType.VarBinary ||
- type == SqlDbType.Image;
-
// Does this type use PLP format values?
internal static bool IsPlpFormat(SmiMetaData metaData) =>
metaData.MaxLength == SmiMetaData.UnlimitedMaxLengthIndicator ||
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiConnection.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiConnection.netfx.cs
deleted file mode 100644
index ec9ad6e0ac..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiConnection.netfx.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-#if NETFRAMEWORK
-
-using System;
-using System.Data;
-
-namespace Microsoft.Data.SqlClient.Server
-{
-
- internal abstract class SmiConnection : IDisposable
- {
-
- //
- // Miscellaneous directives / accessors
- //
- internal abstract string GetCurrentDatabase(SmiEventSink eventSink);
-
- internal abstract void SetCurrentDatabase(string databaseName, SmiEventSink eventSink);
-
- //
- // IDisposable
- //
- public virtual void Dispose()
- {
- // Obsoleting from SMI -- use Close( SmiEventSink ) instead.
- // Intended to be removed (along with inheriting IDisposable) prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- Common.ADP.InternalError(Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void Close(SmiEventSink eventSink)
- {
- // Adding as of V3
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V2- and hasn't implemented V3 yet.
- // 2) Server didn't implement V3 on some interface, but negotiated V3+.
- Common.ADP.InternalError(Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- //
- // Transaction API
- //
- internal abstract void BeginTransaction(string name, IsolationLevel level, SmiEventSink eventSink);
-
- internal abstract void CommitTransaction(long transactionId, SmiEventSink eventSink);
-
- internal abstract void CreateTransactionSavePoint(long transactionId, string name, SmiEventSink eventSink);
-
- internal abstract byte[] GetDTCAddress(SmiEventSink eventSink);
-
- internal abstract void EnlistTransaction(byte[] token, SmiEventSink eventSink);
-
- internal abstract byte[] PromoteTransaction(long transactionId, SmiEventSink eventSink);
-
- internal abstract void RollbackTransaction(long transactionId, string savePointName, SmiEventSink eventSink);
-
- }
-}
-
-#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink.cs
deleted file mode 100644
index a7de4b1947..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace Microsoft.Data.SqlClient.Server
-{
- ///
- /// SqlEventSink is implemented by calling code. In all methods that accept
- /// a SqlEventSink directly the sink must be able to handle multiple callbacks
- /// without control returning from the original call.
- ///
- /// Methods that do not accept SmiEventSync are (generally) ProcessEvent on
- /// the SmiEventStream methods returning a SmiEventStream and methods that
- /// are certain to never call to the server (most will, for in-proc back end).
- ///
- /// Methods are commented with their corresponding TDS token
- ///
- /// NOTE: Throwing from these methods will not usually produce the desired
- /// effect -- the managed to native boundary will eat any exceptions,
- /// and will cause a simple "Something bad happened" exception to be
- /// thrown in the native to managed boundary...
- ///
- internal abstract class SmiEventSink
- {
-#if NETFRAMEWORK
-
- // Called at end of stream whether errors or no
- internal abstract void BatchCompleted();
-
- // Called zero or one time when output parameters are available (errors could prevent event from occuring)
- internal virtual void ParameterAvailable(SmiParameterMetaData metaData, SmiTypedGetterSetter paramValue, int ordinal)
- {
- // Adding as of V200
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3- and hasn't implemented V200 yet.
- // 2) Server didn't implement V200 on some interface, but negotiated V200+.
- Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- // Called when the server database context changes (ENVCHANGE token)
- internal abstract void DefaultDatabaseChanged(string databaseName);
-
- // Called for messages and errors (ERROR and INFO tokens)
- internal abstract void MessagePosted(int number, byte state, byte errorClass, string server, string message, string procedure, int lineNumber);
-
- // Called for new resultset starting (COLMETADATA token)
- internal abstract void MetaDataAvailable(SmiQueryMetaData[] metaData, bool nextEventIsRow);
-
-
- internal virtual void RowAvailable(SmiTypedGetterSetter rowData)
- {
- // Adding as of V200
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3- and hasn't implemented V200 yet.
- // 2) Server didn't implement V200 on some interface, but negotiated V200+.
- Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- // Called when any statement completes on server (DONE token)
- internal abstract void StatementCompleted(int rowsAffected);
-
- // Called when a transaction is committed (ENVCHANGE token)
- internal abstract void TransactionCommitted(long transactionId);
-
- // Called when a transaction is committed (ENVCHANGE token)
- internal abstract void TransactionDefected(long transactionId);
-
- // Called when a transaction is committed (ENVCHANGE token)
- internal abstract void TransactionEnlisted(long transactionId);
-
- // Called when a transaction is forcibly ended in the server, not requested
- // by the provider's batch (ENVCHANGE token)
- internal abstract void TransactionEnded(long transactionId);
-
- // Called when a transaction is rolled back (ENVCHANGE token)
- internal abstract void TransactionRolledBack(long transactionId);
-
- // Called when a transaction is started (ENVCHANGE token)
- internal abstract void TransactionStarted(long transactionId);
-
-
-#region OBSOLETE METHODS
-#region OBSOLETED as of V200 but active in previous version
- // Called zero or one time when output parameters are available (errors could prevent event from occuring)
- internal virtual void ParametersAvailable(SmiParameterMetaData[] metaData, ITypedGettersV3 paramValues)
- {
- // Adding as of V3
- // Obsoleting as of V200
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V200+ and dropped support for V200-.
- // 2) Server didn't implement V3- on some interface and negotiated V3-.
- Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- // Called when a new row arrives (ROW token)
- internal virtual void RowAvailable(ITypedGettersV3 rowData)
- {
- // Adding as of V3
- // Obsoleting as of V200
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V200+ and dropped support for V200-.
- // 2) Server didn't implement V3- on some interface and negotiated V3-.
- Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
-#endregion
-
-#region OBSOLETED and never shipped (without ObsoleteAttribute)
- // Called when a new row arrives (ROW token)
- internal virtual void RowAvailable(ITypedGetters rowData)
- {
- // Obsoleting from SMI -- use end of dispose that takes an event sink instead.
- // Intended to be removed (along with inheriting IDisposable) prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
-#endregion
-#endregion
-
-#endif
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.cs
index 0477b6aea4..6f42a87aa5 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.cs
@@ -6,7 +6,7 @@
namespace Microsoft.Data.SqlClient.Server
{
- internal partial class SmiEventSink_Default : SmiEventSink
+ internal class SmiEventSink_Default
{
private SqlErrorCollection _errors;
private SqlErrorCollection _warnings;
@@ -17,62 +17,36 @@ internal SmiEventSink_Default()
{
}
- internal bool HasMessages
- {
- get
- {
-#if NETFRAMEWORK
- SmiEventSink_Default parent = (SmiEventSink_Default)_parent;
- if (parent != null)
- {
- return parent.HasMessages;
- }
- else
-#endif
- {
- bool result = _errors != null || _warnings != null;
- return result;
- }
- }
- }
+ internal bool HasMessages => _errors is not null || _warnings is not null;
- protected virtual void DispatchMessages(
-#if NETFRAMEWORK
- bool ignoreNonFatalMessages
-#endif
- )
+ #if NETFRAMEWORK
+ protected virtual void DispatchMessages(bool ignoreNonFatalMessages)
+ #else
+ protected virtual void DispatchMessages()
+ #endif
{
// virtual because we want a default implementation in the cases
// where we don't have a connection to process stuff, but we want to
// provide the connection the ability to fire info messages when it
// hooks up.
-#if NETFRAMEWORK
- SmiEventSink_Default parent = (SmiEventSink_Default)_parent;
- if (parent != null)
- {
- parent.DispatchMessages(ignoreNonFatalMessages);
- }
- else
-#endif
+ #if NETFRAMEWORK
+ SqlException errors = ProcessMessages(true, ignoreNonFatalMessages);
+ #else
+ SqlException errors = ProcessMessages(true);
+ #endif
+
+ if (errors != null)
{
- SqlException errors = ProcessMessages(true
-#if NETFRAMEWORK
- , ignoreNonFatalMessages
-#endif
- ); // ignore warnings, because there's no place to send them...
- if (errors != null)
- {
- throw errors;
- }
+ throw errors;
}
}
- protected SqlException ProcessMessages(bool ignoreWarnings
-#if NETFRAMEWORK
- , bool ignoreNonFatalMessages
-#endif
- )
+ #if NETFRAMEWORK
+ protected SqlException ProcessMessages(bool ignoreWarnings, bool ignoreNonFatalMessages)
+ #else
+ protected SqlException ProcessMessages(bool ignoreWarnings)
+ #endif
{
SqlException result = null;
SqlErrorCollection temp = null; // temp variable to store that which is being thrown - so that local copies can be deleted
@@ -136,14 +110,14 @@ protected SqlException ProcessMessages(bool ignoreWarnings
internal void ProcessMessagesAndThrow()
{
-#if NETFRAMEWORK
- ProcessMessagesAndThrow(false);
-#else
if (HasMessages)
{
+ #if NETFRAMEWORK
+ DispatchMessages(false);
+ #else
DispatchMessages();
+ #endif
}
-#endif
}
}
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.netfx.cs
deleted file mode 100644
index 9872953b24..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.netfx.cs
+++ /dev/null
@@ -1,261 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Diagnostics;
-
-namespace Microsoft.Data.SqlClient.Server
-{
- internal partial class SmiEventSink_Default : SmiEventSink
- {
- private SmiEventSink _parent; // next level up, which we'll defer to if we don't need to handle the event.
- private SqlErrorCollection Errors
- {
- get
- {
- if (_errors == null)
- {
- _errors = new SqlErrorCollection();
- }
-
- return _errors;
- }
- }
-
- internal SmiEventSink Parent
- {
- get => _parent;
- set => _parent = value;
- }
-
- private SqlErrorCollection Warnings
- {
- get
- {
- if (_warnings == null)
- {
- _warnings = new SqlErrorCollection();
- }
-
- return _warnings;
- }
- }
-
- internal void ProcessMessagesAndThrow(bool ignoreNonFatalMessages)
- {
- if (HasMessages)
- {
- DispatchMessages(ignoreNonFatalMessages);
- }
- }
-
- internal void CleanMessages()
- {
- SmiEventSink_Default parent = (SmiEventSink_Default)_parent;
- if (parent != null)
- {
- parent.CleanMessages();
- }
- else
- {
- _errors = null;
- _warnings = null;
- }
- }
-
- internal enum UnexpectedEventType
- {
- BatchCompleted,
- ColumnInfoAvailable,
- DefaultDatabaseChanged,
- MessagePosted,
- MetaDataAvailable,
- ParameterAvailable,
- ParametersAvailable,
- RowAvailable,
- StatementCompleted,
- TableNameAvailable,
- TransactionCommitted,
- TransactionDefected,
- TransactionEnlisted,
- TransactionEnded,
- TransactionRolledBack,
- TransactionStarted,
- }
-
- internal SmiEventSink_Default(SmiEventSink parent)
- {
- _parent = parent;
- }
-
- //
- //NOTE: See the note in SmiEventSink about throwing from these methods;
- // We're throwing here because we don't want to miss something, but
- //you'll need to turn on Bid tracing to figure out what it is that
- //was thrown, because they will be eaten by the server and replaced
- //with a different exception.
- // Called at end of stream
- //
- internal override void BatchCompleted()
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.BatchCompleted);
- }
- _parent.BatchCompleted();
- }
-
- internal override void ParametersAvailable(SmiParameterMetaData[] metaData, ITypedGettersV3 paramValues)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.ParametersAvailable);
- }
- _parent.ParametersAvailable(metaData, paramValues);
- }
-
- internal override void ParameterAvailable(SmiParameterMetaData metaData, SmiTypedGetterSetter paramValue, int ordinal)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.ParameterAvailable);
- }
- _parent.ParameterAvailable(metaData, paramValue, ordinal);
- }
-
- // Called when the server database context changes (ENVCHANGE token)
- internal override void DefaultDatabaseChanged(string databaseName)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.DefaultDatabaseChanged);
- }
- _parent.DefaultDatabaseChanged(databaseName);
- }
-
- // Called for messages and errors (ERROR and INFO tokens)
- internal override void MessagePosted(int number, byte state, byte errorClass, string server, string message, string procedure, int lineNumber)
- {
- if (_parent == null)
- {
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, number={1} state={2} errorClass={3} server='{4}' message='{5}' procedure='{6}' linenumber={7}.", 0, number, state, errorClass, server, message, procedure, lineNumber);
- SqlError error = new SqlError(number, state, errorClass, server, message, procedure, lineNumber);
-
- if (error.Class < TdsEnums.MIN_ERROR_CLASS)
- {
- Warnings.Add(error);
- }
- else
- {
- Errors.Add(error);
- }
- }
- else
- {
- _parent.MessagePosted(number, state, errorClass, server, message, procedure, lineNumber);
- }
- }
-
- // Called for new resultset starting (COLMETADATA token)
- internal override void MetaDataAvailable(SmiQueryMetaData[] metaData, bool nextEventIsRow)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.MetaDataAvailable);
- }
- _parent.MetaDataAvailable(metaData, nextEventIsRow);
- }
-
- // Called when a new row arrives (ROW token)
- internal override void RowAvailable(ITypedGetters rowData)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.RowAvailable);
- }
- _parent.RowAvailable(rowData);
- }
-
- // Called when a new row arrives (ROW token)
- internal override void RowAvailable(ITypedGettersV3 rowData)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.RowAvailable);
- }
- _parent.RowAvailable(rowData);
- }
-
- // Called when any statement completes on server (DONE token)
- internal override void StatementCompleted(int rowsAffected)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.StatementCompleted);
- }
- _parent.StatementCompleted(rowsAffected);
- }
-
- // Called when a transaction is committed (ENVCHANGE token)
- internal override void TransactionCommitted(long transactionId)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.TransactionCommitted);
- }
- _parent.TransactionCommitted(transactionId);
- }
-
- // Called when a transaction is committed (ENVCHANGE token)
- internal override void TransactionDefected(long transactionId)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.TransactionDefected);
- }
- _parent.TransactionDefected(transactionId);
- }
-
- // Called when a transaction is committed (ENVCHANGE token)
- internal override void TransactionEnlisted(long transactionId)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.TransactionEnlisted);
- }
- _parent.TransactionEnlisted(transactionId);
- }
-
- // Called when a transaction is forcibly ended in the server, not requested
- // by the provider's batch (ENVCHANGE token)
- internal override void TransactionEnded(long transactionId)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.TransactionEnded);
- }
- _parent.TransactionEnded(transactionId);
- }
-
- // Called when a transaction is rolled back (ENVCHANGE token)
- internal override void TransactionRolledBack(long transactionId)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.TransactionRolledBack);
- }
- _parent.TransactionRolledBack(transactionId);
- }
-
- // Called when a transaction is started (ENVCHANGE token)
- internal override void TransactionStarted(long transactionId)
- {
- if (_parent == null)
- {
- throw SQL.UnexpectedSmiEvent(UnexpectedEventType.TransactionStarted);
- }
- _parent.TransactionStarted(transactionId);
- }
- }
-}
-
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_DeferredProcessing.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_DeferredProcessing.netfx.cs
deleted file mode 100644
index 71ddaec1dc..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_DeferredProcessing.netfx.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-#if NETFRAMEWORK
-
-namespace Microsoft.Data.SqlClient.Server
-{
- // This class exists purely to defer processing of messages until a later time.
- // It is designed to allow calling common code that interacts with the SMI layers
- // without throwing or otherwise processing messages in the sink until later on.
- //
- // Main example:
- // SqlCommand.ExecuteNonQuerySmi calls EventStream.ProcessEvent with it's command event sink (CES)
- // ProcessEvent calls OnParametersAvailable on the CES
- // OnParametersAvailable sets up a deferedprocessing event sink (DPES) with the CES as its parent
- // OnParametersAvailable calls ValueUtils to extract param values passing the DPES
- // ValueUtils calls Smi passing DPES
- // Smi may call MessagePosted, which will send a message up the sink parent chain and save it.
- // ValueUtils calls ProcessMessagesAndThrow on DPES, which skips handling
- // ... return up the stack ...
- // SqlCommand.ExecuteNonQuerySmi calls CES.ProcessMessagesAndThrow, which handles the messages
- // sent from the Smi value extraction code.
- //
- // IMPORTANT: Code that uses the DeferedProccess event sink is responsible for ensuring that
- // these messages ARE processed at some point.
- internal class SmiEventSink_DeferredProcessing : SmiEventSink_Default
- {
- internal SmiEventSink_DeferredProcessing(SmiEventSink parent) : base(parent)
- {
- }
-
- protected override void DispatchMessages(bool ignoreNonFatalMessages)
- {
- // Skip processing messages. Since messages are sent to parent and calling code will call
- // ProcessMessages against parent, messages ARE NOT LOST!
- }
- }
-}
-
-#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventStream.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventStream.netfx.cs
deleted file mode 100644
index cfdcc1bb3d..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventStream.netfx.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-#if NETFRAMEWORK
-
-using System;
-
-namespace Microsoft.Data.SqlClient.Server
-{
- // @TODO: Is this implemented *anywhere*?
- internal abstract class SmiEventStream : IDisposable
- {
- internal abstract bool HasEvents { get; }
-
- internal abstract void Close(SmiEventSink sink);
-
- [Obsolete("Use Close instead.")]
- public virtual void Dispose()
- {
- // Obsoleting from SMI -- use Close instead.
- // Intended to be removed (along with inheriting IDisposable) prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- Common.ADP.InternalError(Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- internal abstract void ProcessEvent(SmiEventSink sink);
- }
-}
-
-#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiExecuteType.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiExecuteType.netfx.cs
deleted file mode 100644
index 8d44f01ecd..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiExecuteType.netfx.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-#if NETFRAMEWORK
-
-namespace Microsoft.Data.SqlClient.Server
-{
- // Enum representing the type of execution requested
- internal enum SmiExecuteType
- {
- NonQuery = 0,
- Reader = 1,
- ToPipe = 2,
- }
-}
-
-#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiLink.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiLink.netfx.cs
deleted file mode 100644
index fbe4211359..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiLink.netfx.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-#if NETFRAMEWORK
-
-[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("SqlAccess, PublicKey=0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")] // SQLBU 437687
-
-namespace Microsoft.Data.SqlClient.Server
-{
- internal abstract class SmiLink
- {
-
- // NOTE: Except for changing the constant value below, adding new members
- // to this class may create versioning issues. We would prefer not
- // to add additional items to this if possible.
-
- internal const ulong InterfaceVersion = 210;
-
- // Version negotiation (appdomain-wide negotiation)
- // This needs to be the first method called when negotiating with a
- // driver back end. Once called, the rest of the back end interface
- // needs to conform to the returned version number's interface.
- internal abstract ulong NegotiateVersion(ulong requestedVersion);
-
- // Get utility class valid in current thread execution environment
- // This returns an object, to allow us to version the context without
- // having to version this class. (eg. SmiContext1 vs SmiContext2)
- internal abstract object GetCurrentContext(SmiEventSink eventSink);
- }
-}
-
-#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiMetaData.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiMetaData.cs
index a94ada1422..220471394c 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiMetaData.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiMetaData.cs
@@ -64,10 +64,6 @@ internal class SmiMetaData
internal const int MinPrecision = 1; // SqlDecimal defines max precision
internal const int MinScale = 0; // SqlDecimal defines max scale
internal const int MaxTimeScale = 7; // Max scale for time, datetime2, and datetimeoffset
- internal static readonly DateTime MaxSmallDateTime = new DateTime(2079, 06, 06, 23, 59, 29, 998);
- internal static readonly DateTime MinSmallDateTime = new DateTime(1899, 12, 31, 23, 59, 29, 999);
- internal static readonly SqlMoney MaxSmallMoney = new SqlMoney(((decimal)int.MaxValue) / 10000);
- internal static readonly SqlMoney MinSmallMoney = new SqlMoney(((decimal)int.MinValue) / 10000);
internal const SqlCompareOptions DefaultStringCompareOptions = SqlCompareOptions.IgnoreCase
| SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth;
@@ -116,41 +112,6 @@ internal class SmiMetaData
internal static readonly SmiMetaData DefaultDateTimeOffset = new SmiMetaData(SqlDbType.DateTimeOffset, 10, 0, 7, SqlCompareOptions.None); // SqlDbType.DateTimeOffset
// No default for generic UDT
- // character defaults hook thread-local culture to get collation
- internal static SmiMetaData DefaultChar =>
- new SmiMetaData(
- DefaultChar_NoCollation.SqlDbType,
- DefaultChar_NoCollation.MaxLength,
- DefaultChar_NoCollation.Precision,
- DefaultChar_NoCollation.Scale,
- CultureInfo.CurrentCulture.LCID,
- SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth,
- null
- );
-
-
- internal static SmiMetaData DefaultNChar =>
- new SmiMetaData(
- DefaultNChar_NoCollation.SqlDbType,
- DefaultNChar_NoCollation.MaxLength,
- DefaultNChar_NoCollation.Precision,
- DefaultNChar_NoCollation.Scale,
- CultureInfo.CurrentCulture.LCID,
- SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth,
- null
- );
-
- internal static SmiMetaData DefaultNText =>
- new SmiMetaData(
- DefaultNText_NoCollation.SqlDbType,
- DefaultNText_NoCollation.MaxLength,
- DefaultNText_NoCollation.Precision,
- DefaultNText_NoCollation.Scale,
- CultureInfo.CurrentCulture.LCID,
- SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth,
- null
- );
-
internal static SmiMetaData DefaultNVarChar =>
new SmiMetaData(
DefaultNVarChar_NoCollation.SqlDbType,
@@ -162,28 +123,6 @@ internal class SmiMetaData
null
);
- internal static SmiMetaData DefaultText =>
- new SmiMetaData(
- DefaultText_NoCollation.SqlDbType,
- DefaultText_NoCollation.MaxLength,
- DefaultText_NoCollation.Precision,
- DefaultText_NoCollation.Scale,
- CultureInfo.CurrentCulture.LCID,
- SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth,
- null
- );
-
- internal static SmiMetaData DefaultVarChar =>
- new SmiMetaData(
- DefaultVarChar_NoCollation.SqlDbType,
- DefaultVarChar_NoCollation.MaxLength,
- DefaultVarChar_NoCollation.Precision,
- DefaultVarChar_NoCollation.Scale,
- CultureInfo.CurrentCulture.LCID,
- SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth,
- null
- );
-
// The one and only constructor for use by outside code.
//
// Parameters that matter for given values of dbType (other parameters are ignored in favor of internal defaults).
@@ -413,63 +352,6 @@ SmiMetaDataPropertyCollection extendedProperties
#endif
}
- internal bool IsValidMaxLengthForCtorGivenType(SqlDbType dbType, long maxLength)
- {
- bool result = true;
- switch (dbType)
- {
- case SqlDbType.BigInt:
- case SqlDbType.Bit:
- case SqlDbType.DateTime:
- case SqlDbType.Float:
- case SqlDbType.Image:
- case SqlDbType.Int:
- case SqlDbType.Money:
- case SqlDbType.Real:
- case SqlDbType.SmallDateTime:
- case SqlDbType.SmallInt:
- case SqlDbType.SmallMoney:
- case SqlDbType.Timestamp:
- case SqlDbType.TinyInt:
- case SqlDbType.UniqueIdentifier:
- case SqlDbType.Variant:
- case SqlDbType.Xml:
- case SqlDbType.NText:
- case SqlDbType.Text:
- case SqlDbType.Decimal:
- case SqlDbType.Udt:
- case SqlDbType.Structured:
- case SqlDbType.Date:
- case SqlDbType.Time:
- case SqlDbType.DateTime2:
- case SqlDbType.DateTimeOffset:
- break;
- case SqlDbType.Binary:
- result = 0 < maxLength && MaxBinaryLength >= maxLength;
- break;
- case SqlDbType.VarBinary:
- result = UnlimitedMaxLengthIndicator == maxLength || (0 < maxLength && MaxBinaryLength >= maxLength);
- break;
- case SqlDbType.Char:
- result = 0 < maxLength && MaxANSICharacters >= maxLength;
- break;
- case SqlDbType.NChar:
- result = 0 < maxLength && MaxUnicodeCharacters >= maxLength;
- break;
- case SqlDbType.NVarChar:
- result = UnlimitedMaxLengthIndicator == maxLength || (0 < maxLength && MaxUnicodeCharacters >= maxLength);
- break;
- case SqlDbType.VarChar:
- result = UnlimitedMaxLengthIndicator == maxLength || (0 < maxLength && MaxANSICharacters >= maxLength);
- break;
- default:
- Debug.Fail("How in the world did we get here? :" + dbType);
- break;
- }
-
- return result;
- }
-
// Sql-style compare options for character types.
internal SqlCompareOptions CompareOptions => _compareOptions;
@@ -501,57 +383,6 @@ internal Type Type
}
}
- // Clr Type instance for user-defined types in cases where we don't want to throw if the assembly isn't available
- internal Type TypeWithoutThrowing
- {
- get
- {
- // Fault-in UDT clr types on access if have assembly-qualified name
- if (_clrType == null && SqlDbType.Udt == _databaseType && _udtAssemblyQualifiedName != null)
- {
- _clrType = Type.GetType(_udtAssemblyQualifiedName, false);
- }
- return _clrType;
- }
- }
-
- internal string TypeName
- {
- get
- {
- string result;
- if (SqlDbType.Udt == _databaseType)
- {
- Debug.Assert(string.Empty == s_typeNameByDatabaseType[(int)_databaseType], "unexpected udt?");
- result = Type.FullName;
- }
- else
- {
- result = s_typeNameByDatabaseType[(int)_databaseType];
- Debug.Assert(result != null, "unknown type name?");
- }
- return result;
- }
- }
-
- internal string AssemblyQualifiedName
- {
- get
- {
- string result = null;
- if (SqlDbType.Udt == _databaseType)
- {
- // Fault-in assembly-qualified name if type is available
- if (_udtAssemblyQualifiedName == null && _clrType != null)
- {
- _udtAssemblyQualifiedName = _clrType.AssemblyQualifiedName;
- }
- result = _udtAssemblyQualifiedName;
- }
- return result;
- }
- }
-
internal bool IsMultiValued => _isMultiValued;
// Returns read-only list of field metadata
@@ -699,8 +530,6 @@ private void SetDefaultsForType(SqlDbType dbType)
_extendedProperties = smdDflt._extendedProperties; // This is ok due to immutability
}
- internal string TraceString() => TraceString(0);
-
virtual internal string TraceString(int indent)
{
string indentStr = new string(' ', indent);
@@ -1221,8 +1050,6 @@ bool isColumnSet
internal bool IsIdentity => _isIdentity;
- internal bool IsColumnSet => _isColumnSet;
-
internal override string TraceString(int indent)
{
return string.Format(CultureInfo.InvariantCulture, "{0}"
@@ -1260,65 +1087,6 @@ internal class SmiQueryMetaData : SmiStorageMetaData
private readonly SqlBoolean _isAliased;
private readonly SqlBoolean _isHidden;
- internal SmiQueryMetaData(
- SqlDbType dbType,
- long maxLength,
- byte precision,
- byte scale,
- long localeId,
- SqlCompareOptions compareOptions,
-#if NET
- [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
-#endif
- Type userDefinedType,
- string name,
- string typeSpecificNamePart1,
- string typeSpecificNamePart2,
- string typeSpecificNamePart3,
- bool allowsDBNull,
- string serverName,
- string catalogName,
- string schemaName,
- string tableName,
- string columnName,
- SqlBoolean isKey,
- bool isIdentity,
- bool isReadOnly,
- SqlBoolean isExpression,
- SqlBoolean isAliased,
- SqlBoolean isHidden
- )
- : this(
- dbType,
- maxLength,
- precision,
- scale,
- localeId,
- compareOptions,
- userDefinedType,
- false,
- null,
- null,
- name,
- typeSpecificNamePart1,
- typeSpecificNamePart2,
- typeSpecificNamePart3,
- allowsDBNull,
- serverName,
- catalogName,
- schemaName,
- tableName,
- columnName,
- isKey,
- isIdentity,
- isReadOnly,
- isExpression,
- isAliased,
- isHidden
- )
- {
- }
-
// SMI V200 ctor.
internal SmiQueryMetaData(
SqlDbType dbType,
@@ -1451,8 +1219,6 @@ SqlBoolean isHidden
_isHidden = isHidden;
}
- internal bool IsReadOnly => _isReadOnly;
-
internal SqlBoolean IsExpression => _isExpression;
internal SqlBoolean IsAliased => _isAliased;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiRecordBuffer.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiRecordBuffer.cs
index a0524dd179..ffb1f8743a 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiRecordBuffer.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiRecordBuffer.cs
@@ -2,860 +2,18 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.Data;
-using System.Data.SqlTypes;
-using Microsoft.Data.Common;
-
namespace Microsoft.Data.SqlClient.Server
{
// Class for implementing a record object that could take advantage of the
// environment available to a particular protocol level (such as storing data
// in native structures for in-proc data access). Includes methods to send
// the record to a context pipe (useful for in-proc scenarios).
- internal abstract class SmiRecordBuffer : SmiTypedGetterSetter, ITypedGettersV3, ITypedSettersV3, ITypedGetters, ITypedSetters, IDisposable
+ internal abstract class SmiRecordBuffer : SmiTypedGetterSetter
{
- #region SMI active methods as of V200
-
-
- #region Supported access method types (Get] vs. Set)
-
// SmiRecordBuffer defaults both CanGet and CanSet to true to support
- // already-shipped SMIV3 record buffer classes. Sub-classes are free to override.
- internal override bool CanGet
- {
- get
- {
- return true;
- }
- }
-
- internal override bool CanSet
- {
- get
- {
- return true;
- }
- }
- #endregion
-
-
-
- #region Value getters
-
- // SmiRecordBuffer subclasses that expose CanGet == true must implement all Getters from SmiTypedGetterSetter
- // SmiRecordBuffer itself does not need to implement these, since it inherits the default implementation from
- // SmiTypedGetterSetter
-
- #endregion
-
- #region Value setters
-
- // SmiRecordBuffer subclasses that expose CanSet == true must implement all Setters from SmiTypedGetterSetter
- // SmiRecordBuffer itself does not need to implement these, since it inherits the default implementation from
- // SmiTypedGetterSetter
-
- #endregion
-
- #endregion
-
- #region OBSOLETE STUFF than never shipped without obsolete attribute
-
- //
- // IDisposable
- //
- public virtual void Dispose()
- {
- // ******** OBSOLETING from SMI -- use Close instead
- // Intended to be removed (along with inheriting IDisposable) prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- //
- // ITypedGetters methods
- //
- public virtual bool IsDBNull(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlDbType GetVariantType(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual bool GetBoolean(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual byte GetByte(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual long GetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual char GetChar(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual long GetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual short GetInt16(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual int GetInt32(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual long GetInt64(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual float GetFloat(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual double GetDouble(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual string GetString(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual decimal GetDecimal(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual DateTime GetDateTime(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual Guid GetGuid(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlBoolean GetSqlBoolean(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlByte GetSqlByte(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlInt16 GetSqlInt16(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlInt32 GetSqlInt32(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlInt64 GetSqlInt64(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlSingle GetSqlSingle(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlDouble GetSqlDouble(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlMoney GetSqlMoney(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlDateTime GetSqlDateTime(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlDecimal GetSqlDecimal(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlString GetSqlString(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlBinary GetSqlBinary(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlGuid GetSqlGuid(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlChars GetSqlChars(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlBytes GetSqlBytes(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlXml GetSqlXml(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlXml GetSqlXmlRef(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlBytes GetSqlBytesRef(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual SqlChars GetSqlCharsRef(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- //
- // ITypedSetters methods
- //
- public virtual void SetDBNull(int ordinal)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetBoolean(int ordinal, bool value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetByte(int ordinal, byte value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetChar(int ordinal, char value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetInt16(int ordinal, short value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetInt32(int ordinal, int value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetInt64(int ordinal, long value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetFloat(int ordinal, float value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetDouble(int ordinal, double value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetString(int ordinal, string value)
- {
- // Implemented as empty virtual method to allow transport to remove it's implementation
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V2 and dropped support for V1.
- // 2) Server didn't implement V1 on some interface and negotiated V1.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetString(int ordinal, string value, int offset)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetDecimal(int ordinal, decimal value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetDateTime(int ordinal, DateTime value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetGuid(int ordinal, Guid value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlBoolean(int ordinal, SqlBoolean value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlByte(int ordinal, SqlByte value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlInt16(int ordinal, SqlInt16 value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlInt32(int ordinal, SqlInt32 value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlInt64(int ordinal, SqlInt64 value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlSingle(int ordinal, SqlSingle value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlDouble(int ordinal, SqlDouble value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlMoney(int ordinal, SqlMoney value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlDateTime(int ordinal, SqlDateTime value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlDecimal(int ordinal, SqlDecimal value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlString(int ordinal, SqlString value)
- {
- // Implemented as empty virtual method to allow transport to remove it's implementation
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V2 and dropped support for V1.
- // 2) Server didn't implement V1 on some interface and negotiated V1.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlString(int ordinal, SqlString value, int offset)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlBinary(int ordinal, SqlBinary value)
- {
- // Implemented as empty virtual method to allow transport to remove it's implementation
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V2 and dropped support for V1.
- // 2) Server didn't implement V1 on some interface and negotiated V1.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlBinary(int ordinal, SqlBinary value, int offset)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlGuid(int ordinal, SqlGuid value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlChars(int ordinal, SqlChars value)
- {
- // Implemented as empty virtual method to allow transport to remove it's implementation
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V2 and dropped support for V1.
- // 2) Server didn't implement V1 on some interface and negotiated V1.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlChars(int ordinal, SqlChars value, int offset)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlBytes(int ordinal, SqlBytes value)
- {
- // Implemented as empty virtual method to allow transport to remove it's implementation
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V2 and dropped support for V1.
- // 2) Server didn't implement V1 on some interface and negotiated V1.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlBytes(int ordinal, SqlBytes value, int offset)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- public virtual void SetSqlXml(int ordinal, SqlXml value)
- {
- // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
- // Intended to be removed prior to RTM.
+ // already-shipped SMIV3 record buffer classes. Sub-classes are free to override.
+ protected override bool CanGet => true;
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
- // 2) Server didn't implement V2- on some interface and negotiated V2-.
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
- #endregion
+ protected override bool CanSet => true;
}
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiRequestExecutor.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiRequestExecutor.netfx.cs
deleted file mode 100644
index 62411c2b1f..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiRequestExecutor.netfx.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-#if NETFRAMEWORK
-
-using System;
-using System.Data;
-using System.Transactions;
-
-namespace Microsoft.Data.SqlClient.Server
-{
- // @TODO: This class is abstract but nothing inherits from it. Code paths that use it are likely very dead.
- internal abstract class SmiRequestExecutor : SmiTypedGetterSetter
- {
- public virtual void Close(SmiEventSink eventSink)
- {
- // Adding as of V3
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V2- and hasn't implemented V3 yet.
- // 2) Server didn't implement V3 on some interface, but negotiated V3+.
- throw Common.ADP.InternalError(Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- // @TODO: No longer used -- delete!
- internal virtual SmiEventStream Execute(
- SmiConnection connection, // Assigned connection
- long transactionId, // Assigned transaction
- Transaction associatedTransaction, // SysTx transaction associated with request, if any.
- CommandBehavior behavior, // CommandBehavior,
- SmiExecuteType executeType // Type of execute called (NonQuery/Pipe/Reader/Row, etc)
- )
- {
- // Adding as of V210
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V200- and hasn't implemented V210 yet.
- // 2) Server didn't implement V210 on some interface, but negotiated V210+.
- throw Common.ADP.InternalError(Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- // @TODO: No longer used -- delete!
- internal virtual SmiEventStream Execute(
- SmiConnection connection, // Assigned connection
- long transactionId, // Assigned transaction
- CommandBehavior behavior, // CommandBehavior,
- SmiExecuteType executeType // Type of execute called (NonQuery/Pipe/Reader/Row, etc)
- )
- {
- // Obsoleting as of V210
-
- // Implement body with throw because there are only a couple of ways to get to this code:
- // 1) Client is calling this method even though the server negotiated for V210+ (and doesn't implement it).
- // 2) Server doesn't implement this method, but negotiated V200-.
- throw Common.ADP.InternalError(Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
-
- // RequestExecutor only supports setting parameter values, not getting
- internal override bool CanGet => false;
-
- internal override bool CanSet => true;
-
- // SmiRequestExecutor and it's subclasses should NOT override Getters from SmiTypedGetterSetter
- // Calls against those methods on a Request Executor are not allowed.
-
- // @TODO: No longer used -- delete!
- // Set DEFAULT bit for parameter
- internal abstract void SetDefault(int ordinal);
-
- // SmiRequestExecutor subclasses must implement all Setters from SmiTypedGetterSetter
- // SmiRequestExecutor itself does not need to implement these, since it inherits the default implementation from
- // SmiTypedGetterSetter
-
-
- }
-}
-
-#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiStream.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiStream.netfx.cs
deleted file mode 100644
index 9774a3e828..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiStream.netfx.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-#if NETFRAMEWORK
-
-using System.IO;
-
-namespace Microsoft.Data.SqlClient.Server
-{
- // Stream-like object that uses SmiEventSink for server-side errors.
- internal abstract class SmiStream
- {
- public abstract bool CanRead { get; }
-
- // If CanSeek is false, Position, Seek, Length, and SetLength should throw.
- public abstract bool CanSeek { get; }
-
- public abstract bool CanWrite { get; }
-
- public abstract long GetLength(SmiEventSink sink);
-
- public abstract long GetPosition(SmiEventSink sink);
- public abstract void SetPosition(SmiEventSink sink, long position);
-
- public abstract void Flush(SmiEventSink sink);
-
- public abstract long Seek(SmiEventSink sink, long offset, SeekOrigin origin);
-
- public abstract void SetLength(SmiEventSink sink, long value);
-
- public abstract int Read(SmiEventSink sink, byte[] buffer, int offset, int count);
- public abstract void Write(SmiEventSink sink, byte[] buffer, int offset, int count);
-
- public abstract int Read(SmiEventSink sink, char[] buffer, int offset, int count);
- public abstract void Write(SmiEventSink sink, char[] buffer, int offset, int count);
- }
-
-}
-
-#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiTypedGetterSetter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiTypedGetterSetter.cs
index 00729cbecf..f12fee9631 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiTypedGetterSetter.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiTypedGetterSetter.cs
@@ -14,23 +14,23 @@ namespace Microsoft.Data.SqlClient.Server
internal abstract class SmiTypedGetterSetter : ITypedGettersV3, ITypedSettersV3
{
#region Read/Write
- // Are calls to Get methods allowed?
- internal abstract bool CanGet
- {
- get;
- }
-
- // Are calls to Set methods allowed?
- internal abstract bool CanSet
- {
- get;
- }
+
+ ///
+ /// Are calls to Get methods allowed?
+ ///
+ protected abstract bool CanGet { get; }
+
+ ///
+ /// Are calls to Set methods allowed?
+ ///
+ protected abstract bool CanSet { get; }
+
#endregion
#region Getters
// Null test
// valid for all types
- public virtual bool IsDBNull(SmiEventSink sink, int ordinal)
+ public virtual bool IsDBNull(int ordinal)
{
if (!CanGet)
{
@@ -44,7 +44,7 @@ public virtual bool IsDBNull(SmiEventSink sink, int ordinal)
// Check what type current sql_variant value is
// valid for SqlDbType.Variant
- public virtual SmiMetaData GetVariantType(SmiEventSink sink, int ordinal)
+ public virtual SmiMetaData GetVariantType(int ordinal)
{
if (!CanGet)
{
@@ -57,7 +57,7 @@ public virtual SmiMetaData GetVariantType(SmiEventSink sink, int ordinal)
}
// valid for SqlDbType.Bit
- public virtual bool GetBoolean(SmiEventSink sink, int ordinal)
+ public virtual bool GetBoolean(int ordinal)
{
if (!CanGet)
{
@@ -70,7 +70,7 @@ public virtual bool GetBoolean(SmiEventSink sink, int ordinal)
}
// valid for SqlDbType.TinyInt
- public virtual byte GetByte(SmiEventSink sink, int ordinal)
+ public virtual byte GetByte(int ordinal)
{
if (!CanGet)
{
@@ -84,7 +84,7 @@ public virtual byte GetByte(SmiEventSink sink, int ordinal)
// valid for SqlDbTypes: Binary, VarBinary, Image, Udt, Xml, Char, VarChar, Text, NChar, NVarChar, NText
// (Character type support needed for ExecuteXmlReader handling)
- public virtual long GetBytesLength(SmiEventSink sink, int ordinal)
+ public virtual long GetBytesLength(int ordinal)
{
if (!CanGet)
{
@@ -95,7 +95,7 @@ public virtual long GetBytesLength(SmiEventSink sink, int ordinal)
throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
}
}
- public virtual int GetBytes(SmiEventSink sink, int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
+ public virtual int GetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
{
if (!CanGet)
{
@@ -108,7 +108,7 @@ public virtual int GetBytes(SmiEventSink sink, int ordinal, long fieldOffset, by
}
// valid for character types: Char, VarChar, Text, NChar, NVarChar, NText
- public virtual long GetCharsLength(SmiEventSink sink, int ordinal)
+ public virtual long GetCharsLength(int ordinal)
{
if (!CanGet)
{
@@ -119,7 +119,7 @@ public virtual long GetCharsLength(SmiEventSink sink, int ordinal)
throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
}
}
- public virtual int GetChars(SmiEventSink sink, int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
+ public virtual int GetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
{
if (!CanGet)
{
@@ -130,7 +130,7 @@ public virtual int GetChars(SmiEventSink sink, int ordinal, long fieldOffset, ch
throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
}
}
- public virtual string GetString(SmiEventSink sink, int ordinal)
+ public virtual string GetString(int ordinal)
{
if (!CanGet)
{
@@ -143,7 +143,7 @@ public virtual string GetString(SmiEventSink sink, int ordinal)
}
// valid for SqlDbType.SmallInt
- public virtual short GetInt16(SmiEventSink sink, int ordinal)
+ public virtual short GetInt16(int ordinal)
{
if (!CanGet)
{
@@ -156,7 +156,7 @@ public virtual short GetInt16(SmiEventSink sink, int ordinal)
}
// valid for SqlDbType.Int
- public virtual int GetInt32(SmiEventSink sink, int ordinal)
+ public virtual int GetInt32(int ordinal)
{
if (!CanGet)
{
@@ -169,7 +169,7 @@ public virtual int GetInt32(SmiEventSink sink, int ordinal)
}
// valid for SqlDbType.BigInt, SqlDbType.Money, SqlDbType.SmallMoney
- public virtual long GetInt64(SmiEventSink sink, int ordinal)
+ public virtual long GetInt64(int ordinal)
{
if (!CanGet)
{
@@ -182,7 +182,7 @@ public virtual long GetInt64(SmiEventSink sink, int ordinal)
}
// valid for SqlDbType.Real
- public virtual float GetSingle(SmiEventSink sink, int ordinal)
+ public virtual float GetSingle(int ordinal)
{
if (!CanGet)
{
@@ -195,7 +195,7 @@ public virtual float GetSingle(SmiEventSink sink, int ordinal)
}
// valid for SqlDbType.Float
- public virtual double GetDouble(SmiEventSink sink, int ordinal)
+ public virtual double GetDouble(int ordinal)
{
if (!CanGet)
{
@@ -208,7 +208,7 @@ public virtual double GetDouble(SmiEventSink sink, int ordinal)
}
// valid for SqlDbType.Numeric (uses SqlDecimal since Decimal cannot hold full range)
- public virtual SqlDecimal GetSqlDecimal(SmiEventSink sink, int ordinal)
+ public virtual SqlDecimal GetSqlDecimal(int ordinal)
{
if (!CanGet)
{
@@ -221,7 +221,7 @@ public virtual SqlDecimal GetSqlDecimal(SmiEventSink sink, int ordinal)
}
// valid for DateTime, SmallDateTime, Date, and DateTime2
- public virtual DateTime GetDateTime(SmiEventSink sink, int ordinal)
+ public virtual DateTime GetDateTime(int ordinal)
{
if (!CanGet)
{
@@ -234,7 +234,7 @@ public virtual DateTime GetDateTime(SmiEventSink sink, int ordinal)
}
// valid for UniqueIdentifier
- public virtual Guid GetGuid(SmiEventSink sink, int ordinal)
+ public virtual Guid GetGuid(int ordinal)
{
if (!CanGet)
{
@@ -247,7 +247,7 @@ public virtual Guid GetGuid(SmiEventSink sink, int ordinal)
}
// valid for SqlDbType.Time
- public virtual TimeSpan GetTimeSpan(SmiEventSink sink, int ordinal)
+ public virtual TimeSpan GetTimeSpan(int ordinal)
{
if (!CanGet)
{
@@ -260,7 +260,7 @@ public virtual TimeSpan GetTimeSpan(SmiEventSink sink, int ordinal)
}
// valid for DateTimeOffset
- public virtual DateTimeOffset GetDateTimeOffset(SmiEventSink sink, int ordinal)
+ public virtual DateTimeOffset GetDateTimeOffset(int ordinal)
{
if (!CanGet)
{
@@ -274,31 +274,18 @@ public virtual DateTimeOffset GetDateTimeOffset(SmiEventSink sink, int ordinal)
// valid for structured types
// This method called for both get and set.
- internal virtual SmiTypedGetterSetter GetTypedGetterSetter(SmiEventSink sink, int ordinal)
+ internal virtual SmiTypedGetterSetter GetTypedGetterSetter(int ordinal)
{
throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
}
-#if NETFRAMEWORK
- // valid for multi-valued types only
- internal virtual bool NextElement(SmiEventSink sink)
- {
- if (!CanGet)
- {
- throw ADP.InternalError(ADP.InternalErrorCode.InvalidSmiCall);
- }
- else
- {
- throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
- }
- }
-#endif
-#endregion
+
+ #endregion
-#region Setters
+ #region Setters
// Set value to null
// valid for all types
- public virtual void SetDBNull(SmiEventSink sink, int ordinal)
+ public virtual void SetDBNull(int ordinal)
{
if (!CanSet)
{
@@ -311,7 +298,7 @@ public virtual void SetDBNull(SmiEventSink sink, int ordinal)
}
// valid for SqlDbType.Bit
- public virtual void SetBoolean(SmiEventSink sink, int ordinal, bool value)
+ public virtual void SetBoolean(int ordinal, bool value)
{
if (!CanSet)
{
@@ -324,7 +311,7 @@ public virtual void SetBoolean(SmiEventSink sink, int ordinal, bool value)
}
// valid for SqlDbType.TinyInt
- public virtual void SetByte(SmiEventSink sink, int ordinal, byte value)
+ public virtual void SetByte(int ordinal, byte value)
{
if (!CanSet)
{
@@ -340,7 +327,7 @@ public virtual void SetByte(SmiEventSink sink, int ordinal, byte value)
// Use in combination with SetLength to ensure overwriting when necessary
// valid for SqlDbTypes: Binary, VarBinary, Image, Udt, Xml
// (VarBinary assumed for variants)
- public virtual int SetBytes(SmiEventSink sink, int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
+ public virtual int SetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
{
if (!CanSet)
{
@@ -351,7 +338,7 @@ public virtual int SetBytes(SmiEventSink sink, int ordinal, long fieldOffset, by
throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
}
}
- public virtual void SetBytesLength(SmiEventSink sink, int ordinal, long length)
+ public virtual void SetBytesLength(int ordinal, long length)
{
if (!CanSet)
{
@@ -367,7 +354,7 @@ public virtual void SetBytesLength(SmiEventSink sink, int ordinal, long length)
// Use in combination with SetLength to ensure overwriting when necessary
// valid for character types: Char, VarChar, Text, NChar, NVarChar, NText
// (NVarChar and global clr collation assumed for variants)
- public virtual int SetChars(SmiEventSink sink, int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
+ public virtual int SetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
{
if (!CanSet)
{
@@ -378,7 +365,7 @@ public virtual int SetChars(SmiEventSink sink, int ordinal, long fieldOffset, ch
throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
}
}
- public virtual void SetCharsLength(SmiEventSink sink, int ordinal, long length)
+ public virtual void SetCharsLength(int ordinal, long length)
{
if (!CanSet)
{
@@ -391,7 +378,7 @@ public virtual void SetCharsLength(SmiEventSink sink, int ordinal, long length)
}
// valid for character types: Char, VarChar, Text, NChar, NVarChar, NText
- public virtual void SetString(SmiEventSink sink, int ordinal, string value, int offset, int length)
+ public virtual void SetString(int ordinal, string value, int offset, int length)
{
if (!CanSet)
{
@@ -404,7 +391,7 @@ public virtual void SetString(SmiEventSink sink, int ordinal, string value, int
}
// valid for SqlDbType.SmallInt
- public virtual void SetInt16(SmiEventSink sink, int ordinal, short value)
+ public virtual void SetInt16(int ordinal, short value)
{
if (!CanSet)
{
@@ -417,7 +404,7 @@ public virtual void SetInt16(SmiEventSink sink, int ordinal, short value)
}
// valid for SqlDbType.Int
- public virtual void SetInt32(SmiEventSink sink, int ordinal, int value)
+ public virtual void SetInt32(int ordinal, int value)
{
if (!CanSet)
{
@@ -430,7 +417,7 @@ public virtual void SetInt32(SmiEventSink sink, int ordinal, int value)
}
// valid for SqlDbType.BigInt, SqlDbType.Money, SqlDbType.SmallMoney
- public virtual void SetInt64(SmiEventSink sink, int ordinal, long value)
+ public virtual void SetInt64(int ordinal, long value)
{
if (!CanSet)
{
@@ -443,7 +430,7 @@ public virtual void SetInt64(SmiEventSink sink, int ordinal, long value)
}
// valid for SqlDbType.Real
- public virtual void SetSingle(SmiEventSink sink, int ordinal, float value)
+ public virtual void SetSingle(int ordinal, float value)
{
if (!CanSet)
{
@@ -456,7 +443,7 @@ public virtual void SetSingle(SmiEventSink sink, int ordinal, float value)
}
// valid for SqlDbType.Float
- public virtual void SetDouble(SmiEventSink sink, int ordinal, double value)
+ public virtual void SetDouble(int ordinal, double value)
{
if (!CanSet)
{
@@ -469,7 +456,7 @@ public virtual void SetDouble(SmiEventSink sink, int ordinal, double value)
}
// valid for SqlDbType.Numeric (uses SqlDecimal since Decimal cannot hold full range)
- public virtual void SetSqlDecimal(SmiEventSink sink, int ordinal, SqlDecimal value)
+ public virtual void SetSqlDecimal(int ordinal, SqlDecimal value)
{
if (!CanSet)
{
@@ -482,7 +469,7 @@ public virtual void SetSqlDecimal(SmiEventSink sink, int ordinal, SqlDecimal val
}
// valid for DateTime, SmallDateTime, Date, and DateTime2
- public virtual void SetDateTime(SmiEventSink sink, int ordinal, DateTime value)
+ public virtual void SetDateTime(int ordinal, DateTime value)
{
if (!CanSet)
{
@@ -495,7 +482,7 @@ public virtual void SetDateTime(SmiEventSink sink, int ordinal, DateTime value)
}
// valid for UniqueIdentifier
- public virtual void SetGuid(SmiEventSink sink, int ordinal, Guid value)
+ public virtual void SetGuid(int ordinal, Guid value)
{
if (!CanSet)
{
@@ -508,7 +495,7 @@ public virtual void SetGuid(SmiEventSink sink, int ordinal, Guid value)
}
// valid for SqlDbType.Time
- public virtual void SetTimeSpan(SmiEventSink sink, int ordinal, TimeSpan value)
+ public virtual void SetTimeSpan(int ordinal, TimeSpan value)
{
if (!CanSet)
{
@@ -521,7 +508,7 @@ public virtual void SetTimeSpan(SmiEventSink sink, int ordinal, TimeSpan value)
}
// valid for DateTimeOffset
- public virtual void SetDateTimeOffset(SmiEventSink sink, int ordinal, DateTimeOffset value)
+ public virtual void SetDateTimeOffset(int ordinal, DateTimeOffset value)
{
if (!CanSet)
{
@@ -533,7 +520,7 @@ public virtual void SetDateTimeOffset(SmiEventSink sink, int ordinal, DateTimeOf
}
}
- public virtual void SetVariantMetaData(SmiEventSink sink, int ordinal, SmiMetaData metaData)
+ public virtual void SetVariantMetaData(int ordinal, SmiMetaData metaData)
{
// ******** OBSOLETING from SMI -- this should have been removed from ITypedSettersV3
// Intended to be removed prior to RTM. Sub-classes need not implement
@@ -544,8 +531,8 @@ public virtual void SetVariantMetaData(SmiEventSink sink, int ordinal, SmiMetaDa
throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
}
- // valid for multi-valued types only
- internal virtual void NewElement(SmiEventSink sink)
+ // valid for multivalued types only
+ internal virtual void NewElement()
{
if (!CanSet)
{
@@ -557,7 +544,7 @@ internal virtual void NewElement(SmiEventSink sink)
}
}
- internal virtual void EndElements(SmiEventSink sink)
+ internal virtual void EndElements()
{
if (!CanSet)
{
@@ -568,7 +555,8 @@ internal virtual void EndElements(SmiEventSink sink)
throw ADP.InternalError(ADP.InternalErrorCode.UnimplementedSMIMethod);
}
}
-#endregion
+
+ #endregion
}
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiXetterAccessMap.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiXetterAccessMap.cs
index add2ce89cd..8e48c44735 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiXetterAccessMap.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiXetterAccessMap.cs
@@ -9,7 +9,7 @@ namespace Microsoft.Data.SqlClient.Server
///
/// Formal encoding of SMI's metadata-to-ITypedSetter/-from-ITypedGetter validity rules
///
- internal partial class SmiXetterAccessMap
+ internal static class SmiXetterAccessMap
{
// A couple of private constants to make the getter/setter access tables more readable
private const bool X = true;
@@ -103,16 +103,6 @@ internal partial class SmiXetterAccessMap
/*DTOffset*/ { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, },
};
- #if NETFRAMEWORK
- internal static bool IsGetterAccessValid(SmiMetaData metaData, SmiXetterTypeCode xetterType)
- {
- // Make sure no-one adds a new xetter type without updating this file!
- Debug.Assert(SmiXetterTypeCode.XetBoolean <= xetterType && SmiXetterTypeCode.XetDateTimeOffset >= xetterType);
-
- return s_isGetterAccessValid[(int)metaData.SqlDbType, (int)xetterType];
- }
- #endif
-
internal static bool IsSetterAccessValid(SmiMetaData metaData, SmiXetterTypeCode xetterType)
{
// Make sure no-one adds a new xetter type without updating this file!
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlMetaData.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlMetaData.cs
index 84613721d4..2c3c6acaab 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlMetaData.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlMetaData.cs
@@ -18,7 +18,7 @@ namespace Microsoft.Data.SqlClient.Server
// 1) enforcing immutability.
// 2) Inferring type from a value.
// 3) Adjusting a value to match the metadata.
- public sealed partial class SqlMetaData
+ public sealed class SqlMetaData
{
private const long MaxUnicodeLength = 4000;
private const long MaxANSILength = 8000;
@@ -97,80 +97,44 @@ public sealed partial class SqlMetaData
// Array of default-valued metadata ordered by corresponding SqlDbType.
- internal static SqlMetaData[] s_defaults =
- {
- // new SqlMetaData(name, DbType, SqlDbType, MaxLen, Prec, Scale, Locale, DatabaseName, SchemaName, isPartialLength)
- new SqlMetaData("bigint", SqlDbType.BigInt,
- 8, 19, 0, 0, SqlCompareOptions.None, false), // SqlDbType.BigInt
- new SqlMetaData("binary", SqlDbType.Binary,
- 1, 0, 0, 0, SqlCompareOptions.None, false), // SqlDbType.Binary
- new SqlMetaData("bit", SqlDbType.Bit,
- 1, 1, 0, 0, SqlCompareOptions.None, false), // SqlDbType.Bit
- new SqlMetaData("char", SqlDbType.Char,
- 1, 0, 0, 0, DefaultStringCompareOptions, false), // SqlDbType.Char
- new SqlMetaData("datetime", SqlDbType.DateTime,
- 8, 23, 3, 0, SqlCompareOptions.None, false), // SqlDbType.DateTime
- new SqlMetaData("decimal", SqlDbType.Decimal,
- 9, 18, 0, 0, SqlCompareOptions.None, false), // SqlDbType.Decimal
- new SqlMetaData("float", SqlDbType.Float,
- 8, 53, 0, 0, SqlCompareOptions.None, false), // SqlDbType.Float
- new SqlMetaData("image", SqlDbType.Image,
- UnlimitedMaxLength, 0, 0, 0, SqlCompareOptions.None, false), // SqlDbType.Image
- new SqlMetaData("int", SqlDbType.Int,
- 4, 10, 0, 0, SqlCompareOptions.None, false), // SqlDbType.Int
- new SqlMetaData("money", SqlDbType.Money,
- 8, 19, 4, 0, SqlCompareOptions.None, false), // SqlDbType.Money
- new SqlMetaData("nchar", SqlDbType.NChar,
- 1, 0, 0, 0, DefaultStringCompareOptions, false), // SqlDbType.NChar
- new SqlMetaData("ntext", SqlDbType.NText,
- UnlimitedMaxLength, 0, 0, 0, DefaultStringCompareOptions, false), // SqlDbType.NText
- new SqlMetaData("nvarchar", SqlDbType.NVarChar,
- MaxUnicodeLength, 0, 0, 0, DefaultStringCompareOptions, false), // SqlDbType.NVarChar
- new SqlMetaData("real", SqlDbType.Real,
- 4, 24, 0, 0, SqlCompareOptions.None, false), // SqlDbType.Real
- new SqlMetaData("uniqueidentifier", SqlDbType.UniqueIdentifier,
- 16, 0, 0, 0, SqlCompareOptions.None, false), // SqlDbType.UniqueIdentifier
- new SqlMetaData("smalldatetime", SqlDbType.SmallDateTime,
- 4, 16, 0, 0, SqlCompareOptions.None, false), // SqlDbType.SmallDateTime
- new SqlMetaData("smallint", SqlDbType.SmallInt,
- 2, 5, 0, 0, SqlCompareOptions.None, false), // SqlDbType.SmallInt
- new SqlMetaData("smallmoney", SqlDbType.SmallMoney,
- 4, 10, 4, 0, SqlCompareOptions.None, false), // SqlDbType.SmallMoney
- new SqlMetaData("text", SqlDbType.Text,
- UnlimitedMaxLength, 0, 0, 0, DefaultStringCompareOptions, false), // SqlDbType.Text
- new SqlMetaData("timestamp", SqlDbType.Timestamp,
- 8, 0, 0, 0, SqlCompareOptions.None, false), // SqlDbType.Timestamp
- new SqlMetaData("tinyint", SqlDbType.TinyInt,
- 1, 3, 0, 0, SqlCompareOptions.None, false), // SqlDbType.TinyInt
- new SqlMetaData("varbinary", SqlDbType.VarBinary,
- MaxBinaryLength, 0, 0, 0, SqlCompareOptions.None, false), // SqlDbType.VarBinary
- new SqlMetaData("varchar", SqlDbType.VarChar,
- MaxANSILength, 0, 0, 0, DefaultStringCompareOptions, false), // SqlDbType.VarChar
- new SqlMetaData("sql_variant", SqlDbType.Variant,
- 8016, 0, 0, 0, SqlCompareOptions.None, false), // SqlDbType.Variant
- new SqlMetaData("nvarchar", SqlDbType.NVarChar,
- 1, 0, 0, 0, DefaultStringCompareOptions, false), // Placeholder for value 24
- new SqlMetaData("xml", SqlDbType.Xml,
- UnlimitedMaxLength, 0, 0, 0, DefaultStringCompareOptions, true), // SqlDbType.Xml
- new SqlMetaData("nvarchar", SqlDbType.NVarChar,
- 1, 0, 0, 0, DefaultStringCompareOptions, false), // Placeholder for value 26
- new SqlMetaData("nvarchar", SqlDbType.NVarChar,
- MaxUnicodeLength, 0, 0, 0, DefaultStringCompareOptions, false), // Placeholder for value 27
- new SqlMetaData("nvarchar", SqlDbType.NVarChar,
- MaxUnicodeLength, 0, 0, 0, DefaultStringCompareOptions, false), // Placeholder for value 28
- new SqlMetaData("udt", SqlDbType.Udt,
- 0, 0, 0, 0, SqlCompareOptions.None, false), // SqlDbType.Udt = 29
- new SqlMetaData("table", SqlDbType.Structured,
- 0, 0, 0, 0, SqlCompareOptions.None, false), // SqlDbType.Structured
- new SqlMetaData("date", SqlDbType.Date,
- 3, 10,0, 0, SqlCompareOptions.None, false), // SqlDbType.Date
- new SqlMetaData("time", SqlDbType.Time,
- 5, 0, 7, 0, SqlCompareOptions.None, false), // SqlDbType.Time
- new SqlMetaData("datetime2", SqlDbType.DateTime2,
- 8, 0, 7, 0, SqlCompareOptions.None, false), // SqlDbType.DateTime2
- new SqlMetaData("datetimeoffset", SqlDbType.DateTimeOffset,
- 10, 0, 7, 0, SqlCompareOptions.None, false), // SqlDbType.DateTimeOffset
- };
+ private static readonly SqlMetaData[] s_defaults =
+ {
+ new SqlMetaData("bigint", SqlDbType.BigInt, 8, 19, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("binary", SqlDbType.Binary, 1, 0, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("bit", SqlDbType.Bit, 1, 1, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("char", SqlDbType.Char, 1, 0, 0, 0, DefaultStringCompareOptions),
+ new SqlMetaData("datetime", SqlDbType.DateTime, 8, 23, 3, 0, SqlCompareOptions.None),
+ new SqlMetaData("decimal", SqlDbType.Decimal, 9, 18, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("float", SqlDbType.Float, 8, 53, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("image", SqlDbType.Image, UnlimitedMaxLength, 0, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("int", SqlDbType.Int, 4, 10, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("money", SqlDbType.Money, 8, 19, 4, 0, SqlCompareOptions.None),
+ new SqlMetaData("nchar", SqlDbType.NChar, 1, 0, 0, 0, DefaultStringCompareOptions),
+ new SqlMetaData("ntext", SqlDbType.NText, UnlimitedMaxLength, 0, 0, 0, DefaultStringCompareOptions),
+ new SqlMetaData("nvarchar", SqlDbType.NVarChar, MaxUnicodeLength, 0, 0, 0, DefaultStringCompareOptions),
+ new SqlMetaData("real", SqlDbType.Real, 4, 24, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("uniqueidentifier", SqlDbType.UniqueIdentifier, 16, 0, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("smalldatetime", SqlDbType.SmallDateTime, 4, 16, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("smallint", SqlDbType.SmallInt, 2, 5, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("smallmoney", SqlDbType.SmallMoney, 4, 10, 4, 0, SqlCompareOptions.None),
+ new SqlMetaData("text", SqlDbType.Text, UnlimitedMaxLength, 0, 0, 0, DefaultStringCompareOptions),
+ new SqlMetaData("timestamp", SqlDbType.Timestamp, 8, 0, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("tinyint", SqlDbType.TinyInt, 1, 3, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("varbinary", SqlDbType.VarBinary, MaxBinaryLength, 0, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("varchar", SqlDbType.VarChar, MaxANSILength, 0, 0, 0, DefaultStringCompareOptions),
+ new SqlMetaData("sql_variant", SqlDbType.Variant, 8016, 0, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("nvarchar", SqlDbType.NVarChar, 1, 0, 0, 0, DefaultStringCompareOptions),
+ new SqlMetaData("xml", SqlDbType.Xml, UnlimitedMaxLength, 0, 0, 0, DefaultStringCompareOptions),
+ new SqlMetaData("nvarchar", SqlDbType.NVarChar, 1, 0, 0, 0, DefaultStringCompareOptions),
+ new SqlMetaData("nvarchar", SqlDbType.NVarChar, MaxUnicodeLength, 0, 0, 0, DefaultStringCompareOptions),
+ new SqlMetaData("nvarchar", SqlDbType.NVarChar, MaxUnicodeLength, 0, 0, 0, DefaultStringCompareOptions),
+ new SqlMetaData("udt", SqlDbType.Udt, 0, 0, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("table", SqlDbType.Structured, 0, 0, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("date", SqlDbType.Date, 3, 10, 0, 0, SqlCompareOptions.None),
+ new SqlMetaData("time", SqlDbType.Time, 5, 0, 7, 0, SqlCompareOptions.None),
+ new SqlMetaData("datetime2", SqlDbType.DateTime2, 8, 0, 7, 0, SqlCompareOptions.None),
+ new SqlMetaData("datetimeoffset", SqlDbType.DateTimeOffset, 10, 0, 7, 0, SqlCompareOptions.None),
+ };
private string _name;
private long _maxLength;
@@ -183,7 +147,6 @@ public sealed partial class SqlMetaData
private string _xmlSchemaCollectionOwningSchema;
private string _xmlSchemaCollectionName;
private string _serverTypeName;
- private bool _partialLength;
private Type _udtType;
private bool _useServerDefault;
private bool _isUniqueKey;
@@ -456,50 +419,15 @@ public SqlMetaData(string name, SqlDbType dbType, string database, string owning
Construct(name, dbType, database, owningSchema, objectName, DefaultUseServerDefault, DefaultIsUniqueKey, DefaultColumnSortOrder, DefaultSortOrdinal);
}
- // Most general constructor, should be able to initialize all SqlMetaData fields.(Used by SqlParameter)
- internal SqlMetaData(
- string name,
- SqlDbType sqlDBType,
- long maxLength,
- byte precision,
- byte scale,
- long localeId,
- SqlCompareOptions compareOptions,
- string xmlSchemaCollectionDatabase,
- string xmlSchemaCollectionOwningSchema,
- string xmlSchemaCollectionName,
- bool partialLength,
- Type udtType
- )
- {
- AssertNameIsValid(name);
-
- _name = name;
- _sqlDbType = sqlDBType;
- _maxLength = maxLength;
- _precision = precision;
- _scale = scale;
- _locale = localeId;
- _compareOptions = compareOptions;
- _xmlSchemaCollectionDatabase = xmlSchemaCollectionDatabase;
- _xmlSchemaCollectionOwningSchema = xmlSchemaCollectionOwningSchema;
- _xmlSchemaCollectionName = xmlSchemaCollectionName;
- _partialLength = partialLength;
- _udtType = udtType;
- }
-
// Private constructor used to initialize default instance array elements.
// DO NOT EXPOSE OUTSIDE THIS CLASS! It performs no validation.
- private SqlMetaData(
- string name,
+ private SqlMetaData(string name,
SqlDbType sqlDbType,
long maxLength,
byte precision,
byte scale,
long localeId,
- SqlCompareOptions compareOptions,
- bool partialLength
- )
+ SqlCompareOptions compareOptions)
{
AssertNameIsValid(name);
@@ -510,7 +438,6 @@ bool partialLength
_scale = scale;
_locale = localeId;
_compareOptions = compareOptions;
- _partialLength = partialLength;
_udtType = null;
}
@@ -587,8 +514,6 @@ public string TypeName
///
public string XmlSchemaCollectionOwningSchema => _xmlSchemaCollectionOwningSchema;
- internal bool IsPartialLength => _partialLength;
-
internal string UdtTypeName
{
get
@@ -2048,32 +1973,6 @@ public char[] Adjust(char[] value)
return value;
}
-
- internal static SqlMetaData GetPartialLengthMetaData(SqlMetaData md)
- {
- if (md.IsPartialLength == true)
- {
- return md;
- }
- if (md.SqlDbType == SqlDbType.Xml)
- {
- ThrowInvalidType(); //Xml should always have IsPartialLength = true
- }
- if (
- md.SqlDbType == SqlDbType.NVarChar ||
- md.SqlDbType == SqlDbType.VarChar ||
- md.SqlDbType == SqlDbType.VarBinary
- )
- {
- return new SqlMetaData(md.Name, md.SqlDbType, SqlMetaData.Max, 0, 0, md.LocaleId,
- md.CompareOptions, null, null, null, true, md.Type);
- }
- else
- {
- return md;
- }
- }
-
private static void ThrowInvalidType()
{
throw ADP.InvalidMetaDataValue();
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlSer.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlSer.cs
index f25aff0135..c10b5779f1 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlSer.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlSer.cs
@@ -12,11 +12,8 @@
namespace Microsoft.Data.SqlClient.Server
{
- internal sealed class SerializationHelperSql9
+ internal static class SerializationHelperSql9
{
- // Don't let anyone create an instance of this class.
- private SerializationHelperSql9() { }
-
// Get the m_size of the serialized stream for this type, in bytes.
// This method creates an instance of the type using the public
// no-argument constructor, serializes it, and returns the m_size
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.cs
index a2eed0bd4b..96c31da63e 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.cs
@@ -27,7 +27,7 @@ namespace Microsoft.Data.SqlClient.Server
//
// These are all based off of knowing the clr type of the value
// as an ExtendedClrTypeCode enum for rapid access (lookup in static array is best, if possible).
- internal static partial class ValueUtilsSmi
+ internal static class ValueUtilsSmi
{
private const int MaxByteChunkSize = TdsEnums.MAXSIZE;
private const int MaxCharChunkSize = TdsEnums.MAXSIZE / sizeof(char);
@@ -239,22 +239,6 @@ internal static DateTime GetDateTime(SmiEventSink_Default sink, ITypedGettersV3
return (DateTime)result;
}
- // calling GetDateTimeOffset on possibly v100 SMI
- internal static DateTimeOffset GetDateTimeOffset(SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, SmiMetaData metaData, bool gettersSupport2008DateTime)
- {
- if (gettersSupport2008DateTime)
- {
- return GetDateTimeOffset(sink, (SmiTypedGetterSetter)getters, ordinal, metaData);
- }
- ThrowIfITypedGettersIsNull(sink, getters, ordinal);
- object result = GetValue(sink, getters, ordinal, metaData);
- if (result == null)
- {
- throw ADP.InvalidCast();
- }
- return (DateTimeOffset)result;
- }
-
// dealing with v200 SMI
internal static DateTimeOffset GetDateTimeOffset(SmiEventSink_Default sink, SmiTypedGetterSetter getters, int ordinal, SmiMetaData metaData)
{
@@ -449,7 +433,7 @@ internal static SqlBytes GetSqlBytes(
else
{
Stream s = new SmiGettersStream(sink, getters, ordinal, metaData);
- s = CopyIntoNewSmiScratchStream(s, sink);
+ s = CopyIntoNewSmiScratchStream(s);
result = new SqlBytes(s);
}
}
@@ -897,7 +881,7 @@ internal static object GetValue200(
switch (metaData.SqlDbType)
{
case SqlDbType.Variant: // Handle variants specifically for v200, since they could contain v200 types
- metaData = getters.GetVariantType(sink, ordinal);
+ metaData = getters.GetVariantType(ordinal);
sink.ProcessMessagesAndThrow();
Debug.Assert(SqlDbType.Variant != metaData.SqlDbType, "Variant-within-variant causes endless recursion!");
result = GetValue200(sink, getters, ordinal, metaData);
@@ -1009,7 +993,7 @@ internal static object GetValue(
result = GetString_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.Variant:
- metaData = getters.GetVariantType(sink, ordinal);
+ metaData = getters.GetVariantType(ordinal);
sink.ProcessMessagesAndThrow();
Debug.Assert(SqlDbType.Variant != metaData.SqlDbType, "Variant-within-variant causes endless recursion!");
result = GetValue(sink, getters, ordinal, metaData);
@@ -1050,7 +1034,7 @@ internal static object GetSqlValue200(
switch (metaData.SqlDbType)
{
case SqlDbType.Variant: // Handle variants specifically for v200, since they could contain v200 types
- metaData = getters.GetVariantType(sink, ordinal);
+ metaData = getters.GetVariantType(ordinal);
sink.ProcessMessagesAndThrow();
Debug.Assert(SqlDbType.Variant != metaData.SqlDbType, "Variant-within-variant causes endless recursion!");
result = GetSqlValue200(sink, getters, ordinal, metaData);
@@ -1167,7 +1151,7 @@ internal static object GetSqlValue(
result = new SqlString(GetString_Unchecked(sink, getters, ordinal));
break;
case SqlDbType.Variant:
- metaData = getters.GetVariantType(sink, ordinal);
+ metaData = getters.GetVariantType(ordinal);
sink.ProcessMessagesAndThrow();
Debug.Assert(SqlDbType.Variant != metaData.SqlDbType, "Variant-within-variant causes endless recursion!");
result = GetSqlValue(sink, getters, ordinal, metaData);
@@ -1285,7 +1269,7 @@ internal static long SetBytesLength(SmiEventSink_Default sink, ITypedSettersV3 s
length = metaData.MaxLength;
}
- setters.SetBytesLength(sink, ordinal, length);
+ setters.SetBytesLength(ordinal, length);
sink.ProcessMessagesAndThrow();
return length;
@@ -1735,133 +1719,6 @@ ParameterPeekAheadValue peekAhead
}
}
- // Copy multiple fields from reader to ITypedSettersV3
- // Assumes caller enforces that reader and setter metadata are compatible
- internal static void FillCompatibleITypedSettersFromReader(SmiEventSink_Default sink, ITypedSettersV3 setters, SmiMetaData[] metaData, SqlDataReader reader)
- {
- for (int i = 0; i < metaData.Length; i++)
- {
- if (reader.IsDBNull(i))
- {
- ValueUtilsSmi.SetDBNull_Unchecked(sink, setters, i);
- }
- else
- {
- switch (metaData[i].SqlDbType)
- {
- case SqlDbType.BigInt:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Int64));
- ValueUtilsSmi.SetInt64_Unchecked(sink, setters, i, reader.GetInt64(i));
- break;
- case SqlDbType.Binary:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
- ValueUtilsSmi.SetSqlBytes_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0);
- break;
- case SqlDbType.Bit:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Boolean));
- SetBoolean_Unchecked(sink, setters, i, reader.GetBoolean(i));
- break;
- case SqlDbType.Char:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlChars));
- SetSqlChars_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlChars(i), 0);
- break;
- case SqlDbType.DateTime:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.DateTime));
- SetDateTime_Checked(sink, setters, i, metaData[i], reader.GetDateTime(i));
- break;
- case SqlDbType.Decimal:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlDecimal));
- SetSqlDecimal_Unchecked(sink, setters, i, reader.GetSqlDecimal(i));
- break;
- case SqlDbType.Float:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Double));
- SetDouble_Unchecked(sink, setters, i, reader.GetDouble(i));
- break;
- case SqlDbType.Image:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
- SetSqlBytes_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0);
- break;
- case SqlDbType.Int:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Int32));
- SetInt32_Unchecked(sink, setters, i, reader.GetInt32(i));
- break;
- case SqlDbType.Money:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlMoney));
- SetSqlMoney_Unchecked(sink, setters, i, metaData[i], reader.GetSqlMoney(i));
- break;
- case SqlDbType.NChar:
- case SqlDbType.NText:
- case SqlDbType.NVarChar:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlChars));
- SetSqlChars_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlChars(i), 0);
- break;
- case SqlDbType.Real:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Single));
- SetSingle_Unchecked(sink, setters, i, reader.GetFloat(i));
- break;
- case SqlDbType.UniqueIdentifier:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Guid));
- SetGuid_Unchecked(sink, setters, i, reader.GetGuid(i));
- break;
- case SqlDbType.SmallDateTime:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.DateTime));
- SetDateTime_Checked(sink, setters, i, metaData[i], reader.GetDateTime(i));
- break;
- case SqlDbType.SmallInt:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Int16));
- SetInt16_Unchecked(sink, setters, i, reader.GetInt16(i));
- break;
- case SqlDbType.SmallMoney:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlMoney));
- SetSqlMoney_Checked(sink, setters, i, metaData[i], reader.GetSqlMoney(i));
- break;
- case SqlDbType.Text:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlChars));
- SetSqlChars_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlChars(i), 0);
- break;
- case SqlDbType.Timestamp:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
- SetSqlBytes_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0);
- break;
- case SqlDbType.TinyInt:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Byte));
- SetByte_Unchecked(sink, setters, i, reader.GetByte(i));
- break;
- case SqlDbType.VarBinary:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
- SetSqlBytes_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0);
- break;
- case SqlDbType.VarChar:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.String));
- SetSqlChars_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlChars(i), 0);
- break;
- case SqlDbType.Xml:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlXml));
- SetSqlXml_Unchecked(sink, setters, i, reader.GetSqlXml(i));
- break;
- case SqlDbType.Variant:
- object o = reader.GetSqlValue(i);
- ExtendedClrTypeCode typeCode = MetaDataUtilsSmi.DetermineExtendedTypeCode(o);
- SetCompatibleValue(sink, setters, i, metaData[i], o, typeCode, 0);
- break;
-
- case SqlDbType.Udt:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
- SetSqlBytes_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0);
- break;
-
- default:
- // In order for us to get here we would have to have an
- // invalid instance of SqlDbType, or one would have to add
- // new member to SqlDbType without adding a case in this
- // switch, hence the assert.
- Debug.Fail("unsupported DbType:" + metaData[i].SqlDbType.ToString());
- throw ADP.NotSupported();
- }
- }
- }
- }
-
// Copy multiple fields from reader to SmiTypedGetterSetter
// Supports V200 code path, without damaging backward compat for V100 code.
// Main differences are supporting DbDataReader, and for binary, character, decimal and Udt types.
@@ -2406,7 +2263,7 @@ private static void SetBytes_FromRecord(SmiEventSink_Default sink, ITypedSetters
bytesWritten != 0
)
{
- bytesWritten = setters.SetBytes(sink, ordinal, currentOffset, buffer, 0, checked((int)bytesRead));
+ bytesWritten = setters.SetBytes(ordinal, currentOffset, buffer, 0, checked((int)bytesRead));
sink.ProcessMessagesAndThrow();
checked
{
@@ -2416,7 +2273,7 @@ private static void SetBytes_FromRecord(SmiEventSink_Default sink, ITypedSetters
}
// Make sure to trim any left-over data
- setters.SetBytesLength(sink, ordinal, currentOffset);
+ setters.SetBytesLength(ordinal, currentOffset);
sink.ProcessMessagesAndThrow();
}
@@ -2441,7 +2298,7 @@ private static void SetBytes_FromReader(SmiEventSink_Default sink, SmiTypedGette
bytesWritten != 0
)
{
- bytesWritten = setters.SetBytes(sink, ordinal, currentOffset, buffer, 0, checked((int)bytesRead));
+ bytesWritten = setters.SetBytes(ordinal, currentOffset, buffer, 0, checked((int)bytesRead));
sink.ProcessMessagesAndThrow();
checked
{
@@ -2451,7 +2308,7 @@ private static void SetBytes_FromReader(SmiEventSink_Default sink, SmiTypedGette
}
// Make sure to trim any left-over data (remember to trim at end of offset, not just the amount written
- setters.SetBytesLength(sink, ordinal, currentOffset);
+ setters.SetBytesLength(ordinal, currentOffset);
sink.ProcessMessagesAndThrow();
}
@@ -2512,7 +2369,7 @@ private static void SetChars_FromRecord(SmiEventSink_Default sink, ITypedSetters
charsWritten != 0
)
{
- charsWritten = setters.SetChars(sink, ordinal, currentOffset, buffer, 0, checked((int)charsRead));
+ charsWritten = setters.SetChars(ordinal, currentOffset, buffer, 0, checked((int)charsRead));
sink.ProcessMessagesAndThrow();
checked
{
@@ -2522,7 +2379,7 @@ private static void SetChars_FromRecord(SmiEventSink_Default sink, ITypedSetters
}
// Make sure to trim any left-over data
- setters.SetCharsLength(sink, ordinal, currentOffset);
+ setters.SetCharsLength(ordinal, currentOffset);
sink.ProcessMessagesAndThrow();
}
@@ -2581,7 +2438,7 @@ private static void SetChars_FromReader(SmiEventSink_Default sink, SmiTypedGette
charsWritten != 0
)
{
- charsWritten = setters.SetChars(sink, ordinal, currentOffset, buffer, 0, checked((int)charsRead));
+ charsWritten = setters.SetChars(ordinal, currentOffset, buffer, 0, checked((int)charsRead));
sink.ProcessMessagesAndThrow();
checked
{
@@ -2591,7 +2448,7 @@ private static void SetChars_FromReader(SmiEventSink_Default sink, SmiTypedGette
}
// Make sure to trim any left-over data (remember to trim at end of offset, not just the amount written
- setters.SetCharsLength(sink, ordinal, currentOffset);
+ setters.SetCharsLength(ordinal, currentOffset);
sink.ProcessMessagesAndThrow();
}
@@ -2600,7 +2457,7 @@ private static void SetString_FromReader(SmiEventSink_Default sink, SmiTypedGett
string value = reader.GetString(ordinal);
int length = CheckXetParameters(metaData.SqlDbType, metaData.MaxLength, value.Length, fieldOffset: 0, bufferLength: NoLengthLimit, bufferOffset: offset, length: NoLengthLimit);
- setters.SetString(sink, ordinal, value, offset, length);
+ setters.SetString(ordinal, value, offset, length);
sink.ProcessMessagesAndThrow();
}
@@ -2647,7 +2504,7 @@ private static void SetUdt_LengthChecked(SmiEventSink_Default sink, ITypedSetter
{
if (ADP.IsNull(value))
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
sink.ProcessMessagesAndThrow();
}
else
@@ -2962,7 +2819,7 @@ int length
//
private static bool IsDBNull_Unchecked(SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal)
{
- bool result = getters.IsDBNull(sink, ordinal);
+ bool result = getters.IsDBNull(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -2971,7 +2828,7 @@ private static bool GetBoolean_Unchecked(SmiEventSink_Default sink, ITypedGetter
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- bool result = getters.GetBoolean(sink, ordinal);
+ bool result = getters.GetBoolean(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -2980,7 +2837,7 @@ private static byte GetByte_Unchecked(SmiEventSink_Default sink, ITypedGettersV3
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- byte result = getters.GetByte(sink, ordinal);
+ byte result = getters.GetByte(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -2989,12 +2846,12 @@ private static byte[] GetByteArray_Unchecked(SmiEventSink_Default sink, ITypedGe
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- long length = getters.GetBytesLength(sink, ordinal);
+ long length = getters.GetBytesLength(ordinal);
sink.ProcessMessagesAndThrow();
int len = checked((int)length);
byte[] buffer = new byte[len];
- getters.GetBytes(sink, ordinal, 0, buffer, 0, len);
+ getters.GetBytes(ordinal, 0, buffer, 0, len);
sink.ProcessMessagesAndThrow();
return buffer;
}
@@ -3009,7 +2866,7 @@ internal static int GetBytes_Unchecked(SmiEventSink_Default sink, ITypedGettersV
Debug.Assert(buffer != null, "Null buffer");
Debug.Assert(bufferOffset >= 0 && length >= 0 && bufferOffset + length <= buffer.Length, $"Bad offset or length. bufferOffset: {bufferOffset}, length: {length}, buffer.Length{buffer.Length}");
- int result = getters.GetBytes(sink, ordinal, fieldOffset, buffer, bufferOffset, length);
+ int result = getters.GetBytes(ordinal, fieldOffset, buffer, bufferOffset, length);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3018,7 +2875,7 @@ private static long GetBytesLength_Unchecked(SmiEventSink_Default sink, ITypedGe
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- long result = getters.GetBytesLength(sink, ordinal);
+ long result = getters.GetBytesLength(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3027,12 +2884,12 @@ private static char[] GetCharArray_Unchecked(SmiEventSink_Default sink, ITypedGe
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- long length = getters.GetCharsLength(sink, ordinal);
+ long length = getters.GetCharsLength(ordinal);
sink.ProcessMessagesAndThrow();
int len = checked((int)length);
char[] buffer = new char[len];
- getters.GetChars(sink, ordinal, 0, buffer, 0, len);
+ getters.GetChars(ordinal, 0, buffer, 0, len);
sink.ProcessMessagesAndThrow();
return buffer;
}
@@ -3047,7 +2904,7 @@ internal static int GetChars_Unchecked(SmiEventSink_Default sink, ITypedGettersV
Debug.Assert(buffer != null, "Null buffer");
Debug.Assert(bufferOffset >= 0 && length >= 0 && bufferOffset + length <= buffer.Length, $"Bad offset or length. bufferOffset: {bufferOffset}, length: {length}, buffer.Length{buffer.Length}");
- int result = getters.GetChars(sink, ordinal, fieldOffset, buffer, bufferOffset, length);
+ int result = getters.GetChars(ordinal, fieldOffset, buffer, bufferOffset, length);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3056,7 +2913,7 @@ private static long GetCharsLength_Unchecked(SmiEventSink_Default sink, ITypedGe
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- long result = getters.GetCharsLength(sink, ordinal);
+ long result = getters.GetCharsLength(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3065,7 +2922,7 @@ private static DateTime GetDateTime_Unchecked(SmiEventSink_Default sink, ITypedG
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- DateTime result = getters.GetDateTime(sink, ordinal);
+ DateTime result = getters.GetDateTime(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3074,7 +2931,7 @@ private static DateTimeOffset GetDateTimeOffset_Unchecked(SmiEventSink_Default s
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- DateTimeOffset result = getters.GetDateTimeOffset(sink, ordinal);
+ DateTimeOffset result = getters.GetDateTimeOffset(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3083,7 +2940,7 @@ private static double GetDouble_Unchecked(SmiEventSink_Default sink, ITypedGette
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- double result = getters.GetDouble(sink, ordinal);
+ double result = getters.GetDouble(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3092,7 +2949,7 @@ private static Guid GetGuid_Unchecked(SmiEventSink_Default sink, ITypedGettersV3
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- Guid result = getters.GetGuid(sink, ordinal);
+ Guid result = getters.GetGuid(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3101,7 +2958,7 @@ private static short GetInt16_Unchecked(SmiEventSink_Default sink, ITypedGetters
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- short result = getters.GetInt16(sink, ordinal);
+ short result = getters.GetInt16(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3110,7 +2967,7 @@ private static int GetInt32_Unchecked(SmiEventSink_Default sink, ITypedGettersV3
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- int result = getters.GetInt32(sink, ordinal);
+ int result = getters.GetInt32(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3119,7 +2976,7 @@ private static long GetInt64_Unchecked(SmiEventSink_Default sink, ITypedGettersV
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- long result = getters.GetInt64(sink, ordinal);
+ long result = getters.GetInt64(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3128,7 +2985,7 @@ private static float GetSingle_Unchecked(SmiEventSink_Default sink, ITypedGetter
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- float result = getters.GetSingle(sink, ordinal);
+ float result = getters.GetSingle(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3145,7 +3002,7 @@ private static SqlDecimal GetSqlDecimal_Unchecked(SmiEventSink_Default sink, ITy
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- SqlDecimal result = getters.GetSqlDecimal(sink, ordinal);
+ SqlDecimal result = getters.GetSqlDecimal(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3154,7 +3011,7 @@ private static SqlMoney GetSqlMoney_Unchecked(SmiEventSink_Default sink, ITypedG
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- long temp = getters.GetInt64(sink, ordinal);
+ long temp = getters.GetInt64(ordinal);
sink.ProcessMessagesAndThrow();
#if NET
return SqlMoney.FromTdsValue(temp);
@@ -3170,7 +3027,7 @@ private static SqlXml GetSqlXml_Unchecked(SmiEventSink_Default sink, ITypedGette
// Note: must make a copy of getter stream, since it will be used beyond
// this method (valid lifetime of getters is limited).
Stream s = new SmiGettersStream(sink, getters, ordinal, SmiMetaData.DefaultXml);
- Stream copy = CopyIntoNewSmiScratchStream(s, sink);
+ Stream copy = CopyIntoNewSmiScratchStream(s);
return new SqlXml(copy);
}
@@ -3182,7 +3039,7 @@ private static string GetString_Unchecked(SmiEventSink_Default sink, ITypedGette
// Inproc process, the getter is InProcRecordBuffer (implemented in SqlAcess), string will be
// truncated to 4000 (if length is more than 4000). If MemoryRecordBuffer getter is used, data
// is not truncated. Please refer VSDD 479655 for more detailed information regarding the string length.
- string result = getters.GetString(sink, ordinal);
+ string result = getters.GetString(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3191,14 +3048,14 @@ private static TimeSpan GetTimeSpan_Unchecked(SmiEventSink_Default sink, SmiType
{
Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
- TimeSpan result = getters.GetTimeSpan(sink, ordinal);
+ TimeSpan result = getters.GetTimeSpan(ordinal);
sink.ProcessMessagesAndThrow();
return result;
}
private static void SetBoolean_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, bool value)
{
- setters.SetBoolean(sink, ordinal, value);
+ setters.SetBoolean(ordinal, value);
sink.ProcessMessagesAndThrow();
}
@@ -3206,10 +3063,10 @@ private static void SetByteArray_Unchecked(SmiEventSink_Default sink, ITypedSett
{
if (length > 0)
{
- setters.SetBytes(sink, ordinal, 0, buffer, bufferOffset, length);
+ setters.SetBytes(ordinal, 0, buffer, bufferOffset, length);
sink.ProcessMessagesAndThrow();
}
- setters.SetBytesLength(sink, ordinal, length);
+ setters.SetBytesLength(ordinal, length);
sink.ProcessMessagesAndThrow();
}
@@ -3235,13 +3092,13 @@ private static void SetStream_Unchecked(SmiEventSink_Default sink, ITypedSetters
break;
}
- setters.SetBytes(sink, ordinal, nWritten, buff, 0, nRead);
+ setters.SetBytes(ordinal, nWritten, buff, 0, nRead);
sink.ProcessMessagesAndThrow();
nWritten += nRead;
} while (len <= 0 || nWritten < len);
- setters.SetBytesLength(sink, ordinal, nWritten);
+ setters.SetBytesLength(ordinal, nWritten);
sink.ProcessMessagesAndThrow();
}
@@ -3267,25 +3124,25 @@ private static void SetTextReader_Unchecked(SmiEventSink_Default sink, ITypedSet
break;
}
- setters.SetChars(sink, ordinal, nWritten, buff, 0, nRead);
+ setters.SetChars(ordinal, nWritten, buff, 0, nRead);
sink.ProcessMessagesAndThrow();
nWritten += nRead;
} while (len <= 0 || nWritten < len);
- setters.SetCharsLength(sink, ordinal, nWritten);
+ setters.SetCharsLength(ordinal, nWritten);
sink.ProcessMessagesAndThrow();
}
private static void SetByte_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, byte value)
{
- setters.SetByte(sink, ordinal, value);
+ setters.SetByte(ordinal, value);
sink.ProcessMessagesAndThrow();
}
private static int SetBytes_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
{
- int result = setters.SetBytes(sink, ordinal, fieldOffset, buffer, bufferOffset, length);
+ int result = setters.SetBytes(ordinal, fieldOffset, buffer, bufferOffset, length);
sink.ProcessMessagesAndThrow();
return result;
}
@@ -3294,99 +3151,99 @@ private static void SetCharArray_Unchecked(SmiEventSink_Default sink, ITypedSett
{
if (length > 0)
{
- setters.SetChars(sink, ordinal, 0, buffer, bufferOffset, length);
+ setters.SetChars(ordinal, 0, buffer, bufferOffset, length);
sink.ProcessMessagesAndThrow();
}
- setters.SetCharsLength(sink, ordinal, length);
+ setters.SetCharsLength(ordinal, length);
sink.ProcessMessagesAndThrow();
}
private static int SetChars_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
{
- int result = setters.SetChars(sink, ordinal, fieldOffset, buffer, bufferOffset, length);
+ int result = setters.SetChars(ordinal, fieldOffset, buffer, bufferOffset, length);
sink.ProcessMessagesAndThrow();
return result;
}
private static void SetDBNull_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
sink.ProcessMessagesAndThrow();
}
private static void SetDecimal_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, decimal value)
{
- setters.SetSqlDecimal(sink, ordinal, new SqlDecimal(value));
+ setters.SetSqlDecimal(ordinal, new SqlDecimal(value));
sink.ProcessMessagesAndThrow();
}
private static void SetDateTime_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, DateTime value)
{
- setters.SetDateTime(sink, ordinal, value);
+ setters.SetDateTime(ordinal, value);
sink.ProcessMessagesAndThrow();
}
private static void SetDateTime2_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SmiMetaData metaData, DateTime value)
{
Debug.Assert(metaData.SqlDbType == SqlDbType.Variant, "Invalid type. This should be called only when the type is variant.");
- setters.SetVariantMetaData(sink, ordinal, SmiMetaData.DefaultDateTime2);
- setters.SetDateTime(sink, ordinal, value);
+ setters.SetVariantMetaData(ordinal, SmiMetaData.DefaultDateTime2);
+ setters.SetDateTime(ordinal, value);
sink.ProcessMessagesAndThrow();
}
private static void SetDate_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SmiMetaData metaData, DateTime value)
{
Debug.Assert(metaData.SqlDbType == SqlDbType.Variant, "Invalid type. This should be called only when the type is variant.");
- setters.SetVariantMetaData(sink, ordinal, SmiMetaData.DefaultDate);
- setters.SetDateTime(sink, ordinal, value);
+ setters.SetVariantMetaData(ordinal, SmiMetaData.DefaultDate);
+ setters.SetDateTime(ordinal, value);
sink.ProcessMessagesAndThrow();
}
private static void SetTimeSpan_Unchecked(SmiEventSink_Default sink, SmiTypedGetterSetter setters, int ordinal, TimeSpan value)
{
- setters.SetTimeSpan(sink, ordinal, value);
+ setters.SetTimeSpan(ordinal, value);
sink.ProcessMessagesAndThrow();
}
private static void SetDateTimeOffset_Unchecked(SmiEventSink_Default sink, SmiTypedGetterSetter setters, int ordinal, DateTimeOffset value)
{
- setters.SetDateTimeOffset(sink, ordinal, value);
+ setters.SetDateTimeOffset(ordinal, value);
sink.ProcessMessagesAndThrow();
}
private static void SetDouble_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, double value)
{
- setters.SetDouble(sink, ordinal, value);
+ setters.SetDouble(ordinal, value);
sink.ProcessMessagesAndThrow();
}
private static void SetGuid_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, Guid value)
{
- setters.SetGuid(sink, ordinal, value);
+ setters.SetGuid(ordinal, value);
sink.ProcessMessagesAndThrow();
}
private static void SetInt16_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, short value)
{
- setters.SetInt16(sink, ordinal, value);
+ setters.SetInt16(ordinal, value);
sink.ProcessMessagesAndThrow();
}
private static void SetInt32_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, int value)
{
- setters.SetInt32(sink, ordinal, value);
+ setters.SetInt32(ordinal, value);
sink.ProcessMessagesAndThrow();
}
private static void SetInt64_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, long value)
{
- setters.SetInt64(sink, ordinal, value);
+ setters.SetInt64(ordinal, value);
sink.ProcessMessagesAndThrow();
}
private static void SetSingle_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, float value)
{
- setters.SetSingle(sink, ordinal, value);
+ setters.SetSingle(ordinal, value);
sink.ProcessMessagesAndThrow();
}
@@ -3394,7 +3251,7 @@ private static void SetSqlBinary_Unchecked(SmiEventSink_Default sink, ITypedSett
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
}
else
{
@@ -3407,11 +3264,11 @@ private static void SetSqlBoolean_Unchecked(SmiEventSink_Default sink, ITypedSet
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
}
else
{
- setters.SetBoolean(sink, ordinal, value.Value);
+ setters.SetBoolean(ordinal, value.Value);
}
sink.ProcessMessagesAndThrow();
}
@@ -3420,11 +3277,11 @@ private static void SetSqlByte_Unchecked(SmiEventSink_Default sink, ITypedSetter
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
}
else
{
- setters.SetByte(sink, ordinal, value.Value);
+ setters.SetByte(ordinal, value.Value);
}
sink.ProcessMessagesAndThrow();
}
@@ -3434,7 +3291,7 @@ private static void SetSqlBytes_Unchecked(SmiEventSink_Default sink, ITypedSette
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
sink.ProcessMessagesAndThrow();
}
else
@@ -3461,7 +3318,7 @@ private static void SetSqlBytes_Unchecked(SmiEventSink_Default sink, ITypedSette
bytesWritten != 0
)
{
- bytesWritten = setters.SetBytes(sink, ordinal, currentOffset, buffer, 0, checked((int)bytesRead));
+ bytesWritten = setters.SetBytes(ordinal, currentOffset, buffer, 0, checked((int)bytesRead));
sink.ProcessMessagesAndThrow();
checked
{
@@ -3474,7 +3331,7 @@ private static void SetSqlBytes_Unchecked(SmiEventSink_Default sink, ITypedSette
}
// Make sure to trim any left-over data
- setters.SetBytesLength(sink, ordinal, currentOffset);
+ setters.SetBytesLength(ordinal, currentOffset);
sink.ProcessMessagesAndThrow();
}
}
@@ -3483,7 +3340,7 @@ private static void SetSqlChars_Unchecked(SmiEventSink_Default sink, ITypedSette
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
sink.ProcessMessagesAndThrow();
}
else
@@ -3510,7 +3367,7 @@ private static void SetSqlChars_Unchecked(SmiEventSink_Default sink, ITypedSette
charsWritten != 0
)
{
- charsWritten = setters.SetChars(sink, ordinal, currentOffset, buffer, 0, checked((int)charsRead));
+ charsWritten = setters.SetChars(ordinal, currentOffset, buffer, 0, checked((int)charsRead));
sink.ProcessMessagesAndThrow();
checked
{
@@ -3520,7 +3377,7 @@ private static void SetSqlChars_Unchecked(SmiEventSink_Default sink, ITypedSette
}
// Make sure to trim any left-over data
- setters.SetCharsLength(sink, ordinal, currentOffset);
+ setters.SetCharsLength(ordinal, currentOffset);
sink.ProcessMessagesAndThrow();
}
}
@@ -3529,11 +3386,11 @@ private static void SetSqlDateTime_Unchecked(SmiEventSink_Default sink, ITypedSe
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
}
else
{
- setters.SetDateTime(sink, ordinal, value.Value);
+ setters.SetDateTime(ordinal, value.Value);
}
sink.ProcessMessagesAndThrow();
}
@@ -3542,11 +3399,11 @@ private static void SetSqlDecimal_Unchecked(SmiEventSink_Default sink, ITypedSet
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
}
else
{
- setters.SetSqlDecimal(sink, ordinal, value);
+ setters.SetSqlDecimal(ordinal, value);
}
sink.ProcessMessagesAndThrow();
}
@@ -3555,11 +3412,11 @@ private static void SetSqlDouble_Unchecked(SmiEventSink_Default sink, ITypedSett
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
}
else
{
- setters.SetDouble(sink, ordinal, value.Value);
+ setters.SetDouble(ordinal, value.Value);
}
sink.ProcessMessagesAndThrow();
}
@@ -3568,11 +3425,11 @@ private static void SetSqlGuid_Unchecked(SmiEventSink_Default sink, ITypedSetter
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
}
else
{
- setters.SetGuid(sink, ordinal, value.Value);
+ setters.SetGuid(ordinal, value.Value);
}
sink.ProcessMessagesAndThrow();
}
@@ -3581,11 +3438,11 @@ private static void SetSqlInt16_Unchecked(SmiEventSink_Default sink, ITypedSette
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
}
else
{
- setters.SetInt16(sink, ordinal, value.Value);
+ setters.SetInt16(ordinal, value.Value);
}
sink.ProcessMessagesAndThrow();
}
@@ -3594,11 +3451,11 @@ private static void SetSqlInt32_Unchecked(SmiEventSink_Default sink, ITypedSette
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
}
else
{
- setters.SetInt32(sink, ordinal, value.Value);
+ setters.SetInt32(ordinal, value.Value);
}
sink.ProcessMessagesAndThrow();
}
@@ -3607,11 +3464,11 @@ private static void SetSqlInt64_Unchecked(SmiEventSink_Default sink, ITypedSette
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
}
else
{
- setters.SetInt64(sink, ordinal, value.Value);
+ setters.SetInt64(ordinal, value.Value);
}
sink.ProcessMessagesAndThrow();
}
@@ -3620,20 +3477,20 @@ private static void SetSqlMoney_Unchecked(SmiEventSink_Default sink, ITypedSette
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
}
else
{
if (metaData.SqlDbType == SqlDbType.Variant)
{
- setters.SetVariantMetaData(sink, ordinal, SmiMetaData.DefaultMoney);
+ setters.SetVariantMetaData(ordinal, SmiMetaData.DefaultMoney);
sink.ProcessMessagesAndThrow();
}
#if NET
- setters.SetInt64(sink, ordinal, value.GetTdsValue());
+ setters.SetInt64(ordinal, value.GetTdsValue());
#else
- setters.SetInt64(sink, ordinal, SqlTypeWorkarounds.SqlMoneyToSqlInternalRepresentation(value));
+ setters.SetInt64(ordinal, SqlTypeWorkarounds.SqlMoneyToSqlInternalRepresentation(value));
#endif
}
sink.ProcessMessagesAndThrow();
@@ -3643,11 +3500,11 @@ private static void SetSqlSingle_Unchecked(SmiEventSink_Default sink, ITypedSett
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
}
else
{
- setters.SetSingle(sink, ordinal, value.Value);
+ setters.SetSingle(ordinal, value.Value);
}
sink.ProcessMessagesAndThrow();
}
@@ -3656,7 +3513,7 @@ private static void SetSqlString_Unchecked(SmiEventSink_Default sink, ITypedSett
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
sink.ProcessMessagesAndThrow();
}
else
@@ -3673,7 +3530,7 @@ private static void SetSqlString_Unchecked(SmiEventSink_Default sink, ITypedSett
value.SqlCompareOptions,
userDefinedType: null
);
- setters.SetVariantMetaData(sink, ordinal, metaData);
+ setters.SetVariantMetaData(ordinal, metaData);
sink.ProcessMessagesAndThrow();
}
SetString_Unchecked(sink, setters, ordinal, value.Value, offset, length);
@@ -3684,7 +3541,7 @@ private static void SetSqlXml_Unchecked(SmiEventSink_Default sink, ITypedSetters
{
if (value.IsNull)
{
- setters.SetDBNull(sink, ordinal);
+ setters.SetDBNull(ordinal);
sink.ProcessMessagesAndThrow();
}
else
@@ -3720,7 +3577,7 @@ private static void SetXmlReader_Unchecked(SmiEventSink_Default sink, ITypedSett
private static void SetString_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, string value, int offset, int length)
{
- setters.SetString(sink, ordinal, value, offset, length);
+ setters.SetString(ordinal, value, offset, length);
sink.ProcessMessagesAndThrow();
}
@@ -3735,19 +3592,19 @@ DbDataReader value
)
{
// Get the target gettersetter
- setters = setters.GetTypedGetterSetter(sink, ordinal);
+ setters = setters.GetTypedGetterSetter(ordinal);
sink.ProcessMessagesAndThrow();
// Iterate over all rows in the current set of results
while (value.Read())
{
- setters.NewElement(sink);
+ setters.NewElement();
sink.ProcessMessagesAndThrow();
FillCompatibleSettersFromReader(sink, setters, metaData.FieldMetaData, value);
}
- setters.EndElements(sink);
+ setters.EndElements();
sink.ProcessMessagesAndThrow();
}
@@ -3761,7 +3618,7 @@ ParameterPeekAheadValue peekAhead
)
{
// Get target gettersetter
- setters = setters.GetTypedGetterSetter(sink, ordinal);
+ setters = setters.GetTypedGetterSetter(ordinal);
sink.ProcessMessagesAndThrow();
IEnumerator enumerator = null;
@@ -3782,7 +3639,7 @@ ParameterPeekAheadValue peekAhead
enumerator = peekAhead.Enumerator;
// send the first record that was obtained earlier
- setters.NewElement(sink);
+ setters.NewElement();
sink.ProcessMessagesAndThrow();
FillCompatibleSettersFromRecord(sink, setters, mdFields, peekAhead.FirstRecord, defaults);
recordNumber++;
@@ -3794,7 +3651,7 @@ ParameterPeekAheadValue peekAhead
while (enumerator.MoveNext())
{
- setters.NewElement(sink);
+ setters.NewElement();
sink.ProcessMessagesAndThrow();
SqlDataRecord record = enumerator.Current;
@@ -3816,7 +3673,7 @@ ParameterPeekAheadValue peekAhead
recordNumber++;
}
- setters.EndElements(sink);
+ setters.EndElements();
sink.ProcessMessagesAndThrow();
}
@@ -3838,7 +3695,7 @@ DataTable value
)
{
// Get the target gettersetter
- setters = setters.GetTypedGetterSetter(sink, ordinal);
+ setters = setters.GetTypedGetterSetter(ordinal);
sink.ProcessMessagesAndThrow();
// iterate over all records
@@ -3850,7 +3707,7 @@ DataTable value
}
foreach (DataRow row in value.Rows)
{
- setters.NewElement(sink);
+ setters.NewElement();
sink.ProcessMessagesAndThrow();
// Set all columns in the record
@@ -3879,12 +3736,12 @@ DataTable value
}
}
- setters.EndElements(sink);
+ setters.EndElements();
sink.ProcessMessagesAndThrow();
}
// spool a Stream into a scratch stream from the Smi interface and return it as a Stream
- internal static Stream CopyIntoNewSmiScratchStream(Stream source, SmiEventSink_Default sink)
+ internal static Stream CopyIntoNewSmiScratchStream(Stream source)
{
Stream dest = new MemoryStream();
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.netfx.cs
deleted file mode 100644
index 4311d28f16..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.netfx.cs
+++ /dev/null
@@ -1,488 +0,0 @@
-using System;
-using System.Data;
-using System.Data.SqlTypes;
-using System.Diagnostics;
-using System.Globalization;
-using System.IO;
-using Microsoft.Data.Common;
-using Microsoft.Data.SqlTypes;
-
-namespace Microsoft.Data.SqlClient.Server
-{
- // Utilities for manipulating values with the Smi interface.
- //
- // THIS CLASS IS BUILT ON TOP OF THE SMI INTERFACE -- SMI SHOULD NOT DEPEND ON IT!
- //
- // These are all based off of knowing the clr type of the value
- // as an ExtendedClrTypeCode enum for rapid access (lookup in static array is best, if possible).
- internal static partial class ValueUtilsSmi
- {
-
- internal static SqlSequentialStreamSmi GetSequentialStream(SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, SmiMetaData metaData, bool bypassTypeCheck = false)
- {
- Debug.Assert(!ValueUtilsSmi.IsDBNull_Unchecked(sink, getters, ordinal), "Should not try to get a SqlSequentialStreamSmi on a null column");
- ThrowIfITypedGettersIsNull(sink, getters, ordinal);
- if ((!bypassTypeCheck) && (!CanAccessGetterDirectly(metaData, ExtendedClrTypeCode.Stream)))
- {
- throw ADP.InvalidCast();
- }
-
- // This will advance the column to ordinal
- long length = GetBytesLength_Unchecked(sink, getters, ordinal);
- return new SqlSequentialStreamSmi(sink, getters, ordinal, length);
- }
-
- internal static SqlSequentialTextReaderSmi GetSequentialTextReader(SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, SmiMetaData metaData)
- {
- Debug.Assert(!ValueUtilsSmi.IsDBNull_Unchecked(sink, getters, ordinal), "Should not try to get a SqlSequentialTextReaderSmi on a null column");
- ThrowIfITypedGettersIsNull(sink, getters, ordinal);
- if (!CanAccessGetterDirectly(metaData, ExtendedClrTypeCode.TextReader))
- {
- throw ADP.InvalidCast();
- }
-
- // This will advance the column to ordinal
- long length = GetCharsLength_Unchecked(sink, getters, ordinal);
- return new SqlSequentialTextReaderSmi(sink, getters, ordinal, length);
- }
-
- internal static Stream GetStream(SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, SmiMetaData metaData, bool bypassTypeCheck = false)
- {
- bool isDbNull = ValueUtilsSmi.IsDBNull_Unchecked(sink, getters, ordinal);
-
- // If a sql_variant, get the internal type
- if (!bypassTypeCheck)
- {
- if ((!isDbNull) && (metaData.SqlDbType == SqlDbType.Variant))
- {
- metaData = getters.GetVariantType(sink, ordinal);
- }
- // If the SqlDbType is still variant, then it must contain null, so don't throw InvalidCast
- if ((metaData.SqlDbType != SqlDbType.Variant) && (!CanAccessGetterDirectly(metaData, ExtendedClrTypeCode.Stream)))
- {
- throw ADP.InvalidCast();
- }
- }
-
- byte[] data;
- if (isDbNull)
- {
- // "null" stream
- data = new byte[0];
- }
- else
- {
- // Read all data
- data = GetByteArray_Unchecked(sink, getters, ordinal);
- }
-
- // Wrap data in pre-built object
- return new MemoryStream(data, writable: false);
- }
-
- internal static TextReader GetTextReader(SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, SmiMetaData metaData)
- {
- bool isDbNull = ValueUtilsSmi.IsDBNull_Unchecked(sink, getters, ordinal);
-
- // If a sql_variant, get the internal type
- if ((!isDbNull) && (metaData.SqlDbType == SqlDbType.Variant))
- {
- metaData = getters.GetVariantType(sink, ordinal);
- }
- // If the SqlDbType is still variant, then it must contain null, so don't throw InvalidCast
- if ((metaData.SqlDbType != SqlDbType.Variant) && (!CanAccessGetterDirectly(metaData, ExtendedClrTypeCode.TextReader)))
- {
- throw ADP.InvalidCast();
- }
-
- string data;
- if (isDbNull)
- {
- // "null" textreader
- data = string.Empty;
- }
- else
- {
- // Read all data
- data = GetString_Unchecked(sink, getters, ordinal);
- }
-
- // Wrap in pre-built object
- return new StringReader(data);
- }
-
- // calling GetTimeSpan on possibly v100 SMI
- internal static TimeSpan GetTimeSpan(SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, SmiMetaData metaData, bool gettersSupport2008DateTime)
- {
- if (gettersSupport2008DateTime)
- {
- return GetTimeSpan(sink, (SmiTypedGetterSetter)getters, ordinal, metaData);
- }
- ThrowIfITypedGettersIsNull(sink, getters, ordinal);
- object obj = GetValue(sink, getters, ordinal, metaData);
- if (obj == null)
- {
- throw ADP.InvalidCast();
- }
- return (TimeSpan)obj;
- }
-
- internal static SqlBuffer.StorageType SqlDbTypeToStorageType(SqlDbType dbType)
- {
- int index = unchecked((int)dbType);
- Debug.Assert(index >= 0 && index < s_dbTypeToStorageType.Length, string.Format(CultureInfo.InvariantCulture, "Unexpected dbType value: {0}", dbType));
- return s_dbTypeToStorageType[index];
- }
-
- private static void GetNullOutputParameterSmi(SmiMetaData metaData, SqlBuffer targetBuffer, ref object result)
- {
- if (SqlDbType.Udt == metaData.SqlDbType)
- {
- result = NullUdtInstance(metaData);
- }
- else
- {
- SqlBuffer.StorageType stype = SqlDbTypeToStorageType(metaData.SqlDbType);
- if (SqlBuffer.StorageType.Empty == stype)
- {
- result = DBNull.Value;
- }
- else if (SqlBuffer.StorageType.SqlBinary == stype)
- {
- // special case SqlBinary, 'cause tds parser never sets SqlBuffer to null, just to empty!
- targetBuffer.SqlBinary = SqlBinary.Null;
- }
- else if (SqlBuffer.StorageType.SqlGuid == stype)
- {
- targetBuffer.SqlGuid = SqlGuid.Null;
- }
- else
- {
- targetBuffer.SetToNullOfType(stype);
- }
- }
- }
-
- ///
- /// UDTs and null variants come back via return value, all else is via targetBuffer.
- /// implements SqlClient 2.0-compatible output parameter semantics.
- ///
- /// Event sink for errors
- /// Getters interface to grab value from
- /// Parameter within getters
- /// Getter's type for this ordinal
- /// Destination
- internal static object GetOutputParameterV3Smi(
- SmiEventSink_Default sink,
- ITypedGettersV3 getters,
- int ordinal,
- SmiMetaData metaData,
- SqlBuffer targetBuffer)
- {
- object result = null; // Workaround for UDT hack in non-Smi code paths.
- if (IsDBNull_Unchecked(sink, getters, ordinal))
- {
- GetNullOutputParameterSmi(metaData, targetBuffer, ref result);
- }
- else
- {
- switch (metaData.SqlDbType)
- {
- case SqlDbType.BigInt:
- targetBuffer.Int64 = GetInt64_Unchecked(sink, getters, ordinal);
- break;
- case SqlDbType.Binary:
- case SqlDbType.Image:
- case SqlDbType.Timestamp:
- case SqlDbType.VarBinary:
- targetBuffer.SqlBinary = GetSqlBinary_Unchecked(sink, getters, ordinal);
- break;
- case SqlDbType.Bit:
- targetBuffer.Boolean = GetBoolean_Unchecked(sink, getters, ordinal);
- break;
- case SqlDbType.NChar:
- case SqlDbType.NText:
- case SqlDbType.NVarChar:
- case SqlDbType.Char:
- case SqlDbType.VarChar:
- case SqlDbType.Text:
- targetBuffer.SetToString(GetString_Unchecked(sink, getters, ordinal));
- break;
- case SqlDbType.DateTime:
- case SqlDbType.SmallDateTime:
- {
- SqlDateTime dt = new(GetDateTime_Unchecked(sink, getters, ordinal));
- targetBuffer.SetToDateTime(dt.DayTicks, dt.TimeTicks);
- break;
- }
- case SqlDbType.Decimal:
- {
- SqlDecimal dec = GetSqlDecimal_Unchecked(sink, getters, ordinal);
- targetBuffer.SetToDecimal(dec.Precision, dec.Scale, dec.IsPositive, dec.Data);
- break;
- }
- case SqlDbType.Float:
- targetBuffer.Double = GetDouble_Unchecked(sink, getters, ordinal);
- break;
- case SqlDbType.Int:
- targetBuffer.Int32 = GetInt32_Unchecked(sink, getters, ordinal);
- break;
- case SqlDbType.Money:
- case SqlDbType.SmallMoney:
- targetBuffer.SetToMoney(GetInt64_Unchecked(sink, getters, ordinal));
- break;
- case SqlDbType.Real:
- targetBuffer.Single = GetSingle_Unchecked(sink, getters, ordinal);
- break;
- case SqlDbType.UniqueIdentifier:
- targetBuffer.SqlGuid = new SqlGuid(GetGuid_Unchecked(sink, getters, ordinal));
- break;
- case SqlDbType.SmallInt:
- targetBuffer.Int16 = GetInt16_Unchecked(sink, getters, ordinal);
- break;
- case SqlDbType.TinyInt:
- targetBuffer.Byte = GetByte_Unchecked(sink, getters, ordinal);
- break;
- case SqlDbType.Variant:
- // For variants, recur using the current value's sqldbtype
- metaData = getters.GetVariantType(sink, ordinal);
- sink.ProcessMessagesAndThrow();
- Debug.Assert(SqlDbType.Variant != metaData.SqlDbType, "Variant-within-variant not supposed to be possible!");
- GetOutputParameterV3Smi(sink, getters, ordinal, metaData, targetBuffer);
- break;
- case SqlDbType.Udt:
- result = GetUdt_LengthChecked(sink, getters, ordinal, metaData);
- break;
- case SqlDbType.Xml:
- targetBuffer.SqlXml = GetSqlXml_Unchecked(sink, getters, ordinal);
- break;
- default:
- Debug.Assert(false, "Unexpected SqlDbType");
- break;
- }
- }
-
- return result;
- }
-
- ///
- /// UDTs and null variants come back via return value, all else is via targetBuffer.
- /// implements SqlClient 1.1-compatible output parameter semantics.
- ///
- /// Event sink for errors
- /// Getters interface to grab value from
- /// Parameter within getters
- /// Getter's type for this ordinal
- /// Destination
- internal static object GetOutputParameterV200Smi(
- SmiEventSink_Default sink,
- SmiTypedGetterSetter getters,
- int ordinal,
- SmiMetaData metaData,
- SqlBuffer targetBuffer)
- {
- object result = null; // Workaround for UDT hack in non-Smi code paths.
- if (IsDBNull_Unchecked(sink, getters, ordinal))
- {
- GetNullOutputParameterSmi(metaData, targetBuffer, ref result);
- }
- else
- {
- switch (metaData.SqlDbType)
- {
- // new types go here
- case SqlDbType.Variant: // Handle variants specifically for v200, since they could contain v200 types
- // For variants, recur using the current value's sqldbtype
- metaData = getters.GetVariantType(sink, ordinal);
- sink.ProcessMessagesAndThrow();
- Debug.Assert(SqlDbType.Variant != metaData.SqlDbType, "Variant-within-variant not supposed to be possible!");
- GetOutputParameterV200Smi(sink, getters, ordinal, metaData, targetBuffer);
- break;
- case SqlDbType.Date:
- targetBuffer.SetToDate(GetDateTime_Unchecked(sink, getters, ordinal));
- break;
- case SqlDbType.DateTime2:
- targetBuffer.SetToDateTime2(GetDateTime_Unchecked(sink, getters, ordinal), metaData.Scale);
- break;
- case SqlDbType.Time:
- targetBuffer.SetToTime(GetTimeSpan_Unchecked(sink, getters, ordinal), metaData.Scale);
- break;
- case SqlDbType.DateTimeOffset:
- targetBuffer.SetToDateTimeOffset(GetDateTimeOffset_Unchecked(sink, getters, ordinal), metaData.Scale);
- break;
- default:
- result = GetOutputParameterV3Smi(sink, getters, ordinal, metaData, targetBuffer);
- break;
- }
- }
-
- return result;
- }
-
- private static readonly SqlBuffer.StorageType[] s_dbTypeToStorageType = new SqlBuffer.StorageType[] {
- SqlBuffer.StorageType.Int64, // BigInt
- SqlBuffer.StorageType.SqlBinary, // Binary
- SqlBuffer.StorageType.Boolean, // Bit
- SqlBuffer.StorageType.String, // Char
- SqlBuffer.StorageType.DateTime, // DateTime
- SqlBuffer.StorageType.Decimal, // Decimal
- SqlBuffer.StorageType.Double, // Float
- SqlBuffer.StorageType.SqlBinary, // Image
- SqlBuffer.StorageType.Int32, // Int
- SqlBuffer.StorageType.Money, // Money
- SqlBuffer.StorageType.String, // NChar
- SqlBuffer.StorageType.String, // NText
- SqlBuffer.StorageType.String, // NVarChar
- SqlBuffer.StorageType.Single, // Real
- SqlBuffer.StorageType.SqlGuid, // UniqueIdentifier
- SqlBuffer.StorageType.DateTime, // SmallDateTime
- SqlBuffer.StorageType.Int16, // SmallInt
- SqlBuffer.StorageType.Money, // SmallMoney
- SqlBuffer.StorageType.String, // Text
- SqlBuffer.StorageType.SqlBinary, // Timestamp
- SqlBuffer.StorageType.Byte, // TinyInt
- SqlBuffer.StorageType.SqlBinary, // VarBinary
- SqlBuffer.StorageType.String, // VarChar
- SqlBuffer.StorageType.Empty, // Variant
- SqlBuffer.StorageType.Empty, // 24
- SqlBuffer.StorageType.SqlXml, // Xml
- SqlBuffer.StorageType.Empty, // 26
- SqlBuffer.StorageType.Empty, // 27
- SqlBuffer.StorageType.Empty, // 28
- SqlBuffer.StorageType.Empty, // Udt
- SqlBuffer.StorageType.Empty, // Structured
- SqlBuffer.StorageType.Date, // Date
- SqlBuffer.StorageType.Time, // Time
- SqlBuffer.StorageType.DateTime2, // DateTime2
- SqlBuffer.StorageType.DateTimeOffset, // DateTimeOffset
- };
-
- internal static void FillCompatibleITypedSettersFromRecord(SmiEventSink_Default sink, ITypedSettersV3 setters, SmiMetaData[] metaData, SqlDataRecord record)
- {
- FillCompatibleITypedSettersFromRecord(sink, setters, metaData, record, null);
- }
-
- internal static void FillCompatibleITypedSettersFromRecord(SmiEventSink_Default sink, ITypedSettersV3 setters, SmiMetaData[] metaData, SqlDataRecord record, SmiDefaultFieldsProperty useDefaultValues)
- {
- for (int i = 0; i < metaData.Length; ++i)
- {
- if (useDefaultValues != null && useDefaultValues[i])
- {
- continue;
- }
- if (record.IsDBNull(i))
- {
- ValueUtilsSmi.SetDBNull_Unchecked(sink, setters, i);
- }
- else
- {
- switch (metaData[i].SqlDbType)
- {
- case SqlDbType.BigInt:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Int64));
- SetInt64_Unchecked(sink, setters, i, record.GetInt64(i));
- break;
- case SqlDbType.Binary:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
- SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
- break;
- case SqlDbType.Bit:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Boolean));
- SetBoolean_Unchecked(sink, setters, i, record.GetBoolean(i));
- break;
- case SqlDbType.Char:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlChars));
- SetChars_FromRecord(sink, setters, i, metaData[i], record, 0);
- break;
- case SqlDbType.DateTime:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.DateTime));
- SetDateTime_Checked(sink, setters, i, metaData[i], record.GetDateTime(i));
- break;
- case SqlDbType.Decimal:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlDecimal));
- SetSqlDecimal_Unchecked(sink, setters, i, record.GetSqlDecimal(i));
- break;
- case SqlDbType.Float:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Double));
- SetDouble_Unchecked(sink, setters, i, record.GetDouble(i));
- break;
- case SqlDbType.Image:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
- SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
- break;
- case SqlDbType.Int:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Int32));
- SetInt32_Unchecked(sink, setters, i, record.GetInt32(i));
- break;
- case SqlDbType.Money:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlMoney));
- SetSqlMoney_Unchecked(sink, setters, i, metaData[i], record.GetSqlMoney(i));
- break;
- case SqlDbType.NChar:
- case SqlDbType.NText:
- case SqlDbType.NVarChar:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlChars));
- SetChars_FromRecord(sink, setters, i, metaData[i], record, 0);
- break;
- case SqlDbType.Real:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Single));
- SetSingle_Unchecked(sink, setters, i, record.GetFloat(i));
- break;
- case SqlDbType.UniqueIdentifier:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Guid));
- SetGuid_Unchecked(sink, setters, i, record.GetGuid(i));
- break;
- case SqlDbType.SmallDateTime:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.DateTime));
- SetDateTime_Checked(sink, setters, i, metaData[i], record.GetDateTime(i));
- break;
- case SqlDbType.SmallInt:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Int16));
- SetInt16_Unchecked(sink, setters, i, record.GetInt16(i));
- break;
- case SqlDbType.SmallMoney:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlMoney));
- SetSqlMoney_Checked(sink, setters, i, metaData[i], record.GetSqlMoney(i));
- break;
- case SqlDbType.Text:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlChars));
- SetChars_FromRecord(sink, setters, i, metaData[i], record, 0);
- break;
- case SqlDbType.Timestamp:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
- SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
- break;
- case SqlDbType.TinyInt:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Byte));
- SetByte_Unchecked(sink, setters, i, record.GetByte(i));
- break;
- case SqlDbType.VarBinary:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
- SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
- break;
- case SqlDbType.VarChar:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.String));
- SetChars_FromRecord(sink, setters, i, metaData[i], record, 0);
- break;
- case SqlDbType.Xml:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlXml));
- SetSqlXml_Unchecked(sink, setters, i, record.GetSqlXml(i)); // perf improvement?
- break;
- case SqlDbType.Variant:
- object o = record.GetSqlValue(i);
- ExtendedClrTypeCode typeCode = MetaDataUtilsSmi.DetermineExtendedTypeCode(o);
- SetCompatibleValue(sink, setters, i, metaData[i], o, typeCode, 0);
- break;
- case SqlDbType.Udt:
- Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
- SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
- break;
- default:
- Debug.Assert(false, "unsupported DbType:" + metaData[i].SqlDbType.ToString());
- throw ADP.NotSupported();
- }
- }
- }
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
index 71a750b22e..ca84636934 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
@@ -194,10 +194,6 @@ public SourceColumnMetadata(ValueMethod method, bool isSqlType, bool isDataFeed)
private DataRowState _rowStateToSkip;
private IEnumerator _rowEnumerator;
- #if NETFRAMEWORK
- private bool _rowSourceIsSqlDataReaderSmi;
- #endif
-
private int RowNumber
{
get
@@ -1206,19 +1202,6 @@ private bool ReadFromRowSource()
private SourceColumnMetadata GetColumnMetadata(int ordinal)
{
- bool IsMetadataDataStream(_SqlMetaData metadata)
- {
- #if NETFRAMEWORK
- if (_rowSourceIsSqlDataReaderSmi)
- {
- return false;
- }
- #endif
-
- return _enableStreaming &&
- (metadata.length == MAX_LENGTH || metadata.type is SqlDbTypeExtensions.Json);
- }
-
int sourceOrdinal = _sortedColumnMappings[ordinal]._sourceColumnOrdinal;
_SqlMetaData metadata = _sortedColumnMappings[ordinal]._metadata;
@@ -1269,7 +1252,8 @@ bool IsMetadataDataStream(_SqlMetaData metadata)
method = ValueMethod.GetValue;
}
}
- else if (IsMetadataDataStream(metadata))
+ // Check for data streams
+ else if (_enableStreaming && (metadata.length == MAX_LENGTH || metadata.metaType.SqlDbType == SqlDbTypeExtensions.Json))
{
isSqlType = false;
@@ -1709,18 +1693,11 @@ public void WriteToServer(DbDataReader reader)
try
{
statistics = SqlStatistics.StartTimer(Statistics);
+
ResetWriteToServerGlobalVariables();
_rowSource = reader;
_dbDataReaderRowSource = reader;
_sqlDataReaderRowSource = reader as SqlDataReader;
-
- #if NETFRAMEWORK
- if (_sqlDataReaderRowSource != null)
- {
- _rowSourceIsSqlDataReaderSmi = _sqlDataReaderRowSource is SqlDataReaderSmi;
- }
- #endif
-
_rowSourceType = ValueSourceType.DbDataReader;
WriteRowSourceToServerAsync(reader.FieldCount, CancellationToken.None); //It returns null since _isAsyncBulkCopy = false;
@@ -1752,19 +1729,13 @@ public void WriteToServer(IDataReader reader)
try
{
statistics = SqlStatistics.StartTimer(Statistics);
+
ResetWriteToServerGlobalVariables();
_rowSource = reader;
_sqlDataReaderRowSource = _rowSource as SqlDataReader;
-
- #if NETFRAMEWORK
- if (_sqlDataReaderRowSource != null)
- {
- _rowSourceIsSqlDataReaderSmi = _sqlDataReaderRowSource is SqlDataReaderSmi;
- }
- #endif
-
_dbDataReaderRowSource = _rowSource as DbDataReader;
_rowSourceType = ValueSourceType.IDataReader;
+
WriteRowSourceToServerAsync(reader.FieldCount, CancellationToken.None); //It returns null since _isAsyncBulkCopy = false;
}
finally
@@ -1875,7 +1846,7 @@ public Task WriteToServerAsync(DataRow[] rows, CancellationToken cancellationTok
{
throw SQL.BulkLoadPendingOperation();
}
-
+
SqlStatistics statistics = Statistics;
try
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs
index b7fad377f4..3248ac6637 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs
@@ -2509,11 +2509,6 @@ static internal Exception SnapshotNotSupported(System.Data.IsolationLevel level)
{
return ADP.Argument(StringsHelper.GetString(Strings.SQL_SnapshotNotSupported, typeof(System.Data.IsolationLevel), level.ToString()));
}
- static internal Exception UnexpectedSmiEvent(Microsoft.Data.SqlClient.Server.SmiEventSink_Default.UnexpectedEventType eventType)
- {
- Debug.Assert(false, "UnexpectedSmiEvent: " + eventType.ToString()); // Assert here, because these exceptions will most likely be eaten by the server.
- return ADP.InvalidOperation(StringsHelper.GetString(Strings.SQL_UnexpectedSmiEvent, (int)eventType));
- }
#endif
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParameterSetter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParameterSetter.cs
index 13446c66ce..9f0bd70c9c 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParameterSetter.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParameterSetter.cs
@@ -27,27 +27,20 @@ internal TdsParameterSetter(TdsParserStateObject stateObj, SmiMetaData md)
#endregion
#region TypedGetterSetter overrides
- // Are calls to Get methods allowed?
- internal override bool CanGet
- {
- get
- {
- return false;
- }
- }
- // Are calls to Set methods allowed?
- internal override bool CanSet
- {
- get
- {
- return true;
- }
- }
+ ///
+ /// Are calls to Get methods allowed?
+ ///
+ protected override bool CanGet => false;
+
+ ///
+ /// Are calls to Set methods allowed?
+ ///
+ protected override bool CanSet => true;
// valid for structured types
// This method called for both get and set.
- internal override SmiTypedGetterSetter GetTypedGetterSetter(SmiEventSink sink, int ordinal)
+ internal override SmiTypedGetterSetter GetTypedGetterSetter(int ordinal)
{
Debug.Assert(0 == ordinal, "TdsParameterSetter only supports 0 for ordinal. Actual = " + ordinal);
return _target;
@@ -55,11 +48,10 @@ internal override SmiTypedGetterSetter GetTypedGetterSetter(SmiEventSink sink, i
// Set value to null
// valid for all types
- public override void SetDBNull(SmiEventSink sink, int ordinal)
+ public override void SetDBNull(int ordinal)
{
Debug.Assert(0 == ordinal, "TdsParameterSetter only supports 0 for ordinal. Actual = " + ordinal);
-
- _target.EndElements(sink);
+ _target.EndElements();
}
#endregion
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsRecordBufferSetter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsRecordBufferSetter.cs
index 90a83057b0..496295e0b8 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsRecordBufferSetter.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsRecordBufferSetter.cs
@@ -46,21 +46,9 @@ internal TdsRecordBufferSetter(TdsParserStateObject stateObj, SmiMetaData md)
}
// TdsRecordBufferSetter supports Setting only
- internal override bool CanGet
- {
- get
- {
- return false;
- }
- }
+ protected override bool CanGet => false;
- internal override bool CanSet
- {
- get
- {
- return true;
- }
- }
+ protected override bool CanSet => true;
#endregion
@@ -68,21 +56,21 @@ internal override bool CanSet
// Set value to null
// valid for all types
- public override void SetDBNull(SmiEventSink sink, int ordinal)
+ public override void SetDBNull(int ordinal)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetDBNull();
}
// valid for SqlDbType.Bit
- public override void SetBoolean(SmiEventSink sink, int ordinal, bool value)
+ public override void SetBoolean(int ordinal, bool value)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetBoolean(value);
}
// valid for SqlDbType.TinyInt
- public override void SetByte(SmiEventSink sink, int ordinal, byte value)
+ public override void SetByte(int ordinal, byte value)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetByte(value);
@@ -92,12 +80,12 @@ public override void SetByte(SmiEventSink sink, int ordinal, byte value)
// Use in combination with SetLength to ensure overwriting when necessary
// valid for SqlDbTypes: Binary, VarBinary, Image, Udt, Xml
// (VarBinary assumed for variants)
- public override int SetBytes(SmiEventSink sink, int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
+ public override int SetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
{
CheckWritingToColumn(ordinal);
return _fieldSetters[ordinal].SetBytes(fieldOffset, buffer, bufferOffset, length);
}
- public override void SetBytesLength(SmiEventSink sink, int ordinal, long length)
+ public override void SetBytesLength(int ordinal, long length)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetBytesLength(length);
@@ -107,130 +95,133 @@ public override void SetBytesLength(SmiEventSink sink, int ordinal, long length)
// Use in combination with SetLength to ensure overwriting when necessary
// valid for character types: Char, VarChar, Text, NChar, NVarChar, NText
// (NVarChar and global clr collation assumed for variants)
- public override int SetChars(SmiEventSink sink, int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
+ public override int SetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
{
CheckWritingToColumn(ordinal);
return _fieldSetters[ordinal].SetChars(fieldOffset, buffer, bufferOffset, length);
}
- public override void SetCharsLength(SmiEventSink sink, int ordinal, long length)
+ public override void SetCharsLength(int ordinal, long length)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetCharsLength(length);
}
// valid for character types: Char, VarChar, Text, NChar, NVarChar, NText
- public override void SetString(SmiEventSink sink, int ordinal, string value, int offset, int length)
+ public override void SetString(int ordinal, string value, int offset, int length)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetString(value, offset, length);
}
// valid for SqlDbType.SmallInt
- public override void SetInt16(SmiEventSink sink, int ordinal, short value)
+ public override void SetInt16(int ordinal, short value)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetInt16(value);
}
// valid for SqlDbType.Int
- public override void SetInt32(SmiEventSink sink, int ordinal, int value)
+ public override void SetInt32(int ordinal, int value)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetInt32(value);
}
// valid for SqlDbType.BigInt, SqlDbType.Money, SqlDbType.SmallMoney
- public override void SetInt64(SmiEventSink sink, int ordinal, long value)
+ public override void SetInt64(int ordinal, long value)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetInt64(value);
}
// valid for SqlDbType.Real
- public override void SetSingle(SmiEventSink sink, int ordinal, float value)
+ public override void SetSingle(int ordinal, float value)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetSingle(value);
}
// valid for SqlDbType.Float
- public override void SetDouble(SmiEventSink sink, int ordinal, double value)
+ public override void SetDouble(int ordinal, double value)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetDouble(value);
}
// valid for SqlDbType.Numeric (uses SqlDecimal since Decimal cannot hold full range)
- public override void SetSqlDecimal(SmiEventSink sink, int ordinal, SqlDecimal value)
+ public override void SetSqlDecimal(int ordinal, SqlDecimal value)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetSqlDecimal(value);
}
// valid for DateTime, SmallDateTime, Date, DateTime2
- public override void SetDateTime(SmiEventSink sink, int ordinal, DateTime value)
+ public override void SetDateTime(int ordinal, DateTime value)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetDateTime(value);
}
// valid for UniqueIdentifier
- public override void SetGuid(SmiEventSink sink, int ordinal, Guid value)
+ public override void SetGuid(int ordinal, Guid value)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetGuid(value);
}
// valid for SqlDbType.Time
- public override void SetTimeSpan(SmiEventSink sink, int ordinal, TimeSpan value)
+ public override void SetTimeSpan(int ordinal, TimeSpan value)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetTimeSpan(value);
}
// valid for DateTimeOffset
- public override void SetDateTimeOffset(SmiEventSink sink, int ordinal, DateTimeOffset value)
+ public override void SetDateTimeOffset(int ordinal, DateTimeOffset value)
{
CheckSettingColumn(ordinal);
_fieldSetters[ordinal].SetDateTimeOffset(value);
}
// valid for SqlDbType.Variant
- public override void SetVariantMetaData(SmiEventSink sink, int ordinal, SmiMetaData metaData)
+ public override void SetVariantMetaData(int ordinal, SmiMetaData metaData)
{
CheckWritingToColumn(ordinal);
_fieldSetters[ordinal].SetVariantType(metaData);
}
// valid for multi-valued types
- internal override void NewElement(SmiEventSink sink)
+ internal override void NewElement()
{
-#if DEBUG
+ #if DEBUG
SkipPossibleDefaultedColumns(ReadyForToken);
Debug.Assert(ReadyForToken == _currentField, "Not on first or last column!");
-#endif
+ #endif
// For TVP types, write new-row token
Debug.Assert(_metaData.IsMultiValued, "Unsupported call for single-valued types");
_stateObj.WriteByte(TdsEnums.TVP_ROW_TOKEN);
-#if DEBUG
+
+ #if DEBUG
_currentField = 0;
-#endif
+ #endif
}
- internal override void EndElements(SmiEventSink sink)
+ internal override void EndElements()
{
-#if DEBUG
+ #if DEBUG
SkipPossibleDefaultedColumns(ReadyForToken);
Debug.Assert(ReadyForToken == _currentField, "Not on first or last column!");
Debug.Assert(_metaData.IsMultiValued, "Unsupported call for single-valued types");
-#endif
+ #endif
+
// For TVP types, write no-more-rows token
_stateObj.WriteByte(TdsEnums.TVP_END_TOKEN);
-#if DEBUG
+
+ #if DEBUG
_currentField = EndElementsCalled;
-#endif
+ #endif
}
diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlMetaDataTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlMetaDataTest.cs
index 9678c3e0f3..cd316a9eab 100644
--- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlMetaDataTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlMetaDataTest.cs
@@ -620,61 +620,6 @@ public void GenericConstructorWithoutXmlSchemaWithInvalidDbType_Throws()
Assert.Contains("dbType", ex.Message, StringComparison.OrdinalIgnoreCase);
}
- [Fact]
- public void GetPartialLengthWithXmlSqlMetaDataType_Throws()
- {
- Type sqlMetaDataType = typeof(SqlMetaData);
- SqlMetaData exampleMetaData = new SqlMetaData("col2", SqlDbType.Xml);
- MethodInfo method = sqlMetaDataType.GetMethod("GetPartialLengthMetaData", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
- Exception ex = Assert.ThrowsAny(() =>
- {
- SqlMetaData metaData = (SqlMetaData)method.Invoke(exampleMetaData, new object[] { exampleMetaData });
- });
- Assert.NotNull(ex.InnerException);
- Assert.IsType(ex.InnerException);
- Assert.NotEmpty(ex.InnerException.Message);
- Assert.Contains("metadata", ex.InnerException.Message, StringComparison.OrdinalIgnoreCase);
- }
-
- public static IEnumerable