-
Notifications
You must be signed in to change notification settings - Fork 314
Description
Describe the bug
SqlBulkCopy.RowsCopied
is supposed to return "The number of rows processed in the ongoing bulk copy operation". However, because it is Int32
rather than Int64
like SqlRowsCopiedEventArgs.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 is long
.
To reproduce
- Run a SqlBulkCopy operation with > int.MaxValue rows.
- Observe SqlBulkCopy.RowsCopied after the fact (and/or observe the SqlRowsCopied event's args)
Expected behavior
Ideally, both properties would be long
and would only overflow after long.MaxValue
rows copied, which seems extremely unlikely to happen. Given that we probably can't change the type of the RowsCopied
property at this point, what would be nice to see is:
- Internally the rows are tracked as
long
so that the event args has the right value - A new
long 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