Bug #82003 Rows event are decoded one byte at a time
Submitted: 25 Jun 2016 16:15 Modified: 18 Aug 2016 11:12
Reporter: Davi Arnaut (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Row Based Replication ( RBR ) Severity:S3 (Non-critical)
Version:5.7.13 OS:Any
Assigned to: CPU Architecture:Any
Tags: binlogevents, byte-by-byte, Rows_event

[25 Jun 2016 16:15] Davi Arnaut
Description:
The constructor of Rows_events takes a buffer that contains the
row event and decodes it into fields. One of these fields is the
actual row data, which is being copied from the buffer one byte
at time, which is not required and is a slow way to copy data.

How to repeat:
https://github.com/mysql/mysql-server/blob/5.7/libbinlogevents/src/rows_event.cpp#L289-L29...

Suggested fix:
diff --git a/libbinlogevents/src/rows_event.cpp b/libbinlogevents/src/rows_event.cpp
index 8beddbf..aac649b 100644
--- a/libbinlogevents/src/rows_event.cpp
+++ b/libbinlogevents/src/rows_event.cpp
@@ -286,14 +286,7 @@ Rows_event::Rows_event(const char *buf, unsigned int event_len,
                           (ptr_rows_data + common_header_len -
                           (const unsigned char *) buf);
 
-  row.reserve(data_size + 1);
-  for (unsigned long i= 0; i < data_size + 1; i++)
-  {
-    row.push_back(*ptr_rows_data);
-    ptr_rows_data++;
-  }
-  BAPI_ASSERT( row.size() == data_size + 1);
-  return;
+  row.assign(ptr_rows_data, ptr_rows_data + data_size + 1);
 }
 
 Rows_event::~Rows_event()
[27 Jun 2016 5:10] Umesh Shastry
Hello Davi,

Thank you for the report and contribution.

Thanks,
Umesh
[18 Aug 2016 11:12] Erlend Dahl
[10 Aug 2016 8:53] David Moss

Thank you for your feedback and contribution, this has been fixed in upcoming
versions and the following was added to the 5.7.14 changelog:
The constructor of Rows_events has been improved to not decode the supplied
row event one byte at a time.