~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/suite/binlog/r/binlog_unsafe.result

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
==== Setup tables ====
 
2
CREATE TABLE t1 (a INT);
 
3
CREATE TABLE t2 (a CHAR(40));
 
4
CREATE TABLE t3 (a INT AUTO_INCREMENT PRIMARY KEY);
 
5
CREATE TABLE trigger_table (a CHAR(7));
 
6
CREATE TABLE trigger_table2 (a INT);
 
7
==== Non-deterministic statements ====
 
8
INSERT DELAYED INTO t1 VALUES (5);
 
9
==== Some variables that *should* be unsafe ====
 
10
---- Insert directly ----
 
11
INSERT INTO t1 VALUES (@@global.sync_binlog);
 
12
Warnings:
 
13
Note    1592    Statement may not be safe to log in statement format.
 
14
INSERT INTO t1 VALUES (@@session.insert_id);
 
15
Warnings:
 
16
Note    1592    Statement may not be safe to log in statement format.
 
17
INSERT INTO t1 VALUES (@@global.auto_increment_increment);
 
18
Warnings:
 
19
Note    1592    Statement may not be safe to log in statement format.
 
20
INSERT INTO t2 SELECT UUID();
 
21
Warnings:
 
22
Note    1592    Statement may not be safe to log in statement format.
 
23
INSERT INTO t2 VALUES (@@session.sql_mode);
 
24
Warnings:
 
25
Note    1592    Statement may not be safe to log in statement format.
 
26
INSERT INTO t2 VALUES (@@global.init_slave);
 
27
Warnings:
 
28
Note    1592    Statement may not be safe to log in statement format.
 
29
INSERT INTO t2 VALUES (@@hostname);
 
30
Warnings:
 
31
Note    1592    Statement may not be safe to log in statement format.
 
32
---- Insert from stored procedure ----
 
33
CREATE PROCEDURE proc()
 
34
BEGIN
 
35
INSERT INTO t1 VALUES (@@global.sync_binlog);
 
36
INSERT INTO t1 VALUES (@@session.insert_id);
 
37
INSERT INTO t1 VALUES (@@global.auto_increment_increment);
 
38
INSERT INTO t2 SELECT UUID();
 
39
INSERT INTO t2 VALUES (@@session.sql_mode);
 
40
INSERT INTO t2 VALUES (@@global.init_slave);
 
41
INSERT INTO t2 VALUES (@@hostname);
 
42
END|
 
43
CALL proc();
 
44
Warnings:
 
45
Note    1592    Statement may not be safe to log in statement format.
 
46
Note    1592    Statement may not be safe to log in statement format.
 
47
Note    1592    Statement may not be safe to log in statement format.
 
48
Note    1592    Statement may not be safe to log in statement format.
 
49
Note    1592    Statement may not be safe to log in statement format.
 
50
Note    1592    Statement may not be safe to log in statement format.
 
51
Note    1592    Statement may not be safe to log in statement format.
 
52
---- Insert from stored function ----
 
53
CREATE FUNCTION func()
 
54
RETURNS INT
 
55
BEGIN
 
56
INSERT INTO t1 VALUES (@@global.sync_binlog);
 
57
INSERT INTO t1 VALUES (@@session.insert_id);
 
58
INSERT INTO t1 VALUES (@@global.auto_increment_increment);
 
59
INSERT INTO t2 SELECT UUID();
 
60
INSERT INTO t2 VALUES (@@session.sql_mode);
 
61
INSERT INTO t2 VALUES (@@global.init_slave);
 
62
INSERT INTO t2 VALUES (@@hostname);
 
63
RETURN 0;
 
64
END|
 
65
SELECT func();
 
66
func()
 
67
0
 
68
Warnings:
 
69
Note    1592    Statement may not be safe to log in statement format.
 
70
Note    1592    Statement may not be safe to log in statement format.
 
71
Note    1592    Statement may not be safe to log in statement format.
 
72
Note    1592    Statement may not be safe to log in statement format.
 
73
Note    1592    Statement may not be safe to log in statement format.
 
74
Note    1592    Statement may not be safe to log in statement format.
 
75
Note    1592    Statement may not be safe to log in statement format.
 
76
---- Insert from trigger ----
 
77
CREATE TRIGGER trig
 
78
BEFORE INSERT ON trigger_table
 
79
FOR EACH ROW
 
80
BEGIN
 
81
INSERT INTO t1 VALUES (@@global.sync_binlog);
 
