Skip to content

Commit 2bda3c9

Browse files
authored
remove some un-used fields (#5027)
* remove some un-used fields * Restore _SqlRPC.options field The field is still assigned in SqlCommand and read when TdsParser writes the RPC header, so removing it broke the build. * Remove more unused fields Remove fields that are never read: SqlLogin.authentication, SqlEnvChange._oldValue and _oldCollation, SmiStorageMetaData._isColumnSet, SmiQueryMetaData._isReadOnly, SmiMetaData.s_typeNameByDatabaseType, SmiXetterAccessMap.s_isGetterAccessValid, SqlSecurityUtility.ColumnMasterKeyMetadataSignatureVerificationCache, SqlNotificationEventArgs.s_notifyError, TdsTableName.Null, and the TdsEnums WHIDBEY_TIME_LENGTH, WHIDBEY_DATETIME2_LENGTH and WHIDBEY_DATETIMEOFFSET_LENGTH arrays. The old env change value and collation are still read from the stream to advance past them, but are discarded.
1 parent c2d132e commit 2bda3c9

15 files changed

Lines changed: 7 additions & 132 deletions

File tree

‎src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ColumnEncryptionKeyInfo.cs‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ namespace Microsoft.Data.SqlClient
1212
/// </summary>
1313
internal class ColumnEncryptionKeyInfo
1414
{
15-
internal readonly int KeyId;
16-
internal readonly int DatabaseId;
1715
internal readonly byte[] DecryptedKeyBytes;
1816
internal readonly byte[] KeyIdBytes;
1917
internal readonly byte[] DatabaseIdBytes;
@@ -34,7 +32,6 @@ internal class ColumnEncryptionKeyInfo
3432
/// <param name="keyid">key id for this column encryption key</param>
3533
internal ColumnEncryptionKeyInfo(byte[] decryptedKey, int databaseId, ulong keyMetadataVersion, int keyid)
3634
{
37-
3835
if (decryptedKey == null)
3936
{
4037
throw SQL.NullArgumentInConstructorInternal(_decryptedKeyName, _className);
@@ -44,8 +41,6 @@ internal ColumnEncryptionKeyInfo(byte[] decryptedKey, int databaseId, ulong keyM
4441
throw SQL.EmptyArgumentInConstructorInternal(_decryptedKeyName, _className);
4542
}
4643

47-
KeyId = keyid;
48-
DatabaseId = databaseId;
4944
DecryptedKeyBytes = decryptedKey;
5045
KeyMetadataVersion = keyMetadataVersion;
5146

@@ -101,7 +96,6 @@ internal int GetLengthForSerialization()
10196
/// <returns>next available offset</returns>
10297
internal int SerializeToBuffer(byte[] bytePackage, int startOffset)
10398
{
104-
10599
if (null == bytePackage)
106100
{
107101
throw SQL.NullArgumentInternal(_bytePackageName, _className, _serializeToBufferMethodName);

‎src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3334,7 +3334,6 @@ private void Login(
33343334
}
33353335

33363336
// @TODO: How about we define all the easy ones in one block, then have the conditional ones below that
3337-
login.authentication = ConnectionOptions.Authentication;
33383337
login.timeout = timeoutInSeconds;
33393338
login.userInstance = ConnectionOptions.UserInstance;
33403339
login.hostName = ConnectionOptions.ObtainWorkstationId();

‎src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Login/SqlLogin.cs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace Microsoft.Data.SqlClient.Parser.Login;
99

1010
internal sealed class SqlLogin
1111
{
12-
internal SqlAuthenticationMethod authentication = SqlAuthenticationMethod.NotSpecified; // Authentication type
1312
internal int timeout; // login timeout
1413
internal bool userInstance = false; // user instance
1514
internal string hostName = ""; // client machine name

‎src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsEnums.cs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,6 @@ internal enum GenericType
640640
internal const int MAX_TIME_LENGTH = 5; // Maximum length for time
641641
internal const int MAX_DATETIME2_LENGTH = 8; // Maximum length for datetime2
642642
internal const int WHIDBEY_DATE_LENGTH = 10;
643-
internal static readonly int[] WHIDBEY_TIME_LENGTH = { 8, 10, 11, 12, 13, 14, 15, 16 };
644-
internal static readonly int[] WHIDBEY_DATETIME2_LENGTH = { 19, 21, 22, 23, 24, 25, 26, 27 };
645-
internal static readonly int[] WHIDBEY_DATETIMEOFFSET_LENGTH = { 26, 28, 29, 30, 31, 32, 33, 34 };
646643

647644
internal enum FedAuthInfoId : byte
648645
{

‎src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/TdsParser.cs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3367,7 +3367,8 @@ private TdsOperationStatus TryProcessEnvChange(int tokenLength, TdsParserStateOb
33673367
Debug.Assert(env._oldLength == 5 || env._oldLength == 0, "Improper length in old collation!");
33683368
if (env._oldLength == 5)
33693369
{
3370-
result = TryProcessCollation(stateObj, out env._oldCollation);
3370+
// The old collation is not used; read it to advance past it.
3371+
result = TryProcessCollation(stateObj, out _);
33713372
if (result != TdsOperationStatus.Done)
33723373
{
33733374
return result;
@@ -3691,7 +3692,7 @@ private TdsOperationStatus TryReadTwoStringFields(SqlEnvChange env, TdsParserSta
36913692
{
36923693
// Used by ProcessEnvChangeToken
36933694
byte newLength, oldLength;
3694-
string newValue, oldValue;
3695+
string newValue;
36953696
TdsOperationStatus result = stateObj.TryReadByte(out newLength);
36963697
if (result != TdsOperationStatus.Done)
36973698
{
@@ -3707,7 +3708,8 @@ private TdsOperationStatus TryReadTwoStringFields(SqlEnvChange env, TdsParserSta
37073708
{
37083709
return result;
37093710
}
3710-
result = stateObj.TryReadString(oldLength, out oldValue);
3711+
// The old value is not used; read it to advance past it.
3712+
result = stateObj.TryReadString(oldLength, out _);
37113713
if (result != TdsOperationStatus.Done)
37123714
{
37133715
return result;
@@ -3716,7 +3718,6 @@ private TdsOperationStatus TryReadTwoStringFields(SqlEnvChange env, TdsParserSta
37163718
env._newLength = newLength;
37173719
env._newValue = newValue;
37183720
env._oldLength = oldLength;
3719-
env._oldValue = oldValue;
37203721

37213722
// env.length includes 1 byte type token
37223723
env._length = 3 + env._newLength * 2 + env._oldLength * 2;

‎src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Parser/Tokens/TdsTableName.cs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ namespace Microsoft.Data.SqlClient.Parser.Tokens;
1212
/// </summary>
1313
internal struct TdsTableName
1414
{
15-
internal static readonly TdsTableName Null = new([null, null, null, null]);
16-
1715
private string _multipartName;
1816
private string _serverName;
1917
private string _catalogName;

‎src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiMetaData.cs‎

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -472,48 +472,6 @@ SqlCompareOptions compareOptions
472472
DefaultDateTimeOffset, // SqlDbType.DateTimeOffset
473473
};
474474

475-
// static array of type names ordered by corresponding SqlDbType.
476-
// NOTE: INDEXED BY SqlDbType ENUM! MUST UPDATE THIS ARRAY WHEN UPDATING SqlDbType!
477-
// ONLY ACCESS THIS GLOBAL FROM get_TypeName!
478-
private static readonly string[] s_typeNameByDatabaseType =
479-
{
480-
"bigint", // SqlDbType.BigInt
481-
"binary", // SqlDbType.Binary
482-
"bit", // SqlDbType.Bit
483-
"char", // SqlDbType.Char
484-
"datetime", // SqlDbType.DateTime
485-
"decimal", // SqlDbType.Decimal
486-
"float", // SqlDbType.Float
487-
"image", // SqlDbType.Image
488-
"int", // SqlDbType.Int
489-
"money", // SqlDbType.Money
490-
"nchar", // SqlDbType.NChar
491-
"ntext", // SqlDbType.NText
492-
"nvarchar", // SqlDbType.NVarChar
493-
"real", // SqlDbType.Real
494-
"uniqueidentifier", // SqlDbType.UniqueIdentifier
495-
"smalldatetime", // SqlDbType.SmallDateTime
496-
"smallint", // SqlDbType.SmallInt
497-
"smallmoney", // SqlDbType.SmallMoney
498-
"text", // SqlDbType.Text
499-
"timestamp", // SqlDbType.Timestamp
500-
"tinyint", // SqlDbType.TinyInt
501-
"varbinary", // SqlDbType.VarBinary
502-
"varchar", // SqlDbType.VarChar
503-
"sql_variant", // SqlDbType.Variant
504-
null, // placeholder for 24
505-
"xml", // SqlDbType.Xml
506-
null, // placeholder for 26
507-
null, // placeholder for 27
508-
null, // placeholder for 28
509-
string.Empty, // SqlDbType.Udt -- get type name from Type.FullName instead.
510-
string.Empty, // Structured types have user-defined type names.
511-
"date", // SqlDbType.Date
512-
"time", // SqlDbType.Time
513-
"datetime2", // SqlDbType.DateTime2
514-
"datetimeoffset", // SqlDbType.DateTimeOffset
515-
};
516-
517475
// Internal setter to be used by constructors only! Modifies state!
518476
private void SetDefaultsForType(SqlDbType dbType)
519477
{
@@ -865,7 +823,6 @@ internal class SmiStorageMetaData : SmiExtendedMetaData
865823
private readonly string _columnName; // underlying column's name
866824
private readonly SqlBoolean _isKey; // Is this one of a set of key columns that uniquely identify an underlying table?
867825
private readonly bool _isIdentity; // Is this from an identity column
868-
private readonly bool _isColumnSet; // Is this column the XML representation of a columnset?
869826

870827
internal SmiStorageMetaData(
871828
SqlDbType dbType,
@@ -1031,7 +988,6 @@ bool isColumnSet
1031988
_columnName = columnName;
1032989
_isKey = isKey;
1033990
_isIdentity = isIdentity;
1034-
_isColumnSet = isColumnSet;
1035991
}
1036992

1037993
internal bool AllowsDBNull => _allowsDBNull;
@@ -1082,7 +1038,6 @@ internal override string TraceString(int indent)
10821038
// Maps to full COLMETADATA + COLINFO + TABNAME tokens on TDS.
10831039
internal class SmiQueryMetaData : SmiStorageMetaData
10841040
{
1085-
private readonly bool _isReadOnly;
10861041
private readonly SqlBoolean _isExpression;
10871042
private readonly SqlBoolean _isAliased;
10881043
private readonly SqlBoolean _isHidden;
@@ -1213,7 +1168,6 @@ SqlBoolean isHidden
12131168
isColumnSet
12141169
)
12151170
{
1216-
_isReadOnly = isReadOnly;
12171171
_isExpression = isExpression;
12181172
_isAliased = isAliased;
12191173
_isHidden = isHidden;

‎src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiXetterAccessMap.cs‎

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,6 @@ internal static class SmiXetterAccessMap
1515
private const bool X = true;
1616
private const bool _ = false;
1717

18-
#if NETFRAMEWORK
19-
private static readonly bool[,] s_isGetterAccessValid =
20-
{
21-
// Getters as columns (abbreviated from XetterTypeCode names)
22-
// SqlDbTypes as rows
23-
// bool, byte, bytes, chars, strng, int16, int32, int64, singl, doubl, sqldec, date, guid, varmd, Xetr, time, dtost
24-
/*BigInt*/ { _, _, _, _, _, _, _, X, _, _, _, _, _, _, _, _, _, },
25-
/*Binary*/ { _, _, X, _, _, _, _, _, _, _, _, _, _, _, _, _, _, },
26-
/*Bit*/ { X, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, },
27-
/*Char*/ { _, _, X, X, X, _, _, _, _, _, _, _, _, _, _, _, _, },
28-
/*DTime*/ { _, _, _, _, _, _, _, _, _, _, _, X, _, _, _, _, _, },
29-
/*Decimal*/ { _, _, _, _, _, _, _, _, _, _, X, _, _, _, _, _, _, },
30-
/*Float*/ { _, _, _, _, _, _, _, _, _, X, _, _, _, _, _, _, _, },
31-
/*Image*/ { _, _, X, _, _, _, _, _, _, _, _, _, _, _, _, _, _, },
32-
/*Int*/ { _, _, _, _, _, _, X, _, _, _, _, _, _, _, _, _, _, },
33-
/*Money*/ { _, _, _, _, _, _, _, X, _, _, _, _, _, _, _, _, _, },
34-
/*NChar*/ { _, _, X, X, X, _, _, _, _, _, _, _, _, _, _, _, _, },
35-
/*NText*/ { _, _, X, X, X, _, _, _, _, _, _, _, _, _, _, _, _, },
36-
/*NVarChar*/ { _, _, X, X, X, _, _, _, _, _, _, _, _, _, _, _, _, },
37-
/*Real*/ { _, _, _, _, _, _, _, _, X, _, _, _, _, _, _, _, _, },
38-
/*UniqueId*/ { _, _, _, _, _, _, _, _, _, _, _, _, X, _, _, _, _, },
39-
/*SmDTime*/ { _, _, _, _, _, _, _, _, _, _, _, X, _, _, _, _, _, },
40-
/*SmInt*/ { _, _, _, _, _, X, _, _, _, _, _, _, _, _, _, _, _, },
41-
/*SmMoney*/ { _, _, _, _, _, _, _, X, _, _, _, _, _, _, _, _, _, },
42-
/*Text*/ { _, _, X, X, X, _, _, _, _, _, _, _, _, _, _, _, _, },
43-
/*Tstamp*/ { _, _, X, _, _, _, _, _, _, _, _, _, _, _, _, _, _, },
44-
/*TinyInt*/ { _, X, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, },
45-
/*VarBin*/ { _, _, X, _, _, _, _, _, _, _, _, _, _, _, _, _, _, },
46-
/*VarChar*/ { _, _, X, X, X, _, _, _, _, _, _, _, _, _, _, _, _, },
47-
/*Variant*/ { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, X, X, },
48-
/* 24 */ { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, },
49-
/*Xml*/ { _, _, X, _, _, _, _, _, _, _, _, _, _, _, _, _, _, },
50-
/* 26 */ { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, },
51-
/* 27 */ { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, },
52-
/* 28 */ { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, },
53-
/*Udt*/ { _, _, X, _, _, _, _, _, _, _, _, _, _, _, _, _, _, },
54-
/*Struct*/ { _, _, X, _, _, _, _, _, _, _, _, _, _, _, X, _, _, },
55-
/*Date*/ { _, _, _, _, _, _, _, _, _, _, _, X, _, _, _, _, _, },
56-
/*Time*/ { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, _, },
57-
/*DTime2*/ { _, _, _, _, _, _, _, _, _, _, _, X, _, _, _, _, _, },
58-
/*DTOffset*/ { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, },
59-
};
60-
#endif
61-
6218
private static readonly bool[,] s_isSetterAccessValid =
6319
{
6420
// Setters as columns (abbreviated from XetterTypeCode names)

‎src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBulkCopyColumnMapping.cs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public sealed class SqlBulkCopyColumnMapping
1616

1717
// devnote: we don't want the user to detect the columnordinal after WriteToServer call.
1818
// _sourceColumnOrdinal(s) will be copied to _internalSourceColumnOrdinal when WriteToServer executes.
19-
internal int _internalDestinationColumnOrdinal;
2019
internal int _internalSourceColumnOrdinal; // -1 indicates an undetermined value
2120

2221
// Used by SqlBulkCopy to generate the correct column name after mapping alternate names.
@@ -39,7 +38,7 @@ public string DestinationColumn
3938
}
4039
set
4140
{
42-
_destinationColumnOrdinal = _internalDestinationColumnOrdinal = -1;
41+
_destinationColumnOrdinal = -1;
4342
_destinationColumnName = value;
4443
}
4544
}
@@ -56,7 +55,7 @@ public int DestinationOrdinal
5655
if (value >= 0)
5756
{
5857
_destinationColumnName = null;
59-
_destinationColumnOrdinal = _internalDestinationColumnOrdinal = value;
58+
_destinationColumnOrdinal = value;
6059
}
6160
else
6261
{

‎src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ internal class SharedState
6868
private ALTROWSTATUS _altRowStatus;
6969
private int _recordsAffected = -1;
7070
private long _defaultTimeoutMilliseconds;
71-
private SqlConnectionOptions.TypeSystem _typeSystem;
7271

7372
// SQLStatistics support
7473
private SqlStatistics _statistics;
@@ -118,7 +117,6 @@ internal SqlDataReader(SqlCommand command, CommandBehavior behavior)
118117
if (_connection != null)
119118
{
120119
_statistics = _connection.Statistics;
121-
_typeSystem = _connection.TypeSystem;
122120
}
123121
}
124122
_sharedState._dataReady = false;

0 commit comments

Comments
 (0)