From d2aa1f9a473a1bb8cf4b78c9ebf79ee2f393426c Mon Sep 17 00:00:00 2001 From: BohuTANG Date: Thu, 14 May 2020 16:21:44 +0800 Subject: [PATCH] Disable XA ROLLBACK and SAVEPOINT type for QueryEvent --- src/Core/MySQLReplication.cpp | 15 ++++++++++----- src/Core/MySQLReplication.h | 2 +- src/Core/tests/mysql_protocol.cpp | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Core/MySQLReplication.cpp b/src/Core/MySQLReplication.cpp index db749fec170..a2e081823b3 100644 --- a/src/Core/MySQLReplication.cpp +++ b/src/Core/MySQLReplication.cpp @@ -97,14 +97,19 @@ namespace MySQLReplication = header.event_size - EVENT_HEADER_LENGTH - 4 - 4 - 1 - 2 - 2 - status_len - schema_len - 1 - CHECKSUM_CRC32_SIGNATURE_LENGTH; query.resize(len); payload.readStrict(reinterpret_cast(query.data()), len); - - if (query == "BEGIN") + if (query.rfind("BEGIN", 0) == 0) { typ = BEGIN; } - else if (query == "SAVEPOINT") + else if (query.rfind("XA", 0) == 0) { - typ = SAVEPOINT; + if (query.rfind("XA ROLLBACK", 0) == 0) + throw ReplicationError("ParseQueryEvent: Unsupported query event:" + query, ErrorCodes::UNKNOWN_EXCEPTION); + typ = XA; + } + else if (query.rfind("SAVEPOINT", 0) == 0) + { + throw ReplicationError("ParseQueryEvent: Unsupported query event:" + query, ErrorCodes::UNKNOWN_EXCEPTION); } } @@ -756,7 +761,7 @@ namespace MySQLReplication switch (query->typ) { case BEGIN: - case SAVEPOINT: { + case XA: { event = std::make_shared(); break; } diff --git a/src/Core/MySQLReplication.h b/src/Core/MySQLReplication.h index caef184add2..df0eb36e395 100644 --- a/src/Core/MySQLReplication.h +++ b/src/Core/MySQLReplication.h @@ -340,7 +340,7 @@ namespace MySQLReplication { DDL = 0, BEGIN = 1, - SAVEPOINT = 2 + XA = 2 }; class QueryEvent : public EventBase diff --git a/src/Core/tests/mysql_protocol.cpp b/src/Core/tests/mysql_protocol.cpp index 96de2c5ce1d..931884a1cee 100644 --- a/src/Core/tests/mysql_protocol.cpp +++ b/src/Core/tests/mysql_protocol.cpp @@ -212,6 +212,7 @@ int main(int, char **) break; } default: + event->dump(); break; } }