Re: Trapping errors from pl/perl (trigger) functions - Mailing list pgsql-general

From Tom Lane
Subject Re: Trapping errors from pl/perl (trigger) functions
Date
Msg-id 16470.1183319409@sss.pgh.pa.us
Whole thread Raw
In response to Re: Trapping errors from pl/perl (trigger) functions  (Wiebe Cazemier <halfgaar@gmx.net>)
Responses Re: Trapping errors from pl/perl (trigger) functions  (Michael Fuhr <mike@fuhr.org>)
List pgsql-general
Wiebe Cazemier <halfgaar@gmx.net> writes:
> When I do something on the table which the trigger function prevents, I get a
> message saying ERROR: blablabla. When such an error is generated by a pl/pgsql
> trigger function, I can trap the error with WHEN raise_exception. This does
> not work for the exception generated by the pl/perl function.

Why would you expect it to?  The raise_exception SQLSTATE applies
specifically and solely to the plpgsql RAISE command.  The entire
point of those identifiers is to match fairly narrow classes of
exceptions, not anything thrown by anyone.

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.

            regards, tom lane

pgsql-general by date:

Previous
From: Wiebe Cazemier
Date:
Subject: Re: Trapping errors from pl/perl (trigger) functions
Next
From: Alvaro Herrera
Date:
Subject: Re: [pgsql-general] In memory tables/databases