Skip to content

Commit d4ae3e2

Browse files
author
Luis Soares
committed
BUG#49562: SBR out of sync when using numeric data types + user
variable Incremental commit: 1. Moved part of the test case to binlog suite. 2. Removed cast set when writing the flags field.
1 parent 14d959f commit d4ae3e2

File tree

5 files changed

+243
-69
lines changed

5 files changed

+243
-69
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
SET @positive= 18446744073709551615;
2+
SET @negative= -9223372036854775808;
3+
CREATE TABLE t1 (`tinyint` TINYINT,
4+
`smallint` SMALLINT,
5+
`mediumint` MEDIUMINT,
6+
`integer` INTEGER,
7+
`bigint` BIGINT,
8+
`utinyint` TINYINT UNSIGNED,
9+
`usmallint` SMALLINT UNSIGNED,
10+
`umediumint` MEDIUMINT UNSIGNED,
11+
`uinteger` INTEGER UNSIGNED,
12+
`ubigint` BIGINT UNSIGNED,
13+
`double` DOUBLE,
14+
`float` FLOAT,
15+
`real` REAL(30,2),
16+
`decimal` DECIMAL(30,2)) ENGINE = MyISAM;
17+
### insert max unsigned
18+
### a) declarative
19+
INSERT INTO t1 VALUES (18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615,18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615);;
20+
TRUNCATE t1;
21+
### b) user var
22+
INSERT INTO t1 VALUES (@positive,
23+
@positive,
24+
@positive,
25+
@positive,
26+
@positive,
27+
@positive,
28+
@positive,
29+
@positive,
30+
@positive,
31+
@positive,
32+
@positive,
33+
@positive,
34+
@positive,
35+
@positive);
36+
## assertion: checks that User_var_log_event::pack_info
37+
## correctly displays the binlog content by taking into
38+
## account the unsigned_flag
39+
show binlog events from <binlog_start>;
40+
Log_name Pos Event_type Server_id End_log_pos Info
41+
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (`tinyint` TINYINT,
42+
`smallint` SMALLINT,
43+
`mediumint` MEDIUMINT,
44+
`integer` INTEGER,
45+
`bigint` BIGINT,
46+
`utinyint` TINYINT UNSIGNED,
47+
`usmallint` SMALLINT UNSIGNED,
48+
`umediumint` MEDIUMINT UNSIGNED,
49+
`uinteger` INTEGER UNSIGNED,
50+
`ubigint` BIGINT UNSIGNED,
51+
`double` DOUBLE,
52+
`float` FLOAT,
53+
`real` REAL(30,2),
54+
`decimal` DECIMAL(30,2)) ENGINE = MyISAM
55+
master-bin.000001 # Query # # BEGIN
56+
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615,18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615)
57+
master-bin.000001 # Query # # COMMIT
58+
master-bin.000001 # Query # # use `test`; TRUNCATE t1
59+
master-bin.000001 # Query # # BEGIN
60+
master-bin.000001 # User var # # @`positive`=18446744073709551615
61+
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (@positive,
62+
@positive,
63+
@positive,
64+
@positive,
65+
@positive,
66+
@positive,
67+
@positive,
68+
@positive,
69+
@positive,
70+
@positive,
71+
@positive,
72+
@positive,
73+
@positive,
74+
@positive)
75+
master-bin.000001 # Query # # COMMIT
76+
### insert min signed
77+
### a) declarative
78+
INSERT INTO t1 VALUES (-9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808,-9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808);;
79+
TRUNCATE t1;
80+
### b) user var
81+
INSERT INTO t1 VALUES (@negative,
82+
@negative,
83+
@negative,
84+
@negative,
85+
@negative,
86+
@negative,
87+
@negative,
88+
@negative,
89+
@negative,
90+
@negative,
91+
@negative,
92+
@negative,
93+
@negative,
94+
@negative);
95+
## assertion: checks that User_var_log_event::pack_info
96+
## correctly displays the binlog content by taking into
97+
## account the unsigned_flag
98+
show binlog events from <binlog_start>;
99+
Log_name Pos Event_type Server_id End_log_pos Info
100+
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (`tinyint` TINYINT,
101+
`smallint` SMALLINT,
102+
`mediumint` MEDIUMINT,
103+
`integer` INTEGER,
104+
`bigint` BIGINT,
105+
`utinyint` TINYINT UNSIGNED,
106+
`usmallint` SMALLINT UNSIGNED,
107+
`umediumint` MEDIUMINT UNSIGNED,
108+
`uinteger` INTEGER UNSIGNED,
109+
`ubigint` BIGINT UNSIGNED,
110+
`double` DOUBLE,
111+
`float` FLOAT,
112+
`real` REAL(30,2),
113+
`decimal` DECIMAL(30,2)) ENGINE = MyISAM
114+
master-bin.000001 # Query # # BEGIN
115+
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615,18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615)
116+
master-bin.000001 # Query # # COMMIT
117+
master-bin.000001 # Query # # use `test`; TRUNCATE t1
118+
master-bin.000001 # Query # # BEGIN
119+
master-bin.000001 # User var # # @`positive`=18446744073709551615
120+
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (@positive,
121+
@positive,
122+
@positive,
123+
@positive,
124+
@positive,
125+
@positive,
126+
@positive,
127+
@positive,
128+
@positive,
129+
@positive,
130+
@positive,
131+
@positive,
132+
@positive,
133+
@positive)
134+
master-bin.000001 # Query # # COMMIT
135+
master-bin.000001 # Query # # BEGIN
136+
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (-9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808,-9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808)
137+
master-bin.000001 # Query # # COMMIT
138+
master-bin.000001 # Query # # use `test`; TRUNCATE t1
139+
master-bin.000001 # Query # # BEGIN
140+
master-bin.000001 # User var # # @`negative`=-9223372036854775808
141+
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (@negative,
142+
@negative,
143+
@negative,
144+
@negative,
145+
@negative,
146+
@negative,
147+
@negative,
148+
@negative,
149+
@negative,
150+
@negative,
151+
@negative,
152+
@negative,
153+
@negative,
154+
@negative)
155+
master-bin.000001 # Query # # COMMIT
156+
DROP TABLE t1;
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
-- source include/have_binlog_format_statement.inc
2+
#
3+
# BUG#49562: SBR out of sync when using numeric data types + user variable
4+
#
5+
6+
-- let $max_unsigned_long= 18446744073709551615
7+
-- let $min_signed_long= -9223372036854775808
8+
-- eval SET @positive= $max_unsigned_long
9+
-- eval SET @negative= $min_signed_long
10+
11+
CREATE TABLE t1 (`tinyint` TINYINT,
12+
`smallint` SMALLINT,
13+
`mediumint` MEDIUMINT,
14+
`integer` INTEGER,
15+
`bigint` BIGINT,
16+
`utinyint` TINYINT UNSIGNED,
17+
`usmallint` SMALLINT UNSIGNED,
18+
`umediumint` MEDIUMINT UNSIGNED,
19+
`uinteger` INTEGER UNSIGNED,
20+
`ubigint` BIGINT UNSIGNED,
21+
`double` DOUBLE,
22+
`float` FLOAT,
23+
`real` REAL(30,2),
24+
`decimal` DECIMAL(30,2)) ENGINE = MyISAM;
25+
26+
-- echo ### insert max unsigned
27+
-- echo ### a) declarative
28+
-- disable_warnings
29+
-- eval INSERT INTO t1 VALUES ($max_unsigned_long, $max_unsigned_long, $max_unsigned_long, $max_unsigned_long, $max_unsigned_long, $max_unsigned_long, $max_unsigned_long,$max_unsigned_long, $max_unsigned_long, $max_unsigned_long, $max_unsigned_long, $max_unsigned_long, $max_unsigned_long, $max_unsigned_long);
30+
-- enable_warnings
31+
TRUNCATE t1;
32+
33+
-- echo ### b) user var
34+
-- disable_warnings
35+
INSERT INTO t1 VALUES (@positive,
36+
@positive,
37+
@positive,
38+
@positive,
39+
@positive,
40+
@positive,
41+
@positive,
42+
@positive,
43+
@positive,
44+
@positive,
45+
@positive,
46+
@positive,
47+
@positive,
48+
@positive);
49+
-- enable_warnings
50+
51+
-- echo ## assertion: checks that User_var_log_event::pack_info
52+
-- echo ## correctly displays the binlog content by taking into
53+
-- echo ## account the unsigned_flag
54+
-- source include/show_binlog_events.inc
55+
56+
-- echo ### insert min signed
57+
-- echo ### a) declarative
58+
-- disable_warnings
59+
-- eval INSERT INTO t1 VALUES ($min_signed_long, $min_signed_long, $min_signed_long, $min_signed_long, $min_signed_long, $min_signed_long, $min_signed_long,$min_signed_long, $min_signed_long, $min_signed_long, $min_signed_long, $min_signed_long, $min_signed_long, $min_signed_long);
60+
-- enable_warnings
61+
TRUNCATE t1;
62+
63+
-- echo ### b) user var
64+
-- disable_warnings
65+
INSERT INTO t1 VALUES (@negative,
66+
@negative,
67+
@negative,
68+
@negative,
69+
@negative,
70+
@negative,
71+
@negative,
72+
@negative,
73+
@negative,
74+
@negative,
75+
@negative,
76+
@negative,
77+
@negative,
78+
@negative);
79+
-- enable_warnings
80+
81+
-- echo ## assertion: checks that User_var_log_event::pack_info
82+
-- echo ## correctly displays the binlog content by taking into
83+
-- echo ## account the unsigned_flag
84+
-- source include/show_binlog_events.inc
85+
86+
DROP TABLE t1;

