Skip to content

Comments

Feature | Add enhanced routing env change support.#3970

Open
mdaigle wants to merge 2 commits intodev/mdaigle/enhanced-routing-1from
dev/mdaigle/enhanced-routing-2
Open

Feature | Add enhanced routing env change support.#3970
mdaigle wants to merge 2 commits intodev/mdaigle/enhanced-routing-1from
dev/mdaigle/enhanced-routing-2

Conversation

@mdaigle
Copy link
Contributor

@mdaigle mdaigle commented Feb 19, 2026

Ports #3646 to main

Copilot AI review requested due to automatic review settings February 19, 2026 23:40
@mdaigle mdaigle linked an issue Feb 19, 2026 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request ports enhanced routing support from a preview branch to main (originally from PR #3646). Enhanced routing is a TDS protocol extension that allows SQL Server to route connections to an alternate server and specify the target database, extending the existing routing feature which only provided server and port information.

Changes:

  • Adds TDS protocol support for enhanced routing ENVCHANGE token (type 21) alongside legacy routing (type 20)
  • Implements feature extension negotiation for enhanced routing support between client and server
  • Extends test infrastructure (simulated TDS server) to support enhanced routing scenarios
  • Adds validation logic and error messages for enhanced routing information

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
TDS/TDS.csproj Removes explicit file list, relying on SDK-style auto-discovery
TdsEnhancedRoutingEnvChangeTokenValue.cs New class for parsing enhanced routing token with database name
TDSEnvChangeTokenType.cs Adds EnhancedRouting enum value (21)
TDSEnvChangeToken.cs Adds inflation/deflation for enhanced routing token
RoutingTdsServerArguments.cs Adds RoutingDatabaseName property to control test behavior
RoutingTdsServer.cs Refactors to use RoutingDatabaseName to decide legacy vs enhanced routing
FeatureExtensionBehavior.cs Renames enum from FeatureExtensionEnablementTriState for clarity
GenericTdsServerSession.cs Renames property to IsEnhancedRoutingSupportRequested
GenericTdsServer.cs Updates to use renamed FeatureExtensionBehavior and simplifies ack logic
ITDSServerSession.cs Updates interface property name to IsEnhancedRoutingSupportRequested
TdsServerFixture.cs Extracts shared test fixture for TdsServer lifecycle management
FeatureExtensionNegotiationTests.cs Uses shared TdsServerFixture, updates to new enum name
ConnectionEnhancedRoutingTests.cs New test class verifying enhanced routing scenarios (sync/async/ignored/rejected)
Strings.resx / Strings.Designer.cs Adds SQLROR_InvalidEnhancedRoutingInfo error message
TdsParserHelperClasses.cs Extends RoutingInfo with optional DatabaseName property
TdsParser.cs Implements TryProcessEnhancedRoutingToken to parse enhanced routing ENVCHANGE
TdsEnums.cs Adds ENV_ENHANCEDROUTING constant (21), removes unused EnvChangeType enum
SqlUtil.cs Adds ROR_InvalidEnhancedRoutingInfo exception factory method
SqlConnectionInternal.cs Handles ENV_ENHANCEDROUTING in OnEnvChange, validates enhanced routing info, converts fields to auto-properties
ServerInfo.cs Uses RoutingInfo.DatabaseName when available, falls back to InitialCatalog
Files not reviewed (1)
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Language not supported
Comments suppressed due to low confidence (2)

src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/FeatureExtensionNegotiationTests.cs:47

  • The comment incorrectly states "UserAgent FE token" but should reference "EnhancedRoutingSupport FE token" since the test is verifying enhanced routing support, not user agent functionality.
            // Test should fail if no UserAgent FE token is found

src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/TdsServerArguments.cs:31

  • This TODO comment was added without sufficient context or a tracking issue reference. Please either provide more context (e.g., "TODO: change this to expect ITestOutputHelper for better test output integration with xUnit") or remove it if not actionable. If this is tracking work for a future improvement, consider creating a GitHub issue and referencing it in the TODO.
        /// TODO: change this to expect ITestOutputHelper?

IsEnhancedRoutingSupportEnabled = data[0] == 1;

SqlClientEventSource.Log.TryAdvancedTraceEvent(
$"SqlInternalConnectionTds.OnFeatureExtAck | ADV | " +
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the format of other trace messages in this file. As a separate piece of work, the messages should be edited up to better match the file name.

@mdaigle mdaigle marked this pull request as ready for review February 20, 2026 18:26
@mdaigle mdaigle requested a review from a team as a code owner February 20, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support routing to named read replicas

1 participant