From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Tighten CREATE AGGREGATE's checks on validity of a SORTOP option
Date: Mon, 09 Nov 2026 14:21:48 +0000
Message-ID: <E1xQQFo-000000003Ge-1oBd@gemulon.postgresql.org> (raw)
Tighten CREATE AGGREGATE's checks on validity of a SORTOP option.
A sort-operator option only makes sense for an aggregate that behaves
like MIN or MAX. We can't really verify that the proposed aggregate
does, but for our purposes the most important expectation is that
the aggregate returns the same type as its input. Without this, the
planner's conversion to a MinMaxAggPath plan risks type violations.
So check it during CREATE AGGREGATE.
While we're at it, try to make sure that the specified SORTOP operator
is sane. Ideally we'd insist that the sortop be an ordering operator
in some index opclass. But checking that during CREATE AGGREGATE
risks dump/reload ordering problems, since the opclass might not exist
yet; and it's not essential since the planner will discover the lack
of a suitable opclass when trying to plan usage of the aggregate.
We can at least check that the operator returns boolean.
This is a sufficient fix for the master branch, but it wouldn't
prevent exploitation of pre-installed dangerous aggregates.
So the back branches will use a different fix.
Reported-by: Zheng Yu <zheng@depthfirst.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Security: CVE-2026-116331
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/fffd8a41f3ceaa200bcbd422006306db49c9ba23
Author: Tom Lane <tgl@sss.pgh.pa.us>
Modified Files
--------------
src/backend/catalog/pg_aggregate.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
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-committers@postgresql.org
Cc: noah@leadboat.com
Subject: Re: pgsql: Tighten CREATE AGGREGATE's checks on validity of a SORTOP option
In-Reply-To: <E1xQQFo-000000003Ge-1oBd@gemulon.postgresql.org>
References: <E1xQQFo-000000003Ge-1oBd@gemulon.postgresql.org>
* 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