From faab7fccc5c05daeb4f717bb9d8e72fbad4b58f8 Mon Sep 17 00:00:00 2001 From: lance6716 Date: Wed, 25 Nov 2020 16:12:14 +0800 Subject: [PATCH] cherry pick #1298 to release-2.0 Signed-off-by: ti-srebot --- pkg/binlog/event/util.go | 5 +++++ pkg/binlog/event/util_test.go | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/pkg/binlog/event/util.go b/pkg/binlog/event/util.go index 6f69d6e01a..c8ac8d1230 100644 --- a/pkg/binlog/event/util.go +++ b/pkg/binlog/event/util.go @@ -442,6 +442,11 @@ func statusVarsToKV(statusVars []byte) (map[byte][]byte, error) { return generateError(err) } value = append(value, count) + // if count is 254 (OVER_MAX_DBS_IN_EVENT_MTS), there's no following DB names + // https://github.com/mysql/mysql-server/blob/ee4455a33b10f1b1886044322e4893f587b319ed/libbinlogevents/include/binlog_event.h#L107 + if count == 254 { + break + } buf := make([]byte, 0, 128) b := byte(1) // initialize to any non-zero value diff --git a/pkg/binlog/event/util_test.go b/pkg/binlog/event/util_test.go index 4dde0d8114..a67e454d60 100644 --- a/pkg/binlog/event/util_test.go +++ b/pkg/binlog/event/util_test.go @@ -78,6 +78,18 @@ func (t *testUtilSuite) TestStatusVarsToKV(c *C) { }, nil, }, + // OVER_MAX_DBS_IN_EVENT_MTS in Q_UPDATED_DB_NAMES + { + []byte{0, 0, 0, 0, 0, 1, 0, 0, 160, 85, 0, 0, 0, 0, 6, 3, 115, 116, 100, 4, 45, 0, 45, 0, 33, 0, 12, 254}, + map[byte][]byte{ + 0: {0, 0, 0, 0}, + 1: {0, 0, 160, 85, 0, 0, 0, 0}, + 6: {3, 115, 116, 100}, + 4: {45, 0, 45, 0, 33, 0}, + 12: {254}, + }, + nil, + }, } for _, t := range testCases {