From 8de1783a499516ccee4005bb1102e5ee4bb95850 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Sep 2006 18:05:02 +0200 Subject: [PATCH] BUG#22550 (Replication of BIT column failing): Using move_field_offset() to move field pointer to other record before calling pack()/unpack(). sql/log_event.cc: Using move_field_offset() to move the field pointer. It is necessary for unpack() and pack() of BIT fields to operate correctly. Adding debug printouts. sql/sql_class.cc: Using move_field_offset() to move the field pointer. It is necessary for unpack() and pack() of BIT fields to operate correctly. Adding debug printouts to packing of update rows event. --- sql/log_event.cc | 11 +++++++++-- sql/sql_class.cc | 13 +++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index ebfaa4bfff3..496dbb88085 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5375,7 +5375,9 @@ unpack_row(RELAY_LOG_INFO *rli, if (bitmap_is_set(cols, field_ptr - begin_ptr)) { - ptr= f->unpack(f->ptr + offset, ptr); + f->move_field_offset(offset); + ptr= f->unpack(f->ptr, ptr); + f->move_field_offset(-offset); /* Field...::unpack() cannot return 0 */ DBUG_ASSERT(ptr != NULL); } @@ -6589,7 +6591,7 @@ static int find_and_fetch_row(TABLE *table, byte *key) /* We have a key: search the table using the index */ if (!table->file->inited && (error= table->file->ha_index_init(0, FALSE))) return error; - + /* We need to set the null bytes to ensure that the filler bit are all set when returning. There are storage engines that just set @@ -6675,6 +6677,7 @@ static int find_and_fetch_row(TABLE *table, byte *key) table->s->null_bytes > 0 ? table->s->null_bytes - 1 : 0; table->record[1][pos]= 0xFF; error= table->file->rnd_next(table->record[1]); + switch (error) { case 0: @@ -6956,6 +6959,10 @@ int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli, row_start, &m_cols, row_end, &m_master_reclength, table->write_set, UPDATE_ROWS_EVENT); + DBUG_DUMP("record[0]", table->record[0], table->s->reclength); + DBUG_DUMP("m_after_image", m_after_image, table->s->reclength); + + /* If we will access rows using the random access method, m_key will be set to NULL, so we do not need to make a key copy in that case. diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 35b527584dc..16a215c1245 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2529,7 +2529,9 @@ my_size_t THD::pack_row(TABLE *table, MY_BITMAP const* cols, byte *row_data, { my_ptrdiff_t const offset= field->is_null(rec_offset) ? def_offset : rec_offset; - ptr= (byte*)field->pack((char *) ptr, field->ptr + offset); + field->move_field_offset(offset); + ptr= (byte*)field->pack((char *) ptr, field->ptr); + field->move_field_offset(-offset); } } return (static_cast(ptr - row_data)); @@ -2614,12 +2616,19 @@ int THD::binlog_update_row(TABLE* table, bool is_trans, my_size_t const after_size= pack_row(table, cols, after_row, after_record); + DBUG_DUMP("before_record", before_record, table->s->reclength); + DBUG_DUMP("after_record", after_record, table->s->reclength); + DBUG_DUMP("before_row", before_row, before_size); + DBUG_DUMP("after_row", after_row, after_size); + Rows_log_event* const ev= binlog_prepare_pending_rows_event(table, server_id, cols, colcnt, before_size + after_size, is_trans, static_cast(0)); - error= (unlikely(!ev)) || ev->add_row_data(before_row, before_size) || + error= + unlikely(!ev) || + ev->add_row_data(before_row, before_size) || ev->add_row_data(after_row, after_size); if (!table->write_row_record)