Re: PL/PgSQL: EXIT USING ROLLBACK - Mailing list pgsql-hackers

From Joel Jacobson
Subject Re: PL/PgSQL: EXIT USING ROLLBACK
Date
Msg-id CAASwCXd+4vfoF-c5bxPizTfKfA5ZeVBN-ZcVrH8W2MhbYmf3cw@mail.gmail.com
Whole thread Raw
In response to Re: PL/PgSQL: EXIT USING ROLLBACK  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: PL/PgSQL: EXIT USING ROLLBACK
List pgsql-hackers
On Sat, Jul 26, 2014 at 8:39 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Basically my point is that this just seems like inventing another way to
> do what one can already do with RAISE, and it doesn't have much redeeming
> social value to justify the cognitive load of inventing another construct.

The main difference is with RAISE EXCEPTION 'OK'; you cannot know if
it was *your* line of code which throw the 'OK'-exception or if it
came from some other function which was called in the block of code.

This means with the current way you have to inspect all lines of code
in all functions in the entire call graph for the block of code for
which you want to capture the 'OK'-exception (or whatever name one
wishes to use),
alternatively to use a name which is guaranteed to be unique, such as
a UUID or something which no other line of code could possibly emmit
as an exception.

Both approaches are ugly and hackish. I think the language should
provide a documented and safe way of exiting from a begin block
without having to worry about other code raising exceptions of the
same name.



pgsql-hackers by date:

Previous
From: Joel Jacobson
Date:
Subject: PL/pgSQL 2
Next
From: Andres Freund
Date:
Subject: Re: PL/pgSQL 2