Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jackysp committed Aug 27, 2018
1 parent 670fee7 commit 10de78f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 3 additions & 5 deletions server/conn_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,8 @@ func parseStmtArgs(args []interface{}, boundParams [][]byte, nullBitmap, paramTy
args[i] = nil
continue
}
if boundParamLength := len(boundParams[i]); boundParamLength != 0 {
// Trim out the last ending byte.
args[i] = boundParams[i][:boundParamLength-1]
if boundParams[i] != nil {
args[i] = boundParams[i]
continue
}

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

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

func (cc *clientConn) handleStmtReset(data []byte) (err error) {
Expand Down
7 changes: 6 additions & 1 deletion server/driver_tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ func (ts *TiDBStatement) AppendParam(paramID int, data []byte) error {
if paramID >= len(ts.boundParams) {
return mysql.NewErr(mysql.ErrWrongArguments, "stmt_send_longdata")
}
ts.boundParams[paramID] = append(ts.boundParams[paramID], data...)
// If len(data) is 0, append an empty byte slice to the end to distinguish no data and no parameter.
if len(data) == 0 {
ts.boundParams[paramID] = []byte{}
} else {
ts.boundParams[paramID] = append(ts.boundParams[paramID], data...)
}
return nil
}

Expand Down

0 comments on commit 10de78f

Please sign in to comment.