1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Fix BUG#2260: Handler NOT FOUND declaration does't work in stored procedure

mysql-test/r/sp.result:
  Test case for BUG#2260.
mysql-test/t/sp.test:
  Test case for BUG#2260.
sql/sp_rcontext.cc:
  Detect warning and not found, and exception condition correctly.
This commit is contained in:
unknown
2004-01-08 10:55:10 +01:00
parent 027535733d
commit 03b652cfbf
3 changed files with 37 additions and 3 deletions

View File

@ -893,6 +893,21 @@ avg 0 4.4
delete from t1|
delete from t2|
drop procedure bug1874|
create procedure bug2260()
begin
declare v1 int;
declare continue handler for not found set @x2 = 1;
declare c1 cursor for select data from t1;
open c1;
fetch c1 into v1;
set @x2 = 2;
close c1;
end|
call bug2260()|
select @x2|
@x2
2
drop procedure bug2260|
drop table if exists fac|
create table fac (n int unsigned not null primary key, f bigint unsigned)|
create procedure ifac(n int unsigned)

View File

@ -1036,6 +1036,25 @@ delete from t1|
delete from t2|
drop procedure bug1874|
#
# BUG#2260
#
create procedure bug2260()
begin
declare v1 int;
declare continue handler for not found set @x2 = 1;
declare c1 cursor for select data from t1;
open c1;
fetch c1 into v1;
set @x2 = 2;
close c1;
end|
call bug2260()|
select @x2|
drop procedure bug2260|
#
# Some "real" examples

View File

@ -72,15 +72,15 @@ sp_rcontext::find_handler(uint sql_errno)
found= 1;
break;
case sp_cond_type_t::warning:
if (sqlstate[0] == '0' && sqlstate[0] == '1')
if (sqlstate[0] == '0' && sqlstate[1] == '1')
found= 1;
break;
case sp_cond_type_t::notfound:
if (sqlstate[0] == '0' && sqlstate[0] == '2')
if (sqlstate[0] == '0' && sqlstate[1] == '2')
found= 1;
break;
case sp_cond_type_t::exception:
if (sqlstate[0] != '0' || sqlstate[0] > '2')
if (sqlstate[0] != '0' || sqlstate[1] > '2')
found= 1;
break;
}