model-writtenrun 3366 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Zuming Jiang reported a fuzzer-generated ntile query that raised “WindowFunc not found in subplan target lists” in #1; Tom Lane bisected the regression in #2, and Richard Guo supplied a minimal reproducer and traced the failure to duplicated SubLinks receiving different parameter IDs in #3.
- Tom Lane concluded that duplicating WindowFunc before subquery preprocessing was fundamentally unsafe, rejected restricting subquery pull-up as an excessive performance compromise, and also identified expression-copying and query-level concerns in #5.
- David Rowley proposed attaching intermediate run-condition data directly to WindowFunc and delaying OpExpr construction, while restricting optimization for nonconstant ntile and count arguments on older branches, in #6; he supplied a proof-of-concept implementation in #7.
- Richard Guo endorsed the delayed construction approach in #8 and demonstrated that count(expr) suffered the same failure in #9, while noting that some constant expressions are not represented as Const nodes.
- David supplied a more complete implementation and a conservative back-branch fix using constant folding in #11, initially arranging them as a restriction followed by a structural fix that restored the optimization.
- Tom requested independent patches to avoid unnecessary changes and reversals in repository history, accepted a PostgreSQL 17 catalog-version bump, and suggested adding PlannerInfo to the support request in #12; David separated the fixes in #13 and explained that the required subquery PlannerInfo did not yet exist at that planning stage.
- David prioritized the older-branch fix for the approaching minor releases and deferred the PostgreSQL 17 patch briefly in #14.
- David committed the PostgreSQL 17 patch from #13 as 7d2c7f08d9, adding consistent local-variable names, the catalog-version bump and revised explanatory prose; the commit message records that PostgreSQL 15 and 16 had already been fixed separately, and his final announcement in #15 confirms the PostgreSQL 17 landing.