summaryrefslogtreecommitdiff
path: root/sql/rpl_utility.cc
diff options
context:
space:
mode:
authorunknown <cbell/Chuck@mysql_cab_desk.>2007-08-10 12:48:01 -0400
committerunknown <cbell/Chuck@mysql_cab_desk.>2007-08-10 12:48:01 -0400
commit9ad300d50d531d930c649002ee34123b452ec526 (patch)
treed3ef511f255d489f7a8ebaf7ce57c0512a4a2607 /sql/rpl_utility.cc
parent21c55af5a103bcd3133c28073a7cd6e09d0521e3 (diff)
downloadmariadb-git-9ad300d50d531d930c649002ee34123b452ec526.tar.gz
BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash
This patch adds functionality to row-based replication to ensure the slave's column sizes are >= to that of the master. It also includes some refactoring for the code from WL#3228. mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash Removed commented out portion of test referenced in bug report. This test supports the original request of the bug report. mysql-test/suite/rpl/r/rpl_extraCol_innodb.result: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash New result file for additional test. mysql-test/suite/rpl/r/rpl_extraCol_myisam.result: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash New result file for additional test. mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash New result file for additional test. sql/field.cc: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash This patch refactors the additions made by this bug patch and those made by WL#3228. The effort consolidates the large switches on type() into functions within the field classes. sql/field.h: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash This patch refactors the additions made by this bug patch and those made by WL#3228. The effort consolidates the large switches on type() into functions within the field classes. sql/log_event.cc: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash This patch refactors the calc_field_size() method to use the new methods implemented in the field classes. It also corrects comments concerning how replication of field metadata works. sql/log_event.h: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash This patch refactors out the calc_field_size() method into the method save_field_metadata(). sql/rpl_utility.cc: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash This patch adds a method to check the size of the field on the master using the field metadata from WL#3228. Each column is checked to ensure the slave's column is >= to the master's column in size. sql/rpl_utility.h: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash This patch changes the table_def class so that it records the size of the metadata. This is a result of refactoring out the calc_field_size() method into the method save_field_metadata(). Prevents access via field_metadata(col) to unitialized memory when there is no metadata transmitted from the master. mysql-test/suite/rpl/r/rpl_row_colSize.result: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash New result file for additional test. mysql-test/suite/rpl/t/rpl_row_colSize.test: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash Added a test file to test each variable type that relies on field metadata from the master. mysql-test/include/test_fieldsize.inc: BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash Sub unit file to test each variable type that relies on field metadata from the master.
Diffstat (limited to 'sql/rpl_utility.cc')
-rw-r--r--sql/rpl_utility.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index 40937e98b27..7ea94fda39f 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -156,6 +156,25 @@ table_def::compatible_with(RELAY_LOG_INFO const *rli_arg, TABLE *table)
rli->report(ERROR_LEVEL, ER_BINLOG_ROW_WRONG_TABLE_DEF,
ER(ER_BINLOG_ROW_WRONG_TABLE_DEF), buf);
}
+ /*
+ Check the slave's field size against that of the master.
+ */
+ if (!error &&
+ !table->field[col]->compatible_field_size(field_metadata(col)))
+ {
+ error= 1;
+ char buf[256];
+ my_snprintf(buf, sizeof(buf), "Column %d size mismatch - "
+ "master has size %d, %s.%s on slave has size %d."
+ " Master's column size should be <= the slave's "
+ "column size.", col,
+ table->field[col]->pack_length_from_metadata(
+ m_field_metadata[col]),
+ tsh->db.str, tsh->table_name.str,
+ table->field[col]->row_pack_length());
+ rli->report(ERROR_LEVEL, ER_BINLOG_ROW_WRONG_TABLE_DEF,
+ ER(ER_BINLOG_ROW_WRONG_TABLE_DEF), buf);
+ }
}
return error;