From: | Andreas Pflug <pgadmin(at)pse-consulting(dot)de> |
---|---|
To: | Simon Riggs <simon(at)2ndquadrant(dot)com> |
Cc: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Nested Transactions, Abort All |
Date: | 2004-07-09 10:45:04 |
Message-ID: | 40EE7730.6080006@pse-consulting.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Simon Riggs wrote:
>ISTM - my summary would be
>1. We seem to agree we should support SAVEPOINTs
>
>2. We seem to agree that BEGIN/COMMIT should stay unchanged...
>
>
>
>>With savepoints, it looks pretty strange:
>>
>>BEGIN;
>> SAVEPOINT x1;
>> INSERT INTO ...;
>> SAVEPOINT x2;
>> INSERT INTO ...;
>> SAVEPOINT x3;
>> INSERT INTO ...;
>>
>>
>>
>
>This isn't how you would use SAVEPOINTs...look at this...
>
>BEGIN
> display one screen to user - book the flight
> INSERT INTO ...
> INSERT INTO ...
> UPDATE ...
> SAVEPOINT
> display another related screen - book the hotel
> INSERT INTO
> DELETE
> UPDATE
> UPDATE
> SAVEPOINT
> offer confirmation screen
>COMMIT (or ROLLBACK)
>
>
No, SAVEPOINT is not some kind of intermediate commit, but a point where
a rollback can rollback to.
Look at this oracle stuff when googling for SAVEPOINT ROLLBACK:
BEGIN
SAVEPOINT before_insert_programmers;
insert_programmers (p_deptno);
EXCEPTION
WHEN OTHERS THEN ROLLBACK TO before_insert_programmers;
END;
There's no need for an intermediate commit, because the top level
rollback would overrule it (if not, it would be an independent
transaction, not nested).
I'd opt for BEGIN as a start of a subtransaction (no need for special
semantics in plpgsql), the corresponding END simply changes the
transaction context to the parent level.
BEGIN is an unnamed savepoint in this case, so if we have SAVEPOINT
<name> we'd also have the corresponding ROLLBACK TO [SAVEPOINT] <name>.
For the unnamed savepoint ROLLBACK INNER or ROLLBACK SUB could be used.
This would be an extension to oracle's usage, which seems quite
reasonable to me.
Regards,
Andreas
From | Date | Subject | |
---|---|---|---|
Next Message | Zeugswetter Andreas SB SD | 2004-07-09 10:59:57 | Re: Nested Transactions, Abort All |
Previous Message | Zeugswetter Andreas SB SD | 2004-07-09 10:09:16 | Re: Nested Transactions, Abort All |