Bug #29770 Two handlers are allowed to catch an error in an stored procedure.
Submitted: 12 Jul 2007 19:40 Modified: 10 Jan 2008 0:51
Reporter: Evgeny Potemkin Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.0-bk OS:Any
Assigned to: Davi Arnaut CPU Architecture:Any

[12 Jul 2007 19:40] Evgeny Potemkin
Description:
If two error handlers are defined in a procedure and both applicable for an error then the most specific one should catch the error.
Currently both are called. 

How to repeat:
mysql> create table t1(f1 int)|
Query OK, 0 rows affected (0.00 sec)

mysql> create procedure proc()
    -> begin
    ->   DECLARE CONTINUE HANDLER FOR SQLSTATE '42S22' SET @b:= 'error';
    ->   DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @a:= 'exception';
    ->   select x from t1;
    -> END|
Query OK, 0 rows affected (0.00 sec)

mysql> call proc|
Query OK, 0 rows affected (0.00 sec)

mysql> select @a,@b|
+-----------+-------+
| @a        | @b    |
+-----------+-------+
| exception | error | 
+-----------+-------+
1 row in set (0.00 sec)

mysql> select version()|
+--------------+
| version()    |
+--------------+
| 5.0.46-debug | 
+--------------+
1 row in set (0.00 sec)
[8 Jan 2008 20:40] Davi Arnaut
Can't repeat on 5.0-bk, committing just the test case.
[8 Jan 2008 20:43] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/40721

ChangeSet@1.2583, 2008-01-08 18:43:25-02:00, davi@mysql.com +2 -0
  Bug#29770 Two handlers are allowed to catch an error in an stored procedure.
  
  Add test case.
[25 Jan 2008 12:34] Bugs System
Pushed into 5.0.56
[25 Jan 2008 12:35] Bugs System
Pushed into 5.1.24-rc
[25 Jan 2008 12:40] Bugs System
Pushed into 6.0.5-alpha