Re: Parsing error with begin atomic syntax used in a do block - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Parsing error with begin atomic syntax used in a do block
Date
Msg-id 2082387.1705533447@sss.pgh.pa.us
Whole thread Raw
In response to Parsing error with begin atomic syntax used in a do block  (Samuel Dussault <Samuel.Dussault@USherbrooke.ca>)
Responses Re: Parsing error with begin atomic syntax used in a do block  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Samuel Dussault <Samuel.Dussault@USherbrooke.ca> writes:
> I encounter a problem when creating a procedure using the begin atomic syntax in a script encapsulated in a DO block.
Whenexecuting the DO block, the parser throws a syntax error. I would expect to be able to create the procedure with
boththe new begin atomic and the old syntax. 

> do
> $$
>     begin
>         create or replace procedure test2()
>             language sql
>         begin atomic
>             insert into example (id) values (1);
>         end;
>     exception
>         when others then
>             rollback;
>     end
> $$;

The problem here is that "begin" is a reserved word in plpgsql
(and for that matter, so is "end").

I'm not terribly excited about trying to find some kludge that
would make this work, because it would almost certainly break
other cases.  I'd suggest doing the "create procedure" step
via EXECUTE, so that you can hide "begin ... end" from the
plpgsql parser in a string literal.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Samuel Dussault
Date:
Subject: Parsing error with begin atomic syntax used in a do block
Next
From: Jeff Davis
Date:
Subject: Re: [16+] subscription can end up in inconsistent state