Debian Codegraph @

src/test/isolation/specs/skip-locked-3.spec

raw
1 # Test SKIP LOCKED with tuple locks.
2
3 setup
4 {
5 CREATE TABLE queue (
6 id int PRIMARY KEY,
7 data text NOT NULL,
8 status text NOT NULL
9 );
10 INSERT INTO queue VALUES (1, 'foo', 'NEW'), (2, 'bar', 'NEW');
11 }
12
13 teardown
14 {
15 DROP TABLE queue;
16 }
17
18 session s1
19 setup { BEGIN; }
20 step s1a { SELECT * FROM queue ORDER BY id FOR UPDATE LIMIT 1; }
21 step s1b { COMMIT; }
22
23 session s2
24 setup { BEGIN; }
25 step s2a { SELECT * FROM queue ORDER BY id FOR UPDATE LIMIT 1; }
26 step s2b { COMMIT; }
27
28 session s3
29 setup { BEGIN; }
30 step s3a { SELECT * FROM queue ORDER BY id FOR UPDATE SKIP LOCKED LIMIT 1; }
31 step s3b { COMMIT; }
32
33 # s3 skips to the second record because it can't obtain the tuple lock
34 # (s2 holds the tuple lock because it is next in line to obtain the
35 # row lock, and s1 holds the row lock)
36 permutation s1a s2a s3a s1b s2b s3b