2
# Test of init_connect variable
5
# should work with embedded server after mysqltest is fixed
6
-- source include/not_embedded.inc
7
connect (con0,localhost,root,,);
10
connect (con1,localhost,user_1,,);
14
set global init_connect="set @a=2;set @b=3";
15
connect (con2,localhost,user_1,,);
19
set GLOBAL init_connect=DEFAULT;
20
connect (con3,localhost,user_1,,);
24
set global init_connect="drop table if exists t1; create table t1(a char(10));\
25
insert into t1 values ('\0');insert into t1 values('abc')";
26
connect (con4,localhost,user_1,,);
28
select hex(a) from t1;
30
set GLOBAL init_connect="adsfsdfsdfs";
31
connect (con5,localhost,user_1,,);
44
--echo End of 4.1 tests
49
create table t1 (x int);
50
insert into t1 values (3), (5), (7);
51
create table t2 (y int);
53
create user mysqltest1@localhost;
54
grant all privileges on test.* to mysqltest1@localhost;
56
# Create a simple procedure
58
set global init_connect="create procedure p1() select * from t1";
59
connect (con1,localhost,mysqltest1,,);
67
# Create a multi-result set procedure
69
set global init_connect="create procedure p1(x int)\
71
select count(*) from t1;\
75
connect (con1,localhost,mysqltest1,,);
83
# Just call it - this will not generate any output
85
set global init_connect="call p1(4711)";
86
connect (con1,localhost,mysqltest1,,);
95
set global init_connect="drop procedure if exists p1";
96
connect (con1,localhost,mysqltest1,,);
98
--error ER_SP_DOES_NOT_EXIST
104
# Execution of a more complex procedure
107
create procedure p1(out sum int)
109
declare n int default 0;
110
declare c cursor for select * from t1;
111
declare exit handler for not found
130
# Call the procedure with a cursor
131
set global init_connect="call p1(@sum)";
132
connect (con1,localhost,mysqltest1,,);
143
create procedure p1(tbl char(10), v int)
145
set @s = concat('insert into ', tbl, ' values (?)');
147
prepare stmt1 from @s;
148
execute stmt1 using @v;
149
deallocate prepare stmt1;
152
# Call the procedure with prepared statements
153
set global init_connect="call p1('t1', 11)";
154
connect (con1,localhost,mysqltest1,,);
165
create function f1() returns int
169
select count(*) into n from t1;
174
set global init_connect="set @x = f1()";
175
connect (con1,localhost,mysqltest1,,);
184
set global init_connect="create view v1 as select f1()";
185
connect (con1,localhost,mysqltest1,,);
194
set global init_connect="drop view v1";
195
connect (con1,localhost,mysqltest1,,);
197
--error ER_NO_SUCH_TABLE
204
# We can't test "create trigger", since this requires super privileges
205
# in 5.0, but with super privileges, init_connect is not executed.
206
# (However, this can be tested in 5.1)
208
#set global init_connect="create trigger trg1\
209
# after insert on t2\
211
# insert into t1 values (new.y)";
212
#connect (con1,localhost,mysqltest1,,);
214
#insert into t2 values (2), (4);
223
insert into t1 values (new.y);
226
set global init_connect="insert into t2 values (13), (17), (19)";
227
connect (con1,localhost,mysqltest1,,);
235
set global init_connect=default;
237
revoke all privileges, grant option from mysqltest1@localhost;
238
drop user mysqltest1@localhost;