Commit 5f006200 authored by unknown's avatar unknown

Fixed BUG#7299: Stored procedures: exception handler catches not-found conditions

mysql-test/r/sp-error.result:
  Added test case for BUG#7299.
mysql-test/t/sp-error.test:
  Added test case for BUG#7299.
sql/sp_rcontext.cc:
  Corrected cut&paste error; make sure we only catch actual errors with sqlexception.
parent 99c0dd3b
No related merge requests found
......@@ -513,4 +513,17 @@ call bug9566()|
ERROR HY000: Table 'proc' was not locked with LOCK TABLES
unlock tables|
drop procedure bug9566|
drop procedure if exists bug7299|
create procedure bug7299()
begin
declare v int;
declare c cursor for select val from t1;
declare exit handler for sqlexception select 'Error!';
open c;
fetch c into v;
end|
delete from t1|
call bug7299()|
ERROR 02000: No data to FETCH
drop procedure bug7299|
drop table t1|
......@@ -720,6 +720,28 @@ unlock tables|
drop procedure bug9566|
#
# BUG#7299: Stored procedures: exception handler catches not-found conditions
#
--disable_warnings
drop procedure if exists bug7299|
--enable_warnings
create procedure bug7299()
begin
declare v int;
declare c cursor for select val from t1;
declare exit handler for sqlexception select 'Error!';
open c;
fetch c into v;
end|
delete from t1|
--error ER_SP_FETCH_NO_DATA
call bug7299()|
drop procedure bug7299|
#
# BUG#NNNN: New bug synopsis
#
......
......@@ -95,8 +95,8 @@ sp_rcontext::find_handler(uint sql_errno,
found= i;
break;
case sp_cond_type_t::exception:
if ((sqlstate[0] != '0' || sqlstate[1] > '2' ||
level == MYSQL_ERROR::WARN_LEVEL_ERROR) &&
if ((sqlstate[0] != '0' || sqlstate[1] > '2') &&
level == MYSQL_ERROR::WARN_LEVEL_ERROR &&
(found < 0 || m_handler[found].cond->type > sp_cond_type_t::state))
found= i;
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment