Skip to content

Commit 577c6ab

Browse files
committed
combine isEOFPacket, comment on why 0xffffff
1 parent a76f228 commit 577c6ab

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

client/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ func (c *Conn) FieldList(table string, wildcard string) ([]*mysql.Field, error)
466466
}
467467

468468
// EOF Packet
469-
if data[0] == mysql.EOF_HEADER && len(data) <= 0xffffff {
469+
if c.isEOFPacket(data) {
470470
return fs, nil
471471
}
472472

client/resp.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ import (
1414
"github.com/go-mysql-org/go-mysql/utils"
1515
)
1616

17-
// this should only be called when CLIENT_DEPRECATE_EOF not enabled
17+
// 0xffffff due to https://dev.mysql.com/worklog/task/?id=7766
18+
// "Server will never send OK packet longer than 16777216 bytes thus limiting
19+
// size of OK packet to be 16777215 bytes"
1820
func (c *Conn) isEOFPacket(data []byte) bool {
19-
return data[0] == mysql.EOF_HEADER && len(data) <= 5
21+
return data[0] == mysql.EOF_HEADER && len(data) <= 0xffffff
2022
}
2123

2224
func (c *Conn) handleOKPacket(data []byte) (*mysql.Result, error) {
@@ -378,7 +380,7 @@ func (c *Conn) readResultRows(result *mysql.Result, isBinary bool) (err error) {
378380
}
379381
data = result.RawPkg[rawPkgLen:]
380382

381-
if data[0] == mysql.EOF_HEADER && len(data) <= 0xffffff {
383+
if c.isEOFPacket(data) {
382384
if c.capability&mysql.CLIENT_DEPRECATE_EOF != 0 {
383385
// Treat like OK
384386
affectedRows, _, n := mysql.LengthEncodedInt(data[1:])
@@ -431,7 +433,7 @@ func (c *Conn) readResultRowsStreaming(result *mysql.Result, isBinary bool, perR
431433
return err
432434
}
433435

434-
if data[0] == mysql.EOF_HEADER && len(data) <= 0xffffff {
436+
if c.isEOFPacket(data) {
435437
if c.capability&mysql.CLIENT_DEPRECATE_EOF != 0 {
436438
// Treat like OK
437439
affectedRows, _, n := mysql.LengthEncodedInt(data[1:])

0 commit comments

Comments
 (0)