pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Don't use MinMaxAggPath if aggregate's input and output types do
Date: Mon, 09 Nov 2026 14:21:53 +0000
Message-ID: <E1xQQFt-000000003Qw-0LJ5@gemulon.postgresql.org> (raw)

Don't use MinMaxAggPath if aggregate's input and output types don't match.

A sort-operator option only makes sense for an aggregate that behaves
like MIN or MAX.  We can't really verify whether an 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.
Since such aggregate definitions might already exist in the wild,
check this during planning and don't generate MinMaxAggPath if the
types don't match.

Reported-by: Zheng Yu <zheng@depthfirst.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14-19
Security: CVE-2026-116331

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/75c0441bad98dda75b18cb2b7cf3d8c41e7bc631
Author: Tom Lane <tgl@sss.pgh.pa.us>

Modified Files
--------------
src/backend/optimizer/plan/planagg.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)



view thread (3+ messages)  latest in thread

Message-ID: <E1xQQFt-000000003Qw-0LJ5@gemulon.postgresql.org>
Permalink:  ../E1xQQFt-000000003Qw-0LJ5@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xQQFt-000000003Qw-0LJ5@gemulon.postgresql.org

 · 

reply

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: Don't use MinMaxAggPath if aggregate's input and output types do
  In-Reply-To: <E1xQQFt-000000003Qw-0LJ5@gemulon.postgresql.org>
  References: <E1xQQFt-000000003Qw-0LJ5@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