Re: Syntax decisions for pl/pgsql RAISE extension

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brendan Jurd" <direvus(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
Subject: Re: Syntax decisions for pl/pgsql RAISE extension
Date: 2008-05-12 18:10:50
Message-ID: 23346.1210615850@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Brendan Jurd" <direvus(at)gmail(dot)com> writes:
> I agree that the % formatting in the RAISE message is weird, but it is
> useful.

Sure, I'm not proposing removing it.

> What would we do if the user specifies a %-formatted message as well
> as a MESSAGE option?

Throw an error (just like if they specified the same option type twice).

> I like "RAISE condition_name", can we support it in conjunction with
> the current syntax? That is:

> RAISE level [condition] [string literal, [parameter, ...]] [USING
> [option = value, ...]]

Well, it's sort of a mess because level has to become optional in order
to be Oracle-compatible (or PSM-compliant, if Kevin is correct). We
could get away with it only if the condition were not allowed to be
a string literal, which I guess is tolerable but it's a bit annoying.
It would get less annoying if we allowed user-declared exception names.
I find the Oracle syntax for those to be spectacularly awful:

DECLARE
deadlock_detected EXCEPTION;
PRAGMA EXCEPTION_INIT(deadlock_detected, -60);

but it sounds like SQL/PSM's syntax isn't so bad. I could live with
the reported

DECLARE
condition-name CONDITION FOR SQLSTATE VALUE character-literal

However, that's a separate feature and I don't want to get into it as
part of the current patch.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2008-05-12 18:11:19 Re: Syntax decisions for pl/pgsql RAISE extension
Previous Message Matthew T. O'Connor 2008-05-12 17:55:45 Re: XIDs and big boxes again ...