Bug #6900 Stored procedure inner handler ignored
Submitted: 30 Nov 2004 23:43 Modified: 12 Apr 2005 9:54
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.2-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Bugs System CPU Architecture:Any

[30 Nov 2004 23:43] Peter Gulutzan
Description:
I have an inner compound statement within an outer compound statement, 
BEGIN ... BEGIN ... END ... END. 
Both the inner and outer compound statements have a handler for SQLEXCEPTION. 
I cause an error within the inner compound statement. 
But the inner compound statement's handler does not catch the error. 
The outer compound statement's handler catches the error. 
(This would be acceptable if the error was within the inner compound statement's 
DECLARE, but that's not the case.) 
 

How to repeat:
mysql> create procedure p1 () begin declare exit handler for sqlexception select '1'; begin 
declare exit handler for sqlexception select '2'; drop table if exists tqq; select * from tqq; 
end; end;// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> call p1()// 
+---+ 
| 1 | 
+---+ 
| 1 | 
+---+ 
1 row in set (0.00 sec) 
 
Query OK, 0 rows affected (0.00 sec)