1
by brian
clean slate |
1 |
# ==== Purpose ====
|
2 |
#
|
|
3 |
# In general, queries referencing @@system_variables are not
|
|
4 |
# considered safe to write to the binlog in statement-based logging
|
|
5 |
# mode. However, a few special cases are supported.
|
|
6 |
#
|
|
7 |
# This test verifies that queries referencing these specially
|
|
8 |
# supported variables are replicated correctly in statement mode.
|
|
9 |
#
|
|
10 |
#
|
|
11 |
# ==== Method ====
|
|
12 |
#
|
|
13 |
# The test simply does a lot of "INSERT INTO t1 VALUES (@@variable)"
|
|
14 |
# and checks the result on the slave.
|
|
15 |
#
|
|
16 |
# Statements referencing a variable only replicate correctly in mixed
|
|
17 |
# and row mode: in row mode, the values inserted are replicated. In
|
|
18 |
# mixed mode, statements referencing a variable are marked as unsafe,
|
|
19 |
# meaning they will be replicated by row. In statement mode, the
|
|
20 |
# slave's value will be used and replication will break. (Except in a
|
|
21 |
# small number of special cases: random seeds, insert_id, and
|
|
22 |
# auto_increment are replicated).
|
|
23 |
#
|
|
24 |
# We test all replicated variables, from each of the following
|
|
25 |
# contexts:
|
|
26 |
# - directly
|
|
27 |
# - from a stored procedure
|
|
28 |
# - from a stored function
|
|
29 |
# - from a trigger
|
|
30 |
# - from a prepared statement
|
|
31 |
#
|
|
32 |
# For all variables where it is possible, we set the variable to one
|
|
33 |
# value on slave, and insert it on the master with two distinct
|
|
34 |
# values.
|
|
35 |
#
|
|
36 |
# The same insertions are made in four different tables using direct
|
|
37 |
# insert, stored procedure, stored function, or trigger. Then all
|
|
38 |
# eight resulting tables on master and slave are compared.
|
|
39 |
#
|
|
40 |
#
|
|
41 |
# ==== Related bugs ====
|
|
42 |
#
|
|
43 |
# BUG#31168: @@hostname does not replicate
|
|
44 |
#
|
|
45 |
#
|
|
46 |
# ==== Related test cases ====
|
|
47 |
#
|
|
48 |
# binlog.binlog_unsafe tests that a warning is issued if system
|
|
49 |
# variables are replicated in statement mode.
|
|
50 |
#
|
|
51 |
# rpl.rpl_variables verifies that variables which cannot be replicated
|
|
52 |
# safely in statement mode are replicated correctly in mixed or row
|
|
53 |
# mode.
|
|
54 |
||
55 |
source include/master-slave.inc; |
|
56 |
source include/have_binlog_format_mixed_or_statement.inc; |
|
57 |
||
58 |
||
59 |
--echo ==== Initialization ==== |
|
60 |
||
61 |
# Backup the values of global variables so that they can be restored
|
|
62 |
# later.
|
|
63 |
||
64 |
--echo [on master] |
|
65 |
connection master; |
|
66 |
SET @m_pseudo_thread_id= @@global.pseudo_thread_id; |
|
67 |
SET @m_auto_increment_increment= @@global.auto_increment_increment; |
|
68 |
SET @m_auto_increment_offset= @@global.auto_increment_offset; |
|
69 |
SET @m_character_set_client= @@global.character_set_client; |
|
70 |
SET @m_collation_connection= @@global.collation_connection; |
|
71 |
SET @m_collation_server= @@global.collation_server; |
|
72 |
SET @m_time_zone= @@global.time_zone; |
|
73 |
SET @m_lc_time_names= @@global.lc_time_names; |
|
74 |
SET @m_collation_database= @@global.collation_database; |
|
75 |
||
76 |
--echo [on slave] |
|
77 |
connection slave; |
|
78 |
SET @s_pseudo_thread_id= @@global.pseudo_thread_id; |
|
79 |
SET @s_auto_increment_increment= @@global.auto_increment_increment; |
|
80 |
SET @s_auto_increment_offset= @@global.auto_increment_offset; |
|
81 |
SET @s_character_set_client= @@global.character_set_client; |
|
82 |
SET @s_collation_connection= @@global.collation_connection; |
|
83 |
SET @s_collation_server= @@global.collation_server; |
|
84 |
SET @s_time_zone= @@global.time_zone; |
|
85 |
SET @s_lc_time_names= @@global.lc_time_names; |
|
86 |
SET @s_collation_database= @@global.collation_database; |
|
87 |
||
88 |
SET @@global.pseudo_thread_id= 4711; |
|
89 |
SET @@global.auto_increment_increment=19; |
|
90 |
SET @@global.auto_increment_offset=4; |
|
91 |
SET @@global.character_set_client='latin2'; |
|
92 |
SET @@global.collation_connection='latin2_bin'; |
|
93 |
SET @@global.collation_server='geostd8_general_ci'; |
|
94 |
SET @@global.time_zone='Japan'; |
|
95 |
SET @@global.lc_time_names='sv_SE'; |
|
96 |
SET @@global.collation_database='geostd8_bin'; |
|
97 |
||
98 |
--echo [on master] |
|
99 |
connection master; |
|
100 |
||
101 |
# Tables where everything happens.
|
|
102 |
CREATE TABLE tstmt (id INT AUTO_INCREMENT PRIMARY KEY, |
|
103 |
num INT, |
|
104 |
text VARCHAR(100)); |
|
105 |
CREATE TABLE tproc LIKE tstmt; |
|
106 |
CREATE TABLE tfunc LIKE tstmt; |
|
107 |
CREATE TABLE ttrig LIKE tstmt; |
|
108 |
CREATE TABLE tprep LIKE tstmt; |
|
109 |
||
110 |
# Table on which we put a trigger.
|
|
111 |
CREATE TABLE trigger_table (text CHAR(4)); |
|
112 |
||
113 |
||
114 |
--echo ==== Insert variables directly ==== |
|
115 |
||
116 |
SET @@pseudo_thread_id= 4712; |
|
117 |
INSERT INTO tstmt(num) VALUES (@@session.pseudo_thread_id); |
|
118 |
SET @@pseudo_thread_id= 4713; |
|
119 |
INSERT INTO tstmt(num) VALUES (@@session.pseudo_thread_id); |
|
120 |
||
121 |
SET @@foreign_key_checks= 0; |
|
122 |
INSERT INTO tstmt(num) VALUES (@@session.foreign_key_checks); |
|
123 |
SET @@foreign_key_checks= 1; |
|
124 |
INSERT INTO tstmt(num) VALUES (@@session.foreign_key_checks); |
|
125 |
||
126 |
SET @@sql_auto_is_null= 0; |
|
127 |
INSERT INTO tstmt(num) VALUES (@@session.sql_auto_is_null); |
|
128 |
SET @@sql_auto_is_null= 1; |
|
129 |
INSERT INTO tstmt(num) VALUES (@@session.sql_auto_is_null); |
|
130 |
||
131 |
SET @@unique_checks= 0; |
|
132 |
INSERT INTO tstmt(num) VALUES (@@session.unique_checks); |
|
133 |
SET @@unique_checks= 1; |
|
134 |
INSERT INTO tstmt(num) VALUES (@@session.unique_checks); |
|
135 |
||
136 |
SET @@auto_increment_increment= 11; |
|
137 |
INSERT INTO tstmt(num) VALUES (@@session.auto_increment_increment); |
|
138 |
SET @@auto_increment_increment= 19; |
|
139 |
INSERT INTO tstmt(num) VALUES (@@session.auto_increment_increment); |
|
140 |
||
141 |
SET @@auto_increment_offset= 13; |
|
142 |
INSERT INTO tstmt(num) VALUES (@@session.auto_increment_offset); |
|
143 |
SET @@auto_increment_offset= 17; |
|
144 |
INSERT INTO tstmt(num) VALUES (@@session.auto_increment_offset); |
|
145 |
||
146 |
# reset these as they affect the index column
|
|
147 |
SET @@auto_increment_increment= 1; |
|
148 |
SET @@auto_increment_offset= 1; |
|
149 |
||
150 |
SET @@character_set_client= 'cp1257'; |
|
151 |
INSERT INTO tstmt(text) VALUES (@@session.character_set_client); |
|
152 |
SET @@character_set_client= 'cp1256'; |
|
153 |
INSERT INTO tstmt(text) VALUES (@@session.character_set_client); |
|
154 |
||
155 |
SET @@collation_connection= 'cp1251_ukrainian_ci'; |
|
156 |
INSERT INTO tstmt(text) VALUES (@@session.collation_connection); |
|
157 |
INSERT INTO tstmt(text) VALUES (@@session.character_set_connection); |
|
158 |
SET @@collation_connection= 'cp1251_bulgarian_ci'; |
|
159 |
INSERT INTO tstmt(text) VALUES (@@session.collation_connection); |
|
160 |
INSERT INTO tstmt(text) VALUES (@@session.character_set_connection); |
|
161 |
||
162 |
SET @@collation_server= 'latin7_bin'; |
|
163 |
INSERT INTO tstmt(text) VALUES (@@session.collation_server); |
|
164 |
INSERT INTO tstmt(text) VALUES (@@session.character_set_server); |
|
165 |
SET @@collation_server= 'latin7_general_cs'; |
|
166 |
INSERT INTO tstmt(text) VALUES (@@session.collation_server); |
|
167 |
INSERT INTO tstmt(text) VALUES (@@session.character_set_server); |
|
168 |
||
169 |
SET @@time_zone= 'Europe/Moscow'; |
|
170 |
INSERT INTO tstmt(text) VALUES (@@session.time_zone); |
|
171 |
SET @@time_zone= 'Universal'; |
|
172 |
INSERT INTO tstmt(text) VALUES (@@session.time_zone); |
|
173 |
||
174 |
SET @@lc_time_names= 'sv_FI'; |
|
175 |
INSERT INTO tstmt(text) VALUES (@@session.lc_time_names); |
|
176 |
SET @@lc_time_names= 'no_NO'; |
|
177 |
INSERT INTO tstmt(text) VALUES (@@session.lc_time_names); |
|
178 |
||
179 |
SET @@collation_database= 'latin7_general_ci'; |
|
180 |
INSERT INTO tstmt(text) VALUES (@@session.collation_database); |
|
181 |
INSERT INTO tstmt(text) VALUES (@@session.character_set_database); |
|
182 |
SET @@collation_database= 'latin7_estonian_cs'; |
|
183 |
INSERT INTO tstmt(text) VALUES (@@session.collation_database); |
|
184 |
INSERT INTO tstmt(text) VALUES (@@session.character_set_database); |
|
185 |
||
186 |
SET @@timestamp= 47114711; |
|
187 |
INSERT INTO tstmt(text) VALUES (@@session.timestamp); |
|
188 |
SET @@timestamp= 47124712; |
|
189 |
INSERT INTO tstmt(text) VALUES (@@session.timestamp); |
|
190 |
||
191 |
SET @@last_insert_id= 1616; |
|
192 |
INSERT INTO tstmt(text) VALUES (@@session.last_insert_id); |
|
193 |
SET @@last_insert_id= 1717; |
|
194 |
INSERT INTO tstmt(text) VALUES (@@session.last_insert_id); |
|
195 |
||
196 |
||
197 |
--echo ==== Insert variables from a stored procedure ==== |
|
198 |
||
199 |
DELIMITER |; |
|
200 |
CREATE PROCEDURE proc() |
|
201 |
BEGIN
|
|
202 |
||
203 |
SET @@pseudo_thread_id= 4712; |
|
204 |
INSERT INTO tproc(num) VALUES (@@session.pseudo_thread_id); |
|
205 |
SET @@pseudo_thread_id= 4713; |
|
206 |
INSERT INTO tproc(num) VALUES (@@session.pseudo_thread_id); |
|
207 |
||
208 |
SET @@foreign_key_checks= 0; |
|
209 |
INSERT INTO tproc(num) VALUES (@@session.foreign_key_checks); |
|
210 |
SET @@foreign_key_checks= 1; |
|
211 |
INSERT INTO tproc(num) VALUES (@@session.foreign_key_checks); |
|
212 |
||
213 |
SET @@sql_auto_is_null= 0; |
|
214 |
INSERT INTO tproc(num) VALUES (@@session.sql_auto_is_null); |
|
215 |
SET @@sql_auto_is_null= 1; |
|
216 |
INSERT INTO tproc(num) VALUES (@@session.sql_auto_is_null); |
|
217 |
||
218 |
SET @@unique_checks= 0; |
|
219 |
INSERT INTO tproc(num) VALUES (@@session.unique_checks); |
|
220 |
SET @@unique_checks= 1; |
|
221 |
INSERT INTO tproc(num) VALUES (@@session.unique_checks); |
|
222 |
||
223 |
SET @@auto_increment_increment= 11; |
|
224 |
INSERT INTO tproc(num) VALUES (@@session.auto_increment_increment); |
|
225 |
SET @@auto_increment_increment= 19; |
|
226 |
INSERT INTO tproc(num) VALUES (@@session.auto_increment_increment); |
|
227 |
||
228 |
SET @@auto_increment_offset= 13; |
|
229 |
INSERT INTO tproc(num) VALUES (@@session.auto_increment_offset); |
|
230 |
SET @@auto_increment_offset= 17; |
|
231 |
INSERT INTO tproc(num) VALUES (@@session.auto_increment_offset); |
|
232 |
||
233 |
# reset these as they affect the index column
|
|
234 |
SET @@auto_increment_increment= 1; |
|
235 |
SET @@auto_increment_offset= 1; |
|
236 |
||
237 |
SET @@character_set_client= 'cp1257'; |
|
238 |
INSERT INTO tproc(text) VALUES (@@session.character_set_client); |
|
239 |
SET @@character_set_client= 'cp1256'; |
|
240 |
INSERT INTO tproc(text) VALUES (@@session.character_set_client); |
|
241 |
||
242 |
SET @@collation_connection= 'cp1251_ukrainian_ci'; |
|
243 |
INSERT INTO tproc(text) VALUES (@@session.collation_connection); |
|
244 |
INSERT INTO tproc(text) VALUES (@@session.character_set_connection); |
|
245 |
SET @@collation_connection= 'cp1251_bulgarian_ci'; |
|
246 |
INSERT INTO tproc(text) VALUES (@@session.collation_connection); |
|
247 |
INSERT INTO tproc(text) VALUES (@@session.character_set_connection); |
|
248 |
||
249 |
SET @@collation_server= 'latin7_bin'; |
|
250 |
INSERT INTO tproc(text) VALUES (@@session.collation_server); |
|
251 |
INSERT INTO tproc(text) VALUES (@@session.character_set_server); |
|
252 |
SET @@collation_server= 'latin7_general_cs'; |
|
253 |
INSERT INTO tproc(text) VALUES (@@session.collation_server); |
|
254 |
INSERT INTO tproc(text) VALUES (@@session.character_set_server); |
|
255 |
||
256 |
SET @@time_zone= 'Europe/Moscow'; |
|
257 |
INSERT INTO tproc(text) VALUES (@@session.time_zone); |
|
258 |
SET @@time_zone= 'Universal'; |
|
259 |
INSERT INTO tproc(text) VALUES (@@session.time_zone); |
|
260 |
||
261 |
SET @@lc_time_names= 'sv_FI'; |
|
262 |
INSERT INTO tproc(text) VALUES (@@session.lc_time_names); |
|
263 |
SET @@lc_time_names= 'no_NO'; |
|
264 |
INSERT INTO tproc(text) VALUES (@@session.lc_time_names); |
|
265 |
||
266 |
SET @@collation_database= 'latin7_general_ci'; |
|
267 |
INSERT INTO tproc(text) VALUES (@@session.collation_database); |
|
268 |
INSERT INTO tproc(text) VALUES (@@session.character_set_database); |
|
269 |
SET @@collation_database= 'latin7_estonian_cs'; |
|
270 |
INSERT INTO tproc(text) VALUES (@@session.collation_database); |
|
271 |
INSERT INTO tproc(text) VALUES (@@session.character_set_database); |
|
272 |
||
273 |
SET @@timestamp= 47114711; |
|
274 |
INSERT INTO tproc(text) VALUES (@@session.timestamp); |
|
275 |
SET @@timestamp= 47124712; |
|
276 |
INSERT INTO tproc(text) VALUES (@@session.timestamp); |
|
277 |
||
278 |
SET @@last_insert_id= 1616; |
|
279 |
INSERT INTO tproc(text) VALUES (@@session.last_insert_id); |
|
280 |
SET @@last_insert_id= 1717; |
|
281 |
INSERT INTO tproc(text) VALUES (@@session.last_insert_id); |
|
282 |
||
283 |
END| |
|
284 |
DELIMITER ;| |
|
285 |
||
286 |
CALL proc(); |
|
287 |
||
288 |
||
289 |
--echo ==== Insert variables from a stored function ==== |
|
290 |
||
291 |
DELIMITER |; |
|
292 |
CREATE FUNCTION func() |
|
293 |
RETURNS INT |
|
294 |
BEGIN
|
|
295 |
||
296 |
SET @@pseudo_thread_id= 4712; |
|
297 |
INSERT INTO tfunc(num) VALUES (@@session.pseudo_thread_id); |
|
298 |
SET @@pseudo_thread_id= 4713; |
|
299 |
INSERT INTO tfunc(num) VALUES (@@session.pseudo_thread_id); |
|
300 |
||
301 |
SET @@foreign_key_checks= 0; |
|
302 |
INSERT INTO tfunc(num) VALUES (@@session.foreign_key_checks); |
|
303 |
SET @@foreign_key_checks= 1; |
|
304 |
INSERT INTO tfunc(num) VALUES (@@session.foreign_key_checks); |
|
305 |
||
306 |
SET @@sql_auto_is_null= 0; |
|
307 |
INSERT INTO tfunc(num) VALUES (@@session.sql_auto_is_null); |
|
308 |
SET @@sql_auto_is_null= 1; |
|
309 |
INSERT INTO tfunc(num) VALUES (@@session.sql_auto_is_null); |
|
310 |
||
311 |
SET @@unique_checks= 0; |
|
312 |
INSERT INTO tfunc(num) VALUES (@@session.unique_checks); |
|
313 |
SET @@unique_checks= 1; |
|
314 |
INSERT INTO tfunc(num) VALUES (@@session.unique_checks); |
|
315 |
||
316 |
SET @@auto_increment_increment= 11; |
|
317 |
INSERT INTO tfunc(num) VALUES (@@session.auto_increment_increment); |
|
318 |
SET @@auto_increment_increment= 19; |
|
319 |
INSERT INTO tfunc(num) VALUES (@@session.auto_increment_increment); |
|
320 |
||
321 |
SET @@auto_increment_offset= 13; |
|
322 |
INSERT INTO tfunc(num) VALUES (@@session.auto_increment_offset); |
|
323 |
SET @@auto_increment_offset= 17; |
|
324 |
INSERT INTO tfunc(num) VALUES (@@session.auto_increment_offset); |
|
325 |
||
326 |
# reset these as they affect the index column
|
|
327 |
SET @@auto_increment_increment= 1; |
|
328 |
SET @@auto_increment_offset= 1; |
|
329 |
||
330 |
SET @@character_set_client= 'cp1257'; |
|
331 |
INSERT INTO tfunc(text) VALUES (@@session.character_set_client); |
|
332 |
SET @@character_set_client= 'cp1256'; |
|
333 |
INSERT INTO tfunc(text) VALUES (@@session.character_set_client); |
|
334 |
||
335 |
SET @@collation_connection= 'cp1251_ukrainian_ci'; |
|
336 |
INSERT INTO tfunc(text) VALUES (@@session.collation_connection); |
|
337 |
INSERT INTO tfunc(text) VALUES (@@session.character_set_connection); |
|
338 |
SET @@collation_connection= 'cp1251_bulgarian_ci'; |
|
339 |
INSERT INTO tfunc(text) VALUES (@@session.collation_connection); |
|
340 |
INSERT INTO tfunc(text) VALUES (@@session.character_set_connection); |
|
341 |
||
342 |
SET @@collation_server= 'latin7_bin'; |
|
343 |
INSERT INTO tfunc(text) VALUES (@@session.collation_server); |
|
344 |
INSERT INTO tfunc(text) VALUES (@@session.character_set_server); |
|
345 |
SET @@collation_server= 'latin7_general_cs'; |
|
346 |
INSERT INTO tfunc(text) VALUES (@@session.collation_server); |
|
347 |
INSERT INTO tfunc(text) VALUES (@@session.character_set_server); |
|
348 |
||
349 |
SET @@time_zone= 'Europe/Moscow'; |
|
350 |
INSERT INTO tfunc(text) VALUES (@@session.time_zone); |
|
351 |
SET @@time_zone= 'Universal'; |
|
352 |
INSERT INTO tfunc(text) VALUES (@@session.time_zone); |
|
353 |
||
354 |
SET @@lc_time_names= 'sv_FI'; |
|
355 |
INSERT INTO tfunc(text) VALUES (@@session.lc_time_names); |
|
356 |
SET @@lc_time_names= 'no_NO'; |
|
357 |
INSERT INTO tfunc(text) VALUES (@@session.lc_time_names); |
|
358 |
||
359 |
SET @@collation_database= 'latin7_general_ci'; |
|
360 |
INSERT INTO tfunc(text) VALUES (@@session.collation_database); |
|
361 |
INSERT INTO tfunc(text) VALUES (@@session.character_set_database); |
|
362 |
SET @@collation_database= 'latin7_estonian_cs'; |
|
363 |
INSERT INTO tfunc(text) VALUES (@@session.collation_database); |
|
364 |
INSERT INTO tfunc(text) VALUES (@@session.character_set_database); |
|
365 |
||
366 |
SET @@timestamp= 47114711; |
|
367 |
INSERT INTO tfunc(text) VALUES (@@session.timestamp); |
|
368 |
SET @@timestamp= 47124712; |
|
369 |
INSERT INTO tfunc(text) VALUES (@@session.timestamp); |
|
370 |
||
371 |
SET @@last_insert_id= 1616; |
|
372 |
INSERT INTO tfunc(text) VALUES (@@session.last_insert_id); |
|
373 |
SET @@last_insert_id= 1717; |
|
374 |
INSERT INTO tfunc(text) VALUES (@@session.last_insert_id); |
|
375 |
||
376 |
RETURN 0; |
|
377 |
END| |
|
378 |
DELIMITER ;| |
|
379 |
||
380 |
SELECT func(); |
|
381 |
||
382 |
||
383 |
--echo ==== Insert variables from a trigger ==== |
|
384 |
||
385 |
DELIMITER |; |
|
386 |
CREATE TRIGGER trig |
|
387 |
BEFORE INSERT ON trigger_table |
|
388 |
FOR EACH ROW |
|
389 |
BEGIN
|
|
390 |
||
391 |
SET @@pseudo_thread_id= 4712; |
|
392 |
INSERT INTO ttrig(num) VALUES (@@session.pseudo_thread_id); |
|
393 |
SET @@pseudo_thread_id= 4713; |
|
394 |
INSERT INTO ttrig(num) VALUES (@@session.pseudo_thread_id); |
|
395 |
||
396 |
SET @@foreign_key_checks= 0; |
|
397 |
INSERT INTO ttrig(num) VALUES (@@session.foreign_key_checks); |
|
398 |
SET @@foreign_key_checks= 1; |
|
399 |
INSERT INTO ttrig(num) VALUES (@@session.foreign_key_checks); |
|
400 |
||
401 |
SET @@sql_auto_is_null= 0; |
|
402 |
INSERT INTO ttrig(num) VALUES (@@session.sql_auto_is_null); |
|
403 |
SET @@sql_auto_is_null= 1; |
|
404 |
INSERT INTO ttrig(num) VALUES (@@session.sql_auto_is_null); |
|
405 |
||
406 |
SET @@unique_checks= 0; |
|
407 |
INSERT INTO ttrig(num) VALUES (@@session.unique_checks); |
|
408 |
SET @@unique_checks= 1; |
|
409 |
INSERT INTO ttrig(num) VALUES (@@session.unique_checks); |
|
410 |
||
411 |
SET @@auto_increment_increment= 11; |
|
412 |
INSERT INTO ttrig(num) VALUES (@@session.auto_increment_increment); |
|
413 |
SET @@auto_increment_increment= 19; |
|
414 |
INSERT INTO ttrig(num) VALUES (@@session.auto_increment_increment); |
|
415 |
||
416 |
SET @@auto_increment_offset= 13; |
|
417 |
INSERT INTO ttrig(num) VALUES (@@session.auto_increment_offset); |
|
418 |
SET @@auto_increment_offset= 17; |
|
419 |
INSERT INTO ttrig(num) VALUES (@@session.auto_increment_offset); |
|
420 |
||
421 |
# reset these as they affect the index column
|
|
422 |
SET @@auto_increment_increment= 1; |
|
423 |
SET @@auto_increment_offset= 1; |
|
424 |
||
425 |
SET @@character_set_client= 'cp1257'; |
|
426 |
INSERT INTO ttrig(text) VALUES (@@session.character_set_client); |
|
427 |
SET @@character_set_client= 'cp1256'; |
|
428 |
INSERT INTO ttrig(text) VALUES (@@session.character_set_client); |
|
429 |
||
430 |
SET @@collation_connection= 'cp1251_ukrainian_ci'; |
|
431 |
INSERT INTO ttrig(text) VALUES (@@session.collation_connection); |
|
432 |
INSERT INTO ttrig(text) VALUES (@@session.character_set_connection); |
|
433 |
SET @@collation_connection= 'cp1251_bulgarian_ci'; |
|
434 |
INSERT INTO ttrig(text) VALUES (@@session.collation_connection); |
|
435 |
INSERT INTO ttrig(text) VALUES (@@session.character_set_connection); |
|
436 |
||
437 |
SET @@collation_server= 'latin7_bin'; |
|
438 |
INSERT INTO ttrig(text) VALUES (@@session.collation_server); |
|
439 |
INSERT INTO ttrig(text) VALUES (@@session.character_set_server); |
|
440 |
SET @@collation_server= 'latin7_general_cs'; |
|
441 |
INSERT INTO ttrig(text) VALUES (@@session.collation_server); |
|
442 |
INSERT INTO ttrig(text) VALUES (@@session.character_set_server); |
|
443 |
||
444 |
SET @@time_zone= 'Europe/Moscow'; |
|
445 |
INSERT INTO ttrig(text) VALUES (@@session.time_zone); |
|
446 |
SET @@time_zone= 'Universal'; |
|
447 |
INSERT INTO ttrig(text) VALUES (@@session.time_zone); |
|
448 |
||
449 |
SET @@lc_time_names= 'sv_FI'; |
|
450 |
INSERT INTO ttrig(text) VALUES (@@session.lc_time_names); |
|
451 |
SET @@lc_time_names= 'no_NO'; |
|
452 |
INSERT INTO ttrig(text) VALUES (@@session.lc_time_names); |
|
453 |
||
454 |
SET @@collation_database= 'latin7_general_ci'; |
|
455 |
INSERT INTO ttrig(text) VALUES (@@session.collation_database); |
|
456 |
INSERT INTO ttrig(text) VALUES (@@session.character_set_database); |
|
457 |
SET @@collation_database= 'latin7_estonian_cs'; |
|
458 |
INSERT INTO ttrig(text) VALUES (@@session.collation_database); |
|
459 |
INSERT INTO ttrig(text) VALUES (@@session.character_set_database); |
|
460 |
||
461 |
SET @@timestamp= 47114711; |
|
462 |
INSERT INTO ttrig(text) VALUES (@@session.timestamp); |
|
463 |
SET @@timestamp= 47124712; |
|
464 |
INSERT INTO ttrig(text) VALUES (@@session.timestamp); |
|
465 |
||
466 |
SET @@last_insert_id= 1616; |
|
467 |
INSERT INTO ttrig(text) VALUES (@@session.last_insert_id); |
|
468 |
SET @@last_insert_id= 1717; |
|
469 |
INSERT INTO ttrig(text) VALUES (@@session.last_insert_id); |
|
470 |
||
471 |
END| |
|
472 |
DELIMITER ;| |
|
473 |
||
474 |
INSERT INTO trigger_table VALUES ('bye.'); |
|
475 |
||
476 |
||
477 |
--echo ==== Insert variables from a prepared statement ==== |
|
478 |
||
479 |
# GLOBAL
|
|
480 |
||
481 |
PREPARE p1 FROM 'SET @@pseudo_thread_id= 4712'; |
|
482 |
PREPARE p2 FROM 'INSERT INTO tprep(num) VALUES (@@session.pseudo_thread_id)'; |
|
483 |
PREPARE p3 FROM 'SET @@pseudo_thread_id= 4713'; |
|
484 |
PREPARE p4 FROM 'INSERT INTO tprep(num) VALUES (@@session.pseudo_thread_id)'; |
|
485 |
||
486 |
PREPARE p5 FROM 'SET @@foreign_key_checks= 0'; |
|
487 |
PREPARE p6 FROM 'INSERT INTO tprep(num) VALUES (@@session.foreign_key_checks)'; |
|
488 |
PREPARE p7 FROM 'SET @@foreign_key_checks= 1'; |
|
489 |
PREPARE p8 FROM 'INSERT INTO tprep(num) VALUES (@@session.foreign_key_checks)'; |
|
490 |
||
491 |
PREPARE p9 FROM 'SET @@sql_auto_is_null= 0'; |
|
492 |
PREPARE p10 FROM 'INSERT INTO tprep(num) VALUES (@@session.sql_auto_is_null)'; |
|
493 |
PREPARE p11 FROM 'SET @@sql_auto_is_null= 1'; |
|
494 |
PREPARE p12 FROM 'INSERT INTO tprep(num) VALUES (@@session.sql_auto_is_null)'; |
|
495 |
||
496 |
PREPARE p13 FROM 'SET @@unique_checks= 0'; |
|
497 |
PREPARE p14 FROM 'INSERT INTO tprep(num) VALUES (@@session.unique_checks)'; |
|
498 |
PREPARE p15 FROM 'SET @@unique_checks= 1'; |
|
499 |
PREPARE p16 FROM 'INSERT INTO tprep(num) VALUES (@@session.unique_checks)'; |
|
500 |
||
501 |
PREPARE p17 FROM 'SET @@auto_increment_increment= 11'; |
|
502 |
PREPARE p18 FROM 'INSERT INTO tprep(num) VALUES (@@session.auto_increment_increment)'; |
|
503 |
PREPARE p19 FROM 'SET @@auto_increment_increment= 19'; |
|
504 |
PREPARE p20 FROM 'INSERT INTO tprep(num) VALUES (@@session.auto_increment_increment)'; |
|
505 |
||
506 |
PREPARE p21 FROM 'SET @@auto_increment_offset= 13'; |
|
507 |
PREPARE p22 FROM 'INSERT INTO tprep(num) VALUES (@@session.auto_increment_offset)'; |
|
508 |
PREPARE p23 FROM 'SET @@auto_increment_offset= 17'; |
|
509 |
PREPARE p24 FROM 'INSERT INTO tprep(num) VALUES (@@session.auto_increment_offset)'; |
|
510 |
||
511 |
# reset these as they affect the index column
|
|
512 |
PREPARE p25 FROM 'SET @@auto_increment_increment= 1'; |
|
513 |
PREPARE p26 FROM 'SET @@auto_increment_offset= 1'; |
|
514 |
||
515 |
PREPARE p27 FROM 'SET @@character_set_client= \'cp1257\''; |
|
516 |
PREPARE p28 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_client)'; |
|
517 |
PREPARE p29 FROM 'SET @@character_set_client= \'cp1256\''; |
|
518 |
PREPARE p30 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_client)'; |
|
519 |
||
520 |
PREPARE p31 FROM 'SET @@collation_connection= \'cp1251_ukrainian_ci\''; |
|
521 |
PREPARE p32 FROM 'INSERT INTO tprep(text) VALUES (@@session.collation_connection)'; |
|
522 |
PREPARE p33 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_connection)'; |
|
523 |
PREPARE p34 FROM 'SET @@collation_connection= \'cp1251_bulgarian_ci\''; |
|
524 |
PREPARE p35 FROM 'INSERT INTO tprep(text) VALUES (@@session.collation_connection)'; |
|
525 |
PREPARE p36 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_connection)'; |
|
526 |
||
527 |
PREPARE p37 FROM 'SET @@collation_server= \'latin7_bin\''; |
|
528 |
PREPARE p38 FROM 'INSERT INTO tprep(text) VALUES (@@session.collation_server)'; |
|
529 |
PREPARE p39 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_server)'; |
|
530 |
PREPARE p40 FROM 'SET @@collation_server= \'latin7_general_cs\''; |
|
531 |
PREPARE p41 FROM 'INSERT INTO tprep(text) VALUES (@@session.collation_server)'; |
|
532 |
PREPARE p42 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_server)'; |
|
533 |
||
534 |
PREPARE p43 FROM 'SET @@time_zone= \'Europe/Moscow\''; |
|
535 |
PREPARE p44 FROM 'INSERT INTO tprep(text) VALUES (@@session.time_zone)'; |
|
536 |
PREPARE p45 FROM 'SET @@time_zone= \'Universal\''; |
|
537 |
PREPARE p46 FROM 'INSERT INTO tprep(text) VALUES (@@session.time_zone)'; |
|
538 |
||
539 |
PREPARE p47 FROM 'SET @@lc_time_names= \'sv_FI\''; |
|
540 |
PREPARE p48 FROM 'INSERT INTO tprep(text) VALUES (@@session.lc_time_names)'; |
|
541 |
PREPARE p49 FROM 'SET @@lc_time_names= \'no_NO\''; |
|
542 |
PREPARE p50 FROM 'INSERT INTO tprep(text) VALUES (@@session.lc_time_names)'; |
|
543 |
||
544 |
PREPARE p51 FROM 'SET @@collation_database= \'latin7_general_ci\''; |
|
545 |
PREPARE p52 FROM 'INSERT INTO tprep(text) VALUES (@@session.collation_database)'; |
|
546 |
PREPARE p53 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_database)'; |
|
547 |
PREPARE p54 FROM 'SET @@collation_database= \'latin7_estonian_cs\''; |
|
548 |
PREPARE p55 FROM 'INSERT INTO tprep(text) VALUES (@@session.collation_database)'; |
|
549 |
PREPARE p56 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_database)'; |
|
550 |
||
551 |
PREPARE p57 FROM 'SET @@timestamp= 47114711'; |
|
552 |
PREPARE p58 FROM 'INSERT INTO tprep(text) VALUES (@@session.timestamp)'; |
|
553 |
PREPARE p59 FROM 'SET @@timestamp= 47124712'; |
|
554 |
PREPARE p60 FROM 'INSERT INTO tprep(text) VALUES (@@session.timestamp)'; |
|
555 |
||
556 |
PREPARE p61 FROM 'SET @@last_insert_id= 1616'; |
|
557 |
PREPARE p62 FROM 'INSERT INTO tprep(text) VALUES (@@session.last_insert_id)'; |
|
558 |
PREPARE p63 FROM 'SET @@last_insert_id= 1717'; |
|
559 |
PREPARE p64 FROM 'INSERT INTO tprep(text) VALUES (@@session.last_insert_id)'; |
|
560 |
||
561 |
EXECUTE p1; EXECUTE p2; EXECUTE p3; EXECUTE p4; EXECUTE p5; EXECUTE p6; |
|
562 |
EXECUTE p7; EXECUTE p8; EXECUTE p9; EXECUTE p10; EXECUTE p11; EXECUTE p12; |
|
563 |
EXECUTE p13; EXECUTE p14; EXECUTE p15; EXECUTE p16; EXECUTE p17; EXECUTE p18; |
|
564 |
EXECUTE p19; EXECUTE p20; EXECUTE p21; EXECUTE p22; EXECUTE p23; EXECUTE p24; |
|
565 |
EXECUTE p25; EXECUTE p26; EXECUTE p27; EXECUTE p28; EXECUTE p29; EXECUTE p30; |
|
566 |
EXECUTE p31; EXECUTE p32; EXECUTE p33; EXECUTE p34; EXECUTE p35; EXECUTE p36; |
|
567 |
EXECUTE p37; EXECUTE p38; EXECUTE p39; EXECUTE p40; EXECUTE p41; EXECUTE p42; |
|
568 |
EXECUTE p43; EXECUTE p44; EXECUTE p45; EXECUTE p46; EXECUTE p47; EXECUTE p48; |
|
569 |
EXECUTE p49; EXECUTE p50; EXECUTE p51; EXECUTE p52; EXECUTE p53; EXECUTE p54; |
|
570 |
EXECUTE p55; EXECUTE p56; EXECUTE p57; EXECUTE p58; EXECUTE p59; EXECUTE p60; |
|
571 |
EXECUTE p61; EXECUTE p62; EXECUTE p63; EXECUTE p64; |
|
572 |
||
573 |
||
574 |
--echo ==== Results ==== |
|
575 |
||
576 |
# Show the result in table test.tstmt on master...
|
|
577 |
SELECT * FROM tstmt ORDER BY id; |
|
578 |
let $diff_table_1=master:test.tstmt; |
|
579 |
||
580 |
# ... then compare test.tstmt on master to the other tables on master...
|
|
581 |
let $diff_table_2=master:test.tproc; |
|
582 |
source include/diff_tables.inc; |
|
583 |
let $diff_table_2=master:test.tfunc; |
|
584 |
source include/diff_tables.inc; |
|
585 |
let $diff_table_2=master:test.ttrig; |
|
586 |
source include/diff_tables.inc; |
|
587 |
let $diff_table_2=master:test.tprep; |
|
588 |
source include/diff_tables.inc; |
|
589 |
||
590 |
# ... and to all tables on slave.
|
|
591 |
sync_slave_with_master; |
|
592 |
let $diff_table_2=slave:test.tstmt; |
|
593 |
source include/diff_tables.inc; |
|
594 |
let $diff_table_2=slave:test.tproc; |
|
595 |
source include/diff_tables.inc; |
|
596 |
let $diff_table_2=slave:test.tfunc; |
|
597 |
source include/diff_tables.inc; |
|
598 |
let $diff_table_2=slave:test.ttrig; |
|
599 |
source include/diff_tables.inc; |
|
600 |
let $diff_table_2=slave:test.tprep; |
|
601 |
source include/diff_tables.inc; |
|
602 |
||
603 |
||
604 |
--echo ==== Clean up ==== |
|
605 |
||
606 |
--echo [on master] |
|
607 |
connection master; |
|
608 |
DROP PROCEDURE proc; |
|
609 |
DROP FUNCTION func; |
|
610 |
DROP TRIGGER trig; |
|
611 |
DROP TABLE tstmt, tproc, tfunc, ttrig, tprep, trigger_table; |
|
612 |
||
613 |
SET @@global.pseudo_thread_id= @m_pseudo_thread_id; |
|
614 |
SET @@global.auto_increment_increment= @m_auto_increment_increment; |
|
615 |
SET @@global.auto_increment_offset= @m_auto_increment_offset; |
|
616 |
SET @@global.character_set_client= @m_character_set_client; |
|
617 |
SET @@global.collation_connection= @m_collation_connection; |
|
618 |
SET @@global.collation_server= @m_collation_server; |
|
619 |
SET @@global.time_zone= @m_time_zone; |
|
620 |
SET @@global.lc_time_names= @m_lc_time_names; |
|
621 |
SET @@global.collation_database= @m_collation_database; |
|
622 |
||
623 |
--echo [on slave] |
|
624 |
connection slave; |
|
625 |
SET @@global.pseudo_thread_id= @s_pseudo_thread_id; |
|
626 |
SET @@global.auto_increment_increment= @s_auto_increment_increment; |
|
627 |
SET @@global.auto_increment_offset= @s_auto_increment_offset; |
|
628 |
SET @@global.character_set_client= @s_character_set_client; |
|
629 |
SET @@global.collation_connection= @s_collation_connection; |
|
630 |
SET @@global.collation_server= @s_collation_server; |
|
631 |
SET @@global.time_zone= @s_time_zone; |
|
632 |
SET @@global.lc_time_names= @s_lc_time_names; |
|
633 |
SET @@global.collation_database= @s_collation_database; |
|
634 |
||
635 |
connection master; |
|
636 |
sync_slave_with_master; |