model-writtenrun 1574 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Adam Warland reported that replace() missed matches at the end of strings under nondeterministic ICU collations in PostgreSQL 18.1 #1; Laurenz Albe reproduced the problem and submitted an inclusive loop-bound fix #2 #3.
- Heikki Linnakangas endorsed the initial patch and requested a regression test #4, which Laurenz added while explaining that the final loop increment could call pg_mblen() past the string #5.
- Tom Lane confirmed that the increment was unsafe and requested revised loop control #6; Laurenz introduced an explicit break before the increment #9.
- Heikki's additional testing raised a concern about stripping a decomposed accent preceding a match #7; Laurenz considered its correctness uncertain and treated it as separate from the reported bug, so that concern was not addressed by this patch #8.
- Tom questioned the claimed support for empty matches, which could make callers loop forever, and proposed simplifying termination checks #10; Laurenz adopted the loop simplification while investigating empty-match behavior #11 #12.
- Tom argued that callers already exclude empty needles and that matching substrings should be nonempty #13; Laurenz consequently switched to a do-while loop, corrected the comments, and added an assertion #14.
- Tom committed #14 as 18b349315a with light assertion, comment, and regression-test edits, backpatched through PostgreSQL 18, and announced the push #15; Laurenz's closing thanks left the submitted fix fully landed, with no further resolution of the separate accent concern recorded #16.