Information Technology Reference
In-Depth Information
It is the responsibility of the application programmer to designate the transaction
to be run at a level of isolation that disallows the occurrence of such a violation
of database integrity, while the concurrency-control mechanism of the database
management system has to ensure that such an isolation level is indeed achieved.
The system has also to ensure that if the transaction indeed commits, the insertion
of the new tuple is recorded permanently in the database and that otherwise if the
transaction after all does not commit, the transaction is aborted and rolled back,
undoing the insertion (if needed).
t
Allowing transactions to be run at an isolation level lower than full isolation
usually means more efficient transaction processing, because of the increased
concurrency between transactions. However, with lower than full isolation, the
execution of transactions may not correspond to any of their serial executions, being
thus incorrect with respect to the usual notion of correctness. In many cases this
is acceptable (see Sects. 5.5 and 9.5 ). Additionally, however, as shown in Chap. 5 ,
if a transaction is run at a low isolation level, it may not be possible for the
system to maintain logical consistency. For example, it would be highly risky to
run the transaction of Example 1.3 at any isolation level lower than full isolation
(serializable).
The program steps between two transaction boundaries in a database application
program can be viewed as a mapping from a vector of input values to a vector
of output values, where the input values are relations, constants, and values of
program variables given as input to database actions, and the output values are
results returned by those actions. The output values include both relations updated
in update actions and the values returned by read actions.
It is in line with the above definition of the ACID property ā€œCā€ and the
responsibility laid on the programmer in this respect to regard such a mapping
as correctly programmed so that an input vector is correctly mapped to an output
vector when the program is run alone on a consistent logical database in the absence
of failures. Again, serial executions are guaranteed to retain correctness, while
correctness may be lost in nonserial executions.
Example 1.4 Assuming the V values in r.X;V/ are numeric, the following
embedded SQL program fragment generates a transaction, T 1 , that scans the relation
r and computes the sum of the V values of all tuples in r :
exec sql select sum (V ) into : s from r ;
exec sql commit .
The mapping defined by this program fragment maps the set of V values retrieved
from r to the sum stored into the program variable s .
Another transaction, T 2 , generated from the following program fragment is run
concurrently with T 1 :
exec sql insert into r values .x; u /;
exec sql insert into r values .y; v /;
exec sql commit .
Search WWH ::




Custom Search