mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +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:
@@ -893,6 +893,21 @@ avg 0 4.4
|
|||||||
delete from t1|
|
delete from t1|
|
||||||
delete from t2|
|
delete from t2|
|
||||||
drop procedure bug1874|
|
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|
|
drop table if exists fac|
|
||||||
create table fac (n int unsigned not null primary key, f bigint unsigned)|
|
create table fac (n int unsigned not null primary key, f bigint unsigned)|
|
||||||
create procedure ifac(n int unsigned)
|
create procedure ifac(n int unsigned)
|
||||||
|
@@ -1036,6 +1036,25 @@ delete from t1|
|
|||||||
delete from t2|
|
delete from t2|
|
||||||
drop procedure bug1874|
|
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
|
# Some "real" examples
|
||||||
|
@@ -72,15 +72,15 @@ sp_rcontext::find_handler(uint sql_errno)
|
|||||||
found= 1;
|
found= 1;
|
||||||
break;
|
break;
|
||||||
case sp_cond_type_t::warning:
|
case sp_cond_type_t::warning:
|
||||||
if (sqlstate[0] == '0' && sqlstate[0] == '1')
|
if (sqlstate[0] == '0' && sqlstate[1] == '1')
|
||||||
found= 1;
|
found= 1;
|
||||||
break;
|
break;
|
||||||
case sp_cond_type_t::notfound:
|
case sp_cond_type_t::notfound:
|
||||||
if (sqlstate[0] == '0' && sqlstate[0] == '2')
|
if (sqlstate[0] == '0' && sqlstate[1] == '2')
|
||||||
found= 1;
|
found= 1;
|
||||||
break;
|
break;
|
||||||
case sp_cond_type_t::exception:
|
case sp_cond_type_t::exception:
|
||||||
if (sqlstate[0] != '0' || sqlstate[0] > '2')
|
if (sqlstate[0] != '0' || sqlstate[1] > '2')
|
||||||
found= 1;
|
found= 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user