mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 21:12:26 +01:00
d4671354f1
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. WL#3915 : (NDB) master's cols > slave Slave starts accepting and handling rows of master's tables which have more columns. The most important part of implementation is how to caclulate the amount of bytes to skip for unknown by slave column. mysql-test/suite/binlog/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/suite/rpl/r/rpl_row_basic_11bugs.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log event. mysql-test/suite/rpl/r/rpl_row_create_table.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log event. mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log event. mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log event. mysql-test/suite/rpl/r/rpl_row_log.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log event. mysql-test/suite/rpl/r/rpl_row_log_innodb.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log event. mysql-test/suite/rpl/r/rpl_row_max_relay_size.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log event. mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log event. mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log event. mysql-test/suite/rpl/r/rpl_row_until.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log event. mysql-test/suite/rpl/r/rpl_skip_error.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log event. mysql-test/suite/rpl/t/disabled.def: WL#3915 master's cols > slave Disabled the rpl_stm_extraColmaster_ndb test because statement-based replication is not supported in NDB at this time. It can be enabled when statement-based replication for NDB is released. mysql-test/suite/rpl/t/rpl_row_create_table.test: WL#3228 : RBR using different table defs on slave/master This patch corrects binlog positions a result of the change to the size of the tablemap log event. mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test: WL#3228 : RBR using different table defs on slave/master This patch corrects binlog positions a result of the change to the size of the tablemap log event. mysql-test/suite/rpl_ndb/r/rpl_ndb_log.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log event. mysql-test/suite/rpl_ndb/r/rpl_truncate_7ndb.result: WL#3228 : RBR using different table defs on slave/master This patch contains a new result file as a result of the change to the size of the tablemap log 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: L#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. WL#3915 master's cols > slave copying extra (slave's) fields returns early if master's table version is wider; removing assert in the way of master > slave cols. 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. WL#3915 master's cols > slave adding a snippet that shift exectution curson donw the row skipping unknown by slave fields' data. 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. WL#3915 master's cols > slave Remove warning message for master's cols > slave. 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/suite/rpl/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. mysql-test/suite/rpl/t/rpl_extraColmaster_innodb-master.opt: WL#3915 master's cols > slave option for innodb mysql-test/suite/rpl/t/rpl_extraColmaster_innodb-slave.opt: WL#3915 master's cols > slave option for innodb mysql-test/suite/rpl/t/rpl_extraColmaster_innodb.test: WL#3915 master's cols > slave Test of innodb. Test runs in both statement- and row-based replication. mysql-test/suite/rpl/t/rpl_extraColmaster_myisam.test: WL#3915 master's cols > slave Test of myisam. Test runs in both statement- and row-based replication. mysql-test/suite/rpl/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/suite/rpl/t/rpl_row_extraColmaster_ndb.test: WL#3915 master's cols > slave Test of ndb. Test runs in row-based replication. mysql-test/suite/rpl/t/rpl_stm_extraColmaster_ndb.test: WL#3915 master's cols > slave Test of ndb. Test runs in statement-based replication. mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result: WL#3915 master's cols > slave new results mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result: WL#3915 master's cols > slave new results mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test: WL#3915 master's cols > slave basic tests checking altering and skipping extra fields by slave. The fields can be of any possible types. mysql-test/suite/rpl/r/rpl_row_extraColmaster_ndb.result: WL#3915 master's cols > slave new results
244 lines
5.7 KiB
Text
244 lines
5.7 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;
|
|
CREATE DATABASE test_ignore;
|
|
**** On Master ****
|
|
SHOW DATABASES;
|
|
Database
|
|
information_schema
|
|
mysql
|
|
test
|
|
test_ignore
|
|
USE test;
|
|
CREATE TABLE t1 (a INT, b INT);
|
|
SHOW TABLES;
|
|
Tables_in_test
|
|
t1
|
|
INSERT INTO t1 VALUES (1,1), (2,2);
|
|
USE test_ignore;
|
|
CREATE TABLE t2 (a INT, b INT);
|
|
SHOW TABLES;
|
|
Tables_in_test_ignore
|
|
t2
|
|
INSERT INTO t2 VALUES (3,3), (4,4);
|
|
show binlog events from <binlog_start>;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b INT)
|
|
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
|
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
|
**** On Slave ****
|
|
SHOW DATABASES;
|
|
Database
|
|
information_schema
|
|
mysql
|
|
test
|
|
USE test;
|
|
SHOW TABLES;
|
|
Tables_in_test
|
|
t1
|
|
USE test_ignore;
|
|
ERROR 42000: Unknown database 'test_ignore'
|
|
DROP DATABASE test_ignore;
|
|
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;
|
|
CREATE TABLE t1 (a INT);
|
|
DELETE FROM t1;
|
|
INSERT INTO t1 VALUES (1),(2);
|
|
DELETE FROM t1 WHERE a = 0;
|
|
UPDATE t1 SET a=99 WHERE a = 0;
|
|
SHOW BINLOG EVENTS;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 4 Format_desc 1 106 Server ver: SERVER_VERSION, Binlog ver: 4
|
|
master-bin.000001 106 Query 1 192 use `test`; CREATE TABLE t1 (a INT)
|
|
master-bin.000001 192 Table_map 1 233 table_id: # (test.t1)
|
|
master-bin.000001 233 Write_rows 1 272 table_id: # flags: STMT_END_F
|
|
DROP TABLE t1;
|
|
================ Test for BUG#17620 ================
|
|
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;
|
|
**** On Slave ****
|
|
SET GLOBAL QUERY_CACHE_SIZE=0;
|
|
**** On Master ****
|
|
CREATE TABLE t1 (a INT);
|
|
INSERT INTO t1 VALUES (1),(2),(3);
|
|
**** On Slave ****
|
|
SET GLOBAL QUERY_CACHE_SIZE=16*1024*1024;
|
|
**** On Master ****
|
|
INSERT INTO t1 VALUES (4),(5),(6);
|
|
**** On Slave ****
|
|
SELECT * FROM t1;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
**** On Master ****
|
|
INSERT INTO t1 VALUES (7),(8),(9);
|
|
**** On Slave ****
|
|
SELECT * FROM t1;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
SET GLOBAL QUERY_CACHE_SIZE=0;
|
|
================ Test for BUG#22550 ================
|
|
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;
|
|
CREATE TABLE t1 (a BIT(1), b INT) ENGINE=MYISAM;
|
|
INSERT INTO t1 VALUES(1,2);
|
|
SELECT HEX(a),b FROM t1;
|
|
HEX(a) b
|
|
1 2
|
|
SELECT HEX(a),b FROM t1;
|
|
HEX(a) b
|
|
1 2
|
|
UPDATE t1 SET a=0 WHERE b=2;
|
|
SELECT HEX(a),b FROM t1;
|
|
HEX(a) b
|
|
0 2
|
|
SELECT HEX(a),b FROM t1;
|
|
HEX(a) b
|
|
0 2
|
|
DROP TABLE IF EXISTS t1;
|
|
================ Test for BUG#22583 ================
|
|
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;
|
|
**** On Master ****
|
|
CREATE TABLE t1_myisam (k INT, a BIT(1), b BIT(9)) ENGINE=MYISAM;
|
|
CREATE TABLE t1_innodb (k INT, a BIT(1), b BIT(9)) ENGINE=INNODB;
|
|
CREATE TABLE t2_myisam (k INT, a BIT(1) NOT NULL, b BIT(4) NOT NULL) ENGINE=MYISAM;
|
|
CREATE TABLE t2_innodb (k INT, a BIT(1) NOT NULL, b BIT(4) NOT NULL) ENGINE=INNODB;
|
|
**** On Slave ****
|
|
ALTER TABLE t1_myisam ENGINE=INNODB;
|
|
ALTER TABLE t1_innodb ENGINE=MYISAM;
|
|
ALTER TABLE t2_myisam ENGINE=INNODB;
|
|
ALTER TABLE t2_innodb ENGINE=MYISAM;
|
|
**** On Master ****
|
|
INSERT INTO t1_myisam VALUES(1, b'0', 257);
|
|
INSERT INTO t1_myisam VALUES(2, b'1', 256);
|
|
INSERT INTO t1_innodb VALUES(1, b'0', 257);
|
|
INSERT INTO t1_innodb VALUES(2, b'1', 256);
|
|
SELECT k, HEX(a),HEX(b) FROM t1_myisam;
|
|
k HEX(a) HEX(b)
|
|
1 0 101
|
|
2 1 100
|
|
SELECT k, HEX(a),HEX(b) FROM t1_innodb;
|
|
k HEX(a) HEX(b)
|
|
1 0 101
|
|
2 1 100
|
|
INSERT INTO t2_myisam VALUES(1, b'0', 9);
|
|
INSERT INTO t2_myisam VALUES(2, b'1', 8);
|
|
INSERT INTO t2_innodb VALUES(1, b'0', 9);
|
|
INSERT INTO t2_innodb VALUES(2, b'1', 8);
|
|
SELECT k, HEX(a),HEX(b) FROM t2_myisam;
|
|
k HEX(a) HEX(b)
|
|
1 0 9
|
|
2 1 8
|
|
SELECT k, HEX(a),HEX(b) FROM t2_innodb;
|
|
k HEX(a) HEX(b)
|
|
1 0 9
|
|
2 1 8
|
|
**** On Slave ****
|
|
SELECT k, HEX(a),HEX(b) FROM t1_myisam;
|
|
k HEX(a) HEX(b)
|
|
1 0 101
|
|
2 1 100
|
|
SELECT k, HEX(a),HEX(b) FROM t1_innodb;
|
|
k HEX(a) HEX(b)
|
|
1 0 101
|
|
2 1 100
|
|
SELECT k, HEX(a),HEX(b) FROM t2_myisam;
|
|
k HEX(a) HEX(b)
|
|
1 0 9
|
|
2 1 8
|
|
SELECT k, HEX(a),HEX(b) FROM t2_innodb;
|
|
k HEX(a) HEX(b)
|
|
1 0 9
|
|
2 1 8
|
|
**** On Master ****
|
|
UPDATE t1_myisam SET a=0 WHERE k=2;
|
|
SELECT k, HEX(a),HEX(b) FROM t1_myisam;
|
|
k HEX(a) HEX(b)
|
|
1 0 101
|
|
2 0 100
|
|
UPDATE t1_innodb SET a=0 WHERE k=2;
|
|
SELECT k, HEX(a),HEX(b) FROM t1_innodb;
|
|
k HEX(a) HEX(b)
|
|
1 0 101
|
|
2 0 100
|
|
UPDATE t2_myisam SET a=0 WHERE k=2;
|
|
SELECT k, HEX(a),HEX(b) FROM t2_myisam;
|
|
k HEX(a) HEX(b)
|
|
1 0 9
|
|
2 0 8
|
|
UPDATE t2_innodb SET a=0 WHERE k=2;
|
|
SELECT k, HEX(a),HEX(b) FROM t2_innodb;
|
|
k HEX(a) HEX(b)
|
|
1 0 9
|
|
2 0 8
|
|
**** On Slave ****
|
|
SELECT k, HEX(a),HEX(b) FROM t1_myisam;
|
|
k HEX(a) HEX(b)
|
|
1 0 101
|
|
2 0 100
|
|
SELECT k, HEX(a),HEX(b) FROM t1_innodb;
|
|
k HEX(a) HEX(b)
|
|
1 0 101
|
|
2 0 100
|
|
SELECT k, HEX(a),HEX(b) FROM t2_myisam;
|
|
k HEX(a) HEX(b)
|
|
1 0 9
|
|
2 0 8
|
|
SELECT k, HEX(a),HEX(b) FROM t2_innodb;
|
|
k HEX(a) HEX(b)
|
|
1 0 9
|
|
2 0 8
|
|
**** On Master ****
|
|
DROP TABLE IF EXISTS t1_myisam, t1_innodb, t2_myisam, t2_innodb;
|
|
drop table if exists t1, t2;
|
|
CREATE TABLE `t1` (
|
|
`a` int(11) NOT NULL auto_increment,
|
|
`b` int(11) default NULL,
|
|
PRIMARY KEY (`a`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
|
|
CREATE TABLE `t2` (
|
|
`a` int(11) NOT NULL auto_increment,
|
|
`b` int(11) default NULL,
|
|
PRIMARY KEY (`a`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
|
|
insert into t1 values (1,1),(2,2);
|
|
insert into t2 values (1,1),(4,4);
|
|
UPDATE t2,t1 SET t2.a=t1.a+2;
|
|
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
|
|
select * from t2 /* must be (3,1), (4,4) */;
|
|
a b
|
|
3 1
|
|
4 4
|
|
select * from t2 /* must be (3,1), (4,4) */;
|
|
a b
|
|
3 1
|
|
4 4
|
|
drop table t1,t2;
|