Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wxQpc-002iIB-0R for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Aug 2026 15:06:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wxQpZ-00Diif-2j for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Aug 2026 15:06:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wxQpZ-00DiiW-1k for pgsql-hackers@lists.postgresql.org; Fri, 21 Aug 2026 15:06:53 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wxQpX-00000000WSw-2AfY for pgsql-hackers@lists.postgresql.org; Fri, 21 Aug 2026 15:06:53 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-47f3b39f2a1so900504f8f.2 for ; Fri, 21 Aug 2026 08:06:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787324804; x=1787929604; darn=lists.postgresql.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=FSZTbV/DlE50nPqqkECDIEWfp8NDRij82F2W56d4hAY=; b=mYMpsma2XhmRipc5BfyUahooIKrtcoOEYlQMiP6LOK5Rm4EQBxaK7I3HBkpbZfrDZw BMyujXOoTzAluT4sG4MUnnaT5gdXjoo4KcF3w2dwyo9GiZ93nI5xwNKSlMq3iecX0bcT U1BVwpJGZMu4wWpLcEuSRtJscNO0/OAEtT9c1fWX1T+c4HcfXV2oJCrjTkIhk6W8ws+h lE0iYGG+kfYrm3qsvax1h7PDP5VAfEEhzAmQPK8LilUa//pd+nN+d1ga9dQLlL7CtOGD bRKNssyR2TO1K2ecFQWctBSi1m2ZEj5W5xvpStkyiPy4DkRdJiACEsVrk93L3Aki4KWA YmKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787324804; x=1787929604; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=FSZTbV/DlE50nPqqkECDIEWfp8NDRij82F2W56d4hAY=; b=qPXDPDc31GBSpO1pfzeuiE/M0feaVij9nmf2kMiT9YwqK+MRKT3E+3WhKGrtzmLs60 D09Gv89xjMh6TEqVCNCEWP/r9sY/k0LgUKOiQ5DGDkKolbB1K6GK1CQeQsmYxbjlG97E dAv2FKyTh7UkLQAXMGYhLxIesdLN1JFcKj7Kard9gsKdEASqJp3UURHIKa9VLVzvCQru h1HEm6sRiBcvQBE1RZ5HPGDwV0TDbKRIXJKrh5dVIoHXU6NeZnOOQmz2qUstn4CHQnMB LpyB7TUQQiNhxX5vpOmF91m2EXVtb6MYELfrexm24tn6Q2GREnfIa6vp9LEGB5gcKczD VSiQ== X-Forwarded-Encrypted: i=1; AHgh+RqPzaYPdfUCABvKZ5TRj7WTMtJUt96H0f2yS6q8L3O9jrxNDJQlUMKEIaz2GIq2UvqCOOQPAvu1fplS7B8/@lists.postgresql.org X-Gm-Message-State: AOJu0YwSPPsZ8lQZbhNXieQpnocFNzUtrAAm1wGI9syYmgOxqqXtx4Iw G1pQurZdb74xm7bLt1D6deOayyQBJ1Rn2becosL9/RpS/Qp8PWp4Xtw8 X-Gm-Gg: AR+sD10sK+RlNhe249YGjqu7wFsioeM+j08Yuzqek9/DhX7GiLC4dWZ9OnpxRHTK6RH qfdFYtEWhGJafQJlHXPfv8rBr1Zaht5AfUlIxf7ay7+l5xSUs86MBhMh8HBnAkBY5VhNI1ea477 5Ul4NEw2lwVE3qkaLnvmTtnVqW+qbLJiFNdok+gUa9Dmv0hUpZAS5E0INb+1BlSFuqwV5KDacF/ 2TkvA295iJWxd/1SzstHUHdGoi5cmA6pTWgXEGkKs9ucHdPELVbWUxllKIwoANshLjjYnVZwJSy c6ngpjpW1bTjp6J2oOAPXvutF71CSHznrkqo0dv8rUhKa0zxQq8qTOSMkOGGV6OJatZ3T0qnc4d 3G917XzrsIqrsIQlV88qLqKM3xyKjsx6vkwQoBaNUwo07SIllKuH8/BS9D12T40r4sQ8koFzdQR pUJqFmvyKpt2B8ibHahh3Xr763u4+H3eL+M/+StG5Tq1cdkYTpE921IYlUWyomHs/lvsnWAn6Pe 6Q= X-Received: by 2002:a05:600c:4f06:b0:499:a5fc:207e with SMTP id 5b1f17b1804b1-499b8340754mr121319125e9.8.1787324804191; Fri, 21 Aug 2026 08:06:44 -0700 (PDT) Received: from [192.168.15.155] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-499b911584bsm31440295e9.14.2026.08.21.08.06.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Aug 2026 08:06:43 -0700 (PDT) Message-ID: <1f2140fe-e4ae-4a52-9365-d5cbadcf5ae4@gmail.com> Date: Fri, 21 Aug 2026 17:06:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Allow a prosupport function to be attached to an aggregate To: Tom Lane Cc: David Rowley , PostgreSQL Hackers , Corey Huinker References: <8f58c96d-d3c7-4c0f-9898-116f00eeaff6@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> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: <4008013.1787256399@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 20/08/2026 22:06, Tom Lane wrote: > I wrote: >> After reflection I realized that the approach I took in my first patch >> is wrong: letting ALTER FUNCTION work on an aggregate is pretty >> non-orthogonal, if the only property it can set is SUPPORT. The right >> way to do this is to add a SUPPORT option to CREATE AGGREGATE, which >> slots nicely into getting pg_dump to handle it. As attached. > > Grumble ... for some reason I was thinking that ProcedureCreate would > handle checking for superuser when specifying a support function, > but it doesn't; AggregateCreate must do that. v3 attached contains > just that one addition. 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. What I want to optimise is the built-in functions like sum(), avg(), and similar ones, because those are what users actually use. 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. Even worse, CREATE OR REPLACE in an extension script should record an extension dependency, so pg_catalog.sum would become a member of the extension and DROP EXTENSION would try to drop it. ALTER AGGREGATE ... SUPPORT avoids both problems, and for this use case it does not need anything from pg_dump. The statement is part of the extension script, so CREATE EXTENSION replays it on restore. That is why v0 had both forms. Could we commit your patch now and add the ALTER form as well, in v20 if it is too late for v19? Also, I am not sure I understand the reason for not exporting interpret_func_support(), as v0 did, instead of repeating the lookup, return-type, and superuser checks. > One thing I don't quite love about this is that the CREATE AGGREGATE > docs already refer to transfn, finalfn, etc as "support functions", In v0, I just added a paragraph to the create_aggregate.sgml: "Note that this is unrelated to the aggregate's transition, final and other helper functions described above, which implement the aggregate itself; a planner support function instead advises the planner about calls to the aggregate." I think this should be enough. -- regards, Andrei Lepikhov, pgEdge