Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,8 @@ public override void EnlistTransaction(Transaction transaction)
ValidateConnectionForExecute(null);

// If a connection has a local transaction outstanding, and you try to enlist in a DTC
// transaction, SQL Server will roll back the local transaction and then enlist (7.0 and
// 2000). So, if the user tries to do this, throw.
// transaction, SQL Server will roll back the local transaction and then enlist.
// So, if the user tries to do this, throw.
if (HasLocalTransaction)
{
throw ADP.LocalTransactionPresent();
Expand All @@ -848,12 +848,9 @@ public override void EnlistTransaction(Transaction transaction)
return;
}

// If a connection is already enlisted in a DTC transaction, and you try to enlist in
// another one, in 7.0 the existing DTC transaction would roll back and then the
// connection would enlist in the new one. In SQL 2000 & 2005, when you enlist in a DTC
// transaction while the connection is already enlisted in a DTC transaction, the
// connection simply switches enlistments. Regardless, simply enlist in the user
// specified distributed transaction. This behavior matches OLEDB and ODBC.
// If a connection is already enlisted in a DTC transaction and you try to enlist in
// another one, the connection simply switches enlistments. This behavior matches
// OLEDB and ODBC.

Enlist(transaction);
// @TODO: CER Exception Handling was removed here (see GH#3581)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ internal sealed class SqlConnectionString : DbConnectionOptions
internal enum TypeSystem
{
Latest = 2008,
SQLServer2000 = 2000,
SQLServer2005 = 2005,
SQLServer2008 = 2008,
SQLServer2012 = 2012,
Expand All @@ -35,7 +34,6 @@ internal enum TypeSystem
internal static class TYPESYSTEMVERSION
{
internal const string Latest = "Latest";
internal const string SQL_Server_2000 = "SQL Server 2000";
internal const string SQL_Server_2005 = "SQL Server 2005";
internal const string SQL_Server_2008 = "SQL Server 2008";
internal const string SQL_Server_2012 = "SQL Server 2012";
Expand Down Expand Up @@ -409,10 +407,6 @@ internal SqlConnectionString(string connectionString): base(connectionString, s_
{
_typeSystemVersion = TypeSystem.Latest;
}
else if (typeSystemVersionString.Equals(TYPESYSTEMVERSION.SQL_Server_2000, StringComparison.OrdinalIgnoreCase))
{
_typeSystemVersion = TypeSystem.SQLServer2000;
}
else if (typeSystemVersionString.Equals(TYPESYSTEMVERSION.SQL_Server_2005, StringComparison.OrdinalIgnoreCase))
{
_typeSystemVersion = TypeSystem.SQLServer2005;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,19 +593,11 @@ internal DataTable BuildSchemaTable()
break;
}
}
else if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && col.IsLargeUdt)
else if (_typeSystem == SqlConnectionString.TypeSystem.SQLServer2005 && col.IsLargeUdt)
{
if (_typeSystem == SqlConnectionString.TypeSystem.SQLServer2005)
{
schemaRow[providerType] = SqlDbType.VarBinary;
}
else
{
// TypeSystem.SQLServer2000
schemaRow[providerType] = SqlDbType.Image;
}
schemaRow[providerType] = SqlDbType.VarBinary;
}
else if (_typeSystem != SqlConnectionString.TypeSystem.SQLServer2000)
else
{
// TypeSystem.SQLServer2005 and above

Expand All @@ -624,13 +616,6 @@ internal DataTable BuildSchemaTable()
schemaRow[xmlSchemaCollectionName] = col.xmlSchemaCollection?.Name;
}
}
else
{
// TypeSystem.SQLServer2000

// SqlDbType enum value - variable for certain types when SQLServer2000.
schemaRow[providerType] = GetVersionedMetaType(col.metaType).SqlDbType;
}

if (col.cipherMD != null)
{
Expand Down Expand Up @@ -1197,19 +1182,11 @@ private string GetDataTypeNameInternal(_SqlMetaData metaData)
{
dataTypeName = MetaType.MetaNVarChar.TypeName;
}
else if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && metaData.IsLargeUdt)
else if (_typeSystem == SqlConnectionString.TypeSystem.SQLServer2005 && metaData.IsLargeUdt)
{
if (_typeSystem == SqlConnectionString.TypeSystem.SQLServer2005)
{
dataTypeName = MetaType.MetaMaxVarBinary.TypeName;
}
else
{
// TypeSystem.SQLServer2000
dataTypeName = MetaType.MetaImage.TypeName;
}
dataTypeName = MetaType.MetaMaxVarBinary.TypeName;
}
else if (_typeSystem != SqlConnectionString.TypeSystem.SQLServer2000)
else
{
// TypeSystem.SQLServer2005 and above

Expand All @@ -1230,12 +1207,6 @@ private string GetDataTypeNameInternal(_SqlMetaData metaData)
}
}
}
else
{
// TypeSystem.SQLServer2000

dataTypeName = GetVersionedMetaType(metaData.metaType).TypeName;
}

