model-writtenrun 3424 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Michal Bartak reported that a line comment after a PL/pgSQL CASE WHEN expression caused a syntax error because the generated IN expression's closing parenthesis became part of the comment #1.
- Erik Wienhold reproduced the bug on master and proposed inserting a newline before the generated closing parenthesis, with a regression test #2.
- Tom Lane argued that removing trailing comments from collected expressions would prevent similar failures elsewhere #3; Erik adopted token-end tracking in #5, while explaining that the implementation still broke other tests #4.
- Tom diagnosed incorrect lengths for compound tokens such as qualified names and supplied a corrected patch that also removed manual whitespace trimming and the obsolete cursor-argument exception #6. He left similar trimming in make_execsql_stmt() unchanged because handling pushed-back tokens was more involved and the hazard appeared latent.
- Pavel Stehule endorsed Tom's final patch before it landed #7.
- Tom committed #6 unchanged on the development branch as 5392dd3d2a, crediting Erik and himself; the other supplied candidate, 48f216dc63, is the same fix backpatched to PostgreSQL 16.
- After the fix landed, Erik asked why compound tokens were handled in the lexer #8 and clarified that this was a historical design question unrelated to the fix #10; Tom discussed the parser's limitations #9 and ultimately said he did not know the original rationale #11, leaving no further patch revision pending.