Re: PL/PgSQL: EXIT USING ROLLBACK

From: Joel Jacobson <joel(at)trustly(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Marko Tiikkaja <marko(at)joh(dot)to>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/PgSQL: EXIT USING ROLLBACK
Date: 2014-09-01 09:08:23
Message-ID: CAASwCXd+4vfoF-c5bxPizTfKfA5ZeVBN-ZcVrH8W2MhbYmf3cw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Jul 26, 2014 at 8:39 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-09-01 09:24:42 Re: PL/pgSQL 2
Previous Message Joel Jacobson 2014-09-01 09:04:53 PL/pgSQL 2