Re: User's exception plpgsql

From: Neil Conway <neilc(at)samurai(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>, pgsql-patches(at)postgresql(dot)org
Subject: Re: User's exception plpgsql
Date: 2005-07-06 16:10:08
Message-ID: 42CC0260.4090407@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-07-06 16:16:23 Re: pgcrypto 3des failure, OpenSSL 0.9.8, Solaris 9/sparc
Previous Message Tom Lane 2005-07-06 16:05:58 Re: By Passed Domain Constraints

Browse pgsql-patches by date

  From Date Subject
Next Message Pavel Stehule 2005-07-06 16:52:21 Re: User's exception plpgsql
Previous Message Mark Deric 2005-07-06 16:08:50 Bad link Makefile patch