Error message with COMMIT/ROLLBACK within PL/pgSQL

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Error message with COMMIT/ROLLBACK within PL/pgSQL
Дата
Msg-id 4CC954C0.40106@enterprisedb.com
обсуждение исходный текст
Список pgsql-hackers
This is not very user-friendly:

postgres=# do $$
begin
   COMMIT;
end;
$$;
ERROR:  SPI_execute_plan_with_paramlist failed executing query "COMMIT":
SPI_ERROR_TRANSACTION
CONTEXT:  PL/pgSQL function "inline_code_block" line 2 at SQL statement

Clearly we don't support that, but seems like it would deserve a better
error message.

Curiously, we *do* give a better error message if you try that with EXECUTE:

postgres=# do $$
begin
   EXECUTE 'COMMIT';
end;
$$;
ERROR:  cannot begin/end transactions in PL/pgSQL
HINT:  Use a BEGIN block with an EXCEPTION clause instead.
CONTEXT:  PL/pgSQL function "inline_code_block" line 2 at EXECUTE statement

Barring objections, I'll add the same error message to the non-execute
codepath.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Boszormenyi Zoltan
Дата:
Сообщение: Re: plan time of MASSIVE partitioning ...
Следующее
От: Boszormenyi Zoltan
Дата:
Сообщение: Re: plan time of MASSIVE partitioning ...