Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
Parsed test spec with 3 sessions
 
starting permutation: s2b s2ukey s1b s1i s2c s1c s2s s1s
step s2b: BEGIN;
step s2ukey: UPDATE parent SET parent_key = 2 WHERE parent_key = 1;
step s1b: BEGIN;
step s1i: INSERT INTO child VALUES (1, 1); <waiting ...>
step s2c: COMMIT;
step s1i: <... completed>
ERROR:  insert or update on table "child" violates foreign key constraint "child_parent_key_fkey"
step s1c: COMMIT;
step s2s: SELECT * FROM parent;
parent_key|aux
----------+---
         2|foo
(1 row)
 
step s1s: SELECT * FROM child;
child_key|parent_key
---------+----------
(0 rows)
 
 
starting permutation: s2b s2uaux s1b s1i s2c s1c s2s s1s
step s2b: BEGIN;
step s2uaux: UPDATE parent SET aux = 'bar' WHERE parent_key = 1;
step s1b: BEGIN;
step s1i: INSERT INTO child VALUES (1, 1);
step s2c: COMMIT;
step s1c: COMMIT;
step s2s: SELECT * FROM parent;
parent_key|aux
----------+---
         1|bar
(1 row)
 
step s1s: SELECT * FROM child;
child_key|parent_key
---------+----------
        1|         1
(1 row)
 
 
starting permutation: s2b s2ukey s1b s1i s2ukey2 s2c s1c s2s s1s
step s2b: BEGIN;
step s2ukey: UPDATE parent SET parent_key = 2 WHERE parent_key = 1;
step s1b: BEGIN;
step s1i: INSERT INTO child VALUES (1, 1); <waiting ...>
step s2ukey2: UPDATE parent SET parent_key = 1 WHERE parent_key = 2;
step s2c: COMMIT;
step s1i: <... completed>
step s1c: COMMIT;
step s2s: SELECT * FROM parent;
parent_key|aux
----------+---
         1|foo
(1 row)
 
step s1s: SELECT * FROM child;
child_key|parent_key
---------+----------
        1|         1
(1 row)
 
 
starting permutation: s2b s2ukey s3b s3i s2c s3c s2s s3s
step s2b: BEGIN;
step s2ukey: UPDATE parent SET parent_key = 2 WHERE parent_key = 1;
step s3b: BEGIN ISOLATION LEVEL REPEATABLE READ;
step s3i: INSERT INTO child VALUES (2, 1); <waiting ...>
step s2c: COMMIT;
step s3i: <... completed>
ERROR:  could not serialize access due to concurrent update
step s3c: COMMIT;
step s2s: SELECT * FROM parent;
parent_key|aux
----------+---
         2|foo
(1 row)
 
step s3s: SELECT * FROM child;
child_key|parent_key
---------+----------
(0 rows)
 
 
starting permutation: s2b s2dkey s3b s3i s2c s3c s2s s3s
step s2b: BEGIN;
step s2dkey: DELETE FROM parent WHERE parent_key = 1;
step s3b: BEGIN ISOLATION LEVEL REPEATABLE READ;
step s3i: INSERT INTO child VALUES (2, 1); <waiting ...>
step s2c: COMMIT;
step s3i: <... completed>
ERROR:  could not serialize access due to concurrent delete
step s3c: COMMIT;
step s2s: SELECT * FROM parent;
parent_key|aux
----------+---
(0 rows)
 
step s3s: SELECT * FROM child;
child_key|parent_key
---------+----------
(0 rows)
 
 
starting permutation: s2b s2uaux s3b s3i s2c s3c s2s s3s
step s2b: BEGIN;
step s2uaux: UPDATE parent SET aux = 'bar' WHERE parent_key = 1;
step s3b: BEGIN ISOLATION LEVEL REPEATABLE READ;
step s3i: INSERT INTO child VALUES (2, 1);
step s2c: COMMIT;
step s3c: COMMIT;
step s2s: SELECT * FROM parent;
parent_key|aux
----------+---
         1|bar
(1 row)
 
step s3s: SELECT * FROM child;
child_key|parent_key
---------+----------
        2|         1
(1 row)