Debian Codegraph @

src/test/isolation/specs/simple-write-skew.spec

raw
1 # Write skew test.
2 #
3 # This test has two serializable transactions: one which updates all
4 # 'apple' rows to 'pear' and one which updates all 'pear' rows to
5 # 'apple'. If these were serialized (run one at a time) either
6 # value could be present, but not both. One must be rolled back to
7 # prevent the write skew anomaly.
8 #
9 # Any overlap between the transactions must cause a serialization failure.
10
11 setup
12 {
13 CREATE TABLE test (i int PRIMARY KEY, t text);
14 INSERT INTO test VALUES (5, 'apple'), (7, 'pear'), (11, 'banana');
15 }
16
17 teardown
18 {
19 DROP TABLE test;
20 }
21
22 session s1
23 setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
24 step rwx1 { UPDATE test SET t = 'apple' WHERE t = 'pear'; }
25 step c1 { COMMIT; }
26
27 session s2
28 setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
29 step rwx2 { UPDATE test SET t = 'pear' WHERE t = 'apple'}
30 step c2 { COMMIT; }