oceanbase
103 строки · 2.6 Кб
1# owner: linlin.xll
2# owner group: SQL1
3# description:
4#tags: pl
5
6--disable_query_log
7set @@session.explicit_defaults_for_timestamp=off;
8--enable_query_log
9--result_format 4
10#
11# Bug #11602: SP with very large body not handled well
12#
13
14--disable_warnings
15drop procedure if exists test.longprocedure;
16drop table if exists t1, t2;
17--enable_warnings
18
19create table t1 (a int);
20insert into t1 values (1),(2),(3);
21
22#let $body=`select repeat('select count(*) from t1 into out1;\n', 3072)`;
23let $body=`select repeat('select count(*) from t1 into out1;\n', 100)`;
24
25delimiter //;
26--disable_query_log
27eval select length('$body') as length//
28eval create procedure test.longprocedure (out out1 int) deterministic
29begin
30$body
31end//
32--enable_query_log
33
34delimiter ;//
35
36# this is larger than the length above, because it includes the 'begin' and
37# 'end' bits and some whitespace
38select length(routine_definition) from information_schema.routines where routine_schema = 'test' and routine_name = 'longprocedure';
39
40set ob_query_timeout=10000000000;
41set ob_trx_timeout=10000000000;
42call test.longprocedure(@value); select @value;
43set ob_query_timeout=default;
44set ob_trx_timeout=default;
45
46drop procedure test.longprocedure;
47drop table t1;
48#
49# Bug #9819 "Cursors: Mysql Server Crash while fetching from table with 5
50# million records.":
51# To really test the bug, increase the number of loop iterations ($1).
52# For 4 millions set $1 to 22.
53create table t1 (f1 char(100) , f2 mediumint , f3 int , f4 real, f5 numeric);
54insert into t1 (f1, f2, f3, f4, f5) values
55("This is a test case for for Bug#9819", 1, 2, 3.0, 4.598);
56create table t2 like t1;
57let $1=8;
58--disable_query_log
59--disable_result_log
60while ($1)
61{
62eval insert into t1 select * from t1;
63dec $1;
64}
65--enable_result_log
66--enable_query_log
67select count(*) from t1;
68select count(*) from t2;
69--disable_warnings
70drop procedure if exists p1;
71--enable_warnings
72delimiter |;
73create procedure p1()
74begin
75declare done integer default 0;
76declare vf1 char(100) ;
77declare vf2 mediumint;
78declare vf3 int ;
79declare vf4 real ;
80declare vf5 numeric ;
81declare cur1 cursor for select f1,f2,f3,f4,f5 from t1;
82declare continue handler for sqlstate '02000' set done = 1;
83open cur1;
84while done <> 1 do
85fetch cur1 into vf1, vf2, vf3, vf4, vf5;
86if not done then
87insert into t2 values (vf1, vf2, vf3, vf4, vf5);
88end if;
89end while;
90close cur1;
91end|
92delimiter ;|
93set ob_query_timeout=10000000000;
94set ob_trx_timeout=10000000000;
95call p1();
96set ob_query_timeout=default;
97set ob_trx_timeout=default;
98select count(*) from t1;
99select count(*) from t2;
100select f1 from t1 limit 1;
101select f1 from t2 limit 1;
102drop procedure p1;
103drop table t1, t2;
104