model-writtenrun 3615 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- David G. Johnston reported incorrect aggregation in PostgreSQL 17 when a view included UNION ALL, while PostgreSQL 16 returned the expected results, and narrowed the trigger to an ordered string_agg call #1 #2.
- David Rowley suggested disabling presorted aggregation and requested a more self-contained reproducer; Johnston confirmed that disabling it avoided the bug and bisected the regression to the introduction of alternative GROUP BY orderings #3 #4 #5 #6.
- Andrei Lepikhov simplified the reproducer and traced the incorrect incremental-sort ordering to overlapping sort references for grouping and aggregate pathkeys #8 #9 #10.
- Lepikhov supplied a synthetic example producing ten groups instead of two and a patch restricting lookups to grouping pathkeys, while asking whether the underlying sort-reference design needed broader repair #11.
- Alexander Korotkov chose the targeted fix and deferred broader refactoring, posting a revision with explanatory comments, safer list handling, and a regression test #12.
- In the thread's final message, Lepikhov reported only a comment typo in the revised patch #13; Korotkov subsequently committed that correction with the otherwise unchanged revision as c01f6ef46c, completing the targeted fix while leaving broader refactoring for future work.