Debian Codegraph @

src/test/isolation/specs/fk-snapshot.spec

raw
1 setup
2 {
3 CREATE TABLE pk_noparted (
4 a int PRIMARY KEY
5 );
6
7 CREATE TABLE fk_parted_pk (
8 a int PRIMARY KEY REFERENCES pk_noparted ON DELETE CASCADE
9 ) PARTITION BY LIST (a);
10 CREATE TABLE fk_parted_pk_1 PARTITION OF fk_parted_pk FOR VALUES IN (1);
11 CREATE TABLE fk_parted_pk_2 PARTITION OF fk_parted_pk FOR VALUES IN (2);
12
13 CREATE TABLE fk_noparted (
14 a int REFERENCES fk_parted_pk ON DELETE NO ACTION INITIALLY DEFERRED
15 );
16
17 CREATE TABLE fk_noparted_sn (
18 a int REFERENCES pk_noparted ON DELETE SET NULL
19 );
20
21 INSERT INTO pk_noparted VALUES (1);
22 INSERT INTO fk_parted_pk VALUES (1);
23 INSERT INTO fk_noparted VALUES (1);
24 }
25
26 teardown
27 {
28 DROP TABLE pk_noparted, fk_parted_pk, fk_noparted, fk_noparted_sn;
29 }
30
31 session s1
32 step s1brr { BEGIN ISOLATION LEVEL REPEATABLE READ; }
33 step s1brc { BEGIN ISOLATION LEVEL READ COMMITTED; }
34 step s1ifp2 { INSERT INTO fk_parted_pk VALUES (2); }
35 step s1ifp1 { INSERT INTO fk_parted_pk VALUES (1); }
36 step s1ifn2 { INSERT INTO fk_noparted_sn VALUES (2); }
37 step s1dfp { DELETE FROM fk_parted_pk WHERE a = 1; }
38 step s1c { COMMIT; }
39 step s1sfp { SELECT * FROM fk_parted_pk; }
40 step s1sp { SELECT * FROM pk_noparted; }
41 step s1sfn { SELECT * FROM fk_noparted; }
42
43 session s2
44 step s2brr { BEGIN ISOLATION LEVEL REPEATABLE READ; }
45 step s2brc { BEGIN ISOLATION LEVEL READ COMMITTED; }
46 step s2ip2 { INSERT INTO pk_noparted VALUES (2); }
47 step s2dp2 { DELETE FROM pk_noparted WHERE a = 2; }
48 step s2ifn2 { INSERT INTO fk_noparted VALUES (2); }
49 step s2c { COMMIT; }
50 step s2sfp { SELECT * FROM fk_parted_pk; }
51 step s2sfn { SELECT * FROM fk_noparted; }
52
53 # inserting into referencing tables in transaction-snapshot mode
54 # PK table is non-partitioned
55 permutation s1brr s2brc s2ip2 s1sp s2c s1sp s1ifp2 s1c s1sfp
56 # PK table is partitioned: buggy, because s2's serialization transaction can
57 # see the uncommitted row thanks to the latest snapshot taken for
58 # partition lookup to work correctly also ends up getting used by the PK index
59 # scan
60 permutation s2ip2 s2brr s1brc s1ifp2 s2sfp s1c s2sfp s2ifn2 s2c s2sfn
61
62 # inserting into referencing tables in up-to-date snapshot mode
63 permutation s1brc s2brc s2ip2 s1sp s2c s1sp s1ifp2 s2brc s2sfp s1c s1sfp s2ifn2 s2c s2sfn
64
65 # deleting a referenced row and then inserting again in the same transaction; works
66 # the same no matter the snapshot mode
67 permutation s1brr s1dfp s1ifp1 s1c s1sfn
68 permutation s1brc s1dfp s1ifp1 s1c s1sfn
69
70 # trying to delete a row through DELETE CASCADE, whilst that row is deleted
71 # in a concurrent transaction
72 permutation s2ip2 s1brr s1ifp2 s2brr s2dp2 s1c s2c
73
74 # trying to update a row through DELETE SET NULL, whilst that row is deleted
75 # in a concurrent transaction
76 permutation s2ip2 s1brr s1ifn2 s2brr s2dp2 s1c s2c