Skip to content

Commit c0cd0ab

Browse files
authored
Merge branch 'master' into master
2 parents c4e7077 + a778272 commit c0cd0ab

16 files changed

+170
-61
lines changed

client/resp.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"fmt"
1010

1111
"github.com/pingcap/errors"
12-
"github.com/siddontang/go/hack"
1312

1413
. "github.com/go-mysql-org/go-mysql/mysql"
1514
"github.com/go-mysql-org/go-mysql/utils"
@@ -78,11 +77,11 @@ func (c *Conn) handleErrorPacket(data []byte) error {
7877
if c.capability&CLIENT_PROTOCOL_41 > 0 {
7978
// skip '#'
8079
pos++
81-
e.State = hack.String(data[pos : pos+5])
80+
e.State = utils.ByteSliceToString(data[pos : pos+5])
8281
pos += 5
8382
}
8483

85-
e.Message = hack.String(data[pos:])
84+
e.Message = utils.ByteSliceToString(data[pos:])
8685

8786
return e
8887
}
@@ -372,7 +371,7 @@ func (c *Conn) readResultColumns(result *Result) (err error) {
372371
return err
373372
}
374373

375-
result.FieldNames[hack.String(result.Fields[i].Name)] = i
374+
result.FieldNames[utils.ByteSliceToString(result.Fields[i].Name)] = i
376375

377376
i++
378377
}

driver/driver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717

1818
"github.com/go-mysql-org/go-mysql/client"
1919
"github.com/go-mysql-org/go-mysql/mysql"
20+
"github.com/go-mysql-org/go-mysql/utils"
2021
"github.com/pingcap/errors"
21-
"github.com/siddontang/go/hack"
2222
)
2323

2424
var customTLSMutex sync.Mutex
@@ -352,7 +352,7 @@ func newRows(r *mysql.Resultset) (*rows, error) {
352352
rs.columns = make([]string, len(r.Fields))
353353

354354
for i, f := range r.Fields {
355-
rs.columns[i] = hack.String(f.Name)
355+
rs.columns[i] = utils.ByteSliceToString(f.Name)
356356
}
357357
rs.step = 0
358358

driver/driver_options_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"time"
1717

1818
"github.com/pingcap/errors"
19-
"github.com/siddontang/go/log"
19+
"github.com/siddontang/go-log/log"
2020
"github.com/stretchr/testify/require"
2121

2222
"github.com/go-mysql-org/go-mysql/client"

go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ require (
1515
github.com/pingcap/errors v0.11.5-0.20240311024730-e056997136bb
1616
github.com/pingcap/tidb/pkg/parser v0.0.0-20241118164214-4f047be191be
1717
github.com/shopspring/decimal v1.2.0
18-
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726
1918
github.com/siddontang/go-log v0.0.0-20180807004314-8d05993dda07
2019
github.com/stretchr/testify v1.8.4
2120
)

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR
4848
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
4949
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
5050
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
51-
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726 h1:xT+JlYxNGqyT+XcU8iUrN18JYed2TvG9yN5ULG2jATM=
52-
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
5351
github.com/siddontang/go-log v0.0.0-20180807004314-8d05993dda07 h1:oI+RNwuC9jF2g2lP0u0cVEEZrc/AYBCuFdvwrLWM/6Q=
5452
github.com/siddontang/go-log v0.0.0-20180807004314-8d05993dda07/go.mod h1:yFdBgwXP24JziuRl2NMUahT7nGLNOKi1SIiFxMttVD4=
5553
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

mysql/mysql_gtid.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"strconv"
1111
"strings"
1212

13+
"github.com/go-mysql-org/go-mysql/utils"
1314
"github.com/google/uuid"
1415
"github.com/pingcap/errors"
15-
"github.com/siddontang/go/hack"
1616
)
1717

1818
// Like MySQL GTID Interval struct, [start, stop), left closed and right open
@@ -318,7 +318,7 @@ func (s *UUIDSet) MinusInterval(in IntervalSlice) {
318318
}
319319

