model-writtenrun 9236 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Aleksandr Parfenov proposed folding functions used as FROM relations after Oleg Bartunov observed poor text-search plans; the initial patch replaced references with simplified expressions but retained the function scan and join #1.
- Andrew Gierth identified missing attribute checks, unsafe assumptions about function inlining, and the risk of extra evaluations #2 #4; Parfenov responded with base-type restrictions and simplify_function()-based evaluation #5.
- Heikki Linnakangas argued that simplifying once and using subquery-style pullup could also eliminate the join #6, while Tom Lane emphasized non-set-returning eligibility, lateral references, and preserving single evaluation #7.
- Parfenov moved the optimization into pull_up_subqueries() #8, then fixed an assertion-build failure reported by Anthony Bykov and cleaned up copied code #9 #10.
- Kyotaro Horiguchi demonstrated a missing-relation error with a join #11, and Antonin Houska traced problems to differences from VALUES processing, questioned PlaceHolderVar handling, and recommended refactoring duplicated code #12 #13.
- Tom Lane recommended using pending dummy-relation infrastructure and folding function expressions before pulling up only actual constants, avoiding repeated evaluation of expensive functions #14; after that infrastructure landed, he requested a rewrite #16.
- Alexander Kuzmenkov took over and supplied an implementation that converted constant-valued RTE_FUNCTION entries to RTE_RESULT, added outer-join handling and tests, and explicitly left append-relation handling uncertain #17 #20.
- After a several-month gap, Anastasia Lubennikova rebased Kuzmenkov's patch and reviewed it, adding comments and a nested outer-join test before marking it ready for a committer #22 #23.
- Tom Lane found that the tests used no-op casts rather than actual function calls and requested clearer naming, documentation, and a further constant-folding test #24 #25; Lubennikova supplied real immutable-function tests and a text-search example #26.
- Tom Lane committed #26 as 7266d0997d after substantial restructuring: folding moved to a guaranteed traversal of function RTEs, variable replacement became shared infrastructure, and additional planner contexts were handled #27.
- Raúl Marín Rodríguez subsequently reported that functions returning composite constants failed in PostGIS tests and supplied a standalone reproduction #28.
- At the thread's last message, Tom Lane chose to skip pullup for non-scalar results rather than decompose composite constants #29; that fix landed as a9ae99d019, leaving the scalar optimization committed and composite pullup unsupported.