Re: Savepoints in PL/pgSQL

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: BigSmoke <bigsmoke(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Savepoints in PL/pgSQL
Date: 2006-12-19 15:16:12
Message-ID: 30483a97cc63e671a4fc5c681f4cf85a@oopsware.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 19 Dec 2006 07:05:10 -0800, "BigSmoke" <bigsmoke(at)gmail(dot)com> wrote:
> I understand that due to a lack of nested transaction support, it is
> not possible to use START TRANSACTION within a PL/PgSQL function. What
> I, however, do not understand is why I can't use SAVEPOINT either. I'm
> writing long test functions wherein, at the start of the function, I'd
> like to define all test data followed by a "SAVEPOINT
> fresh_test_data;". Will this become possible in the (near) future? I
> mean, savepoints are of limited use to me if they imply that I can't
> stick my tests in stored procedures.
>

Use

BEGIN

...

EXCEPTION

...

END;

Blocks instead. The pl/pgsql exception handling is implemented on top
of PostgreSQL's SAVEPOINT infrastructure. We are lacking user defined
exception support, but you can raise generic errors with RAISE EXCEPTION.

See

http://www.postgresql.org/docs/8.2/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

for details.

Bernd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2006-12-19 15:19:34 Re: psql too noisy
Previous Message Marc Evans 2006-12-19 15:14:55 psql too noisy