model-writtenrun 6239 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Tom Lane proposed making REG_NOSUB discard capture work that callers do not need while preserving captures referenced by backreferences, reporting a reduction from 10:17 to 5:46 on a large regexp corpus in #1.
- Andrew Dunstan questioned whether removing captures would disturb backreference numbering in #2; Tom explained that numbering was already fixed and identified a need for more tests in #3, while Robert Haas supported automatic avoidance of capture overhead in #4.
- Mark Dilger exposed an obsolete capture-node assertion in #7; Tom removed the assertion rather than complicating tree simplification, added tests, and rebased over separate regex fixes in #8.
- Mark then found incorrect regexp_split_to_array results in #9, leading Tom to restore reporting of the overall match position in #10; Mark reported nearly 1.5 million successful regex tests in #11 and judged the patch ready in #13.
- Tom committed the capture optimization as 0e6aa8747d from #10, adding a local optimization that limits the match-vector entries processed by pg_regexec().
- After announcing that landing, Tom proposed extending REG_NOSUB to regexp_replace when its replacement string needs no numbered submatches, moving compilation after escape inspection and replacing handwritten scans with memchr in #14.
- Mark reported another assertion failure involving zero repetitions and nested captures in #15; Tom traced it to dangling capture pointers in #16 and reproduced the longstanding bug across branches in #17.
- Tom's first fix recursively cleared capture pointers and rejected later references to discarded captures in #18; Mark discussed Perl's more permissive behavior in #20 and later confirmed that the fix removed assertions but introduced questionable user-visible errors in #26.
- Separately, Mark completed review and testing of the regexp_replace enhancement in #19, and Tom landed it as 18bac60ede from #14 with additional escape-handling tests, announcing the commit and deferring the backpatchable zero-repetition fix until after the release window in #22.
- Following the semantic discussion, Tom replaced the error-producing fix with an approach that preserves disconnected capture subexpressions in #27, allowing references that never match and allowing an empty match when both capture and reference have zero repetitions.
- Tom reported finding no applicable POSIX guidance and treated Perl's behavior as the useful precedent in #28; after a two-week gap, Mark confirmed randomized testing and inspection of changed results found no problems in #30.
- The thread ends with Tom promising to push the revised fix in #31; he subsequently committed #27 as 65dc30ced6 with expanded regression coverage and backports to supported branches, completing all three changes.