diff --git a/packets.go b/packets.go index e14dc95cf..ec62bbe38 100644 --- a/packets.go +++ b/packets.go @@ -131,7 +131,9 @@ func (mc *mysqlConn) writePacket(data []byte) error { } return err } - if n != size+4 { + if n != 4+size { + // io.Writer(b) must return a non-nil error if it cannot write len(b) bytes. + // The io.ErrShortWrite error is used to indicate that this rule has not been followed. mc.cleanup() return io.ErrShortWrite } @@ -142,7 +144,6 @@ func (mc *mysqlConn) writePacket(data []byte) error { } pktLen -= size data = data[size:] - continue } }