Skip to content

Commit a3d204b

Browse files
committed
Merge branch 'master' of https://github.com/RainJoe/go-mysql
2 parents 76c71d8 + ba716a8 commit a3d204b

File tree

7 files changed

+62
-36
lines changed

7 files changed

+62
-36
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
test:
66
strategy:
77
matrix:
8-
go: [ 1.19, 1.18, 1.17, 1.16 ]
8+
go: [ "1.20", "1.19", "1.18" ]
99
os: [ ubuntu-22.04, ubuntu-20.04 ]
1010
name: Tests Go ${{ matrix.go }} # This name is used in main branch protection rules
1111
runs-on: ${{ matrix.os }}
@@ -49,3 +49,23 @@ jobs:
4949
with:
5050
version: latest
5151
args: --timeout=3m
52+
53+
platforms:
54+
strategy:
55+
matrix:
56+
arch: [ "amd64", "arm64" ]
57+
os: [ "linux", "freebsd", "darwin" ]
58+
name: platforms
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Prepare for Go
62+
run: |
63+
sudo apt-get install -y make gcc
64+
- name: Install Go
65+
uses: actions/setup-go@v2
66+
with:
67+
go-version: "1.20"
68+
- name: Checkout code
69+
uses: actions/checkout@v1
70+
- name: Build on ${{ matrix.os }}/${{ matrix.arch }}
71+
run: GOARCH=${{ matrix.arch }} GOOS=${{ matrix.os }} go build ./...

