Re: Numeric multiplication overflow errors - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: Numeric multiplication overflow errors
Date
Msg-id CAEZATCUOR7XUDvpEYdJf1fMicbWo+Hhu3S0fcWj=PHkmJgJh7A@mail.gmail.com
Whole thread Raw
In response to Re: Numeric multiplication overflow errors  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: Numeric multiplication overflow errors
List pgsql-hackers
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

Attachment

pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: PROXY protocol support
Next
From: Amit Kapila
Date:
Subject: Re: Refactor "mutually exclusive options" error reporting code in parse_subscription_options