Add BigInteger type support for PG numeric type#3646
Conversation
|
When we abort reading because we don't accept the data, such as too big values when reading as System.Decimal, should we just throw or first make sure to |
roji
left a comment
There was a problem hiding this comment.
Thanks! I didn't inspect the math too closely (:sweat_smile:) but looks good! See comments.
Allows the reading/writing of numerics that don't have any fractional bits (but all fractional bits are zero is allowed).
Maybe add tests for these two cases (with all-zero fractional -> ok, with non-all-zero fractional -> correct exception)?
When we abort reading because we don't accept the data, such as too big values when reading as System.Decimal, should we just throw or first make sure to Skip to the end of the buffer?
You no longer have to handle this in the handler - NpgsqlDataReader already contains the logic to skip to the end of the value as long as the connection isn't broken (you can look in GetFieldValue)
src/Npgsql/Internal/TypeHandlers/NumericHandlers/NumericHandler.cs
Outdated
Show resolved
Hide resolved
src/Npgsql/Internal/TypeHandlers/NumericHandlers/NumericHandler.cs
Outdated
Show resolved
Hide resolved
src/Npgsql/Internal/TypeHandlers/NumericHandlers/NumericHandler.cs
Outdated
Show resolved
Hide resolved
|
/cc @YohDeadfall in case you're interested in this |
The tests contain such cases.
Does npgsql/src/Npgsql/NpgsqlDataReader.cs Line 1576 in ac3f904 |
Good catch - that indeed seems like a bug... There's an assumption in the error-handling code that the type handler hasn't cleared the buffer and repopulated it... I suspect this hasn't been a problem because most recoverable errors (i.e. which don't break the connection) occur at the start of the reading (or we just haven't had cases where they happen to occur after another buffer read). Fixing this generally at the NpgsqlDataReader seems very tricky, since we're not aware at all the I/O/buffer operations happening below in the type handler, and can't know how much was read in the column. We may need to go back to handling this at the type handler level (/cc @YohDeadfall), though it's seems somewhat of a corner case that only occurs in negative cases anyway (i.e. this is just about the connection not losing protocol sync after an exception is thrown). I suggest we scope it out of this PR, unless you feel like handling it in the NumericHandler... though can you open a new issue? |
|
@Emill just to make sure, when you want me to review again don't forget to request that (the arrows icon in the reviewers tab above). It's also helpful to click "Resolve conversation" on things which have already been dealt with. |
|
I think all outstanding comments have been resolved now :) |
|
Thanks @Emill! |
Partial fix for #448.
Allows the reading/writing of numerics that don't have any fractional bits (but all fractional bits are zero is allowed).