Skip to content

Commit 382f349

Browse files
committed
Remove one more place that does header calculations
1 parent 276fa30 commit 382f349

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

packets.go

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -748,26 +748,13 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
748748
if len(args) == 0 {
749749
const pktLen = 1 + 4 + 1 + 4
750750
data = mc.buf.takeBuffer(4 + pktLen)
751-
if data == nil {
752-
// can not take the buffer. Something must be wrong with the connection
753-
errLog.Print("Busy buffer")
754-
return driver.ErrBadConn
755-
}
756-
757-
// packet header [4 bytes]
758-
data[0] = byte(pktLen)
759-
data[1] = byte(pktLen >> 8)
760-
data[2] = byte(pktLen >> 16)
761-
data[3] = 0x00 // new command, sequence id is always 0
762751
} else {
763752
data = mc.buf.takeCompleteBuffer()
764-
if data == nil {
765-
// can not take the buffer. Something must be wrong with the connection
766-
errLog.Print("Busy buffer")
767-
return driver.ErrBadConn
768-
}
769-
770-
// header (bytes 0-3) is added after we know the packet size
753+
}
754+
if data == nil {
755+
// can not take the buffer. Something must be wrong with the connection
756+
errLog.Print("Busy buffer")
757+
return driver.ErrBadConn
771758
}
772759

773760
// command [1 byte]

0 commit comments

Comments
 (0)