Skip to content

Commit c884f77

Browse files
committed
Added support to byte
1 parent 2025086 commit c884f77

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

replication/row_event.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,10 @@ func (e *RowsEvent) decodeValue(data []byte, tp byte, meta uint16) (v interface{
11411141
v, err = littleDecodeBit(data, nbits, n)
11421142
case MYSQL_TYPE_BLOB:
11431143
v, n, err = decodeBlob(data, meta)
1144+
nv, b := byteToString(v)
1145+
if b {
1146+
v = nv
1147+
}
11441148
case MYSQL_TYPE_VARCHAR,
11451149
MYSQL_TYPE_VAR_STRING:
11461150
length = int(meta)
@@ -1152,6 +1156,10 @@ func (e *RowsEvent) decodeValue(data []byte, tp byte, meta uint16) (v interface{
11521156
length = int(FixedLengthInt(data[0:meta]))
11531157
n = length + int(meta)
11541158
v, err = e.decodeJsonBinary(data[meta:n])
1159+
nv, b := byteToString(v)
1160+
if b {
1161+
v = nv
1162+
}
11551163
case MYSQL_TYPE_GEOMETRY:
11561164
// MySQL saves Geometry as Blob in binlog
11571165
// Seem that the binary format is SRID (4 bytes) + WKB, outer can use
@@ -1167,6 +1175,20 @@ func (e *RowsEvent) decodeValue(data []byte, tp byte, meta uint16) (v interface{
11671175
return v, n, err
11681176
}
11691177

1178+
// byteToString Check if a value is base64
1179+
func byteToString(s interface{}) (string, bool) {
1180+
if s == nil {
1181+
return "", false
1182+
}
1183+
switch v := s.(type) {
1184+
case []uint8:
1185+
str := string(v)
1186+
return str, true
1187+
default:
1188+
return "", false
1189+
}
1190+
}
1191+
11701192
func decodeString(data []byte, length int) (v string, n int) {
11711193
if length < 256 {
11721194
length = int(data[0])

0 commit comments

Comments
 (0)