diff options
-rw-r--r-- | mysql-test/r/sp-error.result | 13 | ||||
-rw-r--r-- | mysql-test/t/sp-error.test | 22 | ||||
-rw-r--r-- | sql/sp_rcontext.cc | 4 |
3 files changed, 37 insertions, 2 deletions
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index ff7d71b3384..42e45f67d33 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -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| diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 51776453730..90c776a8b88 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -721,6 +721,28 @@ 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 # #--disable_warnings diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 9b29c173856..e9271146cad 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -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; |