Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a rare bug in Conn.readResultStreaming #573

Merged
merged 1 commit into from
Apr 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion client/resp.go
Original file line number Diff line number Diff line change
@@ -242,7 +242,24 @@ func (c *Conn) readResultStreaming(binary bool, result *Result, perRowCb SelectP
}

if firstPkgBuf[0] == OK_HEADER {
return ErrMalformPacket // Streaming allowed only for SELECT queries
// https://dev.mysql.com/doc/internals/en/com-query-response.html
// 14.6.4.1 COM_QUERY Response
// If the number of columns in the resultset is 0, this is a OK_Packet.

okResult, err := c.handleOKPacket(firstPkgBuf)
if err != nil {
return errors.Trace(err)
}

result.Status = okResult.Status
result.AffectedRows = okResult.AffectedRows
result.InsertId = okResult.InsertId
if result.Resultset == nil {
result.Resultset = NewResultset(0)
} else {
result.Reset(0)
}
return nil
} else if firstPkgBuf[0] == ERR_HEADER {
return c.handleErrorPacket(append([]byte{}, firstPkgBuf...))
} else if firstPkgBuf[0] == LocalInFile_HEADER {