mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / t / sp-threads.test
blobe1012e2b72df51451dc9989dddc24f7932c1f988
1 # This test should work in embedded server after mysqltest is fixed
2 -- source include/not_embedded.inc
4 # Testing stored procedures with multiple connections,
5 # except security/privilege tests, they go to sp-security.test
8 # Save the initial number of concurrent sessions
9 --source include/count_sessions.inc
11 connect (con1root,localhost,root,,);
12 connect (con2root,localhost,root,,);
13 connect (con3root,localhost,root,,);
15 connection con1root;
16 use test;
18 --disable_warnings
19 drop table if exists t1;
20 --enable_warnings
21 create table t1 (s1 int, s2 int, s3 int);
23 delimiter //;
24 create procedure bug4934()
25 begin
26    insert into t1 values (1,0,1);
27 end//
28 delimiter ;//
31 connection con2root;
32 use test;
34 call bug4934();
35 select * from t1;
38 connection con1root;
40 drop table t1;
41 create table t1 (s1 int, s2 int, s3 int);
43 drop procedure bug4934;
44 delimiter //;
45 create procedure bug4934()
46 begin
47 end//
48 delimiter ;//
51 connection con2root;
53 select * from t1;
54 call bug4934();
55 select * from t1;
57 connection con1root;
59 drop table t1;
60 drop procedure bug4934;
64 # Bug#9486 Can't perform multi-update in stored procedure
66 --disable_warnings
67 drop procedure if exists bug9486;
68 drop table if exists t1, t2;
69 --enable_warnings
70 create table t1 (id1 int, val int);
71 create table t2 (id2 int);
73 create procedure bug9486()
74   update t1, t2 set val= 1 where id1=id2;
75 call bug9486();
76 # Let us check that SP invocation requires write lock for t2.
77 connection con2root;
78 lock tables t2 write;
79 connection con1root;
80 send call bug9486();
81 connection con2root;
82 --sleep 2
83 # There should be call statement in locked state.
84 --replace_column 1 # 3 localhost 6 #
85 show processlist;
86 unlock tables;
87 connection con1root;
88 reap;
90 drop procedure bug9486;
91 drop table t1, t2;
95 # Bug#11158 Can't perform multi-delete in stored procedure
97 --disable_warnings
98 drop procedure if exists bug11158;
99 --enable_warnings
100 create procedure bug11158() delete t1 from t1, t2 where t1.id = t2.id;
101 create table t1 (id int, j int);
102 insert into t1 values (1, 1), (2, 2);
103 create table t2 (id int);
104 insert into t2 values (1);
105 # Procedure should work and cause proper effect (delete only first row)
106 call bug11158();
107 select * from t1;
108 # Also let us test that we obtain only read (and thus non exclusive) lock
109 # for table from which we are not going to delete rows.
110 connection con2root;
111 lock tables t2 read;
112 connection con1root;
113 call bug11158();
114 connection con2root;
115 unlock tables;
116 connection con1root;
117 # Clean-up
118 drop procedure bug11158;
119 drop table t1, t2;
123 # Bug#11554 Server crashes on statement indirectly using non-cached function
125 --disable_warnings
126 drop function if exists bug11554;
127 drop view if exists v1;
128 --enable_warnings
129 create table t1 (i int);
130 create function bug11554 () returns int return 1;
131 create view v1 as select bug11554() as f;
132 connection con2root;
133 # This should not crash server
134 insert into t1 (select f from v1);
135 # Clean-up
136 connection con1root;
137 drop function bug11554;
138 drop table t1;
139 drop view v1;
142 # Bug#12228 Crash happens during calling specific SP in multithread environment
143 --disable_warnings
144 drop procedure if exists p1;
145 drop procedure if exists p2;
146 --enable_warnings
148 connection con1root;
149 delimiter |;
150 create table t1 (s1 int)|
151 create procedure p1() select * from t1|
152 create procedure p2()
153 begin
154   insert into t1 values (1);
155   call p1();
156   select * from t1;
157 end|
158 delimiter ;|
160 connection con2root;
161 use test;
162 lock table t1 write;
164 connection con1root;
165 send call p2();
167 connection con3root;
168 use test;
169 drop procedure p1;
170 create procedure p1() select * from t1;
172 connection con2root;
173 unlock tables;
175 connection con1root;
176 # Crash will be here if we hit Bug#12228
177 reap;
179 drop procedure p1;
180 drop procedure p2;
181 drop table t1;
185 # Bug#NNNN New bug synopsis
187 #--disable_warnings
188 #drop procedure if exists bugNNNN;
189 #--enable_warnings
190 #create procedure bugNNNN...
192 connection default;
193 disconnect con1root;
194 disconnect con2root;
195 disconnect con3root;
197 # Wait till we reached the initial number of concurrent sessions
198 --source include/wait_until_count_sessions.inc