Debian Codegraph @

src/test/isolation/specs/lock-update-traversal.spec

raw
1 # When a tuple that has been updated is locked, the locking command must
2 # traverse the update chain; thus, a DELETE (on the newer version of the tuple)
3 # should not be able to proceed until the lock has been released. An UPDATE
4 # that changes the key should not be allowed to continue either; but an UPDATE
5 # that doesn't modify the key should be able to continue immediately.
6
7 setup
8 {
9 CREATE TABLE foo (
10 key int,
11 value int,
12 PRIMARY KEY (key) INCLUDE (value)
13 );
14
15 INSERT INTO foo VALUES (1, 1);
16 }
17
18 teardown
19 {
20 DROP TABLE foo;
21 }
22
23 session s1
24 step s1b { BEGIN ISOLATION LEVEL REPEATABLE READ; }
25 step s1s { SELECT * FROM foo; } # obtain snapshot
26 step s1l { SELECT * FROM foo FOR KEY SHARE; } # obtain lock
27 step s1c { COMMIT; }
28
29 session s2
30 step s2b { BEGIN; }
31 step s2u { UPDATE foo SET value = 2 WHERE key = 1; }
32 step s2c { COMMIT; }
33 step s2d1 { DELETE FROM foo WHERE key = 1; }
34 step s2d2 { UPDATE foo SET key = 3 WHERE key = 1; }
35 step s2d3 { UPDATE foo SET value = 3 WHERE key = 1; }
36
37 permutation s1b s2b s1s s2u s1l s2c s2d1 s1c
38 permutation s1b s2b s1s s2u s1l s2c s2d2 s1c
39 permutation s1b s2b s1s s2u s1l s2c s2d3 s1c