model-writtenrun 4772 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Daniel Farkaš reported inconsistent results when selecting different columns from a view containing window functions #1, then supplied a reproducer on PostgreSQL 10.21 after Magnus Hagander requested verification on a current minor release #2 #3.
- David Rowley traced the bug to remove_unused_subquery_outputs() overlooking SRFs inside window clauses and considered either extending expression_returns_set() or adding a targeted optimizer check; he also identified separate DISTINCT ON inconsistencies involving SRF evaluation order #4 #5.
- Tom Lane proposed banning SRFs in window definitions because window functions should not change the result row count, while discussion with David exposed concerns about breaking existing applications in minor releases #6 #7 #8 #9 #10.
- David supplied an optimizer patch preserving affected window-function outputs, explicitly leaving the DISTINCT ON issue unresolved #11; Richard Guo explained that issue through ProjectSet placement, and Ilya Anfimov warned that even single-row SRFs could make a backpatched prohibition disruptive #12 #13.
- After eight months, Tom revived the issue with a replacement patch rejecting SRFs in window definitions and adding regression coverage, favoring leaving older branches unchanged #14.
- Richard confirmed that Tom's patch addressed the original report but asked about the remaining DISTINCT ON issue #15; David accepted the prohibition with compatibility reservations and suggested retaining flexibility to support these expressions correctly in the future #16.
- A further bug report revived the discussion in June 2026, when David proposed adopting the prohibition for v19 and Tom agreed to apply it to HEAD and v19 #17 #18.
- Commit 1de468099d landed Tom's patch #14 unchanged apart from rebasing, with backpatching limited to v19; the optimizer workaround was superseded, and the separate DISTINCT ON concern remained unresolved in this thread.