82
INSERT INTO t1 VALUES (@@session.insert_id);
 
83
INSERT INTO t1 VALUES (@@global.auto_increment_increment);
 
84
INSERT INTO t2 SELECT UUID();
 
85
INSERT INTO t2 VALUES (@@session.sql_mode);
 
86
INSERT INTO t2 VALUES (@@global.init_slave);
 
87
INSERT INTO t2 VALUES (@@hostname);
 
88
END|
 
89
INSERT INTO trigger_table VALUES ('bye.');
 
90
Warnings:
 
91
Note    1592    Statement may not be safe to log in statement format.
 
92
Note    1592    Statement may not be safe to log in statement format.
 
93
Note    1592    Statement may not be safe to log in statement format.
 
94
Note    1592    Statement may not be safe to log in statement format.
 
95
Note    1592    Statement may not be safe to log in statement format.
 
96
Note    1592    Statement may not be safe to log in statement format.
 
97
Note    1592    Statement may not be safe to log in statement format.
 
98
Note    1592    Statement may not be safe to log in statement format.
 
99
---- Insert from prepared statement ----
 
100
PREPARE p1 FROM 'INSERT INTO t1 VALUES (@@global.sync_binlog)';
 
101
PREPARE p2 FROM 'INSERT INTO t1 VALUES (@@session.insert_id)';
 
102
PREPARE p3 FROM 'INSERT INTO t1 VALUES (@@global.auto_increment_increment)';
 
103
PREPARE p4 FROM 'INSERT INTO t2 SELECT UUID()';
 
104
PREPARE p5 FROM 'INSERT INTO t2 VALUES (@@session.sql_mode)';
 
105
PREPARE p6 FROM 'INSERT INTO t2 VALUES (@@global.init_slave)';
 
106
PREPARE p7 FROM 'INSERT INTO t2 VALUES (@@hostname)';
 
107
EXECUTE p1;
 
108
Warnings:
 
109
Note    1592    Statement may not be safe to log in statement format.
 
110
EXECUTE p2;
 
111
Warnings:
 
112
Note    1592    Statement may not be safe to log in statement format.
 
113
EXECUTE p3;
 
114
Warnings:
 
115
Note    1592    Statement may not be safe to log in statement format.
 
116
EXECUTE p4;
 
117
Warnings:
 
118
Note    1592    Statement may not be safe to log in statement format.
 
119
EXECUTE p5;
 
120
Warnings:
 
121
Note    1592    Statement may not be safe to log in statement format.
 
122
EXECUTE p6;
 
123
Warnings:
 
124
Note    1592    Statement may not be safe to log in statement format.
 
125
EXECUTE p7;
 
126
Warnings:
 
127
Note    1592    Statement may not be safe to log in statement format.
 
128
---- Insert from nested call of triggers / functions / procedures ----
 
129
CREATE PROCEDURE proc1()
 
130
INSERT INTO trigger_table VALUES ('ha!')|
 
131
CREATE FUNCTION func2()
 
132
RETURNS INT
 
133
BEGIN
 
134
CALL proc1();
 
135
RETURN 0;
 
136
END|
 
137
CREATE TRIGGER trig3
 
138
BEFORE INSERT ON trigger_table2
 
139
FOR EACH ROW
 
140
BEGIN
 
141
DECLARE tmp INT;
 
142
SELECT func2() INTO tmp;
 
143
END|
 
144
CREATE PROCEDURE proc4()
 
145
INSERT INTO trigger_table2 VALUES (1)|
 
146
CREATE FUNCTION func5()
 
147
RETURNS INT
 
148
BEGIN
 
149
CALL proc4;
 
150
RETURN 0;
 
151
END|
 
152
PREPARE prep6 FROM 'SELECT func5()'|
 
153
EXECUTE prep6;
 
154
func5()
 
155
0
 
156
Warnings:
 
157
Note    1592    Statement may not be safe to log in statement format.
 
158
Note    1592    Statement may not be safe to log in statement format.
 
159
Note    1592    Statement may not be safe to log in statement format.
 
160
Note    1592    Statement may not be safe to log in statement format.
 
161
Note    1592    Statement may not be safe to log in statement format.
 
162
Note    1592    Statement may not be safe to log in statement format.
 
163
Note    1592    Statement may not be safe to log in statement format.
 
164
==== Variables that should *not* be unsafe ====
 
165
INSERT INTO t1 VALUES (@@session.pseudo_thread_id);
 
