model-writtenrun 4743 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Anban Company reported a WindowAgg assertion failure involving random() inside a FILTER subquery across PostgreSQL 11–15 #1; Andres Freund reduced the reproducer and traced the failure to contain_volatile_functions() not descending into SubPlans #2.
- Tom Lane initially suggested relaxing the assertion #4, but discussion established that inconsistent FILTER results could already have produced incorrect output, leading Andres and Tom to consider an explicit error instead #5 #6.
- Andres proposed disabling moving aggregation whenever subplans are present #7; Tom considered checking volatility earlier in planning but resisted changing contain_volatile_functions() semantics #8, while Andres favored a minimally invasive backpatch and discussed broader planner improvements #9.
- David Rowley submitted a FILTER-only subplan guard, explaining that even subplans without volatile functions could return different results because of synchronous scans and LIMIT #10.
- Tom pointed out that subplans in aggregate arguments present the same risk #11, so David broadened the guard to the entire WindowFunc #12; Tom approved the code and supplied a clearer explanatory comment #14.
- Andres also questioned aggregate deduplication in find_compatible_agg() #13, but David treated that as a separate issue and opposed changing established evaluation behavior in stable branches without a concrete problem #15.
- David committed the revised patch as 836c31ba50, with only Tom's comment rewrite beyond #12, and confirmed the push #16; the change was backpatched through PostgreSQL 11.
- Tom supported leaving aggregate deduplication unchanged because altering it could break existing queries #17, and Andres accepted that scope #18, leaving the WindowAgg fix landed and broader aggregate-planning changes unimplemented in this thread.