mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
5e881cc435
BREAKS RBR Analysis: -------- A table created using a query of the format: CREATE TABLE t1 AS SELECT REPEAT('A',1000) DIV 1 AS a; breaks the Row Based Replication. The query above creates a table having a field of datatype 'bigint' with a display width of 3000 which is beyond the maximum acceptable value of 255. In the RBR mode, CREATE TABLE SELECT statement is replicated as a combination of CREATE TABLE statement equivalent to one the returned by SHOW CREATE TABLE and row events for rows inserted. When this CREATE TABLE event is executed on the slave, an error is reported: Display width out of range for column 'a' (max = 255) The following is the output of 'SHOW CREATE TABLE t1': CREATE TABLE t1(`a` bigint(3000) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1; The problem is due to the combination of two facts: 1) The above CREATE TABLE SELECT statement uses the display width of the result of DIV operation as the display width of the column created without validating the width for out of bound condition. 2) The DIV operation incorrectly returns the length of its first argument as the display width of its result; thus allowing creation of a table with an incorrect display width of 3000 for the field. Fix: ---- This fix changes the DIV operation implementation to correctly evaluate the display width of its result. We check if DIV's results estimated width crosses maximum width for integer value (21) and if yes set it to this maximum value. This patch also fixes fixes maximum display width evaluation for DIV function when its first argument is in UCS2.
28 lines
694 B
Text
28 lines
694 B
Text
# Testing table creations for row-based replication.
|
|
|
|
--source include/have_binlog_format_row.inc
|
|
--source include/master-slave.inc
|
|
|
|
--echo #
|
|
--echo # BUG#17994219: CREATE TABLE .. SELECT PRODUCES INVALID STRUCTURE,
|
|
--echo # BREAKS RBR
|
|
--echo #
|
|
|
|
connection master;
|
|
--echo #After the patch, the display width is set to a default
|
|
--echo #value of 21.
|
|
CREATE TABLE t1 AS SELECT REPEAT('A', 1000) DIV 1 AS a;
|
|
SHOW CREATE TABLE t1;
|
|
|
|
CREATE TABLE t2 AS SELECT CONVERT(REPEAT('A', 255) USING UCS2) DIV 1 AS a;
|
|
SHOW CREATE TABLE t2;
|
|
|
|
--echo #After the patch, no error is reported.
|
|
sync_slave_with_master;
|
|
|
|
connection master;
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
|
|
--source include/rpl_end.inc
|
|
|