model-writtenrun 3044 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Quynh Tran reported that PostgreSQL 16.3 could emit a view definition whose ORDER BY changed meaning when SELECT aliases swapped column names, while earlier releases retained protective table qualification #1; Richard Guo traced the regression to removal of the old and new range-table entries, which disabled automatic qualification for single-table views #2.
- Tom Lane offered blanket ORDER BY qualification and selective qualification as alternatives, preferring the latter to avoid output churn and unnecessary prefixes; the selective approach exposed the SELECT target list to get_variable and added a regression test #3.
- Richard Guo demonstrated that the first selective patch unnecessarily qualified GROUP BY columns and supported separate boolean flags #4; his alternative of setting ORDER BY context more broadly #5 was rejected because only bare variables need protection #6, and Tom incorporated the two-boolean solution #7.
- Before committing, Tom discovered that renamed view columns could still defeat the check, so he matched actual output names through the view's tuple descriptor, moved resultDesc and colNamesVisible into deparse_context, added rename tests, and removed redundant context save/restore operations #8.
- Richard endorsed the corrected final patch #9, and Tom committed it as 9fe6319dcc with only branch compatibility adaptations and unchanged regression tests; the commit specifies backpatching through PostgreSQL 16, and Tom's final message confirms the fix was pushed with no remaining work identified #10.