Re: BUG #17835: Two assertions failed in nodeAgg.c and execExprInterp.c with the same SQL
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: xinwen@stu.scu.edu.cn, pgsql-bugs@lists.postgresql.org
Date: 2023-03-13T16:13:25Z
Lists: pgsql-bugs
Attachments
- fix-nested-agg-detection.patch (text/x-diff) patch
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
Commits
-
Fix failure to detect some cases of improperly-nested aggregates.
- bc0bcce2e74b 13.11 landed
- 62a91a1b0926 12.15 landed
- 5fd61bdc114f 15.3 landed
- 30dbdbe75384 16.0 landed
- 096e708056ea 14.8 landed
- 0736b11318da 11.20 landed
-
Expression evaluation based aggregate transition invocation.
- 69c3936a1499 11.0 cited