File tree Expand file tree Collapse file tree 4 files changed +25
-15
lines changed Expand file tree Collapse file tree 4 files changed +25
-15
lines changed Original file line number Diff line number Diff line change 11name : CI
2+ permissions :
3+ contents : read
24
35on : [pull_request]
46
Original file line number Diff line number Diff line change 11name : migration tests
2+ permissions :
3+ contents : read
24
35on : [pull_request]
46
Original file line number Diff line number Diff line change @@ -78,13 +78,12 @@ func (this *FileBinlogCoordinates) SmallerThan(other BinlogCoordinates) bool {
7878 if ! ok || other == nil {
7979 return false
8080 }
81- if this .LogFile < coord .LogFile {
82- return true
83- }
84- if this .LogFile == coord .LogFile && this .LogPos < coord .LogPos {
85- return true
81+
82+ fileNumberDist := this .FileNumberDistance (coord )
83+ if fileNumberDist == 0 {
84+ return this .LogPos < coord .LogPos
8685 }
87- return false
86+ return fileNumberDist > 0
8887}
8988
9089// SmallerThanOrEquals returns true if this coordinate is the same or equal to the other one.
@@ -100,15 +99,6 @@ func (this *FileBinlogCoordinates) SmallerThanOrEquals(other BinlogCoordinates)
10099 return this .LogFile == coord .LogFile && this .LogPos == coord .LogPos // No Type comparison
101100}
102101
103- // FileSmallerThan returns true if this coordinate's file is strictly smaller than the other's.
104- func (this * FileBinlogCoordinates ) FileSmallerThan (other BinlogCoordinates ) bool {
105- coord , ok := other .(* FileBinlogCoordinates )
106- if ! ok || other == nil {
107- return false
108- }
109- return this .LogFile < coord .LogFile
110- }
111-
112102// FileNumberDistance returns the numeric distance between this coordinate's file number and the other's.
113103// Effectively it means "how many rotates/FLUSHes would make these coordinates's file reach the other's"
114104func (this * FileBinlogCoordinates ) FileNumberDistance (other * FileBinlogCoordinates ) int {
Original file line number Diff line number Diff line change @@ -134,3 +134,19 @@ func TestIsLogPosOverflowBeyond4Bytes(t *testing.T) {
134134 require .True (t , curCoordinates .IsLogPosOverflowBeyond4Bytes (preCoordinates ))
135135 }
136136}
137+
138+ func TestBinlogCoordinates_LogFileZeroPaddedTransition (t * testing.T ) {
139+ c1 := FileBinlogCoordinates {LogFile : "mysql-bin.999999" , LogPos : 100 }
140+ c2 := FileBinlogCoordinates {LogFile : "mysql-bin.1000000" , LogPos : 100 }
141+
142+ require .True (t , c1 .SmallerThan (& c2 ))
143+ }
144+
145+ func TestBinlogCoordinates_SameLogFileDifferentPosition (t * testing.T ) {
146+ c1 := FileBinlogCoordinates {LogFile : "binlog.000001" , LogPos : 100 }
147+ c2 := FileBinlogCoordinates {LogFile : "binlog.000001" , LogPos : 200 }
148+
149+ require .True (t , c1 .SmallerThan (& c2 ))
150+ require .False (t , c2 .SmallerThan (& c1 ))
151+ require .False (t , c1 .SmallerThan (& c1 ))
152+ }
You can’t perform that action at this time.
0 commit comments