From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Samuel Dussault <Samuel(dot)Dussault(at)USherbrooke(dot)ca> |
Cc: | "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Parsing error with begin atomic syntax used in a do block |
Date: | 2024-01-17 23:17:27 |
Message-ID: | 2082387.1705533447@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Samuel Dussault <Samuel(dot)Dussault(at)USherbrooke(dot)ca> writes:
> 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.
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2024-01-18 01:52:11 | Re: [16+] subscription can end up in inconsistent state |
Previous Message | Samuel Dussault | 2024-01-17 21:18:17 | Parsing error with begin atomic syntax used in a do block |