blob: 61b5a4ed773ceb58005a3b015ea9ad41e56d5eff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
include/master-slave.inc
[connection master]
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
connection slave;
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
connection master;
CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t2 (id INT AUTO_INCREMENT PRIMARY KEY);
CREATE PROCEDURE p1()
BEGIN
DECLARE ins_count INT DEFAULT 10;
WHILE ins_count > 0 DO
INSERT INTO t1 VALUES (NULL);
SET ins_count = ins_count - 1;
END WHILE;
DELETE FROM t1 WHERE id = 1;
DELETE FROM t1 WHERE id = 2;
DELETE FROM t2 WHERE id = 1;
DELETE FROM t2 WHERE id = 2;
END//
CREATE PROCEDURE p2()
BEGIN
INSERT INTO t1 VALUES (NULL);
DELETE FROM t1 WHERE id = f1(3);
DELETE FROM t1 WHERE id = f1(4);
DELETE FROM t2 WHERE id = 3;
DELETE FROM t2 WHERE id = 4;
END//
CREATE TRIGGER tr1 BEFORE DELETE
ON t1 FOR EACH ROW
BEGIN
INSERT INTO t2 VALUES (NULL);
END//
CREATE FUNCTION f1 (i int) RETURNS int
BEGIN
INSERT INTO t2 VALUES (NULL);
RETURN i;
END//
CALL p1();
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=1
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=2
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=3
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=4
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=5
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=6
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=7
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=8
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=9
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=10
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=1
master-bin.000001 # Query # # use `test`; DELETE FROM t1 WHERE id = 1
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=2
master-bin.000001 # Query # # use `test`; DELETE FROM t1 WHERE id = 2
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; DELETE FROM t2 WHERE id = 1
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; DELETE FROM t2 WHERE id = 2
master-bin.000001 # Query # # COMMIT
# Result on master
SELECT * FROM t1;
id
3
4
5
6
7
8
9
10
SELECT * FROM t2;
id
connection slave;
SELECT * FROM t1;
id
3
4
5
6
7
8
9
10
SELECT * FROM t2;
id
connection master;
DROP TRIGGER tr1;
CALL p2();
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=11
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=3
master-bin.000001 # Query # # use `test`; DELETE FROM t1 WHERE id = f1(3)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Intvar # # INSERT_ID=12
master-bin.000001 # Query # # use `test`; DELETE FROM t1 WHERE id = f1(4)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; DELETE FROM t2 WHERE id = 3
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; DELETE FROM t2 WHERE id = 4
master-bin.000001 # Query # # COMMIT
# Result on master
SELECT * FROM t1;
id
5
6
7
8
9
10
11
SELECT * FROM t2;
id
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
connection slave;
SELECT * FROM t1;
id
5
6
7
8
9
10
11
SELECT * FROM t2;
id
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
connection master;
DROP TABLE IF EXISTS t1, t2;
DROP PROCEDURE IF EXISTS p1;
DROP PROCEDURE IF EXISTS p2;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS tr1;
connection slave;
include/rpl_end.inc
|