Skip to content

Commit

Permalink
output sorted mysql gtid (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
zr-hebo authored Aug 24, 2020
1 parent 725599e commit 0c5789d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions mysql/mysql_gtid.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,25 @@ func (s *MysqlGTIDSet) Equal(o GTIDSet) bool {
}

func (s *MysqlGTIDSet) String() string {
// there is only one element in gtid set
if len(s.Sets) == 1 {
for _, set := range s.Sets {
return set.String()
}
}

// sort multi set
var buf bytes.Buffer
sep := ""
sets := make([]string, 0, len(s.Sets))
for _, set := range s.Sets {
sets = append(sets, set.String())
}
sort.Strings(sets)

sep := ""
for _, set := range sets {
buf.WriteString(sep)
buf.WriteString(set.String())
buf.WriteString(set)
sep = ","
}

Expand Down

0 comments on commit 0c5789d

Please sign in to comment.