return dataTypeName;
}
Expand Down Expand Up @@ -1286,19 +1257,11 @@ private Type GetFieldTypeInternal(_SqlMetaData metaData)
// Return 2008 types as string
fieldType = MetaType.MetaNVarChar.ClassType;
}
else if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && metaData.IsLargeUdt)
else if (_typeSystem == SqlConnectionString.TypeSystem.SQLServer2005 && metaData.IsLargeUdt)
{
if (_typeSystem == SqlConnectionString.TypeSystem.SQLServer2005)
{
fieldType = MetaType.MetaMaxVarBinary.ClassType;
}
else
{
// TypeSystem.SQLServer2000
fieldType = MetaType.MetaImage.ClassType;
}
fieldType = MetaType.MetaMaxVarBinary.ClassType;
}
else if (_typeSystem != SqlConnectionString.TypeSystem.SQLServer2000)
else
{
// TypeSystem.SQLServer2005 and above
if (metaData.type == SqlDbType.Udt)
Expand All @@ -1319,11 +1282,6 @@ private Type GetFieldTypeInternal(_SqlMetaData metaData)
}
}
}
else
{
// TypeSystem.SQLServer2000
fieldType = GetVersionedMetaType(metaData.metaType).ClassType; // Com+ type.
}

return fieldType;
}
Expand Down Expand Up @@ -1401,19 +1359,11 @@ private Type GetProviderSpecificFieldTypeInternal(_SqlMetaData metaData)
{
providerSpecificFieldType = MetaType.MetaNVarChar.SqlType;
}
else if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && metaData.IsLargeUdt)
else if (_typeSystem == SqlConnectionString.TypeSystem.SQLServer2005 && metaData.IsLargeUdt)
{
if (_typeSystem == SqlConnectionString.TypeSystem.SQLServer2005)
{
providerSpecificFieldType = MetaType.MetaMaxVarBinary.SqlType;
}
else
{
// TypeSystem.SQLServer2000
providerSpecificFieldType = MetaType.MetaImage.SqlType;
}
providerSpecificFieldType = MetaType.MetaMaxVarBinary.SqlType;
}
else if (_typeSystem != SqlConnectionString.TypeSystem.SQLServer2000)
else
{
// TypeSystem.SQLServer2005 and above
if (metaData.type == SqlDbType.Udt)
Expand All @@ -1436,11 +1386,6 @@ private Type GetProviderSpecificFieldTypeInternal(_SqlMetaData metaData)
}
}
}
else
{
// TypeSystem.SQLServer2000
providerSpecificFieldType = GetVersionedMetaType(metaData.metaType).SqlType; // SqlType type.
}

return providerSpecificFieldType;
}
Expand Down Expand Up @@ -2572,27 +2517,7 @@ virtual public SqlXml GetSqlXml(int i)
ReadColumn(i);
SqlXml sx = null;

if (_typeSystem != SqlConnectionString.TypeSystem.SQLServer2000)
{
// TypeSystem.SQLServer2005

sx = _data[i].IsNull ? SqlXml.Null : _data[i].SqlCachedBuffer.ToSqlXml();
}
else
{
// TypeSystem.SQLServer2000

// First, attempt to obtain SqlXml value. If not SqlXml, we will throw the appropriate
// cast exception.
sx = _data[i].IsNull ? SqlXml.Null : _data[i].SqlCachedBuffer.ToSqlXml();

// If the above succeeds, then we received a valid SqlXml instance, now we need to force
// an InvalidCastException since SqlXml is not exposed with the version knob in this setting.
// To do so, we simply force the exception by casting the string representation of the value
// To SqlXml.
object temp = (object)_data[i].String;
sx = (SqlXml)temp;
}
sx = _data[i].IsNull ? SqlXml.Null : _data[i].SqlCachedBuffer.ToSqlXml();

