Information Technology Reference
In-Depth Information
is also the only option in the case in which the database management system is
unable to commit a transaction due to a process failure or a system crash occurring
before or during servicing a
commit
request.
Example 1.1
Assume that in the relation r.X;V/, V is a single numeric-valued
attribute. The following fragment of an application program written in embedded
SQL
generates a transaction that doubles the V value of all tuples in r :
exec sql update
r
set
V = 2
V ;
exec sql select sum
(V )
into
:
new_sum
from
r ;
exec sql commit
.
The application process sends to the server three requests, one by one, waiting for
one request to be serviced before sending the next:
1. A request to execute the
update
statement
2. A request to execute the
select
query
3. A request to commit the transaction
Assuming that the contents of relation r are initially the set of tuples
f
.x
1
;
v
1
/;:::;.x
n
;
v
n
/
g
, request 1 results in performing the following action
sequence at the server, where B denotes the action of beginning a new transaction,
RŒx;
v
the action of reading tuple .x;
v
/,andWŒx;
u
;
v
the action of changing tuple
.x;
u
/ to .x;
v
/:
BR
Œx
1
;
v
1
W Œx
1
;
v
1
;2
v
1
RŒx
2
;
v
2
W Œx
2
;
v
2
;2
v
2
:::RŒx
n
;
v
n
W Œx
n
;
v
n
;2
v
n
:
Because the semantics of the
update
statement does not specify the order in which
r 's tuples are processed, the system selects the most efficient order, probably the
order in which the tuples are physically stored in r 's file. After performing the
update, the server returns to the application an indication of successful completion.
Then request 2 is sent, resulting in the following action sequence:
RŒx
1
;2
v
1
RŒx
2
;2
v
2
:::RŒx
n
;2
v
n
:
The computed sum is returned to the application, which assigns it to the program
variable
new_sum
. Finally, request 3 is sent, resulting in the action
C ,
denoting the commit of the transaction, assuming that no failures occur.
t
In addition to atomicity,
durability
is required for all committed transactions.
This means that the changes produced by a committed transaction need to actually
happen and stay in effect in the logical database, even in the presence of process fail-
ures and system failures occurring after the transaction has successfully committed.
The only way to undo updates produced by a committed transaction is to program
a new transaction (or several new transactions) for effectively compensating for the
updates.
In the above example, if the “commit the transaction” action is finished success-
fully, so that the transaction actually commits, all of the updates in the V attribute of