320320
func (s *UUIDSet) String() string {
321-
return hack.String(s.Bytes())
321+
return utils.ByteSliceToString(s.Bytes())
322322
}
323323

324324
func (s *UUIDSet) encode(w io.Writer) {
@@ -571,7 +571,7 @@ func (s *MysqlGTIDSet) String() string {
571571
sep = ","
572572
}
573573

574-
return hack.String(buf.Bytes())
574+
return utils.ByteSliceToString(buf.Bytes())
575575
}
576576

577577
func (s *MysqlGTIDSet) Encode() []byte {

mysql/resultset.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"strconv"
66
"sync"
77

8+
"github.com/go-mysql-org/go-mysql/utils"
89
"github.com/pingcap/errors"
9-
"github.com/siddontang/go/hack"
1010
)
1111

1212
type StreamingType int
@@ -263,7 +263,7 @@ func (r *Resultset) GetString(row, column int) (string, error) {
263263
case string:
264264
return v, nil
265265
case []byte:
266-
return hack.String(v), nil
266+
return utils.ByteSliceToString(v), nil
267267
case int, int8, int16, int32, int64,
268268
uint, uint8, uint16, uint32, uint64:
269269
return fmt.Sprintf("%d", v), nil

mysql/resultset_helper.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import (
88
"time"
99

1010
"github.com/pingcap/errors"
11-
"github.com/siddontang/go/hack"
11+
12+
"github.com/go-mysql-org/go-mysql/utils"
1213
)
1314

1415
func FormatTextValue(value interface{}) ([]byte, error) {
@@ -40,7 +41,7 @@ func FormatTextValue(value interface{}) ([]byte, error) {
4041
case []byte:
4142
return v, nil
4243
case string:
43-
return hack.Slice(v), nil
44+
return utils.StringToByteSlice(v), nil
4445
case time.Time:
4546
return hack.Slice(v.Format(time.DateTime)), nil
4647
case nil:
@@ -117,7 +118,7 @@ func formatBinaryValue(value interface{}) ([]byte, error) {
117118
case []byte:
118119
return v, nil
119120
case string:
120-
return hack.Slice(v), nil
121+
return utils.StringToByteSlice(v), nil
121122
case time.Time:
122123
return toBinaryDateTime(v)
123124
default:
@@ -175,7 +176,7 @@ func BuildSimpleTextResultset(names []string, values [][]interface{}) (*Resultse
175176

176177
if len(values) == 0 {
177178
for i, name := range names {
178-
r.Fields[i] = &Field{Name: hack.Slice(name), Charset: 33, Type: MYSQL_TYPE_NULL}
179+
r.Fields[i] = &Field{Name: utils.StringToByteSlice(name), Charset: 33, Type: MYSQL_TYPE_NULL}
179180
}
180181
return r, nil
181182
}
@@ -192,7 +193,7 @@ func BuildSimpleTextResultset(names []string, values [][]interface{}) (*Resultse
192193
return nil, errors.Trace(err)
193194
}
194195
if r.Fields[j] == nil {
195-
r.Fields[j] = &Field{Name: hack.Slice(names[j]), Type: typ}
196+
r.Fields[j] = &Field{Name: utils.StringToByteSlice(names[j]), Type: typ}
196197
err = formatField(r.Fields[j], value)
197198
if err != nil {
198199
return nil, errors.Trace(err)
@@ -260,7 +261,7 @@ func BuildSimpleBinaryResultset(names []string, values [][]interface{}) (*Result
260261
if i == 0 {
261262
field := &Field{Type: typ}
262263
r.Fields[j] = field
263-
field.Name = hack.Slice(names[j])
264+
field.Name = utils.StringToByteSlice(names[j])
264265

265266
if err = formatField(field, value); err != nil {
266267
return nil, errors.Trace(err)

mysql/util.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
"time"
1717

1818
"github.com/Masterminds/semver"
19+
"github.com/go-mysql-org/go-mysql/utils"
1920
"github.com/pingcap/errors"
20-
"github.com/siddontang/go/hack"
2121
)
2222

2323
func Pstack() string {
@@ -375,7 +375,7 @@ var (
375375
func Escape(sql string) string {
376376
dest := make([]byte, 0, 2*len(sql))
377377

378-
for _, w := range hack.Slice(sql) {
378+
for _, w := range utils.StringToByteSlice(sql) {
379379
if c := EncodeMap[w]; c == DONTESCAPE {
380380
dest = append(dest, w)
381381
} else {

replication/event.go

+67-10
Original file line numberDiff line numberDiff line change
@@ -229,34 +229,91 @@ type PreviousGTIDsEvent struct {
229229
GTIDSets string
230230
}
231231

232+
type GtidFormat int
233+
234+
const (
235+
GtidFormatClassic = iota
236+
GtidFormatTagged
237+
)
238+
239+
// Decode the number of sids (source identifiers) and if it is using
240+
// tagged GTIDs or classic (non-tagged) GTIDs.
241+
//
242+
// Note that each gtid tag increases the sidno here, so a single UUID
243+
// might turn up multiple times if there are multipl tags.
244+
//
245+
// see also:
246+
// decode_nsids_format in mysql/mysql-server
247+
// https://github.com/mysql/mysql-server/blob/61a3a1d8ef15512396b4c2af46e922a19bf2b174/sql/rpl_gtid_set.cc#L1363-L1378
248+
func decodeSid(data []byte) (format GtidFormat, sidnr uint64) {
249+
if data[7] == 1 {
250+
format = GtidFormatTagged
251+
}
252+
253+
if format == GtidFormatTagged {
254+
masked := make([]byte, 8)
255+
copy(masked, data[1:7])
256+
sidnr = binary.LittleEndian.Uint64(masked)
257+
return
258+
}
259+
sidnr = binary.LittleEndian.Uint64(data[:8])
260+
return
261+
}
262+
232263
func (e *PreviousGTIDsEvent) Decode(data []byte) error {
233264
pos := 0
234-
uuidCount := binary.LittleEndian.Uint16(data[pos : pos+8])
265+
266+
format, uuidCount := decodeSid(data)
235267
pos += 8
236268

237269
previousGTIDSets := make([]string, uuidCount)
238-
for i := range previousGTIDSets {
270+
271+
currentSetnr := 0
272+
var buf strings.Builder
273+
for range previousGTIDSets {
239274
uuid := e.decodeUuid(data[pos : pos+16])
240275
pos += 16
276+
var tag string
277+
if format == GtidFormatTagged {
278+
tagLength := int(data[pos]) / 2
279+
pos += 1
280+
if tagLength > 0 { // 0 == no tag, >0 == tag
281+
tag = string(data[pos : pos+tagLength])
282+
pos += tagLength
283+
}
284+
}
285+
286+
if len(tag) > 0 {
287+
buf.WriteString(":")
288+
buf.WriteString(tag)
289+
} else {
290+
if currentSetnr != 0 {
291+
buf.WriteString(",")
292+
}
293+
buf.WriteString(uuid)
294+
currentSetnr += 1
295+
}
296+
241297
sliceCount := binary.LittleEndian.Uint16(data[pos : pos+8])
242298
pos += 8
243-
intervals := make([]string, sliceCount)
244-
for i := range intervals {
299+
for range sliceCount {
300+
buf.WriteString(":")
301+
245302
start := e.decodeInterval(data[pos : pos+8])
246303
pos += 8
247304
stop := e.decodeInterval(data[pos : pos+8])
248305
pos += 8
249-
interval := ""
250306
if stop == start+1 {
251-
interval = fmt.Sprintf("%d", start)
307+
fmt.Fprintf(&buf, "%d", start)
252308
} else {
253-
interval = fmt.Sprintf("%d-%d", start, stop-1)
309+
fmt.Fprintf(&buf, "%d-%d", start, stop-1)
254310
}
255-
intervals[i] = interval
256311
}
257-
previousGTIDSets[i] = fmt.Sprintf("%s:%s", uuid, strings.Join(intervals, ":"))
312+
if len(tag) == 0 {
313+
currentSetnr += 1
314+
}
258315
}
259-
e.GTIDSets = strings.Join(previousGTIDSets, ",")
316+
e.GTIDSets = buf.String()
260317
return nil
261318
}
262319

replication/event_test.go

+54
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,57 @@ func TestIntVarEvent(t *testing.T) {
140140
require.Equal(t, INSERT_ID, ev.Type)
141141
require.Equal(t, uint64(23), ev.Value)
142142
}
143+
144+
func TestDecodeSid(t *testing.T) {
145+
testcases := []struct {
146+
input []byte
147+
gtidFormat GtidFormat
148+
uuidCount uint64
149+
}{
150+
{[]byte{1, 2, 0, 0, 0, 0, 0, 1}, GtidFormatTagged, 2},
151+
{[]byte{1, 1, 0, 0, 0, 0, 0, 1}, GtidFormatTagged, 1},
152+
{[]byte{1, 0, 0, 0, 0, 0, 0, 1}, GtidFormatTagged, 0},
153+
{[]byte{1, 0, 0, 0, 0, 0, 0, 0}, GtidFormatClassic, 1},
154+
}
155+
156+
for _, tc := range testcases {
157+
format, uuidCount := decodeSid(tc.input)
158+
assert.Equal(t, tc.gtidFormat, format)
159+
assert.Equal(t, tc.uuidCount, uuidCount)
160+
}
161+
}
162+
163+
func TestPreviousGTIDEvent(t *testing.T) {
164+
testcases := []struct {
165+
input []byte
166+
GTIDSets string
167+
}{
168+
{
169+
[]byte{0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1},
170+
"",
171+
},
172+
{
173+
[]byte{0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x89, 0x6e, 0x78, 0x82, 0x18, 0xfe, 0x11, 0xef, 0xab, 0x88, 0x22, 0x22, 0x2d, 0x34, 0xd4, 0x11, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
174+
"896e7882-18fe-11ef-ab88-22222d34d411:1-3",
175+
},
176+
{
177+
[]byte{0x1, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x89, 0x6e, 0x78, 0x82, 0x18, 0xfe, 0x11, 0xef, 0xab, 0x88, 0x22, 0x22, 0x2d, 0x34, 0xd4, 0x11, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x89, 0x6e, 0x78, 0x82, 0x18, 0xfe, 0x11, 0xef, 0xab, 0x88, 0x22, 0x22, 0x2d, 0x34, 0xd4, 0x11, 0x8, 0x61, 0x61, 0x61, 0x61, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
178+
"896e7882-18fe-11ef-ab88-22222d34d411:1-4:aaaa:1",
179+
},
180+
{
181+
[]byte{0x1, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x89, 0x6e, 0x78, 0x82, 0x18, 0xfe, 0x11, 0xef, 0xab, 0x88, 0x22, 0x22, 0x2d, 0x34, 0xd4, 0x11, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x89, 0x6e, 0x78, 0x82, 0x18, 0xfe, 0x11, 0xef, 0xab, 0x88, 0x22, 0x22, 0x2d, 0x34, 0xd4, 0x11, 0x8, 0x61, 0x61, 0x61, 0x61, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x89, 0x6e, 0x78, 0x82, 0x18, 0xfe, 0x11, 0xef, 0xab, 0x88, 0x22, 0x22, 0x2d, 0x34, 0xd4, 0x11, 0x6, 0x61, 0x62, 0x63, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x89, 0x6e, 0x78, 0x82, 0x18, 0xfe, 0x11, 0xef, 0xab, 0x88, 0x22, 0x22, 0x2d, 0x34, 0xd4, 0x11, 0xa, 0x62, 0x62, 0x62, 0x62, 0x62, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x89, 0x6e, 0x78, 0x82, 0x18, 0xfe, 0x11, 0xef, 0xab, 0x88, 0x22, 0x22, 0x2d, 0x34, 0xd4, 0x11, 0xc, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x89, 0x6e, 0x78, 0x82, 0x18, 0xfe, 0x11, 0xef, 0xab, 0x88, 0x22, 0x22, 0x2d, 0x34, 0xd4, 0x11, 0x2, 0x78, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x89, 0x6e, 0x78, 0x82, 0x18, 0xfe, 0x11, 0xef, 0xab, 0x88, 0x22, 0x22, 0x2d, 0x34, 0xd4, 0x12, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
182+
"896e7882-18fe-11ef-ab88-22222d34d411:1-4:aaaa:1:abc:1-3:bbbbb:1:bbbbbb:1:x:1,896e7882-18fe-11ef-ab88-22222d34d412:1-2",
183+
},
184+
{
185+
[]byte{0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x2f, 0x20, 0xcc, 0xbc, 0x4c, 0x11, 0xef, 0xa1, 0xd0, 0x02, 0x42, 0xac, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x2f, 0x20, 0xcc, 0xbc, 0x4c, 0x11, 0xef, 0xa1, 0xd0, 0x02, 0x42, 0xac, 0x11, 0x00, 0x02, 0x06, 0x61, 0x61, 0x61, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x2f, 0x20, 0xcc, 0xbc, 0x4c, 0x11, 0xef, 0xa1, 0xd0, 0x02, 0x42, 0xac, 0x11, 0x00, 0x02, 0x28, 0x74, 0x61, 0x67, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x2f, 0x20, 0xcc, 0xbc, 0x4c, 0x11, 0xef, 0xa1, 0xd0, 0x02, 0x42, 0xac, 0x11, 0x00, 0x02, 0x40, 0x74, 0x61, 0x67, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
186+
"042f20cc-bc4c-11ef-a1d0-0242ac110002:1-7:aaa:1:tag45678901234567890:1:tag45678901234567890123456789012:1",
187+
},
188+
}
189+
190+
for _, tc := range testcases {
191+
e := PreviousGTIDsEvent{}
192+
err := e.Decode(tc.input)
193+
require.NoError(t, err)
194+
require.Equal(t, tc.GTIDSets, e.GTIDSets)
195+
}
196+
}

replication/json_binary.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"fmt"
55
"math"
66

7+
"github.com/go-mysql-org/go-mysql/utils"
78
"github.com/goccy/go-json"
89
"github.com/pingcap/errors"
9-
"github.com/siddontang/go/hack"
1010

1111
. "github.com/go-mysql-org/go-mysql/mysql"
1212
)
@@ -243,7 +243,7 @@ func (d *jsonBinaryDecoder) decodeObjectOrArray(data []byte, isSmall bool, isObj
243243
return nil
244244
}
245245

246-
keys[i] = hack.String(data[keyOffset : keyOffset+keyLength])
246+
keys[i] = utils.ByteSliceToString(data[keyOffset : keyOffset+keyLength])
247247
}
248248
}
249249

@@ -411,7 +411,7 @@ func (d *jsonBinaryDecoder) decodeString(data []byte) string {
411411

412412
data = data[n:]
413413

414-
v := hack.String(data[0:l])
414+
v := utils.ByteSliceToString(data[0:l])
415415
return v
416416
}
417417

@@ -439,7 +439,7 @@ func (d *jsonBinaryDecoder) decodeOpaque(data []byte) interface{} {
439439
case MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME, MYSQL_TYPE_TIMESTAMP:
440440
return d.decodeDateTime(data)
441441
default:
442-
return hack.String(data)
442+
return utils.ByteSliceToString(data)
443443
}
444444
}
445445

0 commit comments

Comments
 (0)