remove sqlserver 7 and 2000 support#4015
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to remove legacy SQL Server 7.0 / 2000 compatibility paths (and related “Type System Version” handling) from SqlClient and its test TDS tooling.
Changes:
- Removed SQL Server 7.0 / 2000 mappings from the test TDS version helper and tightened supported TDS range to 2005–2012.
- Removed
TypeSystemVersion=SQL Server 2000parsing support and deleted SQL Server 2000-specific branches inSqlDataReader. - Cleaned up several legacy-version comments across core TDS/transaction code paths.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSVersion.cs | Removes SQL7/2000 version constants and mapping; tightens supported TDS range. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs | Updates legacy-version comments in TDS parsing logic. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs | Removes 2000-era versioning comment lines; updates datatype “version introduced” comment. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs | Simplifies legacy server notes around parameter size/type elevation. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlInternalTransaction.cs | Removes SQL7/2000-specific commentary from zombie handling explanation. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs | Removes SQL Server 2000-specific type-system behavior and helper method. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs | Drops SQL Server 2000 from TypeSystemVersion recognized values. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs | Updates transaction enlistment comments to remove SQL7/2000 references. |
Comments suppressed due to low confidence (1)
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSVersion.cs:53
GetTDSVersionnow throwsNotSupportedExceptionfor server build majors other than 9/10/11. The simulated TDS server is still used in unit tests withServerVersionmajors 7 and 8 (e.g.,tests/UnitTests/SimulatedServerTests/ConnectionTests.cs), so this will throw during server login handling and likely break those tests (and the ability to simulate legacy servers). Consider keeping mappings for 7.0/2000 in the test server, or update/remove the tests and any callers that still pass 7/8 versions.
else
{
// Not supported TDS version
throw new NotSupportedException("Specified build version is not supported");
}
…arser.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…arameter.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSVersion.cs:53
GetTDSVersionno longer handles server build versions with major 7 or 8. The simulated TDS server (GenericTdsServer.OnLogin7Request) callsTDSVersion.GetTDSVersion(Arguments.ServerVersion)during login, so starting a test server withServerVersion = new Version(7, …)ornew Version(8, …)will now result in an unhandledNotSupportedExceptioninstead of the server returning a clean “unsupported TDS version” response. This is likely to break existing simulated-server unit tests that validate the client rejects SQL Server 7.0/2000. Consider either keeping the 7.0/2000 mapping here for negative-testing purposes, or catchingNotSupportedExceptionat the call site and treating it as an unsupported version viaCheckTDSVersion.
public static Version GetTDSVersion(Version buildVersion)
{
// Check build version Major part
if (buildVersion.Major == 11)
{
return SqlServer2012;
}
else if (buildVersion.Major == 10)
{
return SqlServer2008;
}
else if (buildVersion.Major == 9)
{
return SqlServer2005;
}
else
{
// Not supported TDS version
throw new NotSupportedException("Specified build version is not supported");
}
paulmedynski
left a comment
There was a problem hiding this comment.
Looks good, with one Copilot comment to address.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSVersion.cs:53
GetTDSVersionnow throwsNotSupportedExceptionfor server build versions with major 7/8.GenericTdsServer.OnLogin7Requestcalls this without a try/catch, so starting the simulated server with SQL 7.0/2000 versions will crash the server-side handler rather than returning a clean protocol error to the client. This will also break existing simulated-server unit tests that still cover denied SQL 7.0/2000 versions (e.g.,SimulatedServerTests/ConnectionTests.ConnectionTestDeniedVersion). Consider either removing/updating those tests as part of this PR, or changingGetTDSVersion(or its caller) to handle unsupported build versions gracefully (e.g., return an error token / deny connection) instead of throwing.
else
{
// Not supported TDS version
throw new NotSupportedException("Specified build version is not supported");
}
|
in src\Microsoft.Data.SqlClient\src\Microsoft\Data\SqlClient\SqlParameter.cs we have should that change? |
I would want to see it in a standalone PR. It would require more scrutiny to understand if it's safe to change. |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
cheenamalhotra
left a comment
There was a problem hiding this comment.
Need to make sure there are no environmental regressions - recommend running internal Test pipelines too, Kerberos and Managed Instance targeted tests.
Will approve when we have conformation on no regressions.
|
I'm taking over this PR - @SimonCropp please don't make any updates without coordinating with me first. Thanks! |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
@paulmedynski thanks |
|
@paulmedynski assigned to you since you're already monitoring it. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSVersion.cs:53
GetTDSVersionno longer maps SQL Server major versions 7 (SQL 7.0) and 8 (SQL 2000) and now throwsNotSupportedException. The simulated server usesTDSVersion.GetTDSVersion(Arguments.ServerVersion)(e.g.,TDS.Servers/GenericTdsServer.cs:287), and there are existing unit tests that still start the simulated server withServerVersion7.x/8.x (e.g.,tests/UnitTests/SimulatedServerTests/ConnectionTests.csInlineData for 7.0 and 2000). As-is, those tests/server scenarios will fail during login handling before the client can validate/reject the legacy server version. Either remove/update those tests/scenarios or keep the legacy build-version mapping here (even if the main driver drops support).
public static Version GetTDSVersion(Version buildVersion)
{
// Check build version Major part
if (buildVersion.Major == 11)
{
return SqlServer2012;
}
else if (buildVersion.Major == 10)
{
return SqlServer2008;
}
else if (buildVersion.Major == 9)
{
return SqlServer2005;
}
else
{
// Not supported TDS version
throw new NotSupportedException("Specified build version is not supported");
}
- ConnectionTests: ConnectionTestDeniedVersion now expects SqlException instead of InvalidOperationException for SQL Server 7.0/2000, since the simulated TDS server no longer emits a login for those versions and the client fails to connect. - TDSVersion.IsSupported: enforce a 2005 lower bound so pre-2005/invalid TDS versions cannot be negotiated as a downgraded version. - SqlConnectionOptions: remove the redundant TypeSystem.Latest enum member (it duplicated SQLServer2008); map the 'Latest' connection-string value to SQLServer2008 at parse time with rationale, and document that 'Latest' is a badly named sentinel value. - SqlParameter: replace the stale 'SQL Server 2000' comment with the unit/encoding rationale.
Track the Azure-project SSPI failure under the new task instead of #40107.
|
/azp run sqlclient-pr |
|
Azure Pipelines successfully started running 1 pipeline(s). |
- Guard graph-table (AS NODE/AS EDGE) UnprivilegedLogin test on SQL 2017+, since graph tables are unsupported on SQL Server 2016. - Correct CopyAllFromReader pre-2017 IduCount/Transactions expectations from 0 to 1; the least-privilege bulk copy change (dotnet#4306) added one IDU/transaction but only updated the >=2017 branch, leaving the pre-2017 branch stale.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionOptions.cs:490
Type System Version=SQL Server 2000was removed from parsing (now falls into theInvalidConnectionOptionValuecase), which is an observable behavior change. There doesn’t appear to be any automated test coverage that opening a connection with this value now throwsArgumentException(and that other values likeLatest/SQL Server 2005/2008/2012remain accepted). Adding a regression test would help prevent accidental reintroduction or a future change to where/when validation occurs.
if (typeSystemVersionString.Equals(TYPESYSTEMVERSION.Latest, StringComparison.OrdinalIgnoreCase))
{
// "Latest" (and the default when no version is specified) intentionally maps to
// SQL Server 2008 rather than the newest defined type system. Advancing it would
// alter type mappings (e.g. the Microsoft.SqlServer.Types assembly version and how
// down-level types are surfaced) for existing applications that rely on the default,
// which would be a breaking change. Newer type systems must be requested explicitly.
_typeSystemVersion = TypeSystem.SQLServer2008;
}
else if (typeSystemVersionString.Equals(TYPESYSTEMVERSION.SQL_Server_2005, StringComparison.OrdinalIgnoreCase))
{
_typeSystemVersion = TypeSystem.SQLServer2005;
}
else if (typeSystemVersionString.Equals(TYPESYSTEMVERSION.SQL_Server_2008, StringComparison.OrdinalIgnoreCase))
{
_typeSystemVersion = TypeSystem.SQLServer2008;
}
else if (typeSystemVersionString.Equals(TYPESYSTEMVERSION.SQL_Server_2012, StringComparison.OrdinalIgnoreCase))
{
_typeSystemVersion = TypeSystem.SQLServer2012;
_typeSystemAssemblyVersion = s_constTypeSystemAsmVersion11;
}
else
{
throw ADP.InvalidConnectionOptionValue(DbConnectionStringKeywords.TypeSystemVersion);
}
…sions (PR dotnet#4015) The simulated TDS server had lost the ability to emit a legacy 7.0/2000 LOGINACK, so ConnectionTestDeniedVersion only proved a generic connection failure (the test server threw NotSupportedException before sending a login), not that the driver rejects unsupported server versions. - TDSVersion: restore SqlServer7_0/SqlServer2000 constants and the major 7/8 branches in GetTDSVersion, and revert IsSupported to <= SqlServer2012 so the simulated server emits a genuine legacy LOGINACK. - ConnectionTests: rename the test to ConnectionRefusesUnsupportedServerTdsVersion and assert InvalidOperationException - the driver's real rejection via SQL.InvalidTDSVersion() in TryProcessLoginAck. Addresses review thread r3468675054.
|
/azp run sqlclient-pr, CI-SqlClient, CI-SqlClient-Package |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Summary
Removes support for SQL Server 7.0 and SQL Server 2000 from the driver.
SQL Server 2000's mainstream support ended on April 8, 2008, and extended support ended on April 9, 2013, so it has been fully unsupported for over 12 years. SQL Server 7.0 is older still. The driver already refused to connect to these versions (TDS version negotiation has required SQL Server 2005 or later for a long time — anything below
0x72throwsSQL.InvalidTDSVersion()), so the protocol-level code paths for 7.0/2000 were effectively dead. This PR removes that dead code along with the now-orphanedSQL Server 2000type-system compatibility option.Public API / behavior changes
Type System Version=SQL Server 2000connection-string value removed.The
TypeSystem.SQLServer2000enum value and the"SQL Server 2000"parsing branch are removed fromSqlConnectionOptions. A connection string that specifiesType System Version=SQL Server 2000now throwsArgumentException(ADP.InvalidConnectionOptionValue) when the connection is opened, instead of being accepted.Latest,SQL Server 2005,SQL Server 2008,SQL Server 2012— are unchanged.SqlDataReaderno longer applies SQL Server 2000 type-system mapping.The
TypeSystem.SQLServer2000-specific branches and theGetVersionedMetaTypelegacy down-level type coercion are removed (~215 lines). Only affects applications that previously setType System Version=SQL Server 2000.There is no change to which servers the driver will connect to — 7.0/2000 servers were already rejected during login version negotiation before this PR.
Code changes
Product (
src/Microsoft.Data.SqlClient/src)SqlConnectionOptions.cs— removeTypeSystem.SQLServer2000enum value and"SQL Server 2000"type-system parsing (behavior change SqlSpatial #1).SqlDataReader.cs— remove 2000 type-system code paths andGetVersionedMetaType(behavior change Fixed link to release notes #2).TdsEnums.cs— remove 7.0/2000 TDS version constants/comments (theSQL2005_*/SQL2008_*/etc. constants are unchanged).TdsParser.cs— remove dead 7.0/2000 handling and stale comments; version-negotiation switch is unchanged (still rejects anything below 2005).SqlConnectionInternal.cs,SqlInternalTransaction.cs,SqlParameter.cs— comment-only cleanup of obsolete 7.0/2000 references; no behavior change.Tests (
src/Microsoft.Data.SqlClient/tests)tools/TDS/TDS/TDSVersion.cs— the simulated TDS server retainsSqlServer7_0/SqlServer2000and the major-7/8 mappings inGetTDSVersion, andIsSupportedkeeps its<= SQL Server 2012bound, so the server can still emit a genuine legacy 7.0/2000LOGINACK. This is deliberately preserved so the unit test can exercise the driver's real client-side rejection. (Clarifying comments only; behavior matchesmain.)UnitTests/SimulatedServerTests/ConnectionTests.cs—ConnectionTestDeniedVersionis renamed toConnectionRefusesUnsupportedServerTdsVersion(7.0, 2000 RTM, 2000 SP1) and continues to assertInvalidOperationException. The simulated server emits a legacyLOGINACKand the driver rejects the pre-2005 TDS version inTryProcessLoginAckviaSQL.InvalidTDSVersion(), so this is genuine client-side legacy-version-rejection coverage (addresses review thread r3468675054).Checklist
Type System Version=SQL Server 2000value)