Skip to content

Commit b758aa5

Browse files
committed
Add some comments about new fields in GTIDEvent..
1 parent 569203c commit b758aa5

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

replication/event.go

+20-18
Original file line numberDiff line numberDiff line change
@@ -226,31 +226,31 @@ type PreviousGTIDsEvent struct {
226226
func (e *PreviousGTIDsEvent) Decode(data []byte) error {
227227
var previousGTIDSets []string
228228
pos := 0
229-
uuidCount := binary.LittleEndian.Uint16(data[pos:pos+8])
229+
uuidCount := binary.LittleEndian.Uint16(data[pos : pos+8])
230230
pos += 8
231231

232-
for i := uint16(0);i < uuidCount; i++ {
233-
uuid := e.decodeUuid(data[pos:pos+16])
232+
for i := uint16(0); i < uuidCount; i++ {
233+
uuid := e.decodeUuid(data[pos : pos+16])
234234
pos += 16
235-
sliceCount := binary.LittleEndian.Uint16(data[pos:pos+8])
235+
sliceCount := binary.LittleEndian.Uint16(data[pos : pos+8])
236236
pos += 8
237237
var intervals []string
238-
for i := uint16(0);i < sliceCount; i++ {
239-
start := e.decodeInterval(data[pos:pos+8])
238+
for i := uint16(0); i < sliceCount; i++ {
239+
start := e.decodeInterval(data[pos : pos+8])
240240
pos += 8
241-
stop := e.decodeInterval(data[pos:pos+8])
241+
stop := e.decodeInterval(data[pos : pos+8])
242242
pos += 8
243243
interval := ""
244244
if stop == start+1 {
245-
interval = fmt.Sprintf("%d",start)
246-
}else {
247-
interval = fmt.Sprintf("%d-%d",start,stop-1)
245+
interval = fmt.Sprintf("%d", start)
246+
} else {
247+
interval = fmt.Sprintf("%d-%d", start, stop-1)
248248
}
249-
intervals = append(intervals,interval)
249+
intervals = append(intervals, interval)
250250
}
251-
previousGTIDSets = append(previousGTIDSets,fmt.Sprintf("%s:%s",uuid,strings.Join(intervals,":")))
251+
previousGTIDSets = append(previousGTIDSets, fmt.Sprintf("%s:%s", uuid, strings.Join(intervals, ":")))
252252
}
253-
e.GTIDSets = fmt.Sprintf("%s",strings.Join(previousGTIDSets,","))
253+
e.GTIDSets = fmt.Sprintf("%s", strings.Join(previousGTIDSets, ","))
254254
return nil
255255
}
256256

@@ -260,8 +260,8 @@ func (e *PreviousGTIDsEvent) Dump(w io.Writer) {
260260
}
261261

262262
func (e *PreviousGTIDsEvent) decodeUuid(data []byte) string {
263-
return fmt.Sprintf("%s-%s-%s-%s-%s",hex.EncodeToString(data[0:4]),hex.EncodeToString(data[4:6]),
264-
hex.EncodeToString(data[6:8]),hex.EncodeToString(data[8:10]),hex.EncodeToString(data[10:]))
263+
return fmt.Sprintf("%s-%s-%s-%s-%s", hex.EncodeToString(data[0:4]), hex.EncodeToString(data[4:6]),
264+
hex.EncodeToString(data[6:8]), hex.EncodeToString(data[8:10]), hex.EncodeToString(data[10:]))
265265
}
266266

267267
func (e *PreviousGTIDsEvent) decodeInterval(data []byte) uint64 {
@@ -351,15 +351,17 @@ type GTIDEvent struct {
351351
LastCommitted int64
352352
SequenceNumber int64
353353

354-
// The followings are available only after MySQL-8.0
355-
354+
// ImmediateCommitTimestamp/OriginalCommitTimestamp are introduced in MySQL-8.0.1, see:
355+
// https://mysqlhighavailability.com/replication-features-in-mysql-8-0-1/
356356
ImmediateCommitTimestamp uint64
357357
OriginalCommitTimestamp uint64
358358

359-
// Total transaction length (including this GTIDEvent), see:
359+
// Total transaction length (including this GTIDEvent), introduced in MySQL-8.0.2, see:
360360
// https://mysqlhighavailability.com/taking-advantage-of-new-transaction-length-metadata/
361361
TransactionLength uint64
362362

363+
// ImmediateServerVersion/OriginalServerVersion are introduced in MySQL-8.0.14, see
364+
// https://dev.mysql.com/doc/refman/8.0/en/replication-compatibility.html
363365
ImmediateServerVersion uint32
364366
OriginalServerVersion uint32
365367
}

0 commit comments

Comments
 (0)