Skip to content

Commit 876af07

Browse files
committed
fix todo
1 parent 679cc53 commit 876af07

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

connection.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type mysqlConn struct {
3737
sequence uint8
3838
compressionSequence uint8
3939
parseTime bool
40+
compress bool
4041

4142
// for context support (Go 1.8+)
4243
watching bool
@@ -64,7 +65,7 @@ func (mc *mysqlConn) syncSeqNo() {
6465
// This is done in `net_flush()` in MySQL and MariaDB.
6566
// https://github.com/mariadb-corporation/mariadb-connector-c/blob/8228164f850b12353da24df1b93a1e53cc5e85e9/libmariadb/ma_net.c#L170-L171
6667
// https://github.com/mysql/mysql-server/blob/824e2b4064053f7daf17d7f3f84b7a3ed92e5fb4/sql-common/net_serv.cc#L293
67-
if mc.cfg.compress {
68+
if mc.compress {
6869
mc.sequence = mc.compressionSequence
6970
}
7071
}

connector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
168168
return nil, err
169169
}
170170

171-
if mc.cfg.compress {
171+
if mc.compress {
172172
mc.packetReader = newCompressedReader(&mc.buf, mc)
173173
mc.packetWriter = newCompressedWriter(mc.packetWriter, mc)
174174
}

packets.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,6 @@ func (mc *mysqlConn) readHandshakePacket() (data []byte, plugin string, err erro
215215
return nil, "", ErrNoTLS
216216
}
217217
}
218-
if mc.flags&clientCompress == 0 {
219-
mc.cfg.compress = false
220-
}
221218

222219
pos += 2
223220

@@ -281,8 +278,9 @@ func (mc *mysqlConn) writeHandshakeResponsePacket(authResp []byte, plugin string
281278
if mc.cfg.ClientFoundRows {
282279
clientFlags |= clientFoundRows
283280
}
284-
if mc.cfg.compress {
281+
if mc.cfg.compress && mc.flags&clientCompress == clientCompress {
285282
clientFlags |= clientCompress
283+
mc.compress = true
286284
}
287285
// To enable TLS / SSL
288286
if mc.cfg.TLS != nil {

0 commit comments

Comments
 (0)