166
INSERT INTO t1 VALUES (@@session.pseudo_thread_id);
 
167
INSERT INTO t1 VALUES (@@session.foreign_key_checks);
 
168
INSERT INTO t1 VALUES (@@session.sql_auto_is_null);
 
169
INSERT INTO t1 VALUES (@@session.unique_checks);
 
170
INSERT INTO t1 VALUES (@@session.auto_increment_increment);
 
171
INSERT INTO t1 VALUES (@@session.auto_increment_offset);
 
172
INSERT INTO t2 VALUES (@@session.character_set_client);
 
173
INSERT INTO t2 VALUES (@@session.collation_connection);
 
174
INSERT INTO t2 VALUES (@@session.collation_server);
 
175
INSERT INTO t2 VALUES (@@session.time_zone);
 
176
INSERT INTO t2 VALUES (@@session.lc_time_names);
 
177
INSERT INTO t2 VALUES (@@session.collation_database);
 
178
INSERT INTO t2 VALUES (@@session.timestamp);
 
179
INSERT INTO t2 VALUES (@@session.last_insert_id);
 
180
SET @my_var= 4711;
 
181
INSERT INTO t1 VALUES (@my_var);
 
182
SET insert_id=12;
 
183
INSERT INTO t3 VALUES (NULL);
 
184
==== Clean up ====
 
185
DROP PROCEDURE proc;
 
186
DROP FUNCTION  func;
 
187
DROP TRIGGER   trig;
 
188
DROP PROCEDURE proc1;
 
189
DROP FUNCTION  func2;
 
190
DROP TRIGGER   trig3;
 
191
DROP PROCEDURE proc4;
 
192
DROP FUNCTION  func5;
 
193
DROP PREPARE   prep6;
 
194
DROP TABLE t1, t2, t3, trigger_table, trigger_table2;
 
195
CREATE TABLE t1(a INT, b INT, KEY(a), PRIMARY KEY(b));
 
196
INSERT INTO t1 SELECT * FROM t1 LIMIT 1;
 
197
Warnings:
 
198
Note    1592    Statement may not be safe to log in statement format.
 
199
REPLACE INTO t1 SELECT * FROM t1 LIMIT 1;
 
200
Warnings:
 
201
Note    1592    Statement may not be safe to log in statement format.
 
202
UPDATE t1 SET a=1 LIMIT 1;
 
203
Warnings:
 
204
Note    1592    Statement may not be safe to log in statement format.
 
205
DELETE FROM t1 LIMIT 1;
 
206
Warnings:
 
207
Note    1592    Statement may not be safe to log in statement format.
 
208
CREATE PROCEDURE p1()
 
209
BEGIN
 
210
INSERT INTO t1 SELECT * FROM t1 LIMIT 1;
 
211
REPLACE INTO t1 SELECT * FROM t1 LIMIT 1;
 
212
UPDATE t1 SET a=1 LIMIT 1;
 
213
DELETE FROM t1 LIMIT 1;
 
214
END|
 
215
CALL p1();
 
216
Warnings:
 
217
Note    1592    Statement may not be safe to log in statement format.
 
218
Note    1592    Statement may not be safe to log in statement format.
 
219
Note    1592    Statement may not be safe to log in statement format.
 
220
Note    1592    Statement may not be safe to log in statement format.
 
221
DROP PROCEDURE p1;
 
222
DROP TABLE t1;
 
223
DROP TABLE IF EXISTS t1;
 
224
CREATE TABLE t1 (a VARCHAR(100), b VARCHAR(100));
 
225
INSERT INTO t1 VALUES ('a','b');
 
226
UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1;
 
227
Warnings:
 
228
Note    1592    Statement may not be safe to log in statement format.
 
229
DROP TABLE t1;
 
230
DROP TABLE IF EXISTS t1, t2;
 
231
CREATE TABLE t1(i INT PRIMARY KEY);
 
232
CREATE TABLE t2(i INT PRIMARY KEY);
 
233
CREATE TABLE t3(i INT, ch CHAR(50));
 
234
"Should issue message Statement may not be safe to log in statement format."
 
235
INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
 
236
Warnings:
 
237
Note    1592    Statement may not be safe to log in statement format.
 
238
CREATE FUNCTION func6()
 
239
RETURNS INT
 
240
BEGIN
 
241
INSERT INTO t1 VALUES (10);
 
242
INSERT INTO t1 VALUES (11);
 
