1
############## mysql-test\t\log_bin_trust_function_creators_func.test #########
3
# Variable Name: log_bin_trust_function_creators #
4
# Scope: GLOBAL | SESSION #
5
# Access Type: Dynamic #
7
# Default Value: False #
11
# Creation Date: 2008-03-11 #
12
# Author: Salman Rawala #
14
# Description: Test Cases of Dynamic System Variable #
15
# log_bin_trust_function_creators that checks the functionality #
16
# of this variable in the following ways #
18
# Reference: http://dev.mysql.com/doc/refman/5.1/en/server-system #
19
# -variables.html#option_mysqld_log-bin-trust-function-ceators #
21
###############################################################################
24
drop table if exists t1;
28
--echo '#--------------------FN_DYNVARS_063_01-------------------------#'
29
########################################################################
30
# Setting initial value of variable to 0 and verifying whether user
31
# is allowed to create function or not.
32
########################################################################
34
--echo ## Creating new user tt ##
35
CREATE user tt@localhost;
37
--echo ## Setting value of variable to 0 ##
38
SET @@global.log_bin_trust_function_creators = 0;
40
--echo ## Creating new table t2 ##
41
create table t2 (a INT);
43
--echo ## Creating & connecting with new connection test_con1 ##
44
connect (test_con1,localhost,tt,,);
47
SELECT @@log_bin_trust_function_creators;
50
--echo ## Creating new function f1 ##
52
CREATE FUNCTION f1(a INT) RETURNS INT
55
INSERT INTO t2 VALUES (a);
61
--echo 'Bug: Create Function should give error here because non-super user';
62
--echo 'is creating function here';
64
--echo ## Creating new table t1 ##
65
CREATE TABLE t1 (a INT);
67
--echo ## Inserting some records in t1 ##
68
INSERT INTO t1 VALUES (1),(2),(3);
71
--echo ## Dropping function f1 & table t1 ##
75
--echo '#--------------------FN_DYNVARS_063_02-------------------------#'
76
########################################################################
77
# Setting initial value of variable to 1 and verifying whether user
78
# is allowed to create function or not.
79
########################################################################
81
--echo ## Switching to default connection ##
84
--echo ## Setting value of variable to 1 ##
85
SET @@global.log_bin_trust_function_creators = 1;
87
--echo ## Creating and connecting to new connection test_con2 ##
88
connect (test_con2,localhost,tt,,);
91
--echo ## Verifying value of variable ##
92
SELECT @@log_bin_trust_function_creators;
95
--echo ## Creating new function f1 ##
97
CREATE FUNCTION f1(a INT) RETURNS INT
100
INSERT INTO t2 VALUES (a);
106
--echo ## Creating new table t1 ##
107
CREATE TABLE t1 (a INT);
109
--echo ## Inserting values in table t1 ##
110
INSERT INTO t1 VALUES (1),(2),(3);
111
SELECT f1(a) FROM t1;
113
--echo ## Dropping function f1 ##
116
--echo ## Dropping table t1 & t2 ##
119
--echo ## Disconnecting both the connections ##
120
disconnect test_con2;