Information Technology Reference
In-Depth Information
Thus, the first tuple, .x; u /,insertedbyT 2 is not among the tuples read by T 1 , while
the second tuple, .y; v / D .x j ; v j /,is.
We also note that the phantom phenomenon is not prevented by the simple
locking protocol in which transactions obtain commit-duration shared locks (read
locks) on the keys of tuples read and commit-duration exclusive locks (write locks)
on the keys of tuples inserted, deleted, or updated.
t
1.9
Savepoints and Partial Rollbacks
The transaction model of SQL allows for partial rollbacks of transactions: a subse-
quence of the update actions performed by a forward-rolling transaction is rolled
back without aborting and rolling back the entire transaction. After performing a
partial rollback, the transaction remains in the forward-rolling phase and can thus
perform any new forward-rolling actions.
The actions to be rolled back in a partial rollback constitute a sequence of actions
from the latest update action by the transaction back to preset savepoint . Savepoints
are set in the application program using the SQL statement
set savepoint P
where P is a unique name for the savepoint. The SQL statement
rollback to savepoint P
executes a partial rollback to savepoint P : all forward-rolling update actions
performed by the transaction after setting P that are not yet undone are undone.
Example 1.10 Partial rollbacks can be nested (Fig. 1.2 ).
insert into r values .x 1 ; v 1 /;
set savepoint P 1 ;
insert into r values .x 2 ; v 2 /;
set savepoint P 2 ;
insert into r values .x 3 ; v 3 /;
rollback to savepoint P 2 ;
insert into r values .x 4 ; v 4 /;
rollback to savepoint P 1 ;
insert into r values .x 5 ; v 5 /;
commit .
The statement rollback to savepoint P 2 deletes from relation r the inserted tuple
.x 3 ; v 3 /. The statement rollback to savepoint P 1 deletes from r the inserted tuples
.x 4 ; v 4 / and .x 2 ; v 2 /. At the end of the transaction, an initially empty relation r
contains only the tuples .x 1 ; v 1 / and .x 5 ; v 5 /.
t
We now add partial rollbacks to our transaction model. For that purpose, we
define the following actions:
Search WWH ::




Custom Search