Re: PL/pgSQL: EXCEPTION NOSAVEPOINT

From: Matt Miller <mattm(at)epx(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: PL/pgSQL: EXCEPTION NOSAVEPOINT
Date: 2005-09-01 22:14:55
Message-ID: 1125612895.3636.47.camel@dbamm01-linux
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-patches

[redirected from -patches]

On Wed, 2005-08-03 at 16:25 -0400, Tom Lane wrote:
> Matt Miller <mattm(at)epx(dot)com> writes:
> > allow a PL/pgSQL exception to not automatically rollback
> > the work done by the current block.
>
> This fundamentally breaks the entire backend. You do not have the
> option to continue processing after elog(ERROR);

Okay, I think I'm beginning to see the naivete of that patch's
simplistic attempt to decouple backend error handling from transaction
management. But I still haven't found a way to meet my original need:

On Wed, 2005-08-03 at 19:58 +0000, Matt Miller wrote:
> The benefit is that [PL/pgSQL] exception
> handling can be used as a program flow control technique, without
> invoking transaction management mechanisms. This also adds additional
> means to enhanced Oracle PL/SQL compatibility.

Basically I'd like my Pl/pgSQL code to be able to utilize the try/catch
paradigm of error handling without the overhead of subtransactions and
without the effect of a rollback. If I catch the exception then
everything should be fine as far as the transaction is concerned. If
don't catch the exception, or if I re-raise it, then the enclosing block
can decide to rollback. This is more consistent with Oracle, and I have
hundreds of Oracle procs to convert across multiple databases.

I'm still thinking that some kind of hack to
src/pl/plpgsql/src/pl_exec.c is probably where I'm headed, but I'm open
to consider other approaches/advice.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message vishal saberwal 2005-09-01 22:17:05 Performance question (FOR loop)
Previous Message Michael Fuhr 2005-09-01 22:04:51 Re: Schema problems RedHat / SuSE 9.3 for version 7.4.8

Browse pgsql-hackers by date

  From Date Subject
Next Message Marc G. Fournier 2005-09-01 22:16:38 Re: ALTER TABLE ( smallinto -> boolean ) ...
Previous Message Tom Lane 2005-09-01 22:06:36 Re: rename constraint behavior for duplicate names?

Browse pgsql-patches by date

  From Date Subject
Next Message Simon Riggs 2005-09-01 22:18:25 Re: Version number in psql banner
Previous Message Tom Lane 2005-09-01 18:53:12 Re: Version number in psql banner