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

types: remove param explicitTz from types.ParseTime #48574

Merged
merged 2 commits into from
Nov 15, 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
2 changes: 1 addition & 1 deletion br/pkg/task/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ func ParseTSString(ts string, tzCheck bool) (uint64, error) {
return 0, errors.Errorf("must set timezone when using datetime format ts, e.g. '2018-05-11 01:42:23+0800'")
}
}
t, err := types.ParseTime(sc.TypeCtx(), ts, mysql.TypeTimestamp, types.MaxFsp, nil)
t, err := types.ParseTime(sc.TypeCtx(), ts, mysql.TypeTimestamp, types.MaxFsp)
if err != nil {
return 0, errors.Trace(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ func convertTimestampDefaultValToUTC(ctx sessionctx.Context, defaultVal interfac
}
if vv, ok := defaultVal.(string); ok {
if vv != types.ZeroDatetimeStr && !strings.EqualFold(vv, ast.CurrentTimestamp) {
t, err := types.ParseTime(ctx.GetSessionVars().StmtCtx.TypeCtx(), vv, col.GetType(), col.GetDecimal(), nil)
t, err := types.ParseTime(ctx.GetSessionVars().StmtCtx.TypeCtx(), vv, col.GetType(), col.GetDecimal())
if err != nil {
return defaultVal, errors.Trace(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/brie.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (bq *brieQueue) clearTask(sc *stmtctx.StatementContext) {

func (b *executorBuilder) parseTSString(ts string) (uint64, error) {
sc := stmtctx.NewStmtCtxWithTimeZone(b.ctx.GetSessionVars().Location())
t, err := types.ParseTime(sc.TypeCtx(), ts, mysql.TypeTimestamp, types.MaxFsp, nil)
t, err := types.ParseTime(sc.TypeCtx(), ts, mysql.TypeTimestamp, types.MaxFsp)
if err != nil {
return 0, err
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/executor/inspection_result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func TestInspectionResult(t *testing.T) {
}

func parseTime(t *testing.T, se session.Session, str string) types.Time {
time, err := types.ParseTime(se.GetSessionVars().StmtCtx.TypeCtx(), str, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(se.GetSessionVars().StmtCtx.TypeCtx(), str, mysql.TypeDatetime, types.MaxFsp)
require.NoError(t, err)
return time
}
Expand Down Expand Up @@ -338,7 +338,7 @@ func TestThresholdCheckInspection2(t *testing.T) {
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
datetime := func(s string) types.Time {
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp)
require.NoError(t, err)
return time
}
Expand Down Expand Up @@ -421,7 +421,7 @@ func TestThresholdCheckInspection3(t *testing.T) {
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
datetime := func(s string) types.Time {
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp)
require.NoError(t, err)
return time
}
Expand Down Expand Up @@ -628,7 +628,7 @@ func TestNodeLoadInspection(t *testing.T) {
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
datetime := func(s string) types.Time {
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp)
require.NoError(t, err)
return time
}
Expand Down Expand Up @@ -704,7 +704,7 @@ func TestConfigCheckOfStorageBlockCacheSize(t *testing.T) {
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
datetime := func(s string) types.Time {
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp)
require.NoError(t, err)
return time
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/inspection_summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestInspectionSummary(t *testing.T) {
defer func() { require.NoError(t, failpoint.Disable(fpName)) }()

datetime := func(s string) types.Time {
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp)
require.NoError(t, err)
return time
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestCalibrateResource(t *testing.T) {
}()

datetime := func(s string) types.Time {
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp)
require.NoError(t, err)
return time
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/expression/builtin_cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ func (b *builtinCastStringAsTimeSig) evalTime(ctx sessionctx.Context, row chunk.
return res, isNull, err
}
sc := ctx.GetSessionVars().StmtCtx
res, err = types.ParseTime(sc.TypeCtx(), val, b.tp.GetType(), b.tp.GetDecimal(), nil)
res, err = types.ParseTime(sc.TypeCtx(), val, b.tp.GetType(), b.tp.GetDecimal())
if err != nil {
return types.ZeroTime, true, handleInvalidTimeError(ctx, err)
}
Expand Down Expand Up @@ -1960,7 +1960,7 @@ func (b *builtinCastJSONAsTimeSig) evalTime(ctx sessionctx.Context, row chunk.Ro
return res, false, err
}
sc := ctx.GetSessionVars().StmtCtx
res, err = types.ParseTime(sc.TypeCtx(), s, b.tp.GetType(), b.tp.GetDecimal(), nil)
res, err = types.ParseTime(sc.TypeCtx(), s, b.tp.GetType(), b.tp.GetDecimal())
if err != nil {
return types.ZeroTime, true, handleInvalidTimeError(ctx, err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/expression/builtin_cast_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ func (b *builtinCastJSONAsTimeSig) vecEvalTime(ctx sessionctx.Context, input *ch
if err != nil {
return err
}
tm, err := types.ParseTime(stmtCtx.TypeCtx(), s, b.tp.GetType(), fsp, nil)
tm, err := types.ParseTime(stmtCtx.TypeCtx(), s, b.tp.GetType(), fsp)
if err != nil {
if err = handleInvalidTimeError(ctx, err); err != nil {
return err
Expand Down Expand Up @@ -1770,7 +1770,7 @@ func (b *builtinCastStringAsTimeSig) vecEvalTime(ctx sessionctx.Context, input *
if result.IsNull(i) {
continue
}
tm, err := types.ParseTime(stmtCtx.TypeCtx(), buf.GetString(i), b.tp.GetType(), fsp, nil)
tm, err := types.ParseTime(stmtCtx.TypeCtx(), buf.GetString(i), b.tp.GetType(), fsp)
if err != nil {
if errors.Is(err, strconv.ErrSyntax) || errors.Is(err, strconv.ErrRange) {
err = types.ErrIncorrectDatetimeValue.GenWithStackByArgs(buf.GetString(i))
Expand Down
14 changes: 7 additions & 7 deletions pkg/expression/builtin_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2770,7 +2770,7 @@ func (du *baseDateArithmetical) getDateFromString(ctx sessionctx.Context, args [
}

sc := ctx.GetSessionVars().StmtCtx
date, err := types.ParseTime(sc.TypeCtx(), dateStr, dateTp, types.MaxFsp, nil)
date, err := types.ParseTime(sc.TypeCtx(), dateStr, dateTp, types.MaxFsp)
if err != nil {
err = handleInvalidTimeError(ctx, err)
if err != nil {
Expand Down Expand Up @@ -3180,7 +3180,7 @@ func (du *baseDateArithmetical) vecGetDateFromString(b *baseBuiltinFunc, ctx ses
dateTp = mysql.TypeDatetime
}

date, err := types.ParseTime(sc.TypeCtx(), dateStr, dateTp, types.MaxFsp, nil)
date, err := types.ParseTime(sc.TypeCtx(), dateStr, dateTp, types.MaxFsp)
if err != nil {
err = handleInvalidTimeError(ctx, err)
if err != nil {
Expand Down Expand Up @@ -4349,7 +4349,7 @@ func (b *builtinTimestamp1ArgSig) evalTime(ctx sessionctx.Context, row chunk.Row
if b.isFloat {
tm, err = types.ParseTimeFromFloatString(sc.TypeCtx(), s, mysql.TypeDatetime, types.GetFsp(s))
} else {
tm, err = types.ParseTime(sc.TypeCtx(), s, mysql.TypeDatetime, types.GetFsp(s), nil)
tm, err = types.ParseTime(sc.TypeCtx(), s, mysql.TypeDatetime, types.GetFsp(s))
}
if err != nil {
return types.ZeroTime, true, handleInvalidTimeError(ctx, err)
Expand Down Expand Up @@ -4381,7 +4381,7 @@ func (b *builtinTimestamp2ArgsSig) evalTime(ctx sessionctx.Context, row chunk.Ro
if b.isFloat {
tm, err = types.ParseTimeFromFloatString(sc.TypeCtx(), arg0, mysql.TypeDatetime, types.GetFsp(arg0))
} else {
tm, err = types.ParseTime(sc.TypeCtx(), arg0, mysql.TypeDatetime, types.GetFsp(arg0), nil)
tm, err = types.ParseTime(sc.TypeCtx(), arg0, mysql.TypeDatetime, types.GetFsp(arg0))
}
if err != nil {
return types.ZeroTime, true, handleInvalidTimeError(ctx, err)
Expand Down Expand Up @@ -4432,7 +4432,7 @@ func (c *timestampLiteralFunctionClass) getFunction(ctx sessionctx.Context, args
if !timestampPattern.MatchString(str) {
return nil, types.ErrWrongValue.GenWithStackByArgs(types.DateTimeStr, str)
}
tm, err := types.ParseTime(ctx.GetSessionVars().StmtCtx.TypeCtx(), str, mysql.TypeDatetime, types.GetFsp(str), nil)
tm, err := types.ParseTime(ctx.GetSessionVars().StmtCtx.TypeCtx(), str, mysql.TypeDatetime, types.GetFsp(str))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -4540,7 +4540,7 @@ func isDuration(str string) bool {

// strDatetimeAddDuration adds duration to datetime string, returns a string value.
func strDatetimeAddDuration(sc *stmtctx.StatementContext, d string, arg1 types.Duration) (result string, isNull bool, err error) {
arg0, err := types.ParseTime(sc.TypeCtx(), d, mysql.TypeDatetime, types.MaxFsp, nil)
arg0, err := types.ParseTime(sc.TypeCtx(), d, mysql.TypeDatetime, types.MaxFsp)
if err != nil {
// Return a warning regardless of the sql_mode, this is compatible with MySQL.
sc.AppendWarning(err)
Expand Down Expand Up @@ -4577,7 +4577,7 @@ func strDurationAddDuration(sc *stmtctx.StatementContext, d string, arg1 types.D

// strDatetimeSubDuration subtracts duration from datetime string, returns a string value.
func strDatetimeSubDuration(sc *stmtctx.StatementContext, d string, arg1 types.Duration) (result string, isNull bool, err error) {
arg0, err := types.ParseTime(sc.TypeCtx(), d, mysql.TypeDatetime, types.MaxFsp, nil)
arg0, err := types.ParseTime(sc.TypeCtx(), d, mysql.TypeDatetime, types.MaxFsp)
if err != nil {
// Return a warning regardless of the sql_mode, this is compatible with MySQL.
sc.AppendWarning(err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/expression/builtin_time_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2652,7 +2652,7 @@ func (b *builtinTimestamp1ArgSig) vecEvalTime(ctx sessionctx.Context, input *chu
if b.isFloat {
tm, err = types.ParseTimeFromFloatString(sc.TypeCtx(), s, mysql.TypeDatetime, types.GetFsp(s))
} else {
tm, err = types.ParseTime(sc.TypeCtx(), s, mysql.TypeDatetime, types.GetFsp(s), nil)
tm, err = types.ParseTime(sc.TypeCtx(), s, mysql.TypeDatetime, types.GetFsp(s))
}
if err != nil {
if err = handleInvalidTimeError(ctx, err); err != nil {
Expand Down Expand Up @@ -2705,7 +2705,7 @@ func (b *builtinTimestamp2ArgsSig) vecEvalTime(ctx sessionctx.Context, input *ch
if b.isFloat {
tm, err = types.ParseTimeFromFloatString(sc.TypeCtx(), arg0, mysql.TypeDatetime, types.GetFsp(arg0))
} else {
tm, err = types.ParseTime(sc.TypeCtx(), arg0, mysql.TypeDatetime, types.GetFsp(arg0), nil)
tm, err = types.ParseTime(sc.TypeCtx(), arg0, mysql.TypeDatetime, types.GetFsp(arg0))
}
if err != nil {
if err = handleInvalidTimeError(ctx, err); err != nil {
Expand Down
17 changes: 10 additions & 7 deletions pkg/expression/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ func getTimeCurrentTimeStamp(ctx sessionctx.Context, tp byte, fsp int) (t types.
// GetTimeValue gets the time value with type tp.
func GetTimeValue(ctx sessionctx.Context, v interface{}, tp byte, fsp int, explicitTz *time.Location) (d types.Datum, err error) {
var value types.Time
tc := ctx.GetSessionVars().StmtCtx.TypeCtx()
if explicitTz != nil {
tc = tc.WithLocation(explicitTz)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tc.WithLocation(explicitTz) will create a new context with old one not modified. So there is no data race any more

}

sc := ctx.GetSessionVars().StmtCtx
switch x := v.(type) {
case string:
lowerX := strings.ToLower(x)
Expand All @@ -99,23 +102,23 @@ func GetTimeValue(ctx sessionctx.Context, v interface{}, tp byte, fsp int, expli
return d, err
}
} else if lowerX == types.ZeroDatetimeStr {
value, err = types.ParseTimeFromNum(sc.TypeCtx(), 0, tp, fsp)
value, err = types.ParseTimeFromNum(tc, 0, tp, fsp)
terror.Log(err)
} else {
value, err = types.ParseTime(sc.TypeCtx(), x, tp, fsp, explicitTz)
value, err = types.ParseTime(tc, x, tp, fsp)
if err != nil {
return d, err
}
}
case *driver.ValueExpr:
switch x.Kind() {
case types.KindString:
value, err = types.ParseTime(sc.TypeCtx(), x.GetString(), tp, fsp, nil)
value, err = types.ParseTime(tc, x.GetString(), tp, fsp)
if err != nil {
return d, err
}
case types.KindInt64:
value, err = types.ParseTimeFromNum(sc.TypeCtx(), x.GetInt64(), tp, fsp)
value, err = types.ParseTimeFromNum(tc, x.GetInt64(), tp, fsp)
if err != nil {
return d, err
}
Expand All @@ -137,12 +140,12 @@ func GetTimeValue(ctx sessionctx.Context, v interface{}, tp byte, fsp int, expli
return d, err
}
ft := types.NewFieldType(mysql.TypeLonglong)
xval, err := v.ConvertTo(ctx.GetSessionVars().StmtCtx.TypeCtx(), ft)
xval, err := v.ConvertTo(tc, ft)
if err != nil {
return d, err
}

value, err = types.ParseTimeFromNum(sc.TypeCtx(), xval.GetInt64(), tp, fsp)
value, err = types.ParseTimeFromNum(tc, xval.GetInt64(), tp, fsp)
if err != nil {
return d, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/handler/optimizor/statistics_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (sh StatsHistoryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request
}

se.GetSessionVars().StmtCtx.SetTimeZone(time.Local)
t, err := types.ParseTime(se.GetSessionVars().StmtCtx.TypeCtx(), params[handler.Snapshot], mysql.TypeTimestamp, 6, nil)
t, err := types.ParseTime(se.GetSessionVars().StmtCtx.TypeCtx(), params[handler.Snapshot], mysql.TypeTimestamp, 6)
if err != nil {
handler.WriteError(w, err)
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/internal/column/column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func TestDumpTextValue(t *testing.T) {
require.NoError(t, err)
typeCtx := types.NewContext(types.StrictFlags.WithIgnoreZeroInDate(true), losAngelesTz, func(err error) {})

time, err := types.ParseTime(typeCtx, "2017-01-05 23:59:59.575601", mysql.TypeDatetime, 0, nil)
time, err := types.ParseTime(typeCtx, "2017-01-05 23:59:59.575601", mysql.TypeDatetime, 0)
require.NoError(t, err)
d.SetMysqlTime(time)
columns[0].Type = mysql.TypeDatetime
Expand Down
4 changes: 2 additions & 2 deletions pkg/sessionctx/variable/varsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ func parseTSFromNumberOrTime(s *SessionVars, sVal string) (uint64, error) {
return tso, nil
}

t, err := types.ParseTime(s.StmtCtx.TypeCtx(), sVal, mysql.TypeTimestamp, types.MaxFsp, nil)
t, err := types.ParseTime(s.StmtCtx.TypeCtx(), sVal, mysql.TypeTimestamp, types.MaxFsp)
if err != nil {
return 0, err
}
Expand All @@ -456,7 +456,7 @@ func setTxnReadTS(s *SessionVars, sVal string) error {
return nil
}

t, err := types.ParseTime(s.StmtCtx.TypeCtx(), sVal, mysql.TypeTimestamp, types.MaxFsp, nil)
t, err := types.ParseTime(s.StmtCtx.TypeCtx(), sVal, mysql.TypeTimestamp, types.MaxFsp)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func StrToUint(ctx Context, str string, isFuncCast bool) (uint64, error) {

// StrToDateTime converts str to MySQL DateTime.
func StrToDateTime(ctx Context, str string, fsp int) (Time, error) {
return ParseTime(ctx, str, mysql.TypeDatetime, fsp, nil)
return ParseTime(ctx, str, mysql.TypeDatetime, fsp)
}

// StrToDuration converts str to Duration. It returns Duration in normal case,
Expand Down
6 changes: 3 additions & 3 deletions pkg/types/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ func TestConvertType(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "10:11:12.1", vv.(Duration).String())
typeCtx := DefaultStmtNoWarningContext
vd, err := ParseTime(typeCtx, "2010-10-10 10:11:11.12345", mysql.TypeDatetime, 2, nil)
vd, err := ParseTime(typeCtx, "2010-10-10 10:11:11.12345", mysql.TypeDatetime, 2)
require.Equal(t, "2010-10-10 10:11:11.12", vd.String())
require.NoError(t, err)
v, err = Convert(vd, ft)
require.NoError(t, err)
require.Equal(t, "10:11:11.1", v.(Duration).String())

vt, err := ParseTime(typeCtx, "2010-10-10 10:11:11.12345", mysql.TypeTimestamp, 2, nil)
vt, err := ParseTime(typeCtx, "2010-10-10 10:11:11.12345", mysql.TypeTimestamp, 2)
require.Equal(t, "2010-10-10 10:11:11.12", vt.String())
require.NoError(t, err)
v, err = Convert(vt, ft)
Expand Down Expand Up @@ -343,7 +343,7 @@ func TestConvertToString(t *testing.T) {
testToString(t, Enum{Name: "a", Value: 1}, "a")
testToString(t, Set{Name: "a", Value: 1}, "a")

t1, err := ParseTime(DefaultStmtNoWarningContext, "2011-11-10 11:11:11.999999", mysql.TypeTimestamp, 6, nil)
t1, err := ParseTime(DefaultStmtNoWarningContext, "2011-11-10 11:11:11.999999", mysql.TypeTimestamp, 6)
require.NoError(t, err)
testToString(t, t1, "2011-11-10 11:11:11.999999")

Expand Down
8 changes: 4 additions & 4 deletions pkg/types/datum.go
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ func (d *Datum) convertToMysqlTimestamp(ctx Context, target *FieldType) (Datum,
}
t, err = t.RoundFrac(ctx, fsp)
case KindString, KindBytes:
t, err = ParseTime(ctx, d.GetString(), mysql.TypeTimestamp, fsp, nil)
t, err = ParseTime(ctx, d.GetString(), mysql.TypeTimestamp, fsp)
case KindInt64:
t, err = ParseTimeFromNum(ctx, d.GetInt64(), mysql.TypeTimestamp, fsp)
case KindMysqlDecimal:
Expand All @@ -1283,7 +1283,7 @@ func (d *Datum) convertToMysqlTimestamp(ctx Context, target *FieldType) (Datum,
ret.SetMysqlTime(t)
return ret, err
}
t, err = ParseTime(ctx, s, mysql.TypeTimestamp, fsp, nil)
t, err = ParseTime(ctx, s, mysql.TypeTimestamp, fsp)
default:
return invalidConv(d, mysql.TypeTimestamp)
}
Expand Down Expand Up @@ -1324,7 +1324,7 @@ func (d *Datum) convertToMysqlTime(ctx Context, target *FieldType) (Datum, error
case KindMysqlDecimal:
t, err = ParseTimeFromFloatString(ctx, d.GetMysqlDecimal().String(), tp, fsp)
case KindString, KindBytes:
t, err = ParseTime(ctx, d.GetString(), tp, fsp, nil)
t, err = ParseTime(ctx, d.GetString(), tp, fsp)
case KindInt64:
t, err = ParseTimeFromNum(ctx, d.GetInt64(), tp, fsp)
case KindUint64:
Expand All @@ -1343,7 +1343,7 @@ func (d *Datum) convertToMysqlTime(ctx Context, target *FieldType) (Datum, error
ret.SetMysqlTime(t)
return ret, err
}
t, err = ParseTime(ctx, s, tp, fsp, nil)
t, err = ParseTime(ctx, s, tp, fsp)
default:
return invalidConv(d, tp)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/types/datum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestToBool(t *testing.T) {
testDatumToBool(t, CreateBinaryJSON(true), 1)
testDatumToBool(t, CreateBinaryJSON(false), 1)
testDatumToBool(t, CreateBinaryJSON(""), 1)
t1, err := ParseTime(DefaultStmtNoWarningContext, "2011-11-10 11:11:11.999999", mysql.TypeTimestamp, 6, nil)
t1, err := ParseTime(DefaultStmtNoWarningContext, "2011-11-10 11:11:11.999999", mysql.TypeTimestamp, 6)
require.NoError(t, err)
testDatumToBool(t, t1, 1)

Expand Down Expand Up @@ -133,7 +133,7 @@ func TestToInt64(t *testing.T) {
testDatumToInt64(t, Set{Name: "a", Value: 1}, int64(1))
testDatumToInt64(t, CreateBinaryJSON(int64(3)), int64(3))

t1, err := ParseTime(DefaultStmtNoWarningContext, "2011-11-10 11:11:11.999999", mysql.TypeTimestamp, 0, nil)
t1, err := ParseTime(DefaultStmtNoWarningContext, "2011-11-10 11:11:11.999999", mysql.TypeTimestamp, 0)
require.NoError(t, err)
testDatumToInt64(t, t1, int64(20111110111112))

Expand Down Expand Up @@ -221,7 +221,7 @@ func TestConvertToFloat(t *testing.T) {
}

func mustParseTime(s string, tp byte, fsp int) Time {
t, err := ParseTime(DefaultStmtNoWarningContext, s, tp, fsp, nil)
t, err := ParseTime(DefaultStmtNoWarningContext, s, tp, fsp)
if err != nil {
panic("ParseTime fail")
}
Expand Down
Loading