Bug #2780 Stored procedure exit handler ignored for warnings
Submitted: 13 Feb 2004 13:05 Modified: 6 Apr 2004 7:33
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.0-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Bugs System CPU Architecture:Any

[13 Feb 2004 13:05] Peter Gulutzan
Description:
In a stored procedure, I can use EXIT handlers for errors (SQLERROR) and behaviour is as 
expected, and as in the manual. But EXIT handlers for warnings (SQLWARNING) are not 
handled and do not cause exit. And "show warnings" tells me little. 
 
 

How to repeat:
mysql> delimiter // 
 
mysql> create procedure p () begin declare exit handler for sqlwarning, 1263 set @x = 1; 
set @x = 0; insert into t values (123456789012); insert into t values (0); end;// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> create table t (s1 smallint)// 
Query OK, 0 rows affected (0.38 sec) 
 
mysql> insert into t values (123456789012)// 
Query OK, 1 row affected, 1 warning (0.27 sec) 
 
mysql> show warnings// 
+---------+------+-------------------------------------------------------+ 
| Level   | Code | Message                                               | 
+---------+------+-------------------------------------------------------+ 
| Warning | 1263 | Data truncated, out of range for column 's1' at row 1 | 
+---------+------+-------------------------------------------------------+ 
1 row in set (0.00 sec) 
 
mysql> call p()// 
Query OK, 0 rows affected, 1 warning (0.00 sec) 
 
mysql> show warnings// 
Empty set (0.00 sec) 
 
mysql> select @x// 
+------+ 
| @x   | 
+------+ 
| 0    | 
+------+ 
1 row in set (0.00 sec) 
 
mysql> select * from t// 
+-------+ 
| s1    | 
+-------+ 
| 32767 | 
| 32767 | 
|     0 | 
+-------+ 
3 rows in set (0.00 sec) 
 
Although a too-big INSERT value causes "Data truncated..." (as we see doing the INSERT), 
it is clear that the EXIT handler didn't come into play (we see that @x did not become 1), 
and it is clear that the procedure continued till the end (see see that the INSERT of 0 was 
done).
[20 Feb 2004 9:02] Dean Ellis
Verified against 5.0.1-alpha-log.
[6 Apr 2004 7:33] Per-Erik Martin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html