diff --git a/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test b/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test new file mode 100644 index 00000000000..696bb74ec47 --- /dev/null +++ b/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test @@ -0,0 +1,393 @@ +############################################################# +# Purpose: To test having extra columns on the master WL#3915 +# engine inspecific sourced part +############################################################# + +# TODO: partition specific +# -- source include/have_partition.inc + +########### Clean up ################ +--disable_warnings +--disable_query_log +DROP TABLE IF EXISTS t1,t2,t3,t4,t31; + +--enable_query_log +--enable_warnings + +# +# Setup differently defined tables on master and slave +# + +# Def on master: t (f_1 type_m_1,... f_s type_m_s, f_s1, f_m) +# Def on slave: t (f_1 type_s_1,... f_s type_s_s) +# where type_mi,type_si (0 < i-1 s->fields < (uint) master_fields) + DBUG_RETURN(0); + DBUG_ASSERT(master_reclength <= table->s->reclength); if (master_reclength < table->s->reclength) bmove_align(table->record[0] + master_reclength, @@ -7134,7 +7139,7 @@ copy_extra_record_fields(TABLE *table, } } } - return 0; // All OK + DBUG_RETURN(0); // All OK } #define DBUG_PRINT_BITSET(N,FRM,BS) \ @@ -7723,12 +7728,6 @@ int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, { int error; DBUG_ASSERT(row_start && row_end); - /* - This assertion actually checks that there is at least as many - columns on the slave as on the master. - */ - DBUG_ASSERT(table->s->fields >= m_width); - error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end, &m_master_reclength, table->read_set, DELETE_ROWS_EVENT); /* @@ -7897,12 +7896,6 @@ int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, { int error; DBUG_ASSERT(row_start && row_end); - /* - This assertion actually checks that there is at least as many - columns on the slave as on the master. - */ - DBUG_ASSERT(table->s->fields >= m_width); - /* We need to perform some juggling below since unpack_row() always unpacks into table->record[0]. For more information, see the diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc index d33d60300fd..db79a5dfd77 100644 --- a/sql/rpl_record.cc +++ b/sql/rpl_record.cc @@ -144,7 +144,8 @@ pack_row(TABLE *table, MY_BITMAP const* cols, @param rli Relay log info @param table Table to unpack into @param colcnt Number of columns to read from record - @param row Packed row data + @param row_data + Packed row data @param cols Pointer to columns data to fill in @param row_end Pointer to variable that will hold the value of the one-after-end position for the row @@ -239,6 +240,28 @@ unpack_row(RELAY_LOG_INFO const *rli, i++; } + /* + throw away master's extra fields + */ + uint max_cols= min(tabledef->size(), cols->n_bits); + for (; i < max_cols; i++) + { + if (bitmap_is_set(cols, i)) + { + if ((null_mask & 0xFF) == 0) + { + DBUG_ASSERT(null_ptr < row_data + master_null_byte_count); + null_mask= 1U; + null_bits= *null_ptr++; + } + DBUG_ASSERT(null_mask & 0xFF); // One of the 8 LSB should be set + + if (!((null_bits & null_mask) && tabledef->maybe_null(i))) + pack_ptr+= tabledef->calc_field_size(i, (uchar *) pack_ptr); + null_mask <<= 1; + } + } + /* We should now have read all the null bytes, otherwise something is really wrong. diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 143251991b5..91d045b040b 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -133,21 +133,6 @@ table_def::compatible_with(RELAY_LOG_INFO const *rli_arg, TABLE *table) TABLE_SHARE const *const tsh= table->s; - /* - To get proper error reporting for all columns of the table, we - both check the width and iterate over all columns. - */ - if (tsh->fields < size()) - { - DBUG_ASSERT(tsh->db.str && tsh->table_name.str); - error= 1; - slave_print_msg(ERROR_LEVEL, rli, ER_BINLOG_ROW_WRONG_TABLE_DEF, - "Table width mismatch - " - "received %u columns, %s.%s has %u columns", - (uint) size(), tsh->db.str, tsh->table_name.str, - tsh->fields); - } - /* We now check for column type and size compatibility. */