Subject Re: [firebird-support] commit to savepoint ??
Author Helen Borrie
At 05:35 PM 21/04/2008, you wrote:
>I am aware of commands
>save to savepoint xxx
>rollback to savepoint xxx
>release savepoint xxx [only]
>I thought that savepoints could be a great way to implement an Undo
>feature inside an application almost for free.
>The undo feature requires the ability to cancel 1 or multiple back
>operations, say up to a maximum value of N (where N is a constant).
>However it seems that savepoints won't allow that unless I keep a
>transaction open.
>But it is no good to have a transaction open for a long time in a
>multiuser environment.

There is "long" and then there is "long". The typical "long-running transaction offence" is a SELECT done in a read-write transaction that stays open all day (or longer). A five-minute transaction is not very long by comparison. ;-)

>I would like a command like
>commit to savepoint xxx
>But this command is not avaiable, or am I wrong ?

Of course it is not available! a savepoint does not exist outside the context of a transaction.

>T0 T1 T2 T3
>Say I open a transaction at time T0, then save to savepoints S1, S2,
>S3 at times T1,T2,T3 .
>Say I want my Undo list to have a maximum of 2 back operations.
>For the economy of the database, it is time to commit the operations I
>did at times T0 and time T1.
>But it seems I cannot do that, I cannot _advance_ the transaction to
>savepoint T2 (I have the choice btw committing all or nothing).
>Correct ?

Correct. It is precisely that principle on which the concepts of transaction isolation and consistency are implemented.