From a78604db2bbcb078ef71398253cb00d4160b1fd9 Mon Sep 17 00:00:00 2001 From: BohuTANG Date: Tue, 18 Aug 2020 09:47:26 +0800 Subject: [PATCH] ISSUES-4006 add constructor to initialize number member --- src/Core/MySQL/MySQLGtid.h | 3 ++- src/Core/MySQL/MySQLReplication.cpp | 13 +++---------- src/Core/MySQL/MySQLReplication.h | 13 +++++++++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Core/MySQL/MySQLGtid.h b/src/Core/MySQL/MySQLGtid.h index 5b1bcf18a10..f30fae7a3a7 100644 --- a/src/Core/MySQL/MySQLGtid.h +++ b/src/Core/MySQL/MySQLGtid.h @@ -2,7 +2,6 @@ #include #include - namespace DB { class GTID @@ -10,6 +9,8 @@ class GTID public: UInt8 uuid[16]; Int64 seq_no; + + GTID() : seq_no(0) { } }; class GTIDSet diff --git a/src/Core/MySQL/MySQLReplication.cpp b/src/Core/MySQL/MySQLReplication.cpp index dd710b1991e..51c06b9b5a6 100644 --- a/src/Core/MySQL/MySQLReplication.cpp +++ b/src/Core/MySQL/MySQLReplication.cpp @@ -133,7 +133,6 @@ namespace MySQLReplication void XIDEvent::parseImpl(ReadBuffer & payload) { payload.readStrict(reinterpret_cast(&xid), 8); } - void XIDEvent::dump(std::ostream & out) const { header.dump(out); @@ -756,7 +755,9 @@ namespace MySQLReplication { switch (event->header.type) { - case FORMAT_DESCRIPTION_EVENT: { + case FORMAT_DESCRIPTION_EVENT: + case QUERY_EVENT: + case XID_EVENT: { binlog_pos = event->header.log_pos; break; } @@ -766,14 +767,6 @@ namespace MySQLReplication binlog_pos = event->header.log_pos; break; } - case QUERY_EVENT: { - binlog_pos = event->header.log_pos; - break; - } - case XID_EVENT: { - binlog_pos = event->header.log_pos; - break; - } case GTID_EVENT: { auto gtid_event = std::static_pointer_cast(event); binlog_pos = event->header.log_pos; diff --git a/src/Core/MySQL/MySQLReplication.h b/src/Core/MySQL/MySQLReplication.h index e375bb38c92..7cc2fb0d190 100644 --- a/src/Core/MySQL/MySQLReplication.h +++ b/src/Core/MySQL/MySQLReplication.h @@ -291,6 +291,7 @@ namespace MySQLReplication UInt32 log_pos; UInt16 flags; + EventHeader() : timestamp(0), server_id(0), event_size(0), log_pos(0), flags(0) { } void dump(std::ostream & out) const; void parse(ReadBuffer & payload); }; @@ -312,6 +313,9 @@ namespace MySQLReplication class FormatDescriptionEvent : public EventBase { + public: + FormatDescriptionEvent() : binlog_version(0), create_timestamp(0), event_header_length(0) { } + protected: UInt16 binlog_version; String server_version; @@ -332,6 +336,7 @@ namespace MySQLReplication UInt64 position; String next_binlog; + RotateEvent() : position(0) { } void dump(std::ostream & out) const override; protected: @@ -358,6 +363,7 @@ namespace MySQLReplication String query; QueryType typ = DDL; + QueryEvent() : thread_id(0), exec_time(0), schema_len(0), error_code(0), status_len(0) { } void dump(std::ostream & out) const override; MySQLEventType type() const override { return MYSQL_QUERY_EVENT; } @@ -367,6 +373,9 @@ namespace MySQLReplication class XIDEvent : public EventBase { + public: + XIDEvent() : xid(0) { } + protected: UInt64 xid; @@ -388,6 +397,7 @@ namespace MySQLReplication std::vector column_meta; Bitmap null_bitmap; + TableMapEvent() : table_id(0), flags(0), schema_len(0), table_len(0), column_count(0) { } void dump(std::ostream & out) const override; protected: @@ -452,6 +462,8 @@ namespace MySQLReplication public: UInt8 commit_flag; GTID gtid; + + GTIDEvent() : commit_flag(0) { } void dump(std::ostream & out) const override; protected: @@ -473,6 +485,7 @@ namespace MySQLReplication String binlog_name; GTIDSets gtid_sets; + Position() : binlog_pos(0) { } void update(BinlogEventPtr event); void update(UInt64 binlog_pos_, const String & binlog_name_, const String & gtid_sets_); void dump(std::ostream & out) const;