pgsql: Allow an aggregate's planner support function to be set via CREA

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow an aggregate's planner support function to be set via CREA
Date: 2026-08-23 16:43:09
Message-ID: E1wyBHo-00000001mzb-27Ed@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Allow an aggregate's planner support function to be set via CREATE AGGREGATE.

Commit 42473b3b3 implemented SupportRequestSimplifyAggref, but failed
to think about what infrastructure would be required for an extension
to use that: there is no SQL-level mechanism for attaching a planner
support function to an aggregate. That seems pretty critical for a
feature that's primarily intended to be used by extensions.

To fix, add a SUPPORT clause to CREATE AGGREGATE, and teach pg_dump
(and thereby pg_upgrade) about dumping this aggregate property.
We don't need to touch ALTER AGGREGATE, because it's already the case
that you're supposed to use CREATE OR REPLACE AGGREGATE if you want
to alter any aggregate-specific properties set by CREATE AGGREGATE.
(Maybe at some point we'll think that that policy ought to change,
but I don't think this one feature moves the needle enough.)

Per report from Andrei Lepikhov, who also provided some of the
new documentation text.

Reported-by: Andrei Lepikhov <lepihov(at)gmail(dot)com>
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: Andrei Lepikhov <lepihov(at)gmail(dot)com>
Discussion: https://postgr.es/m/8f58c96d-d3c7-4c0f-9898-116f00eeaff6@gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/165aa5040a02e13011f07e3c6669ac0edf4f8258

Modified Files
--------------
doc/src/sgml/ref/alter_aggregate.sgml | 7 ++++++
doc/src/sgml/ref/create_aggregate.sgml | 15 ++++++++++++
doc/src/sgml/xfunc.sgml | 18 +++++++++++++-
src/backend/catalog/pg_aggregate.c | 33 +++++++++++++++++++++++++-
src/backend/commands/aggregatecmds.c | 4 ++++
src/bin/pg_dump/pg_dump.c | 18 ++++++++++++--
src/include/catalog/pg_aggregate.h | 1 +
src/test/regress/expected/create_aggregate.out | 15 ++++++++++++
src/test/regress/sql/create_aggregate.sql | 8 +++++++
9 files changed, 115 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-08-24 02:15:10 pgsql: Move some node-read support functions from nodes.h to readfuncs.
Previous Message Peter Geoghegan 2026-08-22 18:50:54 pgsql: Fix GIN posting tree page deletion with incomplete splits.