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

pkg/param: add correct fsp for duration #48564

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion pkg/param/binary_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func ExecArgs(typectx types.Context, binaryParams []BinaryParam) (params []expre
continue

case mysql.TypeDuration:
fsp := 0
switch len(binaryParams[i].Val) {
case 0:
tmp = "0"
Expand All @@ -155,13 +156,14 @@ func ExecArgs(typectx types.Context, binaryParams []BinaryParam) (params []expre
return
}
_, tmp = binaryDurationWithMS(1, binaryParams[i].Val, isNegative)
fsp = types.MaxFsp
default:
err = mysql.ErrMalformPacket
return
}
// TODO: generate the duration datum directly
var dur types.Duration
dur, _, err = types.ParseDuration(typectx, tmp.(string), types.MaxFsp)
dur, _, err = types.ParseDuration(typectx, tmp.(string), fsp)
err = typectx.HandleTruncate(err)
if err != nil {
return
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/conn_stmt_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func TestParseExecArgs(t *testing.T) {
},
nil,
types.ErrTruncatedWrongVal,
types.Duration{Duration: types.MinTime, Fsp: types.MaxFsp},
types.Duration{Duration: types.MinTime, Fsp: 0},
},
{
args{
Expand All @@ -226,7 +226,7 @@ func TestParseExecArgs(t *testing.T) {
},
nil,
nil,
types.Duration{Duration: time.Duration(0), Fsp: types.MaxFsp},
types.Duration{Duration: time.Duration(0), Fsp: 0},
},
// For error test
{
Expand Down