@@ -383,13 +383,20 @@ func (e *GTIDEvent) Decode(data []byte) error {
383
383
}
384
384
385
385
func (e * GTIDEvent ) Dump (w io.Writer ) {
386
+ fmtTime := func (t time.Time ) string {
387
+ if t .IsZero () {
388
+ return "N/A"
389
+ }
390
+ return t .Format (time .RFC3339Nano )
391
+ }
392
+
386
393
fmt .Fprintf (w , "Commit flag: %d\n " , e .CommitFlag )
387
394
u , _ := uuid .FromBytes (e .SID )
388
395
fmt .Fprintf (w , "GTID_NEXT: %s:%d\n " , u .String (), e .GNO )
389
396
fmt .Fprintf (w , "LAST_COMMITTED: %d\n " , e .LastCommitted )
390
397
fmt .Fprintf (w , "SEQUENCE_NUMBER: %d\n " , e .SequenceNumber )
391
- fmt .Fprintf (w , "Immediate commmit timestamp: %d (%s)\n " , e .ImmediateCommitTimestamp , e . fmtTime (e .ImmediateCommitTime ()))
392
- fmt .Fprintf (w , "Orignal commmit timestamp: %d (%s)\n " , e .OriginalCommitTimestamp , e . fmtTime (e .OriginalCommitTime ()))
398
+ fmt .Fprintf (w , "Immediate commmit timestamp: %d (%s)\n " , e .ImmediateCommitTimestamp , fmtTime (e .ImmediateCommitTime ()))
399
+ fmt .Fprintf (w , "Orignal commmit timestamp: %d (%s)\n " , e .OriginalCommitTimestamp , fmtTime (e .OriginalCommitTime ()))
393
400
fmt .Fprintf (w , "Transaction length: %d\n " , e .TransactionLength )
394
401
fmt .Fprintf (w , "Immediate server version: %d\n " , e .ImmediateServerVersion )
395
402
fmt .Fprintf (w , "Orignal server version: %d\n " , e .OriginalServerVersion )
@@ -399,27 +406,13 @@ func (e *GTIDEvent) Dump(w io.Writer) {
399
406
// ImmediateCommitTime returns the commit time of this trx on the immediate server
400
407
// or zero time if not available.
401
408
func (e * GTIDEvent ) ImmediateCommitTime () time.Time {
402
- return e . microsecTimestamp2Time (e .ImmediateCommitTimestamp )
409
+ return microSecTimestampToTime (e .ImmediateCommitTimestamp )
403
410
}
404
411
405
412
// OriginalCommitTime returns the commit time of this trx on the original server
406
413
// or zero time if not available.
407
414
func (e * GTIDEvent ) OriginalCommitTime () time.Time {
408
- return e .microsecTimestamp2Time (e .OriginalCommitTimestamp )
409
- }
410
-
411
- func (e * GTIDEvent ) microsecTimestamp2Time (ts uint64 ) time.Time {
412
- if ts == 0 {
413
- return time.Time {}
414
- }
415
- return time .Unix (int64 (ts / 1000000 ), int64 (ts % 1000000 )* 1000 )
416
- }
417
-
418
- func (e * GTIDEvent ) fmtTime (t time.Time ) string {
419
- if t .IsZero () {
420
- return "N/A"
421
- }
422
- return t .Format (time .RFC3339Nano )
415
+ return microSecTimestampToTime (e .OriginalCommitTimestamp )
423
416
}
424
417
425
418
type BeginLoadQueryEvent struct {
0 commit comments