Skip to content

Commit

Permalink
Merge pull request #561 from go-mysql-org/dobegor_patch-1
Browse files Browse the repository at this point in the history
Fix parsing GTIDs from mysqlpdump
  • Loading branch information
atercattus authored Apr 8, 2021
2 parents 8d7152e + 9dcf4c8 commit f5315d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit f5315d9

Please sign in to comment.