pgsql: Don't use MinMaxAggPath if aggregate's input and output types do

Поиск
Список
Период
Сортировка
Искать

pgsql: Don't use MinMaxAggPath if aggregate's input and output types do

От:
Noah Misch <noah@leadboat.com>
Дата:
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 
Author: Tom Lane 
Backpatch-through: 14-19
Security: CVE-2026-116331

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2c03c7c48fb6060155fd9d35fdcef40ddf0a28f6
Author: Tom Lane 

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

FAQ