📄 sp.result
字号:
create function f12_1() returns intbegindrop temporary table if exists t3;create temporary table t3 (id int);insert into t3 values (1), (2), (3);return f12_2();end|create function f12_2() returns intreturn (select count(*) from t3)|drop temporary table t3|select f12_1()|ERROR 42S02: Table 'test.t3' doesn't existselect f12_1() from t1 limit 1|ERROR 42S02: Table 'test.t3' doesn't existdrop function f0|drop function f1|drop function f2|drop function f3|drop function f4|drop function f5|drop function f6|drop function f7|drop function f8|drop function f9|drop function f10|drop function f11|drop function f12_1|drop function f12_2|drop view v0|drop view v1|drop view v2|delete from t1 |delete from t2 |drop table t4|drop table if exists fac|create table fac (n int unsigned not null primary key, f bigint unsigned)|drop procedure if exists ifac|create procedure ifac(n int unsigned)begindeclare i int unsigned default 1;if n > 20 thenset n = 20; # bigint overflow otherwiseend if;while i <= n dobegininsert into test.fac values (i, fac(i));set i = i + 1;end;end while;end|call ifac(20)|select * from fac|n f1 12 23 64 245 1206 7207 50408 403209 36288010 362880011 3991680012 47900160013 622702080014 8717829120015 130767436800016 2092278988800017 35568742809600018 640237370572800019 12164510040883200020 2432902008176640000drop table fac|show function status like '%f%'|Db Name Type Definer Modified Created Security_type Commenttest fac FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER drop procedure ifac|drop function fac|show function status like '%f%'|Db Name Type Definer Modified Created Security_type Commentdrop table if exists primes|create table primes (i int unsigned not null primary key,p bigint unsigned not null)|insert into primes values( 0, 3), ( 1, 5), ( 2, 7), ( 3, 11), ( 4, 13),( 5, 17), ( 6, 19), ( 7, 23), ( 8, 29), ( 9, 31),(10, 37), (11, 41), (12, 43), (13, 47), (14, 53),(15, 59), (16, 61), (17, 67), (18, 71), (19, 73),(20, 79), (21, 83), (22, 89), (23, 97), (24, 101),(25, 103), (26, 107), (27, 109), (28, 113), (29, 127),(30, 131), (31, 137), (32, 139), (33, 149), (34, 151),(35, 157), (36, 163), (37, 167), (38, 173), (39, 179),(40, 181), (41, 191), (42, 193), (43, 197), (44, 199)|drop procedure if exists opp|create procedure opp(n bigint unsigned, out pp bool)begindeclare r double;declare b, s bigint unsigned default 0;set r = sqrt(n);again:loopif s = 45 thenset b = b+200, s = 0;elsebegindeclare p bigint unsigned;select t.p into p from test.primes t where t.i = s;if b+p > r thenset pp = 1;leave again;end if;if mod(n, b+p) = 0 thenset pp = 0;leave again;end if;set s = s+1;end;end if;end loop;end|drop procedure if exists ip|create procedure ip(m int unsigned)begindeclare p bigint unsigned;declare i int unsigned;set i=45, p=201;while i < m dobegindeclare pp bool default 0;call opp(p, pp);if pp theninsert into test.primes values (i, p);set i = i+1;end if;set p = p+2;end;end while;end|show create procedure opp|Procedure sql_mode Create Procedureopp CREATE PROCEDURE `opp`(n bigint unsigned, out pp bool)begindeclare r double;declare b, s bigint unsigned default 0;set r = sqrt(n);again:loopif s = 45 thenset b = b+200, s = 0;elsebegindeclare p bigint unsigned;select t.p into p from test.primes t where t.i = s;if b+p > r thenset pp = 1;leave again;end if;if mod(n, b+p) = 0 thenset pp = 0;leave again;end if;set s = s+1;end;end if;end loop;endshow procedure status like '%p%'|Db Name Type Definer Modified Created Security_type Commenttest ip PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER test opp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER call ip(200)|select * from primes where i=45 or i=100 or i=199|i p45 211100 557199 1229drop table primes|drop procedure opp|drop procedure ip|show procedure status like '%p%'|Db Name Type Definer Modified Created Security_type Commentdrop table if exists fib|create table fib ( f bigint unsigned not null )|drop procedure if exists fib|create procedure fib(n int unsigned)beginif n > 1 thenbegindeclare x, y bigint unsigned;declare c cursor for select f from fib order by f desc limit 2;open c;fetch c into y;fetch c into x;close c;insert into fib values (x+y);call fib(n-1);end;end if;end|set @@max_sp_recursion_depth= 20|insert into fib values (0), (1)|call fib(3)|select * from fib order by f asc|f0112delete from fib|insert into fib values (0), (1)|call fib(20)|select * from fib order by f asc|f011235813213455891442333776109871597258441816765drop table fib|drop procedure fib|set @@max_sp_recursion_depth= 0|drop procedure if exists bar|create procedure bar(x char(16), y int)comment "111111111111" sql security invokerinsert into test.t1 values (x, y)|show procedure status like 'bar'|Db Name Type Definer Modified Created Security_type Commenttest bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER 111111111111alter procedure bar comment "2222222222" sql security definer|alter procedure bar comment "3333333333"|alter procedure bar|show create procedure bar|Procedure sql_mode Create Procedurebar CREATE PROCEDURE `bar`(x char(16), y int) COMMENT '3333333333'insert into test.t1 values (x, y)show procedure status like 'bar'|Db Name Type Definer Modified Created Security_type Commenttest bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER 3333333333drop procedure bar|drop procedure if exists p1|create procedure p1 ()select (select s1 from t3) from t3|create table t3 (s1 int)|call p1()|(select s1 from t3)insert into t3 values (1)|call p1()|(select s1 from t3)1drop procedure p1|drop table t3|drop function if exists foo|create function `foo` () returns intreturn 5|select `foo` ()|`foo` ()5drop function `foo`|drop function if exists t1max|Warnings:Note 1305 FUNCTION t1max does not existcreate function t1max() returns intbegindeclare x int;select max(data) into x from t1;return x;end|insert into t1 values ("foo", 3), ("bar", 2), ("zip", 5), ("zap", 1)|select t1max()|t1max()5drop function t1max|create table t3 (v char(16) not null primary key,c int unsigned not null)|create function getcount(s char(16)) returns intbegindeclare x int;select count(*) into x from t3 where v = s;if x = 0 theninsert into t3 values (s, 1);elseupdate t3 set c = c+1 where v = s;end if;return x;end|select * from t1 where data = getcount("bar")|id datazap 1select * from t3|v cbar 4select getcount("zip")|getcount("zip")0select getcount("zip")|getcount("zip")1select * from t3|v cbar 4zip 2select getcount(id) from t1 where data = 3|getcount(id)0select getcount(id) from t1 where data = 5|getcount(id)1select * from t3|v cbar 4zip 3foo 1drop table t3|drop function getcount|drop procedure if exists bug822|create procedure bug822(a_id char(16), a_data int)begindeclare n int;select count(*) into n from t1 where id = a_id and data = a_data;if n = 0 theninsert into t1 (id, data) values (a_id, a_data);end if;end|delete from t1|call bug822('foo', 42)|call bug822('foo', 42)|call bug822('bar', 666)|select * from t1|id datafoo 42bar 666delete from t1|drop procedure bug822|drop procedure if exists bug1495|create procedure bug1495()begindeclare x int;select data into x from t1 order by id limit 1;if x > 10 theninsert into t1 values ("less", x-10);elseinsert into t1 values ("more", x+10);end if;end|insert into t1 values ('foo', 12)|call bug1495()|delete from t1 where id='foo'|insert into t1 values ('bar', 7)|call bug1495()|delete from t1 where id='bar'|select * from t1|id dataless 2more 17delete from t1|drop procedure bug1495|drop procedure if exists bug1547|create procedure bug1547(s char(16))begindeclare x int;select data into x from t1 where s = id limit 1;if x > 10 theninsert into t1 values ("less", x-10);elseinsert into t1 values ("more", x+10);end if;end|insert into t1 values ("foo", 12), ("bar", 7)|call bug1547("foo")|call bug1547("bar")|select * from t1|id datafoo 12bar 7less 2more 17delete from t1|drop procedure bug1547|drop table if exists t70|create table t70 (s1 int,s2 int)|insert into t70 values (1,2)|drop procedure if exists bug1656|create procedure bug1656(out p1 int, out p2 int)select * into p1, p1 from t70|call bug1656(@1, @2)|select @1, @2|@1 @22 NULLdrop table t70|drop procedure bug1656|create table t3(a int)|drop procedure if exists bug1862|create procedure bug1862()begininsert into t3 values(2); flush tables;end|call bug1862()|call bug1862()|select * from t3|a22drop table t3|drop procedure bug1862|drop procedure if exists bug1874|create procedure bug1874()begindeclare x int;declare y double;select max(data) into x from t1;insert into t2 values ("max", x, 0);select min(data) into x from t1;insert into t2 values ("min", x, 0);select sum(data) into x from t1;insert into t2 values ("sum", x, 0);select avg(data) into y from t1;insert into t2 values ("avg", 0, y);end|insert into t1 (data) values (3), (1), (5), (9), (4)|call bug1874()|select * from t2|s i dmax 9 0min 1 0sum 22 0avg 0 4.4delete from t1|delete from t2|drop procedure bug1874|drop procedure if exists bug2260|create procedure bug2260()begindeclare v1 int;declare c1 cursor for select data from t1;declare continue handler for not found set @x2 = 1;open c1;fetch c1 into v1;set @x2 = 2;close c1;end|call bug2260()|select @x2|@x22drop procedure bug2260|drop procedure if exists bug2267_1|create procedure bug2267_1()beginshow procedure status;end|drop procedure if exists bug2267_2|create procedure bug2267_2()beginshow function status;end|drop procedure if exists bug2267_3|create procedure bug2267_3()beginshow create procedure bug2267_1;end|drop procedure if exists bug2267_4|drop function if exists bug2267_4|create procedure bug2267_4()beginshow create function bug2267_4;end|create function bug2267_4() returns int return 100|call bug2267_1()|Db Name Type Definer Modified Created Security_type Commenttest bug2267_1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER test bug2267_2 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER test bug2267_3 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER test bug2267_4 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER call bug2267_2()|Db Name Type Definer Modified Created Security_type Commenttest bug2267_4 FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER call bug2267_3()|Procedure sql_mode Create Procedurebug2267_1 CREATE PROCEDURE `bug2267_1`()beginshow procedure status;endcall bug2267_4()|Function sql_mode Create Functionbug2267_4 CREATE FUNCTION `bug2267_4`() RETURNS int(11)return 100drop procedure bug2267_1|drop procedure bug2267_2|drop procedure bug2267_3|drop procedure bug2267_4|drop function bug2267_4|drop procedure if exists bug2227|create procedure bug2227(x int)begindeclare y float default 2.6;declare z char(16) default "zzz";select 1.3, x, y, 42, z;end|call bug2227(9)|1.3 x y 42 z1.3 9 2.6 42 zzzdrop procedure bug2227|drop procedure if exists bug2614|create procedure bug2614()begindrop table if exists t3;create table t3 (id int default '0' not null);insert into t3 select 12;insert into t3 select * from t3;end|call bug2614()|call bug2614()|drop table t3|drop procedure bug2614|drop function if exists bug2674|create function bug2674() returns intreturn @@sort_buffer_size|set @osbs = @@sort_buffer_size|set @@sort_buffer_size = 262000|select bug2674()|bug2674()262000drop function bug2674|set @@sort_buffer_size = @osbs|drop procedure if exists bug3259_1 |create procedure bug3259_1 () begin end|drop procedure if exists BUG3259_2 |create procedure BUG3259_2 () begin end|drop procedure if exists Bug3259_3 |create procedure Bug3259_3 () begin end|call BUG3259_1()|call BUG3259_1()|call bug3259_2()|call Bug3259_2()|call bug3259_3()|call bUG3259_3()|drop procedure bUg3259_1|drop procedure BuG3259_2|drop procedure BUG3259_3|drop function if exists bug2772|create function bug2772() returns char(10) character set latin2return 'a'|select bug2772()|bug2772()adrop function bug2772|drop procedure if exists bug2776_1|create procedure bug2776_1(out x int)begindeclare v int;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -