1# Test updating a locked tuple.  When the lock doesn't conflict with the
2# update, no blocking nor serializability problems should occur.
3
4setup
5{
6   DROP TABLE IF EXISTS users, orders;
7   CREATE TABLE users (id INTEGER PRIMARY KEY,
8                       name varchar,
9                       sometime timestamp);
10   CREATE TABLE orders (id INTEGER PRIMARY KEY,
11                        name varchar,
12                        user_id INTEGER REFERENCES users (id));
13   INSERT INTO users (id, name) VALUES (1, 'olivier');
14   INSERT INTO orders (id, name) VALUES (1, 'order of olivier (1)');
15}
16
17teardown
18{
19   DROP TABLE users, orders;
20}
21
22session s1
23step s1b   { BEGIN ISOLATION LEVEL REPEATABLE READ; }
24step s1u1  { UPDATE orders SET name = 'order of olivier (2)', user_id = 1 WHERE id = 1; }
25step s1u2  { UPDATE orders SET name = 'order of olivier (3)', user_id = 1 WHERE id = 1; }
26step s1c   { COMMIT; }
27
28session s2
29step s2b   { BEGIN ISOLATION LEVEL REPEATABLE READ; }
30step s2u   { UPDATE users SET sometime = '1830-10-04' WHERE id = 1; }
31step s2c   { COMMIT; }
32
33permutation s1b s2b s2u s2c s1u1 s1u2 s1c
34permutation s1b s2b s2u s1u1 s2c s1u2 s1c
35permutation s1b s2b s1u1 s2u s2c s1u2 s1c
36permutation s1b s1u1 s2b s2u s2c s1u2 s1c
37permutation s1b s1u1 s2b s1u2 s2u s2c s1c
38permutation s1b s1u1 s1u2 s2b s2u s2c s1c
39