mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
0e0b05ec1d
This patch adds the ability to store extra field metadata in the table map event. This data can include pack_length() or field_lenght() for fields such as CHAR or VARCHAR enabling developers to add code that can check for compatibilty between master and slave columns. More importantly, the extra field metadata can be used to store data from the master correctly should a VARCHAR field on the master be <= 255 bytes while the same field on the slave is > 255 bytes. ' The patch also includes the needed changes to unpack to ensure that data which is smaller on the master can be unpacked correctly on the slave. mysql-test/extra/rpl_tests/rpl_log.test: WL#3228 : RBR using different table defs on slave/master This patch changes the test to display slave status vertically. mysql-test/r/rpl_ndb_log.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the new test designed to test the feature of having columns on the master that are smaller than what is on the slave. mysql-test/r/rpl_rbr_to_sbr.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the new test designed to test the feature of having columns on the master that are smaller than what is on the slave. mysql-test/r/rpl_row_basic_11bugs.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the new test designed to test the feature of having columns on the master that are smaller than what is on the slave. mysql-test/r/rpl_row_create_table.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the new test designed to test the feature of having columns on the master that are smaller than what is on the slave. mysql-test/r/rpl_row_flsh_tbls.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the new test designed to test the feature of having columns on the master that are smaller than what is on the slave. mysql-test/r/rpl_row_inexist_tbl.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the new test designed to test the feature of having columns on the master that are smaller than what is on the slave. mysql-test/r/rpl_row_log.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the new test designed to test the feature of having columns on the master that are smaller than what is on the slave. mysql-test/r/rpl_row_log_innodb.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the new test designed to test the feature of having columns on the master that are smaller than what is on the slave. mysql-test/r/rpl_row_max_relay_size.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the new test designed to test the feature of having columns on the master that are smaller than what is on the slave. mysql-test/r/rpl_row_until.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the new test designed to test the feature of having columns on the master that are smaller than what is on the slave. mysql-test/r/rpl_stm_log.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the rpl_log.test modifications. mysql-test/r/rpl_truncate_7ndb.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the new test designed to test the feature of having columns on the master that are smaller than what is on the slave. mysql-test/t/binlog_row_mix_innodb_myisam.test: WL#3228 : RBR using different table defs on slave/master This patch changes the test to coincide with changes to binlog size of table map event. mysql-test/t/rpl_row_create_table.test: WL#3228 : RBR using different table defs on slave/master This patch changes the test to coincide with changes to binlog size of table map event. mysql-test/t/rpl_row_flsh_tbls.test: WL#3228 : RBR using different table defs on slave/master This patch changes the test to coincide with changes to binlog size of table map event. sql/field.cc: WL#3228 : RBR using different table defs on slave/master This patch includes updates to the unpack() methods for the variable length fields. A new parameter was added (from_length) that is the value stored in the field_metadata of the table map from the table_def class. If the value is non-zero and less than what the field on the slave is then use the from_length else use the original value from the field on the slave. sql/field.h: WL#3228 : RBR using different table defs on slave/master This patch includes updates to the unpack() methods for the variable length fields. A new parameter was added (from_length) that is the value stored in the field_metadata of the table map from the table_def class. sql/log_event.cc: WL#3228 : RBR using different table defs on slave/master This patch adds methods to calculate the field metadata size, prepare the field metadata for writing to the binlog, and additions to the Table_map_log_event::write_body method to include the field metadata in the table map that is written to the binlog. sql/log_event.h: WL#3228 : RBR using different table defs on slave/master This patch adds method declarations and variables needed to support storing field metadata in the table map that is written to the binlog. sql/rpl_record.cc: WL#3228 : RBR using different table defs on slave/master This patch modifies the unpack_row() method to unpack fields passing in the value from the table_def class. This value is the extra field metadata stored there from the master. sql/rpl_rli.h: WL#3228 : RBR using different table defs on slave/master This patch adds a helper function to retrieve the table_def for a given table in the RPL_TABLE_LIST structure. sql/rpl_utility.cc: WL#3228 : RBR using different table defs on slave/master This patch adds a helper method that retrieves the correct size parameter for the field. This method is used to compare the size as sent by the master with that on the slave for all types of fields that can vary in size and storage requirements. sql/rpl_utility.h: WL#3228 : RBR using different table defs on slave/master This patch changes the table_def class constructor to pass in the raw data read from the table map and extract it into an array of dimension size (number of fields). It also adds a method to return the field metadata for any field. The method returns the data stored in the table map or 0 if no data was stored for that field. Lastly, a method to return the results of field->maybe_null() is included so that the slave can determine if a field that is not on the slave is null. mysql-test/r/rpl_colSize.result: WL#3228 : RBR using different table defs on slave/master This patch contains a result file for the new test designed to test the feature of having columns on the master that are smaller than what is on the slave. mysql-test/t/rpl_colSize.test: WL#3228 : RBR using different table defs on slave/master This patch contains a new test designed to test the feature of having columns on the master that are smaller than what is on the slave.
179 lines
4.4 KiB
Text
179 lines
4.4 KiB
Text
stop slave;
|
|
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
|
reset master;
|
|
reset slave;
|
|
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
|
start slave;
|
|
DROP TABLE IF EXISTS t1;
|
|
**** Testing WL#3228 changes. ****
|
|
*** Create "wider" table on slave ***
|
|
STOP SLAVE;
|
|
RESET SLAVE;
|
|
CREATE TABLE t1 (
|
|
a float (47),
|
|
b double (143,9),
|
|
c decimal (65,30),
|
|
d numeric (4,0),
|
|
e bit (32),
|
|
f char (21),
|
|
g varchar (1300),
|
|
h binary (33),
|
|
j varbinary (200),
|
|
k enum ('5','6','7', '8','9','0'),
|
|
l set ('1','2','3','4','5','6','7','8','9','0','11','12','13','14','15','16','17','18','19','21','22','23','24','25','26','27','28','29'),
|
|
m TINYBLOB,
|
|
n BLOB,
|
|
o MEDIUMBLOB,
|
|
p LONGBLOB,
|
|
q TINYTEXT,
|
|
r TEXT,
|
|
s MEDIUMTEXT,
|
|
t LONGTEXT
|
|
);
|
|
*** Create same table on master but with narrow columns ***
|
|
CREATE TABLE t1 (
|
|
a float (44),
|
|
b double (10,3),
|
|
c decimal (10,2),
|
|
d numeric (3,0),
|
|
e bit (16),
|
|
f char (10),
|
|
g varchar (100),
|
|
h binary (20),
|
|
j varbinary (20),
|
|
k enum ('5','6','7'),
|
|
l set ('1','2','3','4','5','6','7','8','9','0'),
|
|
m TINYBLOB,
|
|
n BLOB,
|
|
o MEDIUMBLOB,
|
|
p LONGBLOB,
|
|
q TINYTEXT,
|
|
r TEXT,
|
|
s MEDIUMTEXT,
|
|
t LONGTEXT
|
|
);
|
|
RESET MASTER;
|
|
*** Start replication ***
|
|
START SLAVE;
|
|
*** Insert data on master and display it. ***
|
|
INSERT INTO t1 () VALUES (
|
|
17.567,
|
|
2.123,
|
|
10.20,
|
|
125,
|
|
hex(64),
|
|
'TEST',
|
|
'This is a test',
|
|
'binary data',
|
|
'more binary data',
|
|
'6',
|
|
'7',
|
|
"blob 1",
|
|
"blob 2",
|
|
"blob 3",
|
|
"blob 4",
|
|
"text 1",
|
|
"text 2",
|
|
"text 3",
|
|
"text 4");
|
|
SELECT * FROM t1 ORDER BY a;
|
|
a b c d e f g h j k l m n o p q r s t
|
|
17.567 2.123 10.20 125 # TEST This is a test # more binary data 6 7 blob 1 blob 2 blob 3 blob 4 text 1 text 2 text 3 text 4
|
|
*** Select data from slave to compare ***
|
|
SELECT * FROM t1 ORDER BY a;
|
|
a b c d e f g h j k l m n o p q r s t
|
|
17.567 2.123000000 10.200000000000000000000000000000 125 # TEST This is a test # more binary data 6 7 blob 1 blob 2 blob 3 blob 4 text 1 text 2 text 3 text 4
|
|
DROP TABLE t1;
|
|
Create varchar table on master
|
|
CREATE TABLE t1 (
|
|
a VARCHAR(50),
|
|
b VARCHAR(100),
|
|
c VARCHAR(300),
|
|
d CHAR(5)
|
|
);
|
|
Alter varchar table on slave
|
|
ALTER TABLE t1 CHANGE COLUMN a a VARCHAR(100);
|
|
ALTER TABLE t1 CHANGE COLUMN b b VARCHAR(400);
|
|
ALTER TABLE t1 CHANGE COLUMN c c VARCHAR(500);
|
|
ALTER TABLE t1 CHANGE COLUMN d d CHAR(100);
|
|
Insert some values and select them on master
|
|
INSERT INTO t1 VALUES ("This is a test of col a.",
|
|
"This is another test of col b.",
|
|
"This is a test of the large col c.",
|
|
"Col d");
|
|
SELECT * FROM t1;
|
|
a b c d
|
|
This is a test of col a. This is another test of col b. This is a test of the large col c. Col d
|
|
SHOW CREATE TABLE t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`a` varchar(50) DEFAULT NULL,
|
|
`b` varchar(100) DEFAULT NULL,
|
|
`c` varchar(300) DEFAULT NULL,
|
|
`d` char(5) DEFAULT NULL
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
Insert some values and select them on slave
|
|
SELECT * FROM t1;
|
|
a b c d
|
|
This is a test of col a. This is another test of col b. This is a test of the large col c. Col d
|
|
SHOW CREATE TABLE t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`a` varchar(100) DEFAULT NULL,
|
|
`b` varchar(400) DEFAULT NULL,
|
|
`c` varchar(500) DEFAULT NULL,
|
|
`d` char(100) DEFAULT NULL
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
DROP TABLE t1;
|
|
Create bit table on master
|
|
CREATE TABLE t1 (
|
|
a BIT(7),
|
|
b BIT(8),
|
|
c BIT(21),
|
|
d BIT(11),
|
|
e BIT(11)
|
|
);
|
|
Create bit table on slave
|
|
DROP TABLE t1;
|
|
CREATE TABLE t1 (
|
|
a BIT(16),
|
|
b BIT(22),
|
|
c BIT(54),
|
|
d BIT(25),
|
|
e BIT(13)
|
|
);
|
|
Insert some values and select them on master
|
|
INSERT INTO t1 VALUES (
|
|
b'1010101',
|
|
b'10101011',
|
|
b'101010110101010101111',
|
|
b'10101010101',
|
|
b'10101011111'
|
|
);
|
|
SELECT BIN(a), BIN(b), BIN(c), BIN(d), BIN(e) FROM t1;
|
|
BIN(a) BIN(b) BIN(c) BIN(d) BIN(e)
|
|
1010101 10101011 101010110101010101111 10101010101 10101011111
|
|
SHOW CREATE TABLE t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`a` bit(7) DEFAULT NULL,
|
|
`b` bit(8) DEFAULT NULL,
|
|
`c` bit(21) DEFAULT NULL,
|
|
`d` bit(11) DEFAULT NULL,
|
|
`e` bit(11) DEFAULT NULL
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
Insert some values and select them on master
|
|
SELECT BIN(a), BIN(b), BIN(c), BIN(d), BIN(e) FROM t1;
|
|
BIN(a) BIN(b) BIN(c) BIN(d) BIN(e)
|
|
1010101 10101011 101010110101010101111 10101010101 10101011111
|
|
SHOW CREATE TABLE t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`a` bit(16) DEFAULT NULL,
|
|
`b` bit(22) DEFAULT NULL,
|
|
`c` bit(54) DEFAULT NULL,
|
|
`d` bit(25) DEFAULT NULL,
|
|
`e` bit(13) DEFAULT NULL
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
*** Cleanup ***
|
|
DROP TABLE t1;
|