Skip to content

Commit 10de78f

Browse files
committed
address comments
1 parent 670fee7 commit 10de78f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

server/conn_stmt.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,8 @@ func parseStmtArgs(args []interface{}, boundParams [][]byte, nullBitmap, paramTy
249249
args[i] = nil
250250
continue
251251
}
252-
if boundParamLength := len(boundParams[i]); boundParamLength != 0 {
253-
// Trim out the last ending byte.
254-
args[i] = boundParams[i][:boundParamLength-1]
252+
if boundParams[i] != nil {
253+
args[i] = boundParams[i]
255254
continue
256255
}
257256

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

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

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

server/driver_tidb.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ func (ts *TiDBStatement) AppendParam(paramID int, data []byte) error {
8585
if paramID >= len(ts.boundParams) {
8686
return mysql.NewErr(mysql.ErrWrongArguments, "stmt_send_longdata")
8787
}
88-
ts.boundParams[paramID] = append(ts.boundParams[paramID], data...)
88+
// If len(data) is 0, append an empty byte slice to the end to distinguish no data and no parameter.
89+
if len(data) == 0 {
90+
ts.boundParams[paramID] = []byte{}
91+
} else {
92+
ts.boundParams[paramID] = append(ts.boundParams[paramID], data...)
93+
}
8994
return nil
9095
}
9196

0 commit comments

Comments
 (0)