Re: Trapping errors from pl/perl (trigger) functions

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Trapping errors from pl/perl (trigger) functions
Дата
Msg-id 20070701215330.GA8778@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: Trapping errors from pl/perl (trigger) functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Sun, Jul 01, 2007 at 03:50:09PM -0400, Tom Lane wrote:
> IMHO the real problem with both RAISE and the plperl elog command
> is there's no way to specify which SQLSTATE to throw.  In the case
> of the elog command I think you just get a default.

That default is XX000 (internal_error):

test=> create function foo()
test-> returns void
test-> language plperl
test-> as $_$
test$>     elog(ERROR, 'test error');
test$> $_$;
CREATE FUNCTION
test=> \set VERBOSITY verbose
test=> select foo();
ERROR:  XX000: error from Perl function: test error at line 2.
LOCATION:  plperl_call_perl_func, plperl.c:1076

The code around plperl.c:1076 is

    /* XXX need to find a way to assign an errcode here */
    ereport(ERROR,
            (errmsg("error from Perl function: %s",
                    strip_trailing_ws(SvPV(ERRSV, PL_na)))));

I don't see any relevant TODO items.  Would something like the
following be appropriate?

  * Allow RAISE and its analogues to set SQLSTATE.

--
Michael Fuhr

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: [pgsql-general] In memory tables/databases
Следующее
От: Wiebe Cazemier
Дата:
Сообщение: Re: Trapping errors from pl/perl (trigger) functions