client/auth.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ func (c *Conn) writeAuthHandshake() error {
202202
capability |= c.ccaps&CLIENT_FOUND_ROWS | c.ccaps&CLIENT_IGNORE_SPACE |
203203
c.ccaps&CLIENT_MULTI_STATEMENTS | c.ccaps&CLIENT_MULTI_RESULTS |
204204
c.ccaps&CLIENT_PS_MULTI_RESULTS | c.ccaps&CLIENT_CONNECT_ATTRS |
205-
c.ccaps&CLIENT_COMPRESS | c.ccaps&CLIENT_ZSTD_COMPRESSION_ALGORITHM
205+
c.ccaps&CLIENT_COMPRESS | c.ccaps&CLIENT_ZSTD_COMPRESSION_ALGORITHM |
206+
c.ccaps&CLIENT_LOCAL_FILES
206207

207208
// To enable TLS / SSL
208209
if c.tlsConfig != nil {

go.mod

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
module github.com/go-mysql-org/go-mysql
22

3-
go 1.16
3+
go 1.18
44

55
require (
66
github.com/BurntSushi/toml v0.3.1
7-
github.com/DataDog/zstd v1.5.2
87
github.com/Masterminds/semver v1.5.0
98
github.com/go-sql-driver/mysql v1.6.0
109
github.com/google/uuid v1.3.0
1110
github.com/jmoiron/sqlx v1.3.3
11+
github.com/klauspost/compress v1.16.6
1212
github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8
1313
github.com/pingcap/errors v0.11.5-0.20210425183316-da1aaba5fb63
1414
github.com/pingcap/tidb/parser v0.0.0-20221126021158-6b02a5d8ba7d
15-
github.com/pkg/errors v0.9.1 // indirect
1615
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24
1716
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726
1817
github.com/siddontang/go-log v0.0.0-20180807004314-8d05993dda07
1918
github.com/stretchr/testify v1.8.0
20-
golang.org/x/tools v0.0.0-20201125231158-b5590deeca9b // indirect
19+
)
20+
21+
require (
22+
github.com/davecgh/go-spew v1.1.1 // indirect
23+
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7 // indirect
24+
github.com/pkg/errors v0.9.1 // indirect
25+
github.com/pmezard/go-difflib v1.0.0 // indirect
26+
github.com/stretchr/objx v0.4.0 // indirect
27+
go.uber.org/atomic v1.7.0 // indirect
28+
go.uber.org/multierr v1.6.0 // indirect
29+
go.uber.org/zap v1.18.1 // indirect
30+
golang.org/x/text v0.3.8 // indirect
31+
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
32+
gopkg.in/yaml.v3 v3.0.1 // indirect
2133
)

go.sum

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
22
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
3-
github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=
4-
github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
53
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
64
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
75
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
@@ -19,6 +17,8 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
1917
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
2018
github.com/jmoiron/sqlx v1.3.3 h1:j82X0bf7oQ27XeqxicSZsTU5suPwKElg3oyxNn43iTk=
2119
github.com/jmoiron/sqlx v1.3.3/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ=
20+
github.com/klauspost/compress v1.16.6 h1:91SKEy4K37vkp255cJ8QesJhjyRO0hn9i9G0GoUwLsk=
21+
github.com/klauspost/compress v1.16.6/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
2222
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
2323
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
2424
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -58,7 +58,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
5858
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
5959
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
6060
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
61-
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
6261
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
6362
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
6463
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
@@ -72,35 +71,23 @@ go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
7271
go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4=
7372
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
7473
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
75-
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
76-
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
7774
golang.org/x/exp v0.0.0-20181106170214-d68db9428509/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
7875
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
7976
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
80-
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
8177
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
82-
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
8378
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
84-
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
8579
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
86-
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
8780
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
88-
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
89-
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
9081
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
91-
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
92-
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
9382
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
83+
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
84+
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
9485
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
9586
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
9687
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
9788
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
98-
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
99-
golang.org/x/tools v0.0.0-20201125231158-b5590deeca9b h1:Lq5JUTFhiybGVf28jB6QRpqd13/JPOaCnET17PVzYJE=
100-
golang.org/x/tools v0.0.0-20201125231158-b5590deeca9b/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
89+
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
10190
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
102-
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
103-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
10491
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
10592
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
10693
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

mysql/field.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,42 +49,42 @@ func (f *Field) Parse(p FieldData) (err error) {
4949
//skip catelog, always def
5050
n, err = SkipLengthEncodedString(p)
5151
if err != nil {
52-
return
52+
return err
5353
}
5454
pos += n
5555

5656
//schema
5757
f.Schema, _, n, err = LengthEncodedString(p[pos:])
5858
if err != nil {
59-
return
59+
return err
6060
}
6161
pos += n
6262

6363
//table
6464
f.Table, _, n, err = LengthEncodedString(p[pos:])
6565
if err != nil {
66-
return
66+
return err
6767
}
6868
pos += n
6969

7070
//org_table
7171
f.OrgTable, _, n, err = LengthEncodedString(p[pos:])
7272
if err != nil {
73-
return
73+
return err
7474
}
7575
pos += n
7676

7777
//name
7878
f.Name, _, n, err = LengthEncodedString(p[pos:])
7979
if err != nil {
80-
return
80+
return err
8181
}
8282
pos += n
8383

8484
//org_name
8585
f.OrgName, _, n, err = LengthEncodedString(p[pos:])
8686
if err != nil {
87-
return
87+
return err
8888
}
8989
pos += n
9090

@@ -123,7 +123,7 @@ func (f *Field) Parse(p FieldData) (err error) {
123123

124124
if pos+int(f.DefaultValueLength) > len(p) {
125125
err = ErrMalformPacket
126-
return
126+
return err
127127
}
128128

129129
//default value string[$len]

packet/conn.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313
"net"
1414
"sync"
1515

16-
"github.com/DataDog/zstd"
1716
. "github.com/go-mysql-org/go-mysql/mysql"
1817
"github.com/go-mysql-org/go-mysql/utils"
18+
"github.com/klauspost/compress/zstd"
1919
"github.com/pingcap/errors"
2020
)
2121

@@ -125,7 +125,7 @@ func (c *Conn) ReadPacketReuseMem(dst []byte) ([]byte, error) {
125125
case MYSQL_COMPRESS_ZLIB:
126126
c.compressedReader, err = zlib.NewReader(c.reader)
127127
case MYSQL_COMPRESS_ZSTD:
128-
c.compressedReader = zstd.NewReader(c.reader)
128+
c.compressedReader, err = zstd.NewReader(c.reader)
129129
}
130130
if err != nil {
131131
return nil, err
@@ -290,7 +290,7 @@ func (c *Conn) writeCompressed(data []byte) (n int, err error) {
290290
case MYSQL_COMPRESS_ZLIB:
291291
w, err = zlib.NewWriterLevel(&payload, zlib.HuffmanOnly)
292292
case MYSQL_COMPRESS_ZSTD:
293-
w = zstd.NewWriter(&payload)
293+
w, err = zstd.NewWriter(&payload)
294294
}
295295
if err != nil {
296296
return 0, err

replication/transaction_payload_event.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
"io"
88

9-
"github.com/DataDog/zstd"
9+
"github.com/klauspost/compress/zstd"
1010

1111
. "github.com/go-mysql-org/go-mysql/mysql"
1212
)
@@ -104,7 +104,13 @@ func (e *TransactionPayloadEvent) decodePayload() error {
104104
e.CompressionType, e.compressionType())
105105
}
106106

107-
payloadUncompressed, err := zstd.Decompress(nil, e.Payload)
107+
var decoder, err = zstd.NewReader(nil, zstd.WithDecoderConcurrency(0))
108+
if err != nil {
109+
return err
110+
}
111+
defer decoder.Close()
112+
113+
payloadUncompressed, err := decoder.DecodeAll(e.Payload, nil)
108114
if err != nil {
109115
return err
110116
}

0 commit comments

Comments
 (0)