Re: PL/pgSQL: EXCEPTION NOSAVEPOINT

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

[ redirected to -hackers, where it's actually on topic ]

Matt Miller <mattm(at)epx(dot)com> writes:
> [redirected from -patches]
> On Wed, 2005-08-03 at 16:25 -0400, Tom Lane wrote:
>> 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.

The reason you aren't going to be able to manage this in the current
state of plpgsql is that plpgsql doesn't really have any interesting
computational ability "of its own". It can't even do 2+2 without
calling the main executor --- and recovering from elog(ERROR) without a
transaction rollback is not part of the executor's contract. So while
you could theoretically make a try/catch construct within plpgsql that
doesn't have subtransaction semantics, there'd basically be no way to
do anything useful within it.

You might take a look at the other PLs such as plperl; those have
behavior much closer to what you are looking for, since their
computational engine is separate from the SQL engine.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matt Miller 2005-09-01 22:58:38 Re: PL/pgSQL: EXCEPTION NOSAVEPOINT
Previous Message vishal saberwal 2005-09-01 22:17:05 Performance question (FOR loop)

Browse pgsql-hackers by date

  From Date Subject
Next Message Matt Miller 2005-09-01 22:58:38 Re: PL/pgSQL: EXCEPTION NOSAVEPOINT
Previous Message Simon Riggs 2005-09-01 22:18:25 Re: Version number in psql banner

Browse pgsql-patches by date

  From Date Subject
Next Message Matt Miller 2005-09-01 22:58:38 Re: PL/pgSQL: EXCEPTION NOSAVEPOINT
Previous Message Simon Riggs 2005-09-01 22:18:25 Re: Version number in psql banner