return sx;
}
Expand Down Expand Up @@ -2666,40 +2591,22 @@ private object GetSqlValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
{
return data.SqlValue;
}
else if (_typeSystem != SqlConnectionString.TypeSystem.SQLServer2000)
else if (metaData.type == SqlDbType.Udt)
{
// TypeSystem.SQLServer2005 and above

if (metaData.type == SqlDbType.Udt)
SqlConnection connection = _connection;
if (connection != null)
{
SqlConnection connection = _connection;
if (connection != null)
{
connection.CheckGetExtendedUDTInfo(metaData, true);
return connection.GetUdtValue(data.Value, metaData, false);
}
else
{
throw ADP.DataReaderClosed();
}
connection.CheckGetExtendedUDTInfo(metaData, true);
return connection.GetUdtValue(data.Value, metaData, false);
}
else
{
return data.SqlValue;
throw ADP.DataReaderClosed();
}
}
else
{
// TypeSystem.SQLServer2000

if (metaData.type == SqlDbType.Xml)
{
return data.SqlString;
}
else
{
return data.SqlValue;
}
return data.SqlValue;
}
}

Expand Down Expand Up @@ -2861,49 +2768,38 @@ private object GetValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData metaDa
{
return data.Value;
}
else if (_typeSystem != SqlConnectionString.TypeSystem.SQLServer2000)
else if (metaData.type == SqlDbTypeExtensions.Vector)
{
// TypeSystem.SQLServer2005 and above

if (metaData.type == SqlDbTypeExtensions.Vector)
if (data.IsNull)
{
if (data.IsNull)
{
return DBNull.Value;
}
else
return DBNull.Value;
}
else
{
switch (metaData.scale)
{
switch (metaData.scale)
{
case (byte)MetaType.SqlVectorElementType.Float32:
return data.GetSqlVector<float>();
default:
throw SQL.VectorTypeNotSupported(metaData.scale.ToString());
}
case (byte)MetaType.SqlVectorElementType.Float32:
return data.GetSqlVector<float>();
default:
throw SQL.VectorTypeNotSupported(metaData.scale.ToString());
}
}

if (metaData.type != SqlDbType.Udt)
}
else if (metaData.type == SqlDbType.Udt)
{
SqlConnection connection = _connection;
if (connection != null)
{
return data.Value;
connection.CheckGetExtendedUDTInfo(metaData, true);
return connection.GetUdtValue(data.Value, metaData, true);
}
else
{
SqlConnection connection = _connection;
if (connection != null)
{
connection.CheckGetExtendedUDTInfo(metaData, true);
return connection.GetUdtValue(data.Value, metaData, true);
}
else
{
throw ADP.DataReaderClosed();
}
throw ADP.DataReaderClosed();
}
}
else
{
// TypeSystem.SQLServer2000
return data.Value;
}
}
Expand Down Expand Up @@ -3220,39 +3116,6 @@ override public int GetValues(object[] values)
}
}

private MetaType GetVersionedMetaType(MetaType actualMetaType)
{
Debug.Assert(_typeSystem == SqlConnectionString.TypeSystem.SQLServer2000, "Should not be in this function under anything else but SQLServer2000");

MetaType metaType = null;

if (actualMetaType == MetaType.MetaUdt)
{
metaType = MetaType.MetaVarBinary;
}
else if (actualMetaType == MetaType.MetaXml)
{
metaType = MetaType.MetaNText;
}
else if (actualMetaType == MetaType.MetaMaxVarBinary)
{
metaType = MetaType.MetaImage;
}
else if (actualMetaType == MetaType.MetaMaxVarChar)
{
metaType = MetaType.MetaText;
}
else if (actualMetaType == MetaType.MetaMaxNVarChar)
{
metaType = MetaType.MetaNText;
}
else
{
metaType = actualMetaType;
}

return metaType;
}

private TdsOperationStatus TryHasMoreResults(out bool moreResults)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,8 @@ internal void CloseFromConnection()
{
if (processFinallyBlock)
{
// Always ensure we're zombied; 2005 will send an EnvChange that
// will cause the zombie, but only if we actually go to the wire;
// 7.0 and 2000 won't send the env change, so we have to handle
// them ourselves.
// Always ensure we're zombied; the server will send an EnvChange
// that will cause the zombie, but only if we actually go to the wire.
Zombie();
}
}
Expand Down
Loading
Loading