Bug #14197 Triggers: procedure handler is ignored
Submitted: 21 Oct 2005 1:05 Modified: 10 Nov 2005 9:09
Reporter: Peter Gulutzan Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.16-debug OS:Linux (SUSE 9.2)
Assigned to: Assigned Account CPU Architecture:Any

[21 Oct 2005 1:05] Peter Gulutzan
Description:
Ordinarily an SQLEXCEPTION handler catches exceptions that
occur during execution of a stored procedure. But if the stored
procedure is invoked from a trigger, the exception-handler code
isn't executed.

How to repeat:
mysql> create procedure p5 () begin declare exit handler for sqlexception set @a = 5; drop table t; end//
Query OK, 0 rows affected (0.00 sec)

mysql> create table t5 (s1 int, s2 char(5))//
Query OK, 0 rows affected (0.01 sec)

mysql> create trigger t5_ai after insert on t5 for each row call p5()//
Query OK, 0 rows affected (0.01 sec)

mysql> drop table if exists t//
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> insert into t5 values (0,'a')//
ERROR 1146 (42S02): Table 'db88.t' doesn't exist
mysql> select @a//
+------+
| @a   |
+------+
| NULL |
+------+
1 row in set (0.00 sec)
[10 Nov 2005 9:09] Dmitry Lenev
Hi, Peter!

This bug is duplicate of bug #8407 "Stored function ignores exception handler" (implementation of triggers and functions in MySQL share a lot of code, so these two bugs have common cause).