Debian Codegraph @

mysql-test/suite/binlog/t/binlog_sf.test

raw
1
2 -- source include/have_log_bin.inc
3
4 # We change binlog format inside the test, so no need to re-run with
5 # more than one binlog_format.
6 -- source include/have_binlog_format_statement.inc
7
8 # Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
9 # BUG#41166 stored function requires "deterministic" if binlog_format is "statement"
10
11 # save status
12
13 let $oblf=`select @@SESSION.BINLOG_FORMAT`;
14 let $otfc=`select @@log_bin_trust_function_creators`;
15
16 create function fn16456_1() returns int return 1;
17
18 set global log_bin_trust_function_creators=0;
19
20
21
22 # fail *on definition*
23
24 set binlog_format=STATEMENT;
25
26 delimiter |;
27 --error ER_BINLOG_UNSAFE_ROUTINE
28 create function fn16456()
29 returns int
30 begin
31 return unix_timestamp();
32 end|
33 delimiter ;|
34
35 --error ER_BINLOG_UNSAFE_ROUTINE
36 alter function fn16456_1 comment "fails" contains SQL;
37 --error ER_BINLOG_UNSAFE_ROUTINE
38 alter function fn16456_1 MODIFIES SQL DATA;
39 drop function fn16456_1;
40
41
42
43 # force in definition, so we can see whether we fail on call
44
45 set global log_bin_trust_function_creators=1;
46
47 delimiter |;
48 create function fn16456()
49 returns int
50 begin
51 return unix_timestamp();
52 end|
53 delimiter ;|
54
55 set global log_bin_trust_function_creators=0;
56
57
58
59 # allow funcall in RBR
60
61 set binlog_format='ROW';
62
63 --replace_column 1 timestamp
64 select fn16456();
65
66
67
68 # fail funcall in SBR
69
70 set binlog_format=STATEMENT;
71
72 --error ER_BINLOG_UNSAFE_ROUTINE
73 select fn16456();
74
75
76
77 # clean
78
79 drop function fn16456;
80
81
82
83 # success in definition with deterministic
84
85 set global log_bin_trust_function_creators=0;
86
87 delimiter |;
88 create function fn16456()
89 returns int deterministic
90 begin
91 return unix_timestamp();
92 end|
93 delimiter ;|
94
95
96
97 # allow funcall in RBR
98
99 set binlog_format='ROW';
100
101 --replace_column 1 timestamp
102 select fn16456();
103
104
105
106 # allow funcall in SBR
107
108 set binlog_format=STATEMENT;
109
110 --replace_column 1 timestamp
111 select fn16456();
112
113
114
115 # clean
116
117 drop function fn16456;
118
119
120 # success in definition with NO SQL
121
122 set global log_bin_trust_function_creators=0;
123
124 delimiter |;
125 create function fn16456()
126 returns int no sql
127 begin
128 return unix_timestamp();
129 end|
130 delimiter ;|
131
132
133
134 # allow funcall in RBR
135
136 set binlog_format='ROW';
137
138 --replace_column 1 timestamp
139 select fn16456();
140
141
142
143 # allow funcall in SBR
144
145 set binlog_format=STATEMENT;
146
147 --replace_column 1 timestamp
148 select fn16456();
149
150
151 # clean
152
153 drop function fn16456;
154
155
156
157 # success in definition with reads sql data
158
159 set global log_bin_trust_function_creators=0;
160
161 delimiter |;
162 create function fn16456()
163 returns int reads sql data
164 begin
165 return unix_timestamp();
166 end|
167 delimiter ;|
168
169
170
171 # allow funcall in RBR
172
173 set binlog_format='ROW';
174
175 --replace_column 1 timestamp
176 select fn16456();
177
178
179
180 # allow funcall in SBR
181
182 set binlog_format=STATEMENT;
183
184 --replace_column 1 timestamp
185 select fn16456();
186
187
188
189 # clean
190
191 drop function fn16456;
192
193
194
195 # restore status
196
197 --disable_query_log
198 eval set binlog_format=$oblf;
199 eval set global log_bin_trust_function_creators=$otfc;
200 --enable_query_log