243
INSERT INTO t1 VALUES (12);
 
244
RETURN 0;
 
245
END|
 
246
"Should issue message Statement may not be safe to log in statement format only once"
 
247
INSERT INTO t3 VALUES(func6(), UUID());
 
248
Warnings:
 
249
Note    1592    Statement may not be safe to log in statement format.
 
250
"Check whether SET @@SQL_LOG_BIN = 0/1 doesn't work in substatements"
 
251
CREATE FUNCTION fun_check_log_bin() RETURNS INT
 
252
BEGIN
 
253
SET @@SQL_LOG_BIN = 0;
 
254
INSERT INTO t1 VALUES(@@global.sync_binlog);
 
255
RETURN 100;
 
256
END|
 
257
"One unsafe warning should be issued in the following statement"
 
258
SELECT fun_check_log_bin();
 
259
fun_check_log_bin()
 
260
100
 
261
Warnings:
 
262
Note    1592    Statement may not be safe to log in statement format.
 
263
"SQL_LOG_BIN should be ON still"
 
264
SHOW VARIABLES LIKE "SQL_LOG_BIN";
 
265
Variable_name   Value
 
266
sql_log_bin     ON
 
267
set @save_log_bin = @@SESSION.SQL_LOG_BIN;
 
268
set @@SESSION.SQL_LOG_BIN = 0;
 
269
"Should NOT have any warning message issued in the following statements"
 
270
INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
 
271
DROP TABLE t1,t2;
 
272
"Should NOT have any warning message issued in the following func7() and trig"
 
273
CREATE TABLE t1 (a INT);
 
274
CREATE TABLE t2 (a CHAR(40));
 
275
CREATE TABLE trigger_table (a CHAR(7));
 
276
CREATE FUNCTION func7()
 
277
RETURNS INT
 
278
BEGIN
 
279
INSERT INTO t1 VALUES (@@global.sync_binlog);
 
280
INSERT INTO t1 VALUES (@@session.insert_id);
 
281
INSERT INTO t2 SELECT UUID();
 
282
INSERT INTO t2 VALUES (@@session.sql_mode);
 
283
INSERT INTO t2 VALUES (@@global.init_slave);
 
284
RETURN 0;
 
285
END|
 
286
SHOW VARIABLES LIKE "SQL_LOG_BIN";
 
287
Variable_name   Value
 
288
sql_log_bin     OFF
 
289
SELECT func7();
 
290
func7()
 
291
0
 
292
---- Insert from trigger ----
 
293
CREATE TRIGGER trig
 
294
BEFORE INSERT ON trigger_table
 
295
FOR EACH ROW
 
296
BEGIN
 
297
INSERT INTO t1 VALUES (@@global.sync_binlog);
 
298
INSERT INTO t1 VALUES (@@session.insert_id);
 
299
INSERT INTO t1 VALUES (@@global.auto_increment_increment);
 
300
INSERT INTO t2 SELECT UUID();
 
301
INSERT INTO t2 VALUES (@@session.sql_mode);
 
302
INSERT INTO t2 VALUES (@@global.init_slave);
 
303
INSERT INTO t2 VALUES (@@hostname);
 
304
END|
 
305
INSERT INTO trigger_table VALUES ('bye.');
 
306
DROP FUNCTION fun_check_log_bin;
 
307
DROP FUNCTION func6;
 
308
DROP FUNCTION func7;
 
309
DROP TRIGGER  trig;
 
310
DROP TABLE t1, t2, t3, trigger_table;
 
311
set @@SESSION.SQL_LOG_BIN = @save_log_bin;
 
312
SET @save_sql_mode = @@SESSION.SQL_MODE;
 
313
SET @@SESSION.SQL_MODE = STRICT_ALL_TABLES;
 
314
CREATE TABLE t1(i INT PRIMARY KEY);
 
315
CREATE TABLE t2(i INT PRIMARY KEY);
 
316
INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
 
317
Warnings:
 
318
Note    1592    Statement may not be safe to log in statement format.
 
319
INSERT INTO t1 VALUES(@@global.sync_binlog);
 
320
Warnings:
 
321
Note    1592    Statement may not be safe to log in statement format.
 
322
UPDATE t1 SET i = 999 LIMIT 1;
 
323
Warnings:
 
324
Note    1592    Statement may not be safe to log in statement format.
 
325
DELETE FROM t1 LIMIT 1;
 
326
Warnings:
 
