summaryrefslogtreecommitdiffstats
path: root/sql/log_event_old.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/log_event_old.cc')
-rw-r--r--sql/log_event_old.cc60
1 files changed, 29 insertions, 31 deletions
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index c02c22f4..3ae832c0 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -31,6 +31,9 @@
#include "log_event_old.h"
#include "rpl_record_old.h"
#include "transaction.h"
+#ifdef WITH_WSREP
+#include "wsrep_mysqld.h"
+#endif /* WITH_WSREP */
PSI_memory_key key_memory_log_event_old;
@@ -205,7 +208,10 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, rpl_group_info *rgi)
TIMESTAMP column to a table with one.
So we call set_time(), like in SBR. Presently it changes nothing.
*/
- ev_thd->set_time(ev->when, ev->when_sec_part);
+#ifdef WITH_WSREP
+ if (!wsrep_thd_is_applying(thd))
+#endif
+ ev_thd->set_time(ev->when, ev->when_sec_part);
/*
There are a few flags that are replicated with each row event.
Make sure to set/clear them before executing the main body of
@@ -1156,20 +1162,12 @@ Old_rows_log_event::Old_rows_log_event(THD *thd_arg, TABLE *tbl_arg,
set_flags(RELAXED_UNIQUE_CHECKS_F);
/* if my_bitmap_init fails, caught in is_valid() */
if (likely(!my_bitmap_init(&m_cols,
- m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL,
- m_width)))
+ m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL,
+ m_width)))
{
/* Cols can be zero if this is a dummy binrows event */
if (likely(cols != NULL))
- {
- memcpy(m_cols.bitmap, cols->bitmap, no_bytes_in_map(cols));
- create_last_word_mask(&m_cols);
- }
- }
- else
- {
- // Needed because my_bitmap_init() does not set it to null on failure
- m_cols.bitmap= 0;
+ bitmap_copy(&m_cols, cols);
}
}
#endif
@@ -1231,21 +1229,16 @@ Old_rows_log_event::Old_rows_log_event(const uchar *buf, uint event_len,
/* if my_bitmap_init fails, caught in is_valid() */
if (likely(!my_bitmap_init(&m_cols,
- m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL,
- m_width)))
+ m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL,
+ m_width)))
{
DBUG_PRINT("debug", ("Reading from %p", ptr_after_width));
- memcpy(m_cols.bitmap, ptr_after_width, (m_width + 7) / 8);
- create_last_word_mask(&m_cols);
+ bitmap_import(&m_cols, ptr_after_width);
+ DBUG_DUMP("m_cols", ptr_after_width, no_bytes_in_export_map(&m_cols));
ptr_after_width+= (m_width + 7) / 8;
- DBUG_DUMP("m_cols", (uchar*) m_cols.bitmap, no_bytes_in_map(&m_cols));
}
else
- {
- // Needed because my_bitmap_init() does not set it to null on failure
- m_cols.bitmap= NULL;
DBUG_VOID_RETURN;
- }
const uchar* const ptr_rows_data= (const uchar*) ptr_after_width;
size_t const data_size= event_len - (ptr_rows_data - (const uchar *) buf);
@@ -1263,8 +1256,6 @@ Old_rows_log_event::Old_rows_log_event(const uchar *buf, uint event_len,
m_rows_cur= m_rows_end;
memcpy(m_rows_buf, ptr_rows_data, data_size);
}
- else
- m_cols.bitmap= 0; // to not free it
DBUG_VOID_RETURN;
}
@@ -1272,8 +1263,6 @@ Old_rows_log_event::Old_rows_log_event(const uchar *buf, uint event_len,
Old_rows_log_event::~Old_rows_log_event()
{
- if (m_cols.bitmap == m_bitbuf) // no my_malloc happened
- m_cols.bitmap= 0; // so no my_free in my_bitmap_free
my_bitmap_free(&m_cols); // To pair with my_bitmap_init().
my_free(m_rows_buf);
}
@@ -1285,10 +1274,10 @@ int Old_rows_log_event::get_data_size()
uchar *end= net_store_length(buf, (m_width + 7) / 8);
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master",
- return (int)(6 + no_bytes_in_map(&m_cols) + (end - buf) +
- m_rows_cur - m_rows_buf););
+ return (int)(6 + no_bytes_in_export_map(&m_cols) + (end - buf) +
+ m_rows_cur - m_rows_buf););
int data_size= ROWS_HEADER_LEN;
- data_size+= no_bytes_in_map(&m_cols);
+ data_size+= no_bytes_in_export_map(&m_cols);
data_size+= (uint) (end - buf);
data_size+= (uint) (m_rows_cur - m_rows_buf);
@@ -1508,7 +1497,10 @@ int Old_rows_log_event::do_apply_event(rpl_group_info *rgi)
TIMESTAMP column to a table with one.
So we call set_time(), like in SBR. Presently it changes nothing.
*/
- thd->set_time(when, when_sec_part);
+#ifdef WITH_WSREP
+ if (!wsrep_thd_is_applying(thd))
+#endif
+ thd->set_time(when, when_sec_part);
/*
There are a few flags that are replicated with each row event.
Make sure to set/clear them before executing the main body of
@@ -1806,6 +1798,8 @@ bool Old_rows_log_event::write_data_body()
*/
uchar sbuf[MAX_INT_WIDTH];
my_ptrdiff_t const data_size= m_rows_cur - m_rows_buf;
+ uint bitmap_size= no_bytes_in_export_map(&m_cols);
+ uchar *bitmap;
// This method should not be reached.
assert(0);
@@ -1817,10 +1811,14 @@ bool Old_rows_log_event::write_data_body()
DBUG_DUMP("m_width", sbuf, (size_t) (sbuf_end - sbuf));
res= res || write_data(sbuf, (size_t) (sbuf_end - sbuf));
- DBUG_DUMP("m_cols", (uchar*) m_cols.bitmap, no_bytes_in_map(&m_cols));
- res= res || write_data((uchar*)m_cols.bitmap, no_bytes_in_map(&m_cols));
+ bitmap= (uchar*) my_alloca(bitmap_size);
+ bitmap_export(bitmap, &m_cols);
+
+ DBUG_DUMP("m_cols", bitmap, no_bytes_in_export_map(&m_cols));
+ res= res || write_data(bitmap, no_bytes_in_export_map(&m_cols));
DBUG_DUMP("rows", m_rows_buf, data_size);
res= res || write_data(m_rows_buf, (size_t) data_size);
+ my_afree(bitmap);
return res;