Skip to content

Commit 89bc530

Browse files
committed
fix parsing prepare response
https://dev.mysql.com/doc/dev/mysql-server/9.3.0/page_protocol_com_stmt_prepare.html warnings is optional from server, & is preceded by a reserved byte
1 parent 558ed11 commit 89bc530

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

client/stmt.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,14 @@ func (c *Conn) Prepare(query string) (*Stmt, error) {
265265
s.params = int(binary.LittleEndian.Uint16(data[pos:]))
266266
pos += 2
267267

268-
// warnings
269-
s.warnings = int(binary.LittleEndian.Uint16(data[pos:]))
270-
// pos += 2
268+
// reserved
269+
pos += 1
270+
271+
if len(data) >= 12 {
272+
// warnings
273+
s.warnings = int(binary.LittleEndian.Uint16(data[pos:]))
274+
pos += 2
275+
}
271276

272277
if s.params > 0 {
273278
if err := s.conn.readUntilEOF(); err != nil {

0 commit comments

Comments
 (0)