Skip to content

materialize-*: check rows.Err() after all rows.Next() loops#4234

Merged
Alex-Bair merged 2 commits intomainfrom
bair/materialize-{various}-check-rows-err-after-iteration
Apr 13, 2026
Merged

materialize-*: check rows.Err() after all rows.Next() loops#4234
Alex-Bair merged 2 commits intomainfrom
bair/materialize-{various}-check-rows-err-after-iteration

Conversation

@Alex-Bair
Copy link
Copy Markdown
Member

Description:

This is the materialization counterpart of #4233.

Per Go's database/sql docs, rows.Next() returns false both when the result set is exhausted and when an error is encountered. rows.Err() must be checked afterward to distinguish the two cases. Without this check, a mid-iteration error causes the function to return success with a partial result set.

I also added a defer rows.Close() in a spot in materailize-sqlserver that was missing it.

Notes for reviewers:

When investigating an escalation for source-sqlserver, we found that it wasn't checking rows.Err() after iterating through rows.Next() and could have missed changes as a result of that bug. I'm going through and updating all connectors to make sure they check rows.Err() so we don't encounter the same bug elsewhere, and this PR is a part of that effort. I'm not as familiar with materializations, so feel free to tell me to do things differently if these changes aren't applicable for whatever reason. 😁

Per Go's database/sql docs, `rows.Next()` returns false both when the
result set is exhausted and when an error is encountered. `rows.Err()`
must be checked afterward to distinguish the two cases. Without this
check, a mid-iteration error causes the function to return success
with a partial result set.
@Alex-Bair Alex-Bair marked this pull request as ready for review April 13, 2026 20:35
@Alex-Bair Alex-Bair requested a review from a team April 13, 2026 20:35
@Alex-Bair Alex-Bair merged commit 8a432b2 into main Apr 13, 2026
65 of 70 checks passed
@Alex-Bair Alex-Bair deleted the bair/materialize-{various}-check-rows-err-after-iteration branch April 13, 2026 20:41
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.

2 participants