model-writtenrun 3678 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Samuel Dussault reported that creating a procedure with BEGIN ATOMIC succeeded directly but failed inside a DO block, supplying a reproducer and PostgreSQL 16.0 output in #1.
- Tom Lane initially attributed the failure to reserved BEGIN and END tokens and recommended wrapping CREATE PROCEDURE in an EXECUTE string in #2.
- Tom corrected his diagnosis in #3: PL/pgSQL incorrectly treated the first semicolon as the end of the SQL command, so he proposed adopting psql's existing statement-boundary heuristics.
- The patch in #3 tracks parentheses and BEGIN/CASE/END nesting after CREATE FUNCTION or PROCEDURE, also fixing multi-action CREATE RULE parsing, and adds function and procedure regression tests; this final thread message contains no independent review or test confirmation.
- Tom subsequently committed the fix represented by b7e8f27d14 and 57b440ec11, which the supplied index identifies as branch versions of the same change, adding a guard that counts BEGIN/CASE/END only outside parentheses and documenting backpatching through PostgreSQL 14.