Re: SAVEPOINT SQL conformance

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Michael Paesold <mpaesold(at)gmx(dot)at>
Cc: pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: SAVEPOINT SQL conformance
Date: 2004-09-18 21:41:24
Message-ID: 414CAB84.2090102@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Michael Paesold wrote:

> BEGIN;
> SAVEPOINT a;
> INSERT INTO ...
> SAVEPOINT a;
> INSERT INTO ...
> SAVEPOINT a;
> ...
> (encountering an error it would just ROLLBACK TO a;)
>
> According to the standard this is exactly the same as:
>
> BEGIN;
> SAVEPOINT a;
> INSERT INTO ...
> RELEASE SAVEPOINT a;
> SAVEPOINT a;
> INSERT INTO ...

While that's true in this particular case, you can't do that
transformation in the general case. Consider:

BEGIN
SAVEPOINT a
-- work
SAVEPOINT b
-- work
SAVEPOINT a
-- work
ROLLBACK TO b
-- work

This is valid: the standard says that the second "SAVEPOINT a" destroys
and recreates the savepoint "a", but doesn't say that it destroys
intervening savepoints. In contrast, RELEASE SAVEPOINT explicitly says
that it destroys the specified savepoint and all savepoints established
since the specified savepoint.

If you converted the second "SAVEPOINT a" into "RELEASE SAVEPOINT a;
SAVEPOINT a" then savepoint "b" would be incorrectly destroyed.

It'd work for the (common?) case where there are no intervening
savepoints, though.

-O

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paesold 2004-09-18 21:46:52 Re: SAVEPOINT SQL conformance
Previous Message Tom Lane 2004-09-18 21:37:13 Re: SAVEPOINT SQL conformance