~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to src/test/isolation/specs/total-cash.spec

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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; }