mirror of
https://github.com/MariaDB/server.git
synced 2026-05-10 17:14:30 +02:00
Fixed BUG#6022: Stored procedure shutdown problem with self-calling function.
Fixed the pre-caching of functions. It now gives the expected stack overrun error for functions recursing too deep. mysql-test/r/sp.result: New test case for BUG#6022. mysql-test/t/sp.test: New test case for BUG#6022. sql/sp.cc: Cache function first, then recurse, or the pre-caching loops infinitely for recursive functions.
This commit is contained in:
parent
d73b379cd1
commit
d925bcd8d6
3 changed files with 33 additions and 1 deletions
|
|
@ -1934,6 +1934,19 @@ s1
|
|||
1
|
||||
drop procedure bug4905|
|
||||
drop table t3|
|
||||
drop function if exists bug6022|
|
||||
create function bug6022(x int) returns int
|
||||
begin
|
||||
if x < 0 then
|
||||
return 0;
|
||||
else
|
||||
return bug6022(x-1);
|
||||
end if;
|
||||
end|
|
||||
select bug6022(5)|
|
||||
bug6022(5)
|
||||
0
|
||||
drop function bug6022|
|
||||
drop table if exists fac|
|
||||
create table fac (n int unsigned not null primary key, f bigint unsigned)|
|
||||
create procedure ifac(n int unsigned)
|
||||
|
|
|
|||
|
|
@ -2090,6 +2090,25 @@ select * from t3|
|
|||
drop procedure bug4905|
|
||||
drop table t3|
|
||||
|
||||
#
|
||||
# BUG#6022: Stored procedure shutdown problem with self-calling function.
|
||||
#
|
||||
--disable_warnings
|
||||
drop function if exists bug6022|
|
||||
--enable_warnings
|
||||
|
||||
create function bug6022(x int) returns int
|
||||
begin
|
||||
if x < 0 then
|
||||
return 0;
|
||||
else
|
||||
return bug6022(x-1);
|
||||
end if;
|
||||
end|
|
||||
|
||||
select bug6022(5)|
|
||||
drop function bug6022|
|
||||
|
||||
|
||||
#
|
||||
# Some "real" examples
|
||||
|
|
|
|||
|
|
@ -990,12 +990,12 @@ sp_cache_functions(THD *thd, LEX *lex)
|
|||
if (db_find_routine(thd, TYPE_ENUM_FUNCTION, &name, &sp)
|
||||
== SP_OK)
|
||||
{
|
||||
sp_cache_insert(&thd->sp_func_cache, sp);
|
||||
ret= sp_cache_functions(thd, newlex);
|
||||
delete newlex;
|
||||
thd->lex= oldlex;
|
||||
if (ret)
|
||||
break;
|
||||
sp_cache_insert(&thd->sp_func_cache, sp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue