Re: Parsing error with begin atomic syntax used in a do block

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Parsing error with begin atomic syntax used in a do block
Дата
Msg-id 2082387.1705533447@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Parsing error with begin atomic syntax used in a do block  (Samuel Dussault <Samuel.Dussault@USherbrooke.ca>)
Ответы Re: Parsing error with begin atomic syntax used in a do block  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Samuel Dussault
Дата:
Сообщение: Parsing error with begin atomic syntax used in a do block
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: [16+] subscription can end up in inconsistent state