From d68cba3413e3799656e7478786e494d409356c99 Mon Sep 17 00:00:00 2001 From: Venkatesh Duggirala Date: Thu, 29 Nov 2012 17:33:06 +0530 Subject: [PATCH] BUG#15888454: SLAVE CRASHES WHEN DML REQUIRES CONVERSION & TABLE HAS LESS COLUMNS THAN MASTER Problem: ======== If DML operation requires a converstion at slave and if slave contains less number of columns than master, slave is crashing. Fix: ==== When Slave applies any DML operation, it sees if any of the columns requires conversion. If yes, it creates conversion table. While creating the coversion table, it should look into the actual number of columns required to create the table instead of getting the number of columns from Master (size()). Columns would have dropped or added at Slave. So the value should be min(columns@master, columns@slave) --- sql/rpl_utility.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 627bad741e8..8efb376b5b6 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -878,8 +878,13 @@ TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli, TABLE * DBUG_ENTER("table_def::create_conversion_table"); List field_list; - - for (uint col= 0 ; col < size() ; ++col) + /* + At slave, columns may differ. So we should create + min(columns@master, columns@slave) columns in the + conversion table. + */ + uint const cols_to_create= min(target_table->s->fields, size()); + for (uint col= 0 ; col < cols_to_create; ++col) { Create_field *field_def= (Create_field*) alloc_root(thd->mem_root, sizeof(Create_field));