Skip to content

Clamp RecordsAffected to int.MaxValue instead of throwing - #28

Open
francoisjehl wants to merge 1 commit into
memsql:masterfrom
francoisjehl:francois/clamp-records-affected
Open

francoisjehl wants to merge 1 commit into
memsql:masterfrom
francoisjehl:francois/clamp-records-affected

Conversation

@francoisjehl

Copy link
Copy Markdown

Context

On DDL like ALTER TABLE ADD COLUMN, SingleStore reports the table's row count as affected rows.
Issue is, this is 32 bits in ADO.NET and thus once a table passes 2^31 rows, it throws OverflowException.
We faced that at Pigment on a 4B row table.

Implementation

  • Let's return (int) Math.Min(recordsAffected, int.MaxValue). This keeps the int contract of DbDataReader.RecordsAffected, saturates instead of throwing, and documents the cap in the XML remarks.
  • A simple test that reproduces our OverflowError

@cursor

cursor Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Narrow behavior change on an edge case (overflow); normal row counts are unchanged and the fix prevents failures on large DDL.

Overview
RecordsAffected no longer throws when the server reports more than int.MaxValue affected rows (e.g. DDL such as ALTER TABLE on very large tables, where SingleStore can return the table row count). The reader now saturates at int.MaxValue via Math.Min instead of checked cast, and the XML remarks document that cap.

A regression test runs ExecuteNonQuery against a fake server OK packet with 4 billion rows affected and expects int.MaxValue. The fake server handler was extended to emit that response for the test SQL.

Reviewed by Cursor Bugbot for commit 4576eb6. Configure here.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant