-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SqlBulkCopy.RowsCopied overflows because it is an int #2001
Comments
@madelson thanks for opening the issue. We will look into this and will get back to you soon. |
This seems reasonable. |
Leave as is, people may rely on the current behaviour |
That works for me. Doing nothing is always my preferred option 😁 |
It should be. |
FWIW we did something similar in Npgsql: DbDataReader.RowsAffected is an int, which is insufficient, so we also exposed a ulong property alongside it. For the existing property, I'd consider throwing OverflowException (pointing to the new property); I don't think anyone can be using that negative value productively in any way, and it may be causing subtle bugs. |
We are actually relying on the current behavior. Our goal is to issue a log at the end of the operation with the total count. However, to reduce overhead we don't want to fire the
|
The PR I opened to add RowsCopied64 #2004 leave the current behaviour intact. |
Describe the bug
SqlBulkCopy.RowsCopied
is supposed to return "The number of rows processed in the ongoing bulk copy operation". However, because it isInt32
rather thanInt64
likeSqlRowsCopiedEventArgs.RowsCopied
, it is prone to overflow into the negative with very large copy operations (something we're currently running into).This makes it difficult to track the actual number of rows copied.
Furthermore, the internal
int
field behind this property also flows into the event args, resulting in negative values there even though the data type islong
.To reproduce
Expected behavior
Ideally, both properties would be
long
and would only overflow afterlong.MaxValue
rows copied, which seems extremely unlikely to happen. Given that we probably can't change the type of theRowsCopied
property at this point, what would be nice to see is:long
so that the event args has the right valuelong RowsCopied64
property is added toSqlBulkCopy
that returns the underlying value aslong
.Further technical details
Microsoft.Data.SqlClient version: multiple
.NET target: .NET 6
SQL Server version: SQL Server 2019
Operating system: Windows 10
The text was updated successfully, but these errors were encountered: