Re: Numeric multiplication overflow errors
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-06-29T10:29:01Z
Lists: pgsql-hackers
Attachments
- numeric-mul-overflow-v2.patch (text/x-patch) patch v2
- numeric-agg-sumX2-overflow-v2.patch (text/x-patch) patch v2
Thanks for looking!
On Mon, 28 Jun 2021 at 12:27, David Rowley <dgrowleyml@gmail.com> wrote:
>
> Instead of adding a send/recv function, unless I'm mistaken, it should
> be possible to go the whole hog and optimizing this further by instead
> of having numericvar_send(), add:
>
> static void numericvar_serialize(StringInfo buf, const NumericVar *var)
> {
> /* guts of numericvar_send() here */
> }
>
> and then rename numericvar_recv to numericvar_deserialize.
>
> That should allow the complexity to be reduced a bit further as it'll
> allow you to just serialize the NumericVar into the existing buffer
> rather than having the send function create a new one only to have the
> caller copy it back out again into another buffer. It also allows you
> to get rid of the sumX and sumX2 vars from the serialize functions.
Yes, agreed. That simplifies the code nicely as well as saving a buffer copy.
I'm not a fan of the *serialize() function names in numeric.c though
(e.g., the name numeric_serialize() seems quite misleading for what it
actually does). So rather than adding to those, I've kept the original
names. In the context where they're used, those names seem more
natural.
Regards,
Dean
Commits
-
Fix numeric_mul() overflow due to too many digits after decimal point.
- f8abf6944b12 9.6.23 landed
- 54a0ec1bd6d5 10.18 landed
- 5763ef42c187 11.13 landed
- 357b66ef9470 12.8 landed
- f23a9b8a49af 13.4 landed
- 06883d58ff29 14.0 landed
- e7fc488ad67c 15.0 landed
-
Prevent numeric overflows in parallel numeric aggregates.
- f025f2390e13 15.0 landed