327
Note    1592    Statement may not be safe to log in statement format.
 
328
DROP TABLE t1, t2;
 
329
SET @@SESSION.SQL_MODE = @save_sql_mode;
 
330
CREATE TABLE t1 (a VARCHAR(1000));
 
331
INSERT INTO t1 VALUES (CURRENT_USER());
 
332
Warnings:
 
333
Note    1592    Statement may not be safe to log in statement format.
 
334
INSERT INTO t1 VALUES (FOUND_ROWS());
 
335
Warnings:
 
336
Note    1592    Statement may not be safe to log in statement format.
 
337
INSERT INTO t1 VALUES (GET_LOCK('tmp', 1));
 
338
Warnings:
 
339
Note    1592    Statement may not be safe to log in statement format.
 
340
INSERT INTO t1 VALUES (IS_FREE_LOCK('tmp'));
 
341
Warnings:
 
342
Note    1592    Statement may not be safe to log in statement format.
 
343
INSERT INTO t1 VALUES (IS_USED_LOCK('tmp'));
 
344
Warnings:
 
345
Note    1592    Statement may not be safe to log in statement format.
 
346
INSERT INTO t1 VALUES (LOAD_FILE('../../std_data/words2.dat'));
 
347
Warnings:
 
348
Note    1592    Statement may not be safe to log in statement format.
 
349
INSERT INTO t1 VALUES (MASTER_POS_WAIT('dummy arg', 4711, 1));
 
350
Warnings:
 
351
Note    1592    Statement may not be safe to log in statement format.
 
352
INSERT INTO t1 VALUES (RELEASE_LOCK('tmp'));
 
353
Warnings:
 
354
Note    1592    Statement may not be safe to log in statement format.
 
355
INSERT INTO t1 VALUES (ROW_COUNT());
 
356
Warnings:
 
357
Note    1592    Statement may not be safe to log in statement format.
 
358
INSERT INTO t1 VALUES (SESSION_USER());
 
359
Warnings:
 
360
Note    1592    Statement may not be safe to log in statement format.
 
361
INSERT INTO t1 VALUES (SLEEP(1));
 
362
Warnings:
 
363
Note    1592    Statement may not be safe to log in statement format.
 
364
INSERT INTO t1 VALUES (SYSDATE());
 
365
Warnings:
 
366
Note    1592    Statement may not be safe to log in statement format.
 
367
INSERT INTO t1 VALUES (SYSTEM_USER());
 
368
Warnings:
 
369
Note    1592    Statement may not be safe to log in statement format.
 
370
INSERT INTO t1 VALUES (USER());
 
371
Warnings:
 
372
Note    1592    Statement may not be safe to log in statement format.
 
373
INSERT INTO t1 VALUES (UUID());
 
374
Warnings:
 
375
Note    1592    Statement may not be safe to log in statement format.
 
376
INSERT INTO t1 VALUES (UUID_SHORT());
 
377
Warnings:
 
378
Note    1592    Statement may not be safe to log in statement format.
 
379
INSERT INTO t1 VALUES (VERSION());
 
380
Warnings:
 
381
Note    1592    Statement may not be safe to log in statement format.
 
382
INSERT INTO t1 VALUES (RAND());
 
383
Warnings:
 
384
Note    1592    Statement may not be safe to log in statement format.
 
385
DELETE FROM t1;
 
386
SET TIMESTAMP=1000000;
 
387
INSERT INTO t1 VALUES
 
388
(CURDATE()),
 
389
(CURRENT_DATE()),
 
390
(CURRENT_TIME()),
 
391
(CURRENT_TIMESTAMP()),
 
392
(CURTIME()),
 
393
(LOCALTIME()),
 
394
(LOCALTIMESTAMP()),
 
395
(NOW()),
 
396
(UNIX_TIMESTAMP()),
 
397
(UTC_DATE()),
 
398
(UTC_TIME()),
 
399
(UTC_TIMESTAMP());
 
400
SELECT * FROM t1;
 
401
a
 
402
1970-01-12
 
403
1970-01-12
 
404
16:46:40
 
405
1970-01-12 16:46:40
 
406
16:46:40
 
407
1970-01-12 16:46:40
 
408
1970-01-12 16:46:40
 
409
1970-01-12 16:46:40
 
410
1000000
 
411
1970-01-12
 
412
13:46:40
 
413
1970-01-12 13:46:40
 
414
DROP TABLE t1;
 
415
"End of tests"