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);
13
Warning 1592 Statement is not safe to log in statement format.
14
INSERT INTO t1 VALUES (@@session.insert_id);
16
Warning 1592 Statement is not safe to log in statement format.
17
INSERT INTO t1 VALUES (@@global.auto_increment_increment);
19
Warning 1592 Statement is not safe to log in statement format.
20
INSERT INTO t2 SELECT UUID();
22
Warning 1592 Statement is not safe to log in statement format.
23
INSERT INTO t2 VALUES (@@session.sql_mode);
25
Warning 1592 Statement is not safe to log in statement format.
26
INSERT INTO t2 VALUES (@@global.init_slave);
28
Warning 1592 Statement is not safe to log in statement format.
29
INSERT INTO t2 VALUES (@@hostname);
31
Warning 1592 Statement is not safe to log in statement format.
32
---- Insert from stored procedure ----
33
CREATE PROCEDURE proc()
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);
45
Warning 1592 Statement is not safe to log in statement format.
46
Warning 1592 Statement is not safe to log in statement format.
47
Warning 1592 Statement is not safe to log in statement format.
48
Warning 1592 Statement is not safe to log in statement format.
49
Warning 1592 Statement is not safe to log in statement format.
50
Warning 1592 Statement is not safe to log in statement format.
51
Warning 1592 Statement is not safe to log in statement format.
52
---- Insert from stored function ----
53
CREATE FUNCTION func()
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);
69
Warning 1592 Statement is not safe to log in statement format.
70
Warning 1592 Statement is not safe to log in statement format.
71
Warning 1592 Statement is not safe to log in statement format.
72
Warning 1592 Statement is not safe to log in statement format.
73
Warning 1592 Statement is not safe to log in statement format.
74
Warning 1592 Statement is not safe to log in statement format.
75
Warning 1592 Statement is not safe to log in statement format.
76
---- Insert from trigger ----
78
BEFORE INSERT ON trigger_table
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);
89
INSERT INTO trigger_table VALUES ('bye.');
91
Warning 1592 Statement is not safe to log in statement format.
92
Warning 1592 Statement is not safe to log in statement format.
93
Warning 1592 Statement is not safe to log in statement format.
94
Warning 1592 Statement is not safe to log in statement format.
95
Warning 1592 Statement is not safe to log in statement format.
96
Warning 1592 Statement is not safe to log in statement format.
97
Warning 1592 Statement is not safe to log in statement format.
98
Warning 1592 Statement is not 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)';
109
Warning 1592 Statement is not safe to log in statement format.
112
Warning 1592 Statement is not safe to log in statement format.
115
Warning 1592 Statement is not safe to log in statement format.
118
Warning 1592 Statement is not safe to log in statement format.
121
Warning 1592 Statement is not safe to log in statement format.
124
Warning 1592 Statement is not safe to log in statement format.
127
Warning 1592 Statement is not 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()
138
BEFORE INSERT ON trigger_table2
142
SELECT func2() INTO tmp;
144
CREATE PROCEDURE proc4()
145
INSERT INTO trigger_table2 VALUES (1)|
146
CREATE FUNCTION func5()
152
PREPARE prep6 FROM 'SELECT func5()'|
157
Warning 1592 Statement is not safe to log in statement format.
158
Warning 1592 Statement is not safe to log in statement format.
159
Warning 1592 Statement is not safe to log in statement format.
160
Warning 1592 Statement is not safe to log in statement format.
161
Warning 1592 Statement is not safe to log in statement format.
162
Warning 1592 Statement is not safe to log in statement format.
163
Warning 1592 Statement is not 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);
181
INSERT INTO t1 VALUES (@my_var);
183
INSERT INTO t3 VALUES (NULL);
188
DROP PROCEDURE proc1;
191
DROP PROCEDURE proc4;
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;
198
Warning 1592 Statement is not safe to log in statement format.
199
REPLACE INTO t1 SELECT * FROM t1 LIMIT 1;
201
Warning 1592 Statement is not safe to log in statement format.
202
UPDATE t1 SET a=1 LIMIT 1;
204
Warning 1592 Statement is not safe to log in statement format.
205
DELETE FROM t1 LIMIT 1;
207
Warning 1592 Statement is not safe to log in statement format.
208
CREATE PROCEDURE p1()
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;
217
Warning 1592 Statement is not safe to log in statement format.
218
Warning 1592 Statement is not safe to log in statement format.
219
Warning 1592 Statement is not safe to log in statement format.
220
Warning 1592 Statement is not safe to log in statement format.