summaryrefslogtreecommitdiff
path: root/mysql-test/main/signal_demo2.result
blob: 5c8ac328a4a432172856a88683be2b39709e1fcf (plain)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
drop database if exists demo;
create database demo;
use demo;
create procedure proc_top_a(p1 integer)
begin
## DECLARE CONTINUE HANDLER for SQLEXCEPTION, NOT FOUND
begin
end;
select "Starting ...";
call proc_middle_a(p1);
select "The end";
end
$$
create procedure proc_middle_a(p1 integer)
begin
DECLARE l integer;
# without RESIGNAL:
# Should be: DECLARE EXIT HANDLER for SQLEXCEPTION, NOT FOUND
DECLARE EXIT HANDLER for 1 /* not sure how to handle exceptions */
begin
select "Oops ... now what ?";
end;
select "In prod_middle()";
create temporary table t1(a integer, b integer);
select GET_LOCK("user_mutex", 10) into l;
insert into t1 set a = p1, b = p1;
call proc_bottom_a(p1);
select RELEASE_LOCK("user_mutex") into l;
drop temporary table t1;
end
$$
create procedure proc_bottom_a(p1 integer)
begin
select "In proc_bottom()";
if (p1 = 1) then
begin
select "Doing something that works ...";
select * from t1;
end;
end if;
if (p1 = 2) then
begin
select "Doing something that fail (simulate an error) ...";
drop table no_such_table;
end;
end if;
if (p1 = 3) then
begin
select "Doing something that *SHOULD* works ...";
select * from t1;
end;
end if;
end
$$
call proc_top_a(1);
Starting ...
Starting ...
In prod_middle()
In prod_middle()
In proc_bottom()
In proc_bottom()
Doing something that works ...
Doing something that works ...
a	b
1	1
The end
The end
call proc_top_a(2);
Starting ...
Starting ...
In prod_middle()
In prod_middle()
In proc_bottom()
In proc_bottom()
Doing something that fail (simulate an error) ...
Doing something that fail (simulate an error) ...
ERROR 42S02: Unknown table 'demo.no_such_table'
call proc_top_a(3);
Starting ...
Starting ...
In prod_middle()
In prod_middle()
ERROR 42S01: Table 't1' already exists
call proc_top_a(1);
Starting ...
Starting ...
In prod_middle()
In prod_middle()
ERROR 42S01: Table 't1' already exists
drop temporary table if exists t1;
create procedure proc_top_b(p1 integer)
begin
select "Starting ...";
call proc_middle_b(p1);
select "The end";
end
$$
create procedure proc_middle_b(p1 integer)
begin
DECLARE l integer;
DECLARE EXIT HANDLER for SQLEXCEPTION, NOT FOUND
begin
begin
DECLARE CONTINUE HANDLER for SQLEXCEPTION, NOT FOUND
begin
/* Ignore errors from the cleanup code */
end;
select "Doing cleanup !";
select RELEASE_LOCK("user_mutex") into l;
drop temporary table t1;
end;
RESIGNAL;
end;
select "In prod_middle()";
create temporary table t1(a integer, b integer);
select GET_LOCK("user_mutex", 10) into l;
insert into t1 set a = p1, b = p1;
call proc_bottom_b(p1);
select RELEASE_LOCK("user_mutex") into l;
drop temporary table t1;
end
$$
create procedure proc_bottom_b(p1 integer)
begin
select "In proc_bottom()";
if (p1 = 1) then
begin
select "Doing something that works ...";
select * from t1;
end;
end if;
if (p1 = 2) then
begin
select "Doing something that fail (simulate an error) ...";
drop table no_such_table;
end;
end if;
if (p1 = 3) then
begin
select "Doing something that *SHOULD* works ...";
select * from t1;
end;
end if;
end
$$
call proc_top_b(1);
Starting ...
Starting ...
In prod_middle()
In prod_middle()
In proc_bottom()
In proc_bottom()
Doing something that works ...
Doing something that works ...
a	b
1	1
The end
The end
call proc_top_b(2);
Starting ...
Starting ...
In prod_middle()
In prod_middle()
In proc_bottom()
In proc_bottom()
Doing something that fail (simulate an error) ...
Doing something that fail (simulate an error) ...
Doing cleanup !
Doing cleanup !
ERROR 42S02: Unknown table 'demo.no_such_table'
call proc_top_b(3);
Starting ...
Starting ...
In prod_middle()
In prod_middle()
In proc_bottom()
In proc_bottom()
Doing something that *SHOULD* works ...
Doing something that *SHOULD* works ...
a	b
3	3
The end
The end
call proc_top_b(1);
Starting ...
Starting ...
In prod_middle()
In prod_middle()
In proc_bottom()
In proc_bottom()
Doing something that works ...
Doing something that works ...
a	b
1	1
The end
The end
drop database demo;