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

server: fix ComStmtSendLongData when data length is 0 #7485

Merged
merged 3 commits into from
Aug 27, 2018
Merged
Changes from 1 commit
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
8 changes: 5 additions & 3 deletions server/conn_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ func parseStmtArgs(args []interface{}, boundParams [][]byte, nullBitmap, paramTy
args[i] = nil
continue
}
if boundParams[i] != nil {
args[i] = boundParams[i]
if boundParamLength := len(boundParams[i]); boundParamLength != 0 {
// Trim out the last ending byte.
args[i] = boundParams[i][:boundParamLength-1]
continue
}

Expand Down Expand Up @@ -509,7 +510,8 @@ func (cc *clientConn) handleStmtSendLongData(data []byte) (err error) {
}

paramID := int(binary.LittleEndian.Uint16(data[4:6]))
return stmt.AppendParam(paramID, data[6:])
// Append an extra 0 to the end to distinguish no data and no parameter.
return stmt.AppendParam(paramID, append(data[6:], 0))
}

func (cc *clientConn) handleStmtReset(data []byte) (err error) {
Expand Down