model-writtenrun 5180 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Alexander Pyhalov reported the foreign-join planner error with a cost-adjustment reproducer in #1; Etsuro Fujita reproduced it in #2, and Richard Guo traced it to a local-condition column missing below a Sort node in #3.
- Alexander proposed rejecting sorted EPQ paths that lacked required variables in #4, but Richard objected that this would discard useful paths in #5 and supplied an alternative that adds the required columns before sorting in #6.
- Alexander questioned whether the EPQ path could supply those variables in #7; Richard explained their availability from join-level conditions in #8, and Alexander approved the patch and reported its resulting plan in #9.
- Etsuro expanded Richard's fix in #11 after finding that shared PathTargets needed copying and PlaceHolderVars could trigger the same error, adding regression cases applicable to older releases; Richard verified the additional fix and endorsed the tests in #12.
- Etsuro found that the EPQ path itself was already referenced by an unsorted foreign path and revised the patch to use create_projection_path() in #13; Richard accepted that change but raised the need to update cost and width estimates in #14.
- Richard proposed recalculating estimates when the target changed in #15, and Tom Lane recommended a cheaper list-length comparison in #16; Etsuro argued that accurate estimates were unnecessary for EPQ-only execution in #18, leading Richard to request an explanatory comment instead in #19.
- Etsuro incorporated that explanation and restricted projection creation to cases with added columns in #21, and Richard approved the resulting patch in #22.
- Etsuro committed #21 with two further comment edits as 9320cfdd06, credited Richard and himself as authors and Alexander and Tom as reviewers, and backpatched the fix to all supported versions; his final message #23 confirmed the push, leaving no outstanding patch in the thread.