Re: BUG #17835: Two assertions failed in nodeAgg.c and execExprInterp.c with the same SQL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: xinwen(at)stu(dot)scu(dot)edu(dot)cn, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17835: Two assertions failed in nodeAgg.c and execExprInterp.c with the same SQL
Date: 2023-03-13 16:13:25
Message-ID: 1885605.1678724005@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> v10 detected this in ExecInitAgg, while later versions are trying to
> do it in the parser, but evidently there's some gap there ...

Looking closer, 69c3936a1 didn't really break this, it just exposed
that it was already broken. check_agg_arguments() has never gotten
this case right, but it was back-stopped by the check in ExecInitAgg,
which 69c3936a1 removed because it was no longer easy to check there.

The problem is simple: check_agg_arguments supposes that an inner
(lower level) aggregate cannot contain aggregates of outer levels,
which is just wrong on its face. So we can't skip descending into
an aggregate's arguments. Somebody (probably Gierth) recognized
that this was true for grouping functions, but didn't see that the
adjacent code was buggy.

regards, tom lane

Attachment Content-Type Size
fix-nested-agg-detection.patch text/x-diff 1.9 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-03-13 19:45:44 BUG #17838: Uninstall of PostgreSQL 13.9.3 fails on Windows 11
Previous Message Daniel Verite 2023-03-13 15:49:14 Re: disable pipeline mode