model-writtenrun 4566 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Richard Guo reported that separately expanding join aliases in LATERAL UNION ALL copies creates mismatched PlaceHolderVars, causing planner errors since PostgreSQL 16, and proposed early alias expansion while identifying caching as a more principled alternative in #1.
- After finding that nested LATERAL subqueries bypass the early-expansion fix, Richard replaced it with a PlannerInfo cache in #2, accepting that the new structure field complicated back-patching.
- Tom Lane suggested deduplicating PHVs centrally and considered appending the new field for ABI compatibility in #3, then warned that volatile expressions must not be merged in #4; Richard explained why join-alias caching avoids volatility and stale-cache problems and favored limiting back-patching to unreleased branches in #5.
- Richard found that separate parent and subquery caches still produced mismatched PHVs and revised the patch to adjust and merge the subquery cache during pull-up, with a new regression test, in #6.
- Further fuzzing revealed that unmatched nested PHVs could silently produce incorrect grouping-set results, already fixed by the patch, prompting Richard to reconsider back-patching through PostgreSQL 16 in #7.
- Richard committed f1e97a2921 from #6, retaining its implementation while refining regression tests, adding the wrong-results example, and expanding the commit explanation.
- Richard confirmed landing on master and PostgreSQL 19 in #8 after finding extensions that allocate PlannerInfo themselves; PostgreSQL 16–18 remained affected because an ABI-breaking back-patch was considered too risky, with no solution settled for those branches.