mysql-test/suite/rpl/r/rpl_stm_user_variables.result

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -205,67 +205,4 @@ decimal -9223372036854775808.00
205205
Comparing tables master:test.t1 and slave:test.t1
206206
TRUNCATE t1;
207207
## check: contents of both tables master's and slave's
208-
## assertion: checks that User_var_log_event::pack_info correctly
209-
## displays the binlog content by taking into account the
210-
## unsigned_flag
211-
show binlog events from <binlog_start>;
212-
Log_name Pos Event_type Server_id End_log_pos Info
213-
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (`tinyint` TINYINT,
214-
`smallint` SMALLINT,
215-
`mediumint` MEDIUMINT,
216-
`integer` INTEGER,
217-
`bigint` BIGINT,
218-
`utinyint` TINYINT UNSIGNED,
219-
`usmallint` SMALLINT UNSIGNED,
220-
`umediumint` MEDIUMINT UNSIGNED,
221-
`uinteger` INTEGER UNSIGNED,
222-
`ubigint` BIGINT UNSIGNED,
223-
`double` DOUBLE,
224-
`float` FLOAT,
225-
`real` REAL(30,2),
226-
`decimal` DECIMAL(30,2)) ENGINE = MyISAM
227-
master-bin.000001 # Query # # BEGIN
228-
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615,18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615)
229-
master-bin.000001 # Query # # COMMIT
230-
master-bin.000001 # Query # # use `test`; TRUNCATE t1
231-
master-bin.000001 # Query # # BEGIN
232-
master-bin.000001 # User var # # @`positive`=18446744073709551615
233-
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (@positive,
234-
@positive,
235-
@positive,
236-
@positive,
237-
@positive,
238-
@positive,
239-
@positive,
240-
@positive,
241-
@positive,
242-
@positive,
243-
@positive,
244-
@positive,
245-
@positive,
246-
@positive)
247-
master-bin.000001 # Query # # COMMIT
248-
master-bin.000001 # Query # # use `test`; TRUNCATE t1
249-
master-bin.000001 # Query # # BEGIN
250-
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (-9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808,-9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808, -9223372036854775808)
251-
master-bin.000001 # Query # # COMMIT
252-
master-bin.000001 # Query # # use `test`; TRUNCATE t1
253-
master-bin.000001 # Query # # BEGIN
254-
master-bin.000001 # User var # # @`negative`=-9223372036854775808
255-
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (@negative,
256-
@negative,
257-
@negative,
258-
@negative,
259-
@negative,
260-
@negative,
261-
@negative,
262-
@negative,
263-
@negative,
264-
@negative,
265-
@negative,
266-
@negative,
267-
@negative,
268-
@negative)
269-
master-bin.000001 # Query # # COMMIT
270-
master-bin.000001 # Query # # use `test`; TRUNCATE t1
271208
DROP TABLE t1;

mysql-test/suite/rpl/t/rpl_stm_user_variables.test

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ TRUNCATE t1;
135135
-- echo ## check: contents of both tables master's and slave's
136136
-- enable_warnings
137137

138-
-- echo ## assertion: checks that User_var_log_event::pack_info correctly
139-
-- echo ## displays the binlog content by taking into account the
140-
-- echo ## unsigned_flag
141-
-- source include/show_binlog_events.inc
142-
143138
## cleanup
144139
-- connection master
145140
DROP TABLE t1;

sql/log_event.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5629,7 +5629,7 @@ bool User_var_log_event::write(IO_CACHE* file)
56295629
my_b_safe_write(file, (uchar*) name, name_len) ||
56305630
my_b_safe_write(file, (uchar*) buf1, buf1_length) ||
56315631
my_b_safe_write(file, pos, val_len) ||
5632-
my_b_safe_write(file, (uchar*) &flags, unsigned_len));
5632+
my_b_safe_write(file, &flags, unsigned_len));
56335633
}
56345634
#endif
56355635

0 commit comments

Comments
 (0)