Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

utils: support OVER_MAX_DBS_IN_EVENT_MTS (254) in binlog (#1298) #1299

Merged
merged 1 commit into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/binlog/event/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions pkg/binlog/event/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down