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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Wiebe Cazemier <halfgaar(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Trapping errors from pl/perl (trigger) functions
Date: 2007-07-01 19:50:09
Message-ID: 16470.1183319409@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Wiebe Cazemier <halfgaar(at)gmx(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2007-07-01 19:55:11 Re: [pgsql-general] In memory tables/databases
Previous Message Wiebe Cazemier 2007-07-01 19:31:00 Re: Trapping errors from pl/perl (trigger) functions