Merge romeo.(none):/home/bkroot/mysql-5.1
into romeo.(none):/home/bk/memcheck-mysql-5.1
This commit is contained in:
commit
55b666441e
133
sql/log_event.cc
133
sql/log_event.cc
@ -140,6 +140,21 @@ static void pretty_print_str(IO_CACHE* cache, char* str, int len)
|
|||||||
}
|
}
|
||||||
#endif /* MYSQL_CLIENT */
|
#endif /* MYSQL_CLIENT */
|
||||||
|
|
||||||
|
#ifdef HAVE_purify
|
||||||
|
static void
|
||||||
|
valgrind_check_mem(void *ptr, size_t len)
|
||||||
|
{
|
||||||
|
static volatile uchar dummy;
|
||||||
|
for (volatile uchar *p= (uchar*) ptr ; p != (uchar*) ptr + len ; ++p)
|
||||||
|
{
|
||||||
|
int const c = *p;
|
||||||
|
if (c < 128)
|
||||||
|
dummy= c + 1;
|
||||||
|
else
|
||||||
|
dummy = c - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
|
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
|
||||||
|
|
||||||
@ -5402,7 +5417,13 @@ int Rows_log_event::do_add_row_data(byte *const row_data,
|
|||||||
DBUG_ENTER("Rows_log_event::do_add_row_data");
|
DBUG_ENTER("Rows_log_event::do_add_row_data");
|
||||||
DBUG_PRINT("enter", ("row_data: 0x%lx length: %lu", (ulong) row_data,
|
DBUG_PRINT("enter", ("row_data: 0x%lx length: %lu", (ulong) row_data,
|
||||||
length));
|
length));
|
||||||
|
/*
|
||||||
|
Don't print debug messages when running valgrind since they can
|
||||||
|
trigger false warnings.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_purify
|
||||||
DBUG_DUMP("row_data", (const char*)row_data, min(length, 32));
|
DBUG_DUMP("row_data", (const char*)row_data, min(length, 32));
|
||||||
|
#endif
|
||||||
|
|
||||||
DBUG_ASSERT(m_rows_buf <= m_rows_cur);
|
DBUG_ASSERT(m_rows_buf <= m_rows_cur);
|
||||||
DBUG_ASSERT(!m_rows_buf || m_rows_end && m_rows_buf < m_rows_end);
|
DBUG_ASSERT(!m_rows_buf || m_rows_end && m_rows_buf < m_rows_end);
|
||||||
@ -5489,7 +5510,9 @@ unpack_row(RELAY_LOG_INFO *rli,
|
|||||||
char const **row_end, ulong *master_reclength,
|
char const **row_end, ulong *master_reclength,
|
||||||
MY_BITMAP* const rw_set, Log_event_type const event_type)
|
MY_BITMAP* const rw_set, Log_event_type const event_type)
|
||||||
{
|
{
|
||||||
|
DBUG_ENTER("unpack_row");
|
||||||
DBUG_ASSERT(record && row);
|
DBUG_ASSERT(record && row);
|
||||||
|
DBUG_PRINT("enter", ("row=0x%lx; record=0x%lx", row, record));
|
||||||
my_ptrdiff_t const offset= record - (byte*) table->record[0];
|
my_ptrdiff_t const offset= record - (byte*) table->record[0];
|
||||||
my_size_t master_null_bytes= table->s->null_bytes;
|
my_size_t master_null_bytes= table->s->null_bytes;
|
||||||
|
|
||||||
@ -5530,7 +5553,11 @@ unpack_row(RELAY_LOG_INFO *rli,
|
|||||||
|
|
||||||
if (bitmap_is_set(cols, field_ptr - begin_ptr))
|
if (bitmap_is_set(cols, field_ptr - begin_ptr))
|
||||||
{
|
{
|
||||||
|
DBUG_ASSERT(table->record[0] <= f->ptr);
|
||||||
|
DBUG_ASSERT(f->ptr < table->record[0] + table->s->reclength + (f->pack_length_in_rec() == 0));
|
||||||
f->move_field_offset(offset);
|
f->move_field_offset(offset);
|
||||||
|
|
||||||
|
DBUG_PRINT("info", ("unpacking column '%s' to 0x%lx", f->field_name, f->ptr));
|
||||||
ptr= f->unpack(f->ptr, ptr);
|
ptr= f->unpack(f->ptr, ptr);
|
||||||
f->move_field_offset(-offset);
|
f->move_field_offset(-offset);
|
||||||
/* Field...::unpack() cannot return 0 */
|
/* Field...::unpack() cannot return 0 */
|
||||||
@ -5564,10 +5591,6 @@ unpack_row(RELAY_LOG_INFO *rli,
|
|||||||
{
|
{
|
||||||
uint32 const mask= NOT_NULL_FLAG | NO_DEFAULT_VALUE_FLAG;
|
uint32 const mask= NOT_NULL_FLAG | NO_DEFAULT_VALUE_FLAG;
|
||||||
|
|
||||||
DBUG_PRINT("debug", ("flags = 0x%x, mask = 0x%x, flags & mask = 0x%x",
|
|
||||||
(*field_ptr)->flags, mask,
|
|
||||||
(*field_ptr)->flags & mask));
|
|
||||||
|
|
||||||
if (event_type == WRITE_ROWS_EVENT &&
|
if (event_type == WRITE_ROWS_EVENT &&
|
||||||
((*field_ptr)->flags & mask) == mask)
|
((*field_ptr)->flags & mask) == mask)
|
||||||
{
|
{
|
||||||
@ -5582,7 +5605,7 @@ unpack_row(RELAY_LOG_INFO *rli,
|
|||||||
(*field_ptr)->set_default();
|
(*field_ptr)->set_default();
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Rows_log_event::exec_event(st_relay_log_info *rli)
|
int Rows_log_event::exec_event(st_relay_log_info *rli)
|
||||||
@ -5690,7 +5713,6 @@ int Rows_log_event::exec_event(st_relay_log_info *rli)
|
|||||||
We also invalidate the query cache for all the tables, since
|
We also invalidate the query cache for all the tables, since
|
||||||
they will now be changed.
|
they will now be changed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TABLE_LIST *ptr;
|
TABLE_LIST *ptr;
|
||||||
for (ptr= rli->tables_to_lock ; ptr ; ptr= ptr->next_global)
|
for (ptr= rli->tables_to_lock ; ptr ; ptr= ptr->next_global)
|
||||||
{
|
{
|
||||||
@ -5747,7 +5769,7 @@ int Rows_log_event::exec_event(st_relay_log_info *rli)
|
|||||||
if ((error= do_prepare_row(thd, rli, table, row_start, &row_end)))
|
if ((error= do_prepare_row(thd, rli, table, row_start, &row_end)))
|
||||||
break; // We should perform the after-row operation even in
|
break; // We should perform the after-row operation even in
|
||||||
// the case of error
|
// the case of error
|
||||||
|
|
||||||
DBUG_ASSERT(row_end != NULL); // cannot happen
|
DBUG_ASSERT(row_end != NULL); // cannot happen
|
||||||
DBUG_ASSERT(row_end <= (const char*)m_rows_end);
|
DBUG_ASSERT(row_end <= (const char*)m_rows_end);
|
||||||
|
|
||||||
@ -6048,7 +6070,13 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
|
|||||||
DBUG_PRINT("info",("event_len=%ld, common_header_len=%d, post_header_len=%d",
|
DBUG_PRINT("info",("event_len=%ld, common_header_len=%d, post_header_len=%d",
|
||||||
event_len, common_header_len, post_header_len));
|
event_len, common_header_len, post_header_len));
|
||||||
|
|
||||||
|
/*
|
||||||
|
Don't print debug messages when running valgrind since they can
|
||||||
|
trigger false warnings.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_purify
|
||||||
DBUG_DUMP("event buffer", buf, event_len);
|
DBUG_DUMP("event buffer", buf, event_len);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Read the post-header */
|
/* Read the post-header */
|
||||||
const char *post_start= buf + common_header_len;
|
const char *post_start= buf + common_header_len;
|
||||||
@ -6423,8 +6451,8 @@ int Write_rows_log_event::do_after_row_operations(TABLE *table, int error)
|
|||||||
|
|
||||||
int Write_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli,
|
int Write_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli,
|
||||||
TABLE *table,
|
TABLE *table,
|
||||||
char const *row_start,
|
char const *const row_start,
|
||||||
char const **row_end)
|
char const **const row_end)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(table != NULL);
|
DBUG_ASSERT(table != NULL);
|
||||||
DBUG_ASSERT(row_start && row_end);
|
DBUG_ASSERT(row_start && row_end);
|
||||||
@ -6495,7 +6523,7 @@ copy_extra_record_fields(TABLE *table,
|
|||||||
my_ptrdiff_t master_fields)
|
my_ptrdiff_t master_fields)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("Copying to %p "
|
DBUG_PRINT("info", ("Copying to %p "
|
||||||
"from field %d at offset %u "
|
"from field %ld at offset %u "
|
||||||
"to field %d at offset %u",
|
"to field %d at offset %u",
|
||||||
table->record[0],
|
table->record[0],
|
||||||
master_fields, master_reclength,
|
master_fields, master_reclength,
|
||||||
@ -6733,8 +6761,26 @@ static bool record_compare(TABLE *table)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Find the row given by 'key', if the table has keys, or else use a table scan
|
Find the row given by 'key', if the table has keys, or else use a table scan
|
||||||
to find (and fetch) the row. If the engine allows random access of the
|
to find (and fetch) the row.
|
||||||
records, a combination of position() and rnd_pos() will be used.
|
|
||||||
|
If the engine allows random access of the records, a combination of
|
||||||
|
position() and rnd_pos() will be used.
|
||||||
|
|
||||||
|
@param table Pointer to table to search
|
||||||
|
@param key Pointer to key to use for search, if table has key
|
||||||
|
|
||||||
|
@pre <code>table->record[0]</code> shall contain the row to locate
|
||||||
|
and <code>key</code> shall contain a key to use for searching, if
|
||||||
|
the engine has a key.
|
||||||
|
|
||||||
|
@post If the return value is zero, <code>table->record[1]</code>
|
||||||
|
will contain the fetched row and the internal "cursor" will refer to
|
||||||
|
the row. If the return value is non-zero,
|
||||||
|
<code>table->record[1]</code> is undefined. In either case,
|
||||||
|
<code>table->record[0]</code> is undefined.
|
||||||
|
|
||||||
|
@return Zero if the row was successfully fetched into
|
||||||
|
<code>table->record[1]</code>, error code otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int find_and_fetch_row(TABLE *table, byte *key)
|
static int find_and_fetch_row(TABLE *table, byte *key)
|
||||||
@ -6754,13 +6800,28 @@ static int find_and_fetch_row(TABLE *table, byte *key)
|
|||||||
row reference using the position() member function (it will be
|
row reference using the position() member function (it will be
|
||||||
stored in table->file->ref) and the use rnd_pos() to position
|
stored in table->file->ref) and the use rnd_pos() to position
|
||||||
the "cursor" (i.e., record[0] in this case) at the correct row.
|
the "cursor" (i.e., record[0] in this case) at the correct row.
|
||||||
|
|
||||||
|
TODO: Add a check that the correct record has been fetched by
|
||||||
|
comparing with the original record. Take into account that the
|
||||||
|
record on the master and slave can be of different
|
||||||
|
length. Something along these lines should work:
|
||||||
|
|
||||||
|
ADD>>> store_record(table,record[1]);
|
||||||
|
int error= table->file->rnd_pos(table->record[0], table->file->ref);
|
||||||
|
ADD>>> DBUG_ASSERT(memcmp(table->record[1], table->record[0],
|
||||||
|
table->s->reclength) == 0);
|
||||||
|
|
||||||
*/
|
*/
|
||||||
table->file->position(table->record[0]);
|
table->file->position(table->record[0]);
|
||||||
DBUG_RETURN(table->file->rnd_pos(table->record[0], table->file->ref));
|
int error= table->file->rnd_pos(table->record[0], table->file->ref);
|
||||||
|
/*
|
||||||
|
rnd_pos() returns the record in table->record[0], so we have to
|
||||||
|
move it to table->record[1].
|
||||||
|
*/
|
||||||
|
bmove_align(table->record[1], table->record[0], table->s->reclength);
|
||||||
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBUG_ASSERT(table->record[1]);
|
|
||||||
|
|
||||||
/* We need to retrieve all fields */
|
/* We need to retrieve all fields */
|
||||||
/* TODO: Move this out from this function to main loop */
|
/* TODO: Move this out from this function to main loop */
|
||||||
table->use_all_columns();
|
table->use_all_columns();
|
||||||
@ -6770,7 +6831,16 @@ static int find_and_fetch_row(TABLE *table, byte *key)
|
|||||||
int error;
|
int error;
|
||||||
/* We have a key: search the table using the index */
|
/* We have a key: search the table using the index */
|
||||||
if (!table->file->inited && (error= table->file->ha_index_init(0, FALSE)))
|
if (!table->file->inited && (error= table->file->ha_index_init(0, FALSE)))
|
||||||
return error;
|
DBUG_RETURN(error);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Don't print debug messages when running valgrind since they can
|
||||||
|
trigger false warnings.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_purify
|
||||||
|
DBUG_DUMP("table->record[0]", table->record[0], table->s->reclength);
|
||||||
|
DBUG_DUMP("table->record[1]", table->record[1], table->s->reclength);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We need to set the null bytes to ensure that the filler bit are
|
We need to set the null bytes to ensure that the filler bit are
|
||||||
@ -6790,6 +6860,14 @@ static int find_and_fetch_row(TABLE *table, byte *key)
|
|||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Don't print debug messages when running valgrind since they can
|
||||||
|
trigger false warnings.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_purify
|
||||||
|
DBUG_DUMP("table->record[0]", table->record[0], table->s->reclength);
|
||||||
|
DBUG_DUMP("table->record[1]", table->record[1], table->s->reclength);
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
Below is a minor "optimization". If the key (i.e., key number
|
Below is a minor "optimization". If the key (i.e., key number
|
||||||
0) has the HA_NOSAME flag set, we know that we have found the
|
0) has the HA_NOSAME flag set, we know that we have found the
|
||||||
@ -6974,8 +7052,8 @@ int Delete_rows_log_event::do_after_row_operations(TABLE *table, int error)
|
|||||||
|
|
||||||
int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli,
|
int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli,
|
||||||
TABLE *table,
|
TABLE *table,
|
||||||
char const *row_start,
|
char const *const row_start,
|
||||||
char const **row_end)
|
char const **const row_end)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
DBUG_ASSERT(row_start && row_end);
|
DBUG_ASSERT(row_start && row_end);
|
||||||
@ -7111,8 +7189,8 @@ int Update_rows_log_event::do_after_row_operations(TABLE *table, int error)
|
|||||||
|
|
||||||
int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli,
|
int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli,
|
||||||
TABLE *table,
|
TABLE *table,
|
||||||
char const *row_start,
|
char const *const row_start,
|
||||||
char const **row_end)
|
char const **const row_end)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
DBUG_ASSERT(row_start && row_end);
|
DBUG_ASSERT(row_start && row_end);
|
||||||
@ -7127,16 +7205,21 @@ int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli,
|
|||||||
table, m_width, table->record[0],
|
table, m_width, table->record[0],
|
||||||
row_start, &m_cols, row_end, &m_master_reclength,
|
row_start, &m_cols, row_end, &m_master_reclength,
|
||||||
table->read_set, UPDATE_ROWS_EVENT);
|
table->read_set, UPDATE_ROWS_EVENT);
|
||||||
row_start = *row_end;
|
char const *next_start = *row_end;
|
||||||
/* m_after_image is the after image for the update */
|
/* m_after_image is the after image for the update */
|
||||||
error= unpack_row(rli,
|
error= unpack_row(rli,
|
||||||
table, m_width, m_after_image,
|
table, m_width, m_after_image,
|
||||||
row_start, &m_cols, row_end, &m_master_reclength,
|
next_start, &m_cols, row_end, &m_master_reclength,
|
||||||
table->write_set, UPDATE_ROWS_EVENT);
|
table->write_set, UPDATE_ROWS_EVENT);
|
||||||
|
|
||||||
DBUG_DUMP("record[0]", (const char *)table->record[0], table->s->reclength);
|
/*
|
||||||
DBUG_DUMP("m_after_image", (const char *)m_after_image, table->s->reclength);
|
Don't print debug messages when running valgrind since they can
|
||||||
|
trigger false warnings.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_purify
|
||||||
|
DBUG_DUMP("record[0]", (const char *)table->record[0], m_master_reclength);
|
||||||
|
DBUG_DUMP("m_after_image", (const char *)m_after_image, m_master_reclength);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If we will access rows using the random access method, m_key will
|
If we will access rows using the random access method, m_key will
|
||||||
|
@ -2727,11 +2727,17 @@ int THD::binlog_update_row(TABLE* table, bool is_trans,
|
|||||||
before_record);
|
before_record);
|
||||||
my_size_t const after_size= pack_row(table, cols, after_row,
|
my_size_t const after_size= pack_row(table, cols, after_row,
|
||||||
after_record);
|
after_record);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Don't print debug messages when running valgrind since they can
|
||||||
|
trigger false warnings.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_purify
|
||||||
DBUG_DUMP("before_record", (const char *)before_record, table->s->reclength);
|
DBUG_DUMP("before_record", (const char *)before_record, table->s->reclength);
|
||||||
DBUG_DUMP("after_record", (const char *)after_record, table->s->reclength);
|
DBUG_DUMP("after_record", (const char *)after_record, table->s->reclength);
|
||||||
DBUG_DUMP("before_row", (const char *)before_row, before_size);
|
DBUG_DUMP("before_row", (const char *)before_row, before_size);
|
||||||
DBUG_DUMP("after_row", (const char *)after_row, after_size);
|
DBUG_DUMP("after_row", (const char *)after_row, after_size);
|
||||||
|
#endif
|
||||||
|
|
||||||
Rows_log_event* const ev=
|
Rows_log_event* const ev=
|
||||||
binlog_prepare_pending_rows_event(table, server_id, cols, colcnt,
|
binlog_prepare_pending_rows_event(table, server_id, cols, colcnt,
|
||||||
|
@ -1377,9 +1377,7 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
|
|||||||
if (!(record= (byte*) alloc_root(&outparam->mem_root,
|
if (!(record= (byte*) alloc_root(&outparam->mem_root,
|
||||||
share->rec_buff_length * records)))
|
share->rec_buff_length * records)))
|
||||||
goto err; /* purecov: inspected */
|
goto err; /* purecov: inspected */
|
||||||
#ifdef HAVE_purify
|
|
||||||
bzero(record, share->rec_buff_length * records);
|
|
||||||
#endif
|
|
||||||
if (records == 0)
|
if (records == 0)
|
||||||
{
|
{
|
||||||
/* We are probably in hard repair, and the buffers should not be used */
|
/* We are probably in hard repair, and the buffers should not be used */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user