Skip to content

Commit 1e0f691

Browse files
committed
sort mariadb gtid set
1 parent 0bd942a commit 1e0f691

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

mysql/mariadb_gtid.go

+21-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package mysql
33
import (
44
"bytes"
55
"fmt"
6+
"sort"
67
"strconv"
78
"strings"
89

@@ -157,7 +158,26 @@ func (s *MariadbGTIDSet) Update(GTIDStr string) error {
157158
}
158159

159160
func (s *MariadbGTIDSet) String() string {
160-
return hack.String(s.Encode())
161+
if len(s.Sets) == 1 {
162+
for _, set := range s.Sets {
163+
return set.String()
164+
}
165+
}
166+
167+
var buf bytes.Buffer
168+
sets := make([]string, 0, len(s.Sets))
169+
for _, set := range s.Sets {
170+
sets = append(sets, set.String())
171+
}
172+
sort.Strings(sets)
173+
174+
sep := ""
175+
for _, set := range sets {
176+
buf.WriteString(sep)
177+
buf.WriteString(set)
178+
sep = ","
179+
}
180+
return hack.String(buf.Bytes())
161181
}
162182

163183
// Encode encodes mariadb gtid set

0 commit comments

Comments
 (0)