From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrei Lepikhov <lepihov@gmail.com>
Cc: David Rowley <dgrowleyml@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Corey Huinker <corey.huinker@gmail.com>
Subject: Re: Allow a prosupport function to be attached to an aggregate
Date: Fri, 21 Aug 2026 11:20:28 -0400
Message-ID: <4078101.1787325628@sss.pgh.pa.us> (raw)
In-Reply-To: <1f2140fe-e4ae-4a52-9365-d5cbadcf5ae4@gmail.com>
References: <8f58c96d-d3c7-4c0f-9898-116f00eeaff6@gmail.com>
<CAApHDvpE-_CnMOQ=Y8wveUk-MrUzsyR66fXGq+R7j_g4tmra8g@mail.gmail.com>
<1379592.1787063701@sss.pgh.pa.us>
<3f63c035-e0a6-4dc6-a34e-743df8c19d50@gmail.com>
<3954875.1787255265@sss.pgh.pa.us>
<4008013.1787256399@sss.pgh.pa.us>
<1f2140fe-e4ae-4a52-9365-d5cbadcf5ae4@gmail.com>
Andrei Lepikhov <lepihov@gmail.com> writes:
> Thanks. For aggregates that an extension defines itself, this is clearly the
> right approach, and the pg_dump part is exactly what v0 was missing.
> It does leave out the case I started with, though: attaching a support function
> to an existing aggregate.
How so? The expectation is that you'd issue CREATE OR REPLACE
AGGREGATE. It is a bit tedious to have to re-specify all the
existing properties, but that's the way previous extensions of
aggregate options have been handled. I don't feel that this one
new feature is a big enough deal to redesign that (especially
not this late in beta).
> What I want to optimise is the built-in functions like
> sum(), avg(), and similar ones, because those are what users
> actually use.
For those, wouldn't we just modify the initial contents of pg_proc?
> With
> only CREATE OR REPLACE AGGREGATE available, an extension would have to restate
> the whole definition of pg_catalog.sum(numeric), including sfunc, combinefunc,
> and so on, and keep that copy updated with every major release.
I'm not particularly on board with this goal: I think letting
extensions modify built-in aggregates is fraught with all sorts
of issues. (To name only one, there's no way for multiple
extensions to each attach new behaviors to the same aggregate.)
I'm certainly not going to risk putting in half-considered
support for such a thing at this stage of the release cycle.
There's enough risk in adding what I proposed yesterday.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, lepihov@gmail.com, dgrowleyml@gmail.com, corey.huinker@gmail.com
Subject: Re: Allow a prosupport function to be attached to an aggregate
In-Reply-To: <4078101.1787325628@sss.pgh.pa.us>
References: <8f58c96d-d3c7-4c0f-9898-116f00eeaff6@gmail.com> <CAApHDvpE-_CnMOQ=Y8wveUk-MrUzsyR66fXGq+R7j_g4tmra8g@mail.gmail.com> <1379592.1787063701@sss.pgh.pa.us> <3f63c035-e0a6-4dc6-a34e-743df8c19d50@gmail.com> <3954875.1787255265@sss.pgh.pa.us> <4008013.1787256399@sss.pgh.pa.us> <1f2140fe-e4ae-4a52-9365-d5cbadcf5ae4@gmail.com> <4078101.1787325628@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox