2
# Test of init_connect variable
5
# should work with embedded server after mysqltest is fixed
6
--source include/not_embedded.inc
8
# Save the initial number of concurrent sessions
9
--source include/count_sessions.inc
11
--source include/add_anonymous_users.inc
13
connect (con0,localhost,root,,);
16
connect (con1,localhost,user_1,,);
20
set global init_connect="set @a=2;set @b=3";
21
connect (con2,localhost,user_1,,);
25
set GLOBAL init_connect=DEFAULT;
26
connect (con3,localhost,user_1,,);
30
set global init_connect="drop table if exists t1; create table t1(a char(10));\
31
insert into t1 values ('\0');insert into t1 values('abc')";
32
connect (con4,localhost,user_1,,);
34
select hex(a) from t1;
36
set GLOBAL init_connect="adsfsdfsdfs";
37
connect (con5,localhost,user_1,,);
50
--source include/delete_anonymous_users.inc
52
--echo End of 4.1 tests
57
create table t1 (x int);
58
insert into t1 values (3), (5), (7);
59
create table t2 (y int);
61
create user mysqltest1@localhost;
62
grant all privileges on test.* to mysqltest1@localhost;
64
# Create a simple procedure
66
set global init_connect="create procedure p1() select * from t1";
67
connect (con1,localhost,mysqltest1,,);
75
# Create a multi-result set procedure
77
set global init_connect="create procedure p1(x int)\
79
select count(*) from t1;\
83
connect (con1,localhost,mysqltest1,,);
91
# Just call it - this will not generate any output
93
set global init_connect="call p1(4711)";
94
connect (con1,localhost,mysqltest1,,);
103
set global init_connect="drop procedure if exists p1";
104
connect (con1,localhost,mysqltest1,,);
106
--error ER_SP_DOES_NOT_EXIST
112
# Execution of a more complex procedure
115
create procedure p1(out sum int)
117
declare n int default 0;
118
declare c cursor for select * from t1;
119
declare exit handler for not found
138
# Call the procedure with a cursor
139
set global init_connect="call p1(@sum)";
140
connect (con1,localhost,mysqltest1,,);
151
create procedure p1(tbl char(10), v int)
153
set @s = concat('insert into ', tbl, ' values (?)');
155
prepare stmt1 from @s;
156
execute stmt1 using @v;
157
deallocate prepare stmt1;
160
# Call the procedure with prepared statements
161
set global init_connect="call p1('t1', 11)";
162
connect (con1,localhost,mysqltest1,,);
173
create function f1() returns int
177
select count(*) into n from t1;
182
set global init_connect="set @x = f1()";
183
connect (con1,localhost,mysqltest1,,);
192
set global init_connect="create view v1 as select f1()";
193
connect (con1,localhost,mysqltest1,,);
202
set global init_connect="drop view v1";
203
connect (con1,localhost,mysqltest1,,);
205
--error ER_NO_SUCH_TABLE
212
# We can't test "create trigger", since this requires super privileges
213
# in 5.0, but with super privileges, init_connect is not executed.
214
# (However, this can be tested in 5.1)
216
#set global init_connect="create trigger trg1\
217
# after insert on t2\
219
# insert into t1 values (new.y)";
220
#connect (con1,localhost,mysqltest1,,);
222
#insert into t2 values (2), (4);
231
insert into t1 values (new.y);
234
set global init_connect="insert into t2 values (13), (17), (19)";
235
connect (con1,localhost,mysqltest1,,);
244
# Set init connect back to the value provided in init_connect-master.opt
245
# doesn't matter as server will be restarted
246
set global init_connect="set @a='a\\0c'";
248
revoke all privileges, grant option from mysqltest1@localhost;
249
drop user mysqltest1@localhost;
252
# Wait till all disconnects are completed
253
--source include/wait_until_count_sessions.inc