From 632a7f85089f61526d9d3696e2559d8f43199881 Mon Sep 17 00:00:00 2001 From: George Dobrovolsky <georgy.dobrovolsky@gmail.com> Date: Fri, 2 Apr 2021 11:19:00 +0300 Subject: [PATCH 1/2] Fix parsing GTIDs from mysqlpdump This address the issue https://github.com/siddontang/go-mysql/issues/550. (cherry picked from commit 6f9431a7102cc23e32262dfbf7f0bb74df485545) --- dump/parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dump/parser.go b/dump/parser.go index 3b5c34dc4..bc8ebd985 100644 --- a/dump/parser.go +++ b/dump/parser.go @@ -34,7 +34,7 @@ func init() { 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+)") + gtidExp = regexp.MustCompile(`(\w{8}(-\w{4}){3}-\w{12}(:\d+-\d+)+)`) } // Parse the dump data with Dumper generate. From 9dcf4c8250e7bae2644ffbe4df9bd4734948e6ea Mon Sep 17 00:00:00 2001 From: atercattus <cat@ater.me> Date: Thu, 8 Apr 2021 09:38:13 +0300 Subject: [PATCH 2/2] Add new testcase --- dump/dump_test.go | 5 +++++ dump/parser.go | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dump/dump_test.go b/dump/dump_test.go index 3ef20cd37..5e0f113e5 100644 --- a/dump/dump_test.go +++ b/dump/dump_test.go @@ -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 { diff --git a/dump/parser.go b/dump/parser.go index bc8ebd985..4605e98ca 100644 --- a/dump/parser.go +++ b/dump/parser.go @@ -33,7 +33,8 @@ 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'; + // 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+)+)`) }