@@ -1172,6 +1172,7 @@ func decodeString(data []byte, length int) (v string, n int) {
1172
1172
return
1173
1173
}
1174
1174
1175
+ // ref: https://github.com/mysql/mysql-server/blob/a9b0c712de3509d8d08d3ba385d41a4df6348775/strings/decimal.c#L137
1175
1176
const digitsPerInteger int = 9
1176
1177
1177
1178
var compressedBytes = []int {0 , 1 , 1 , 2 , 2 , 3 , 3 , 4 , 4 , 4 }
@@ -1192,7 +1193,7 @@ func decodeDecimalDecompressValue(compIndx int, data []byte, mask uint8) (size i
1192
1193
return
1193
1194
}
1194
1195
1195
- var zeros = [9 ]byte {48 , 48 , 48 , 48 , 48 , 48 , 48 , 48 , 48 }
1196
+ var zeros = [digitsPerInteger ]byte {48 , 48 , 48 , 48 , 48 , 48 , 48 , 48 , 48 }
1196
1197
1197
1198
func decodeDecimal (data []byte , precision int , decimals int , useDecimal bool ) (interface {}, int , error ) {
1198
1199
//see python mysql replication and https://github.com/jeremycole/mysql_binlog
@@ -1244,7 +1245,7 @@ func decodeDecimal(data []byte, precision int, decimals int, useDecimal bool) (i
1244
1245
}
1245
1246
} else {
1246
1247
toWrite := strconv .FormatUint (uint64 (value ), 10 )
1247
- res .Write (zeros [:9 - len (toWrite )])
1248
+ res .Write (zeros [:digitsPerInteger - len (toWrite )])
1248
1249
res .WriteString (toWrite )
1249
1250
}
1250
1251
}
@@ -1260,7 +1261,7 @@ func decodeDecimal(data []byte, precision int, decimals int, useDecimal bool) (i
1260
1261
value = binary .BigEndian .Uint32 (data [pos :]) ^ mask
1261
1262
pos += 4
1262
1263
toWrite := strconv .FormatUint (uint64 (value ), 10 )
1263
- res .Write (zeros [:9 - len (toWrite )])
1264
+ res .Write (zeros [:digitsPerInteger - len (toWrite )])
1264
1265
res .WriteString (toWrite )
1265
1266
}
1266
1267
0 commit comments