diff --git a/server/driver_tidb.go b/server/driver_tidb.go index 016561b2b18cd..7ad9a5b52d681 100644 --- a/server/driver_tidb.go +++ b/server/driver_tidb.go @@ -83,7 +83,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 }