mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / r / sp-fib.result
bloba26e104c1e8319bcea3be852dba38f6428b1069c
1 drop table if exists t3;
2 create table t3 ( f bigint unsigned not null );
3 drop procedure if exists fib;
4 create procedure fib(n int unsigned)
5 begin
6 if n > 1 then
7 begin
8 declare x, y bigint unsigned;
9 declare c cursor for select f from t3 order by f desc limit 2;
10 open c;
11 fetch c into y;
12 fetch c into x;
13 insert into t3 values (x+y);
14 call fib(n-1);
15 ## Close the cursor AFTER the recursion to ensure that the stack
16 ## frame is somewhat intact.
17 close c;
18 end;
19 end if;
20 end|
21 set @@max_sp_recursion_depth= 20|
22 insert into t3 values (0), (1)|
23 call fib(4)|
24 select * from t3 order by f asc|
31 drop table t3|
32 drop procedure fib|
33 set @@max_sp_recursion_depth= 0|