Hi,
I encounter a problem when creating a procedure using the begin atomic syntax in a script encapsulated in a DO block. When executing the DO block, the parser throws a syntax error. I would expect to be able to create the procedure with both the new begin atomic and the old syntax.
The attached script, demo.sql, highlights the problem and expected behaviours. First, it prints the PostgreSQL version, creates an example table and sets the verbosity parameter to verbose. Then, it successfully creates a procedure using the new begin atomic syntax. Afterwards, it successfully creates the same function using the old syntax but encapsulates the instruction in a do block. Finally, it fails to create the same function using the new syntax with the do block.
The attached file demo.out shows the output I get when executing the script using psql (version: psql (PostgreSQL) 16.0):
PGPASSWORD=postgres psql -h localhost -U postgres -p 15432 -d postgres -f demo.sql &> demo.out
Thank you for your time,
Samuel Dussault