-
Notifications
You must be signed in to change notification settings - Fork 330
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
Optimise MySqlDataReader.GetStream #592
Comments
@bgrainger I really don't think the Stream is supposed to live beyond the row, so once Note that part of the idea is for this not to copy data needlessly, so creating a new |
Reading your description again, I may have misunderstood (I don't know anything about your internals). Assuming that you have the entire column contiguously in memory - which should be the case unless Obviously if you don't have the entire column buffered in memory things become more complicated. |
Right, of course. I had forgotten about the |
@roji I completely agree; that's what I would expect from the API. However, this isn't documented, and since the existing implementation (in |
Yeah, unfortunately not a lot is documented in ADO.NET, but that's also a reflection of the fact that different providers really do behavior differently, sometimes for valid reasons (i.e. because the database/protocol really works differently). For |
Fixed in 0.48.0. |
The default implementation of
DbDataReader.GetStream
creates a newMemoryStream
and copies the data returned byGetBytes
into it, in a loop.A better implementation would be to create a read-only
MemoryStream
directly on the backing store for the row.This does raise a question about the lifetime of the
Stream
, though: its backing memory would be overwritten as soon asDbDataReader.Read
is called again. Is there any documentation on whether consumers can use the returnedStream
after callingRead
again, or after closing theDbDataReader
? (Since, with Connector/NET, these behaviours are implicitly allowed due to the way theStream
is created, there may well be existing code that relies on it.)The text was updated successfully, but these errors were encountered: