Commit 7944acbb authored by pem@mysql.comhem.se's avatar pem@mysql.comhem.se

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.
parent bf60309e
...@@ -1934,6 +1934,19 @@ s1 ...@@ -1934,6 +1934,19 @@ s1
1 1
drop procedure bug4905| drop procedure bug4905|
drop table t3| 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| 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)
......
...@@ -2090,6 +2090,25 @@ select * from t3| ...@@ -2090,6 +2090,25 @@ select * from t3|
drop procedure bug4905| drop procedure bug4905|
drop table t3| 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 # Some "real" examples
......
...@@ -990,12 +990,12 @@ sp_cache_functions(THD *thd, LEX *lex) ...@@ -990,12 +990,12 @@ sp_cache_functions(THD *thd, LEX *lex)
if (db_find_routine(thd, TYPE_ENUM_FUNCTION, &name, &sp) if (db_find_routine(thd, TYPE_ENUM_FUNCTION, &name, &sp)
== SP_OK) == SP_OK)
{ {
sp_cache_insert(&thd->sp_func_cache, sp);
ret= sp_cache_functions(thd, newlex); ret= sp_cache_functions(thd, newlex);
delete newlex; delete newlex;
thd->lex= oldlex; thd->lex= oldlex;
if (ret) if (ret)
break; break;
sp_cache_insert(&thd->sp_func_cache, sp);
} }
else else
{ {
......
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