Commit 5174a837 authored by unknown's avatar unknown

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.
parent 25c45fd1
......@@ -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
{
......
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