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

« back to all changes in this revision

Viewing changes to src/test/isolation/specs/multiple-row-versions.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
# Multiple Row Versions test
 
2
#
 
3
# This test is designed to ensure that predicate locks taken on one version
 
4
# of a row are detected as conflicts when a later version of the row is
 
5
# updated or deleted by a transaction concurrent to the reader.
 
6
#
 
7
# Due to long permutation setup time, we are only testing one specific
 
8
# permutation, which should get a serialization error.
 
9
 
 
10
setup
 
11
{
 
12
 CREATE TABLE t (id int NOT NULL, txt text) WITH (fillfactor=50);
 
13
 INSERT INTO t (id)
 
14
   SELECT x FROM (SELECT * FROM generate_series(1, 1000000)) a(x);
 
15
 ALTER TABLE t ADD PRIMARY KEY (id);
 
16
}
 
17
 
 
18
teardown
 
19
{
 
20
 DROP TABLE t;
 
21
}
 
22
 
 
23
session "s1"
 
24
setup           { BEGIN ISOLATION LEVEL SERIALIZABLE; }
 
25
step "rx1"      { SELECT * FROM t WHERE id = 1000000; }
 
26
# delay until after T3 commits
 
27
step "wz1"      { UPDATE t SET txt = 'a' WHERE id = 1; }
 
28
step "c1"       { COMMIT; }
 
29
 
 
30
session "s2"
 
31
setup           { BEGIN ISOLATION LEVEL SERIALIZABLE; }
 
32
step "wx2"      { UPDATE t SET txt = 'b' WHERE id = 1000000; }
 
33
step "c2"       { COMMIT; }
 
34
 
 
35
session "s3"
 
36
setup           { BEGIN ISOLATION LEVEL SERIALIZABLE; }
 
37
step "wx3"      { UPDATE t SET txt = 'c' WHERE id = 1000000; }
 
38
step "ry3"      { SELECT * FROM t WHERE id = 500000; }
 
39
# delay until after T4 commits
 
40
step "c3"       { COMMIT; }
 
41
 
 
42
session "s4"
 
43
setup           { BEGIN ISOLATION LEVEL SERIALIZABLE; }
 
44
step "wy4"      { UPDATE t SET txt = 'd' WHERE id = 500000; }
 
45
step "rz4"      { SELECT * FROM t WHERE id = 1; }
 
46
step "c4"       { COMMIT; }
 
47
 
 
48
permutation "rx1" "wx2" "c2" "wx3" "ry3" "wy4" "rz4" "c4" "c3" "wz1" "c1"