Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 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
125
126
127
128
129
130
131
132
133
-- Tests with portals set up by a Bind message.
-- All these rely on the unnamed portal with \bind.
CREATE EXTENSION injection_points;
-- Make the injection points local to this session.
SELECT injection_points_set_local();
 injection_points_set_local 
----------------------------
 
(1 row)
 
-- Portal is new, not fully set up yet.
SELECT injection_points_attach('bind-portal-created', 'error');
 injection_points_attach 
-------------------------
 
(1 row)
 
-- No transaction block.
SELECT 1 \bind \g
ERROR:  error triggered for injection point bind-portal-created
SELECT 2;
 ?column? 
----------
        2
(1 row)
 
-- Transaction block, not aborted after failure.
BEGIN;
SELECT 3 \bind \g
ERROR:  error triggered for injection point bind-portal-created
ROLLBACK;
SELECT 4;
 ?column? 
----------
        4
(1 row)
 
-- Transaction block already aborted when failure happens.
BEGIN;
SELECT 1/0;
ERROR:  division by zero
ROLLBACK \bind \g
ERROR:  error triggered for injection point bind-portal-created
ROLLBACK;
SELECT 5;
 ?column? 
----------
        5
(1 row)
 
-- Sub-transaction already aborted when failure happens.
BEGIN;
SAVEPOINT s;
SELECT 1/0;
ERROR:  division by zero
ROLLBACK TO s \bind \g
ERROR:  error triggered for injection point bind-portal-created
ROLLBACK TO s;
SELECT 6;
 ?column? 
----------
        6
(1 row)
 
COMMIT;
SELECT injection_points_detach('bind-portal-created');
 injection_points_detach 
-------------------------
 
(1 row)
 
-- Portal is defined, not fully set up yet.
SELECT injection_points_attach('bind-portal-defined', 'error');
 injection_points_attach 
-------------------------
 
(1 row)
 
-- No transaction block.
SELECT 1 \bind \g
ERROR:  error triggered for injection point bind-portal-defined
SELECT 2;
 ?column? 
----------
        2
(1 row)
 
-- Transaction block, not aborted under failure.
BEGIN;
SELECT 3 \bind \g
ERROR:  error triggered for injection point bind-portal-defined
ROLLBACK;
SELECT 4;
 ?column? 
----------
        4
(1 row)
 
-- Transaction block already aborted when failure happens.
BEGIN;
SELECT 1/0;
ERROR:  division by zero
ROLLBACK \bind \g
ERROR:  error triggered for injection point bind-portal-defined
ROLLBACK;
SELECT 5;
 ?column? 
----------
        5
(1 row)
 
-- Sub-transaction already aborted when failure happens.
BEGIN;
SAVEPOINT s;
SELECT 1/0;
ERROR:  division by zero
ROLLBACK TO s \bind \g
ERROR:  error triggered for injection point bind-portal-defined
ROLLBACK TO s;
SELECT 6;
 ?column? 
----------
        6
(1 row)
 
COMMIT;
SELECT injection_points_detach('bind-portal-defined');
 injection_points_detach 
-------------------------
 
(1 row)
 
DROP EXTENSION injection_points;