Skip to content

Fix parsing GTIDs from mysqlpdump #561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2021
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 dump/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ e7574090-b123-11e8-8bb4-005056a29643:1-12'
{`SET @@GLOBAL.GTID_PURGED='c0977f88-3104-11e9-81e1-00505690245b:1-274559';
`, "c0977f88-3104-11e9-81e1-00505690245b:1-274559"},
{`CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.008995', MASTER_LOG_POS=102052485;`, ""},
{
`SET @@GLOBAL.GTID_PURGED='e50bd2d3-6ad7-11e9-890c-42010af0017c:1-5291126581:5291126583-5323107666';
`,
"e50bd2d3-6ad7-11e9-890c-42010af0017c:1-5291126581:5291126583-5323107666",
},
}

for _, tt := range tbls {
Expand Down
5 changes: 3 additions & 2 deletions dump/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ func init() {
useExp = regexp.MustCompile("^USE `(.+)`;")
valuesExp = regexp.MustCompile("^INSERT INTO `(.+?)` VALUES \\((.+)\\);$")
// The pattern will only match MySQL GTID, as you know SET GLOBAL gtid_slave_pos='0-1-4' is used for MariaDB.
//SET @@GLOBAL.GTID_PURGED='1638041a-0457-11e9-bb9f-00505690b730:1-429405150';
gtidExp = regexp.MustCompile("(\\w{8}(-\\w{4}){3}-\\w{12}:\\d+-\\d+)")
// SET @@GLOBAL.GTID_PURGED='1638041a-0457-11e9-bb9f-00505690b730:1-429405150';
// https://dev.mysql.com/doc/refman/5.7/en/replication-gtids-concepts.html
gtidExp = regexp.MustCompile(`(\w{8}(-\w{4}){3}-\w{12}(:\d+-\d+)+)`)
}

// Parse the dump data with Dumper generate.
Expand Down