Re: Add PRODUCT() aggregate function

From: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add PRODUCT() aggregate function
Date: 2026-06-26 05:53:37
Message-ID: CAM2+6=VU-iLdN_H9xmJRQujxu6qs01FZYhfkTtX7bpvuFiqGsg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

CFbot flagged this for a rebase. The conflicts were due to the catalog
version bump, so I've dropped it here and noted in the commit message
that the committer should bump catversion at commit time to avoid
recurring conflicts.

Also added tests as suggested by Jim.

Thanks

On Tue, Jun 23, 2026 at 5:26 PM Jeevan Chalke <
jeevan(dot)chalke(at)enterprisedb(dot)com> wrote:

>
>
> On Tue, Jun 23, 2026 at 4:32 PM Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
> wrote:
>
>> Hi Jeevan
>>
>> On 23/06/2026 10:37, Dean Rasheed wrote:
>> > On Tue, 23 Jun 2026 at 08:49, Jeevan Chalke
>> > <jeevan(dot)chalke(at)enterprisedb(dot)com> wrote:
>> >> PRODUCT() returns the product of all non-null input values. It is
>> defined for
>> >> int2, int4, int8, float4, float8 and numeric input, and always returns
>> numeric.
>> > I don't think that you need to define it for all those types. I
>> > suspect that you could just define it for numeric and float8, and let
>> > implicit casting do the rest.
>>
>> +1
>>
>> I've tested the patch in many different scenarios and all results look
>> fine -- valgrind also didn't report anything :)
>>
>> The test coverage is comprehensive! For the sake of completeness I'd add
>> numeric tests for NaN and Infitinty with positive numeric values in the
>> set, e.g:
>>
>> postgres=# WITH j (v) AS (VALUES
>> ('NaN'::numeric),('Infinity'::numeric),(3.14))
>> SELECT product(v) FROM j;
>> product
>> ---------
>> NaN
>> (1 row)
>>
>> Other than that and the point mentioned by Dean I have nothing to add at
>> this point.
>>
>
> Thanks, Jim, for the thorough testing.
>
> I'll include that test case in the next version of the patch.
>
>
>
>>
>> Thanks for the patch.
>>
>> Best, Jim
>>
>
>
> --
> *Jeevan Chalke*
> *Senior Principal Engineer, Engineering Manager*
> *Product Development*
>
> enterprisedb.com <https://www.enterprisedb.com>
>

--
*Jeevan Chalke*
*Senior Principal Engineer, Engineering Manager*
*Product Development*

enterprisedb.com <https://www.enterprisedb.com>

Attachment Content-Type Size
v2-0001-Add-PRODUCT-aggregate-function.patch application/octet-stream 45.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2026-06-26 05:55:17 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Ajit Awekar 2026-06-26 05:51:43 Re: Continuous re-validation of session credentials