1
# Multiple Row Versions test
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.
7
# Due to long permutation setup time, we are only testing one specific
8
# permutation, which should get a serialization error.
12
CREATE TABLE t (id int NOT NULL, txt text) WITH (fillfactor=50);
14
SELECT x FROM (SELECT * FROM generate_series(1, 1000000)) a(x);
15
ALTER TABLE t ADD PRIMARY KEY (id);
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; }
31
setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
32
step "wx2" { UPDATE t SET txt = 'b' WHERE id = 1000000; }
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
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; }
48
permutation "rx1" "wx2" "c2" "wx3" "ry3" "wy4" "rz4" "c4" "c3" "wz1" "c1"