Re: User's exception plpgsql - Mailing list pgsql-patches

From Neil Conway
Subject Re: User's exception plpgsql
Date
Msg-id 42CC0260.4090407@samurai.com
Whole thread Raw
In response to Re: User's exception plpgsql  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: User's exception plpgsql
Re: User's exception plpgsql
List pgsql-patches
Tom Lane wrote:
> I think it is a bad idea, if not actually impossible, to have an
> expression for sqlstate with no separating syntax before the 'fmt';
> especially not if you'd like to also allow an expression for the 'fmt'.

I don't actually see much of a need to allow 'fmt' to be an expression,
especially now that RAISE parameters can be expressions. The ratio of
constant printf() format strings to variable format strings is probably
100:1, for good reason...

> The hard part here is that there isn't any very easy way to tell whether
> you have a sqlstate, a fmt, and N exprs, or a fmt and N+1 exprs.  The
> saving grace of the declared-exception approach for this is that you
> can tell by the datatype of the first argument expression which case you
> have

I really don't like the idea of introducing a new concept into the
language ("exception variables") to resolve some ambiguous syntax. It
would be another matter if exception variables actually provided
something that strings do not...

Another solution might be varying the syntax slightly, such as:

     RAISE [ opt_sqlstate ] LEVEL 'fmt' [ , expr ... ]

-Neil

pgsql-patches by date:

Previous
From: Mark Deric
Date:
Subject: Bad link Makefile patch
Next
From: Pavel Stehule
Date:
Subject: Re: User's exception plpgsql