Bug #36348 SQLWARNING and SQLEXCEPTIONs treated differently
Submitted: 25 Apr 2008 15:37 Modified: 27 Apr 2008 7:15
Reporter: Sarah Sproehnle Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.0 and 5.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: stored procedures sqlwarning

[25 Apr 2008 15:37] Sarah Sproehnle
Description:
An unhandled error in a stored procedure is propagated to the calling stored procedure and can be handled there.  However, a warning cannot be handled by the calling procedure.  Example..  This works as desired:
DELIMITER //
CREATE PROCEDURE a ()
BEGIN
  DECLARE EXIT HANDLER FOR 1062 SELECT 'dup key';
  CALL b();
END//

CREATE PROCEDURE b ()
INSERT INTO Country (name, code) VALUES ('Sarah', 'USA'); -- causes error 1062

However, in this example, procedure `a` does not catch the warning:
CREATE PROCEDURE a ()
BEGIN
  DECLARE EXIT HANDLER FOR 1292 SELECT 'casting error';
  CALL b();
END//

CREATE PROCEDURE b ()
SELECT cast('string' AS unsigned int);

How to repeat:
DELIMITER //
CREATE PROCEDURE a ()
BEGIN
  DECLARE EXIT HANDLER FOR 1292 SELECT 'casting error';
  CALL b();
END//

CREATE PROCEDURE b ()
SELECT cast('string' AS unsigned int);//

CALL a()//

Suggested fix:
Treat warnings similar to errors.
[25 Apr 2008 15:41] Davi Arnaut
Very similar if not a duplicate of Bug#23032
[25 Apr 2008 16:19] MySQL Verification Team
Thank you for the report. Looks really it is duplicate of bug
http://bugs.mysql.com/bug.php?id=23032 according Davi's comments.
Do you agree?. Thanks in advance.
[25 Apr 2008 19:38] Sarah Sproehnle
Yes, it appears this is a duplicate.  Is this patch going to be ported to 5.1?
[27 Apr 2008 7:15] Sveta Smirnova
Thank you for the feedback.

Closing as duplicate of bug #23032 because last comment.

Target version of latter bug is 6.0+, so I have no idea if fix would be pushed into 5.1