Debian Codegraph @

src/test/isolation/specs/referential-integrity.spec

raw
1 # Referential Integrity test
2 #
3 # The assumption here is that the application code issuing the SELECT
4 # to test for the presence or absence of a related record would do the
5 # right thing -- this script doesn't include that logic.
6 #
7 # Any overlap between the transactions must cause a serialization failure.
8
9 setup
10 {
11 CREATE TABLE a (i int PRIMARY KEY);
12 CREATE TABLE b (a_id int);
13 INSERT INTO a VALUES (1);
14 }
15
16 teardown
17 {
18 DROP TABLE a, b;
19 }
20
21 session s1
22 setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
23 step rx1 { SELECT i FROM a WHERE i = 1; }
24 step wy1 { INSERT INTO b VALUES (1); }
25 step c1 { COMMIT; }
26
27 session s2
28 setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
29 step rx2 { SELECT i FROM a WHERE i = 1; }
30 step ry2 { SELECT a_id FROM b WHERE a_id = 1; }
31 step wx2 { DELETE FROM a WHERE i = 1; }
32 step c2 { COMMIT; }