Re: plpgsql raise - parameters can be expressions - Mailing list pgsql-patches

From Neil Conway
Subject Re: plpgsql raise - parameters can be expressions
Date
Msg-id 42AFDCDB.2030400@samurai.com
Whole thread Raw
In response to Re: plpgsql raise - parameters can be expressions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: user's exception PL/pgSQL
Re: plpgsql raise - parameters can be expressions
List pgsql-patches
Tom Lane wrote:
> I would also expect that matching is by SQLSTATE, that is if I write
>
>     DECLARE foo EXCEPTION = '12345';
>     ...
>     RAISE ERROR foo, ...;

BTW, is there any value in a separate "EXCEPTION" type? ISTM that an
exception is just a SQLSTATE, which is in turn just a string. A separate
exception type does simplify the parsing of RAISE, but I wonder if it
would be useful to be able to also allow specifying the SQLSTATE code as
a string literal.

> I think we are better off defining exception names as SQLSTATEs and
> nothing else.

That seems the right way to go to me.

> Well, can we get away with making the syntax be
>
>     RAISE level [ exception_name , ] format_string [ , parameters ] ;
>
> where "level" is one of the already-defined level keywords?

I think we can. I don't see the point of inventing a new RAISE level for
exceptions with a custom SQLSTATE. For one thing, it would be useful to
be able to specify a custom SQLSTATE for a RAISE WARNING.

-Neil

pgsql-patches by date:

Previous
From: Andreas Pflug
Date:
Subject: Re: dbsize backend integration
Next
From: Neil Conway
Date:
Subject: Re: hash join: probe both inputs first