Re: SUM(int2)/SUM(int4) do not detect overflow of the int8 accumulator - Mailing list pgsql-hackers

From Andrei Lepikhov
Subject Re: SUM(int2)/SUM(int4) do not detect overflow of the int8 accumulator
Date
Msg-id d0fa5c4b-c801-4c6c-ad83-940c8fa93bb6@gmail.com
Whole thread
In response to Re: SUM(int2)/SUM(int4) do not detect overflow of the int8 accumulator  (Andrei Lepikhov <lepihov@gmail.com>)
List pgsql-hackers
On 04/09/2026 10:55, David Rowley wrote:
> On Fri, 4 Sept 2026 at 16:59, Michael Paquier <michael@paquier.xyz> wrote:
>> Any thoughts or comments from others?
> The patch adds PG_RETURN_INPUT(n) to avoid some of the branching in
> int4_sum() so that it immediately returns the aggstate when the value
> being aggregated is null. With my compiler, it cut int4_sum from 18
> down to 16 instructions.
Thanks for your attention.

I adopted your changes. Although I don't see any overhead beyond noise, it seems
better to optimise than to keep it as is.
Also, tests were rewritten - instead of a direct call, I have used the initcond
trick.

-- 
regards, Andrei Lepikhov,
pgEdge
Attachment

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: pgsql: Fix compilation with OpenSSL 4
Next
From: Fujii Masao
Date:
Subject: Re: pg_createsubscriber does not check output_plugin_libraries