2
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
5
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
7
drop database if exists mysqltest1;
8
create database mysqltest1;
10
create table t1 (a varchar(100));
12
create procedure foo()
16
insert into t1 values (b);
17
insert into t1 values (unix_timestamp());
19
select * from mysql.proc where name='foo' and db='mysqltest1';
20
db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
21
mysqltest1 foo PROCEDURE foo SQL CONTAINS_SQL NO DEFINER begin
24
insert into t1 values (b);
25
insert into t1 values (unix_timestamp());
26
end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
29
insert into t1 values (b);
30
insert into t1 values (unix_timestamp());
32
select * from mysql.proc where name='foo' and db='mysqltest1';
33
db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
34
mysqltest1 foo PROCEDURE foo SQL CONTAINS_SQL NO DEFINER begin
37
insert into t1 values (b);
38
insert into t1 values (unix_timestamp());
39
end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
42
insert into t1 values (b);
43
insert into t1 values (unix_timestamp());
45
set timestamp=1000000000;
56
create procedure foo2()
57
select * from mysqltest1.t1;
60
alter procedure foo2 contains sql;
62
create table t1 (a int);
63
create table t2 like t1;
64
create procedure foo3()
66
insert into t1 values (15);
67
grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1;
68
grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1;
69
grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1;
73
create procedure foo4()
76
insert into t2 values(3);
77
insert into t1 values (5);
80
Got one of the listed errors
85
Got one of the listed errors
86
alter procedure foo4 sql security invoker;
109
alter table t2 add unique (a);
111
create procedure foo4()
114
insert into t2 values(20),(20);
117
ERROR 23000: Duplicate entry '20' for key 'a'
120
Error 1062 Duplicate entry '20' for key 'a'
127
select * from mysql.proc where name="foo4" and db='mysqltest1';
128
db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
129
mysqltest1 foo4 PROCEDURE foo4 SQL CONTAINS_SQL YES DEFINER begin
130
insert into t2 values(20),(20);
131
end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
132
insert into t2 values(20),(20);
135
select * from mysql.proc where name="foo4" and db='mysqltest1';
136
db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
137
select * from mysql.proc where name="foo4" and db='mysqltest1';
138
db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
142
create function fn1(x int)
145
insert into t1 values (x);
148
ERROR HY000: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
149
create function fn1(x int)
153
insert into t1 values (x);
156
delete t1,t2 from t1,t2;
160
insert into t2 values(fn1(21));
176
create function fn1()
180
return unix_timestamp();
182
alter function fn1 contains sql;
183
ERROR HY000: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
185
set timestamp=1000000000;
186
insert into t1 values(fn1());
187
create function fn2()
191
return unix_timestamp();
193
ERROR HY000: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
194
set global log_bin_trust_function_creators=0;
195
set global log_bin_trust_function_creators=1;
196
set global log_bin_trust_function_creators=1;
197
create function fn2()
201
return unix_timestamp();
203
create function fn3()
213
select * from mysql.proc where db='mysqltest1';
214
db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
215
mysqltest1 fn1 FUNCTION fn1 SQL NO_SQL NO DEFINER int(11) begin
216
return unix_timestamp();
217
end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
218
return unix_timestamp();
220
mysqltest1 fn2 FUNCTION fn2 SQL NO_SQL NO DEFINER int(11) begin
221
return unix_timestamp();
222
end zedjzlcsjhd@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
223
return unix_timestamp();
225
mysqltest1 fn3 FUNCTION fn3 SQL READS_SQL_DATA NO DEFINER int(11) begin
227
end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
237
select * from mysql.proc where db='mysqltest1';
238
db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
239
mysqltest1 fn1 FUNCTION fn1 SQL NO_SQL NO DEFINER int(11) begin
240
return unix_timestamp();
241
end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
242
return unix_timestamp();
244
mysqltest1 fn2 FUNCTION fn2 SQL NO_SQL NO DEFINER int(11) begin
245
return unix_timestamp();
246
end zedjzlcsjhd@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
247
return unix_timestamp();
249
mysqltest1 fn3 FUNCTION fn3 SQL READS_SQL_DATA NO DEFINER int(11) begin
251
end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
255
alter table t2 add unique (a);
257
create function fn1(x int)
260
insert into t2 values(x),(x);
265
Error 1062 Duplicate entry '100' for key 'a'
267
ERROR 23000: Duplicate entry '20' for key 'a'
276
create trigger trg before insert on t1 for each row set new.a= 10;
277
ERROR 42000: TRIGGER command denied to user 'zedjzlcsjhd'@'localhost' for table 't1'
279
create trigger trg before insert on t1 for each row set new.a= 10;
280
insert into t1 values (1);
289
insert into t1 values (1);
296
create procedure foo()
305
drop database mysqltest1;
306
drop user "zedjzlcsjhd"@127.0.0.1;
309
drop function if exists f1;
310
create function f1() returns int reads sql data
313
declare c cursor for select a from v1;
319
create view v1 as select 1 as a;
320
create table t1 (a int);
321
insert into t1 (a) values (f1());
330
DROP PROCEDURE IF EXISTS p1;
331
DROP TABLE IF EXISTS t1;
332
CREATE TABLE t1(col VARCHAR(10));
333
CREATE PROCEDURE p1(arg VARCHAR(10))
334
INSERT INTO t1 VALUES(arg);
344
---> Test for BUG#20438
346
---> Preparing environment...
347
---> connection: master
348
DROP PROCEDURE IF EXISTS p1;
349
DROP FUNCTION IF EXISTS f1;
351
---> Synchronizing slave with master...
353
---> connection: master
355
---> Creating procedure...
356
/*!50003 CREATE PROCEDURE p1() SET @a = 1 */;
357
/*!50003 CREATE FUNCTION f1() RETURNS INT RETURN 0 */;
359
---> Checking on master...
360
SHOW CREATE PROCEDURE p1;
361
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
362
p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
363
SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
364
SHOW CREATE FUNCTION f1;
365
Function sql_mode Create Function character_set_client collation_connection Database Collation
366
f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
367
RETURN 0 latin1 latin1_swedish_ci latin1_swedish_ci
369
---> Synchronizing slave with master...
370
---> connection: master
372
---> Checking on slave...
373
SHOW CREATE PROCEDURE p1;
374
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
375
p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
376
SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
377
SHOW CREATE FUNCTION f1;
378
Function sql_mode Create Function character_set_client collation_connection Database Collation
379
f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
380
RETURN 0 latin1 latin1_swedish_ci latin1_swedish_ci
382
---> connection: master
388
drop database if exists mysqltest;
389
drop database if exists mysqltest2;
390
create database mysqltest;
391
create database mysqltest2;
393
create table t ( t integer );
394
create procedure mysqltest.test() begin end;
395
insert into t values ( 1 );
396
create procedure `\\`.test() begin end;
397
ERROR 42000: Unknown database '\\'
398
create function f1 () returns int
400
insert into t values (1);
404
set @a:= mysqltest2.f1();
405
show binlog events from <binlog_start>;
406
Log_name Pos Event_type Server_id End_log_pos Info
407
master-bin.000001 # Query # # drop database if exists mysqltest1
408
master-bin.000001 # Query # # create database mysqltest1
409
master-bin.000001 # Query # # use `mysqltest1`; create table t1 (a varchar(100))
410
master-bin.000001 # Query # # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo()
414
insert into t1 values (b);
415
insert into t1 values (unix_timestamp());
417
master-bin.000001 # Query # # use `mysqltest1`; insert into t1 values ( NAME_CONST('b',8))
418
master-bin.000001 # Query # # use `mysqltest1`; insert into t1 values (unix_timestamp())
419
master-bin.000001 # Query # # use `mysqltest1`; delete from t1
420
master-bin.000001 # Query # # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo2()
421
select * from mysqltest1.t1
422
master-bin.000001 # Query # # use `mysqltest1`; alter procedure foo2 contains sql
423
master-bin.000001 # Query # # use `mysqltest1`; drop table t1
424
master-bin.000001 # Query # # use `mysqltest1`; create table t1 (a int)
425
master-bin.000001 # Query # # use `mysqltest1`; create table t2 like t1
426
master-bin.000001 # Query # # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo3()
428
insert into t1 values (15)
429
master-bin.000001 # Query # # use `mysqltest1`; grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1
430
master-bin.000001 # Query # # use `mysqltest1`; grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1
431
master-bin.000001 # Query # # use `mysqltest1`; grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1
432
master-bin.000001 # Query # # use `mysqltest1`; CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` procedure foo4()
435
insert into t2 values(3);
436
insert into t1 values (5);
438
master-bin.000001 # Query # # use `mysqltest1`; insert into t2 values(3)
439
master-bin.000001 # Query # # use `mysqltest1`; insert into t1 values (15)
440
master-bin.000001 # Query # # use `mysqltest1`; insert into t2 values(3)
441
master-bin.000001 # Query # # use `mysqltest1`; alter procedure foo4 sql security invoker
442
master-bin.000001 # Query # # use `mysqltest1`; insert into t2 values(3)
443
master-bin.000001 # Query # # use `mysqltest1`; insert into t1 values (5)
444
master-bin.000001 # Query # # use `mysqltest1`; delete from t2
445
master-bin.000001 # Query # # use `mysqltest1`; alter table t2 add unique (a)
446
master-bin.000001 # Query # # use `mysqltest1`; drop procedure foo4
447
master-bin.000001 # Query # # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo4()
450
insert into t2 values(20),(20);
452
master-bin.000001 # Query # # use `mysqltest1`; insert into t2 values(20),(20)
453
master-bin.000001 # Query # # use `mysqltest1`; drop procedure foo4
454
master-bin.000001 # Query # # use `mysqltest1`; drop procedure foo
455
master-bin.000001 # Query # # use `mysqltest1`; drop procedure foo2
456
master-bin.000001 # Query # # use `mysqltest1`; drop procedure foo3
457
master-bin.000001 # Query # # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn1(x int)
461
insert into t1 values (x);
464
master-bin.000001 # Query # # use `mysqltest1`; delete t1,t2 from t1,t2
465
master-bin.000001 # Query # # use `mysqltest1`; SELECT `mysqltest1`.`fn1`(20)
466
master-bin.000001 # Query # # use `mysqltest1`; insert into t2 values(fn1(21))
467
master-bin.000001 # Query # # use `mysqltest1`; drop function fn1
468
master-bin.000001 # Query # # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn1()
472
return unix_timestamp();
474
master-bin.000001 # Query # # use `mysqltest1`; delete from t1
475
master-bin.000001 # Query # # use `mysqltest1`; insert into t1 values(fn1())
476
master-bin.000001 # Query # # use `mysqltest1`; CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` function fn2()
480
return unix_timestamp();
482
master-bin.000001 # Query # # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn3()
489
master-bin.000001 # Query # # use `mysqltest1`; delete from t2
490
master-bin.000001 # Query # # use `mysqltest1`; alter table t2 add unique (a)
491
master-bin.000001 # Query # # use `mysqltest1`; drop function fn1
492
master-bin.000001 # Query # # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn1(x int)
495
insert into t2 values(x),(x);
498
master-bin.000001 # Query # # use `mysqltest1`; SELECT `mysqltest1`.`fn1`(100)
499
master-bin.000001 # Query # # use `mysqltest1`; SELECT `mysqltest1`.`fn1`(20)
500
master-bin.000001 # Query # # use `mysqltest1`; delete from t1
501
master-bin.000001 # Query # # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` trigger trg before insert on t1 for each row set new.a= 10
502
master-bin.000001 # Query # # use `mysqltest1`; insert into t1 values (1)
503
master-bin.000001 # Query # # use `mysqltest1`; delete from t1
504
master-bin.000001 # Query # # use `mysqltest1`; drop trigger trg
505
master-bin.000001 # Query # # use `mysqltest1`; insert into t1 values (1)
506
master-bin.000001 # Query # # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo()
510
master-bin.000001 # Query # # use `mysqltest1`; drop procedure foo
511
master-bin.000001 # Query # # use `mysqltest1`; drop function fn1
512
master-bin.000001 # Query # # drop database mysqltest1
513
master-bin.000001 # Query # # drop user "zedjzlcsjhd"@127.0.0.1
514
master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` function f1() returns int reads sql data
517
declare c cursor for select a from v1;
523
master-bin.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 as a
524
master-bin.000001 # Query # # use `test`; create table t1 (a int)
525
master-bin.000001 # Query # # use `test`; insert into t1 (a) values (f1())
526
master-bin.000001 # Query # # use `test`; drop view v1
527
master-bin.000001 # Query # # use `test`; drop function f1
528
master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
529
master-bin.000001 # Query # # use `test`; CREATE TABLE t1(col VARCHAR(10))
530
master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE p1(arg VARCHAR(10))
531
INSERT INTO t1 VALUES(arg)
532
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES( NAME_CONST('arg',_latin1'test'))
533
master-bin.000001 # Query # # use `test`; DROP PROCEDURE p1
534
master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE p1() SET @a = 1
535
master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION f1() RETURNS INT RETURN 0
536
master-bin.000001 # Query # # use `test`; DROP PROCEDURE p1
537
master-bin.000001 # Query # # use `test`; DROP FUNCTION f1
538
master-bin.000001 # Query # # use `test`; drop table t1
539
master-bin.000001 # Query # # drop database if exists mysqltest
540
master-bin.000001 # Query # # drop database if exists mysqltest2
541
master-bin.000001 # Query # # create database mysqltest
542
master-bin.000001 # Query # # create database mysqltest2
543
master-bin.000001 # Query # # use `mysqltest2`; create table t ( t integer )
544
master-bin.000001 # Query # # use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end
545
master-bin.000001 # Query # # use `mysqltest2`; insert into t values ( 1 )
546
master-bin.000001 # Query # # use `mysqltest2`; CREATE DEFINER=`root`@`localhost` function f1 () returns int
548
insert into t values (1);
551
master-bin.000001 # Query # # use `mysqltest`; SELECT `mysqltest2`.`f1`()
552
set global log_bin_trust_function_creators=0;
553
set global log_bin_trust_function_creators=0;
554
drop database mysqltest;
555
drop database mysqltest2;