Re: Savepoints in PL/pgSQL - Mailing list pgsql-general

From Bernd Helmle
Subject Re: Savepoints in PL/pgSQL
Date
Msg-id 30483a97cc63e671a4fc5c681f4cf85a@oopsware.de
Whole thread Raw
In response to Savepoints in PL/pgSQL  ("BigSmoke" <bigsmoke@gmail.com>)
Responses Re: Savepoints in PL/pgSQL  ("BigSmoke" <bigsmoke@gmail.com>)
List pgsql-general


On 19 Dec 2006 07:05:10 -0800, "BigSmoke" <bigsmoke@gmail.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

pgsql-general by date:

Previous
From: Marc Evans
Date:
Subject: psql too noisy
Next
From: Alvaro Herrera
Date:
Subject: Re: psql too noisy