How to trap exceptions inside PL/Perl functions?

Поиск
Список
Период
Сортировка
От Dmitry Koterov
Тема How to trap exceptions inside PL/Perl functions?
Дата
Msg-id d7df81620708150441o7a4133ebl85cecf1b4b9d84fd@mail.gmail.com
обсуждение исходный текст
Список pgsql-general
Hello.

In PL/PGSQL I could write:

BEGIN
  SELECT * FROM non_existed_table;
EXCEPTION
  WHEN ... THEN ...
END;

How to do it in PL/Perl? I tried the standard for Perl trapping method:

eval {
  spi_exec_query("SELECT * FROM non_existed_table");
};
if ($@) { ... }

but it does not work - it says that "eval is not safe" or something like that. But I use eval with {}, not with quotes, so - it has to be safe.
So, how to trap errors in this case?

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

Предыдущее
От: "Ivan Zolotukhin"
Дата:
Сообщение: Best practice for: ERROR: invalid byte sequence for encoding "UTF8"
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Best practice for: ERROR: invalid byte sequence for encoding "UTF8"