Debian Codegraph @

src/test/isolation/specs/total-cash.spec

raw
1 # Total Cash test
2 #
3 # Another famous test of snapshot isolation anomaly.
4 #
5 # Any overlap between the transactions must cause a serialization failure.
6
7 setup
8 {
9 CREATE TABLE accounts (accountid text NOT NULL PRIMARY KEY, balance numeric not null);
10 INSERT INTO accounts VALUES ('checking', 600),('savings',600);
11 }
12
13 teardown
14 {
15 DROP TABLE accounts;
16 }
17
18 session s1
19 setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
20 step wx1 { UPDATE accounts SET balance = balance - 200 WHERE accountid = 'checking'; }
21 step rxy1 { SELECT SUM(balance) FROM accounts; }
22 step c1 { COMMIT; }
23
24 session s2
25 setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
26 step wy2 { UPDATE accounts SET balance = balance - 200 WHERE accountid = 'savings'; }
27 step rxy2 { SELECT SUM(balance) FROM accounts; }
28 step c2 { COMMIT; }