1
# Fibonacci, for recursion test. (Yet Another Numerical series :)
2
# Split from main.sp due to problems reported in Bug#15866
5
drop table if exists t3;
7
create table t3 ( f bigint unsigned not null );
9
# We deliberately do it the awkward way, fetching the last two
10
# values from the table, in order to exercise various statements
11
# and table accesses at each turn.
13
drop procedure if exists fib;
16
# Now for multiple statements...
19
create procedure fib(n int unsigned)
23
declare x, y bigint unsigned;
24
declare c cursor for select f from t3 order by f desc limit 2;
28
insert into t3 values (x+y);
30
## Close the cursor AFTER the recursion to ensure that the stack
31
## frame is somewhat intact.
38
set @@max_sp_recursion_depth= 20|
40
insert into t3 values (0), (1)|
42
# The small number of recursion levels is intentional.
44
# Bug#15866 main.sp fails (thread stack limit
45
# insufficient for recursive call "fib(20)")
46
# which affects some platforms.
49
select * from t3 order by f asc|
53
set @@max_sp_recursion_depth= 0|