Parsing error with begin atomic syntax used in a do block

Samuel Dussault <samuel.dussault@usherbrooke.ca>

From: Samuel Dussault <Samuel.Dussault@USherbrooke.ca>
To: "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>
Date: 2024-01-17T21:18:17Z
Lists: pgsql-bugs

Attachments

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

Commits

  1. Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL command.