Bug #36185 Incorrect precedence for warning and exception handlers
Submitted: 17 Apr 2008 21:07
Reporter: Davi Arnaut
Status: Verified
Category:Server: SP Severity:S3 (Non-critical)
Version:6.0, 5.0, 5.1 OS:Any
Assigned to: Davi Arnaut Target Version:
Triage: Triaged: D4 (Minor)

[17 Apr 2008 21:07] Davi Arnaut
Description:
MySQL calls the handler for the first signaled condition during the execution of a stored
procedure statement, meaning that if a warning is signaled first, it will search for a
handler at that point and if a handler is found it won't look further for other handlers
even if new warning/exception conditions occur.

How to repeat:
create table t1 (a int, b int not null);
delimiter |;
create procedure p()
begin
  declare continue handler for sqlwarning select 'warning';
  declare continue handler for sqlexception select 'exception';
  insert into t1 values (cast('10 ' as signed), NULL);
end|
delimiter ;|
call p();

Although the insert statement throw a exception, only the handler for the warning will be
called because the warning generated by the cast is signaled first.