Re: SUM(int2)/SUM(int4) do not detect overflow of the int8 accumulator

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Subject: Re: SUM(int2)/SUM(int4) do not detect overflow of the int8 accumulator
Date: 2026-09-01 08:22:16
Message-ID: 5a1e3edf-35b7-4931-8064-cd6032b3014d@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 01/09/2026 09:35, Chao Li wrote:
> If newval is negative, the minus operation may also overflow.
I don't think that's the case. An inverted function removes values that were
already included in the aggregate, which usually brings the total closer to zero
instead of pushing it toward the boundary. From what I see, this means there's
no risk of integer overflow.

--
regards, Andrei Lepikhov,
pgEdge

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-09-01 08:23:11 Re: [PATCH] Speed up pg_waldump TAP test and fix some GitHub CI Windows flakiness
Previous Message Ewan Young 2026-09-01 08:20:57 Re: pg_upgrade: Test --check with a running source server