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

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to