Skip to content

[6.1] Propagate Errors from ExecuteScalar#3947

Open
samsharma2700 wants to merge 3 commits intorelease/6.1from
dev/samsharma2700/backport_3912_61
Open

[6.1] Propagate Errors from ExecuteScalar#3947
samsharma2700 wants to merge 3 commits intorelease/6.1from
dev/samsharma2700/backport_3912_61

Conversation

@samsharma2700
Copy link
Copy Markdown
Contributor

Description

Port #3912 to release/6.1 to fix Execute Scalar issue #3736

Issues

Fixes #3736

Copilot AI review requested due to automatic review settings February 10, 2026 23:51
@samsharma2700 samsharma2700 requested a review from a team as a code owner February 10, 2026 23:51
@github-project-automation github-project-automation bot moved this to To triage in SqlClient Board Feb 10, 2026
Copy link
Copy Markdown
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

Ports the fix for #3736 into release/6.1 so ExecuteScalar()/ExecuteScalarAsync() no longer silently ignores server-side errors that arrive after the first row/result, preventing transactional “zombie” scenarios.

Changes:

  • Drain remaining result sets in SqlCommand.CompleteExecuteScalar() (sync) and the ExecuteScalarAsync path to force pending error tokens to surface.
  • Add new manual regression tests for ExecuteScalar/ExecuteScalarAsync, including transactional rollback scenarios.
  • Update an existing multiple-results manual test to reflect the new error-propagation behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs Ensures ExecuteScalar (sync/async) drains remaining results so deferred server errors are propagated.
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs Same ExecuteScalar draining behavior ported to the .NET Framework implementation.
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlCommand/SqlCommandExecuteScalarTest.cs Adds manual regression coverage for conversion-error-after-data and transaction rollback behavior.
src/Microsoft.Data.SqlClient/tests/ManualTests/ProviderAgnostic/MultipleResultsTest/MultipleResultsTest.cs Updates ExecuteScalar test expectations now that ExecuteScalar drains and throws on later errors.
src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj Includes the new manual test file in the test project.

@paulmedynski paulmedynski self-assigned this Feb 11, 2026
@paulmedynski paulmedynski moved this from To triage to In review in SqlClient Board Feb 11, 2026
@github-project-automation github-project-automation bot moved this from In review to In progress in SqlClient Board Feb 11, 2026
@mdaigle mdaigle added this to the 6.1.5 milestone Mar 3, 2026
@mdaigle
Copy link
Copy Markdown
Contributor

mdaigle commented Apr 2, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

@paulmedynski
Copy link
Copy Markdown
Contributor

@copilot Please create a single PR to address the open conversations.

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

@paulmedynski I've opened a new pull request, #4133, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: paulmedynski <31868385+paulmedynski@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@paulmedynski paulmedynski dismissed their stale review April 2, 2026 19:42

Dismissing my request for changes, but not approving.

@paulmedynski paulmedynski changed the title [6.1] Port #3912 to release/6.1 [6.1] Propagate Errors from ExecuteScalar Apr 6, 2026
@paulmedynski paulmedynski linked an issue Apr 6, 2026 that may be closed by this pull request
Copilot AI review requested due to automatic review settings April 6, 2026 11:21
@paulmedynski paulmedynski moved this from In progress to In review in SqlClient Board Apr 6, 2026
@paulmedynski
Copy link
Copy Markdown
Contributor

/azp run

Copy link
Copy Markdown
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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

Failed transaction unexpectedly leaves data in table

6 participants