~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to mysql-test/t/log_bin_trust_function_creators_func.test

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
############## mysql-test\t\log_bin_trust_function_creators_func.test #########
 
2
#                                                                             #
 
3
# Variable Name: log_bin_trust_function_creators                              #
 
4
# Scope: GLOBAL | SESSION                                                     #
 
5
# Access Type: Dynamic                                                        #
 
6
# Data Type: boolean                                                          #
 
7
# Default Value: False                                                        #
 
8
# Range:                                                                      #
 
9
#                                                                             #
 
10
#                                                                             #
 
11
# Creation Date: 2008-03-11                                                   #
 
12
# Author:  Salman Rawala                                                      #
 
13
#                                                                             #
 
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                         #
 
17
#                                                                             #
 
18
# Reference: http://dev.mysql.com/doc/refman/5.1/en/server-system             #
 
19
#            -variables.html#option_mysqld_log-bin-trust-function-ceators     #
 
20
#                                                                             #
 
21
###############################################################################
 
22
 
 
23
--disable_warnings
 
24
drop table if exists t1;
 
25
--enable_warnings
 
26
 
 
27
 
 
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
########################################################################
 
33
 
 
34
--echo ## Creating new user tt ##
 
35
CREATE user tt@localhost;
 
36
 
 
37
--echo ## Setting value of variable to 0 ##
 
38
SET @@global.log_bin_trust_function_creators = 0;
 
39
 
 
40
--echo ## Creating new table t2 ##
 
41
create table t2 (a INT);
 
42
 
 
43
--echo ## Creating & connecting with new connection test_con1 ##
 
44
connect (test_con1,localhost,tt,,);
 
45
connection test_con1;
 
46
 
 
47
SELECT @@log_bin_trust_function_creators;
 
48
SELECT @@sql_log_bin;
 
49
 
 
50
--echo ## Creating new function f1 ##
 
51
delimiter |;
 
52
CREATE FUNCTION f1(a INT) RETURNS INT
 
53
BEGIN
 
54
   IF (a < 3) THEN 
 
55
    INSERT INTO t2 VALUES (a);
 
56
  END IF;
 
57
  RETURN 1;
 
58
END|
 
59
delimiter ;|
 
60
 
 
61
--echo 'Bug: Create Function should give error here because non-super user';
 
62
--echo 'is creating function here';
 
63
 
 
64
--echo ## Creating new table t1 ##
 
65
CREATE TABLE t1 (a INT);
 
66
 
 
67
--echo ## Inserting some records in t1 ##
 
68
INSERT INTO t1 VALUES (1),(2),(3);
 
69
SELECT f1(a) FROM t1;
 
70
 
 
71
--echo ## Dropping function f1 & table t1 ##
 
72
drop function f1;
 
73
drop table t1;
 
74
 
 
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
########################################################################
 
80
 
 
81
--echo ## Switching to default connection ##
 
82
connection default;
 
83
 
 
84
--echo ## Setting value of variable to 1 ##
 
85
SET @@global.log_bin_trust_function_creators = 1;
 
86
 
 
87
--echo ## Creating and connecting to new connection test_con2 ##
 
88
connect (test_con2,localhost,tt,,);
 
89
connection test_con2;
 
90
 
 
91
--echo ## Verifying value of variable ##
 
92
SELECT @@log_bin_trust_function_creators;
 
93
SELECT @@sql_log_bin;
 
94
 
 
95
--echo ## Creating new function f1 ##
 
96
delimiter |;
 
97
CREATE FUNCTION f1(a INT) RETURNS INT
 
98
BEGIN
 
99
   IF (a < 3) THEN 
 
100
    INSERT INTO t2 VALUES (a);
 
101
  END IF;
 
102
  RETURN 1;
 
103
END|
 
104
delimiter ;|
 
105
 
 
106
--echo ## Creating new table t1 ##
 
107
CREATE TABLE t1 (a INT);
 
108
 
 
109
--echo ## Inserting values in table t1 ##
 
110
INSERT INTO t1 VALUES (1),(2),(3);
 
111
SELECT f1(a) FROM t1;
 
112
 
 
113
--echo ## Dropping function f1 ##
 
114
drop function f1;
 
115
 
 
116
--echo ## Dropping table t1 & t2 ##
 
117
drop table t1,t2;
 
118
 
 
119
--echo ## Disconnecting both the connections ##
 
120
disconnect test_con2;
 
121