Skip to content

Commit

Permalink
*: fix a timezone data race which may cause wrong row data (#41146) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Mar 30, 2023
1 parent 00c7ffc commit c0ec81b
Show file tree
Hide file tree
Showing 28 changed files with 120 additions and 109 deletions.
2 changes: 1 addition & 1 deletion br/pkg/task/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ func ParseTSString(ts string) (uint64, error) {
sc := &stmtctx.StatementContext{
TimeZone: loc,
}
t, err := types.ParseTime(sc, ts, mysql.TypeTimestamp, types.MaxFsp)
t, err := types.ParseTime(sc, ts, mysql.TypeTimestamp, types.MaxFsp, nil)
if err != nil {
return 0, errors.Trace(err)
}
Expand Down
6 changes: 3 additions & 3 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ func checkColumnDefaultValue(ctx sessionctx.Context, col *table.Column, value in
if value != nil && ctx.GetSessionVars().SQLMode.HasNoZeroDateMode() &&
ctx.GetSessionVars().SQLMode.HasStrictMode() && types.IsTypeTime(col.GetType()) {
if vv, ok := value.(string); ok {
timeValue, err := expression.GetTimeValue(ctx, vv, col.GetType(), col.GetDecimal())
timeValue, err := expression.GetTimeValue(ctx, vv, col.GetType(), col.GetDecimal(), nil)
if err != nil {
return hasDefaultValue, value, errors.Trace(err)
}
Expand All @@ -845,7 +845,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, vv, col.GetType(), col.GetDecimal())
t, err := types.ParseTime(ctx.GetSessionVars().StmtCtx, vv, col.GetType(), col.GetDecimal(), nil)
if err != nil {
return defaultVal, errors.Trace(err)
}
Expand Down Expand Up @@ -1093,7 +1093,7 @@ func getDefaultValue(ctx sessionctx.Context, col *table.Column, option *ast.Colu
}

if tp == mysql.TypeTimestamp || tp == mysql.TypeDatetime {
vd, err := expression.GetTimeValue(ctx, option.Expr, tp, fsp)
vd, err := expression.GetTimeValue(ctx, option.Expr, tp, fsp, nil)
value := vd.GetValue()
if err != nil {
return nil, false, dbterror.ErrInvalidDefaultValue.GenWithStackByArgs(col.Name.O)
Expand Down
2 changes: 1 addition & 1 deletion executor/brie.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (bq *brieQueue) clearTask(sc *stmtctx.StatementContext) {

func (b *executorBuilder) parseTSString(ts string) (uint64, error) {
sc := &stmtctx.StatementContext{TimeZone: b.ctx.GetSessionVars().Location()}
t, err := types.ParseTime(sc, ts, mysql.TypeTimestamp, types.MaxFsp)
t, err := types.ParseTime(sc, ts, mysql.TypeTimestamp, types.MaxFsp, nil)
if err != nil {
return 0, err
}
Expand Down
2 changes: 1 addition & 1 deletion executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2497,7 +2497,7 @@ func TestTimestampDefaultValueTimeZone(t *testing.T) {
tk.MustExec(`set time_zone = '+00:00'`)
timeIn0 := tk.MustQuery("select b from t").Rows()[0][0]
require.NotEqual(t, timeIn8, timeIn0)
datumTimeIn8, err := expression.GetTimeValue(tk.Session(), timeIn8, mysql.TypeTimestamp, 0)
datumTimeIn8, err := expression.GetTimeValue(tk.Session(), timeIn8, mysql.TypeTimestamp, 0, nil)
require.NoError(t, err)
tIn8To0 := datumTimeIn8.GetMysqlTime()
timeZoneIn8, err := time.LoadLocation("Asia/Shanghai")
Expand Down
10 changes: 5 additions & 5 deletions executor/inspection_result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,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, str, mysql.TypeDatetime, types.MaxFsp)
time, err := types.ParseTime(se.GetSessionVars().StmtCtx, str, mysql.TypeDatetime, types.MaxFsp, nil)
require.NoError(t, err)
return time
}
Expand Down Expand Up @@ -342,7 +342,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, s, mysql.TypeDatetime, types.MaxFsp)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx, s, mysql.TypeDatetime, types.MaxFsp, nil)
require.NoError(t, err)
return time
}
Expand Down Expand Up @@ -427,7 +427,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, s, mysql.TypeDatetime, types.MaxFsp)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx, s, mysql.TypeDatetime, types.MaxFsp, nil)
require.NoError(t, err)
return time
}
Expand Down Expand Up @@ -638,7 +638,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, s, mysql.TypeDatetime, types.MaxFsp)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx, s, mysql.TypeDatetime, types.MaxFsp, nil)
require.NoError(t, err)
return time
}
Expand Down Expand Up @@ -716,7 +716,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, s, mysql.TypeDatetime, types.MaxFsp)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx, s, mysql.TypeDatetime, types.MaxFsp, nil)
require.NoError(t, err)
return time
}
Expand Down
2 changes: 1 addition & 1 deletion executor/inspection_summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,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, s, mysql.TypeDatetime, types.MaxFsp)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx, s, mysql.TypeDatetime, types.MaxFsp, nil)
require.NoError(t, err)
return time
}
Expand Down
2 changes: 1 addition & 1 deletion executor/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func updateRecord(ctx context.Context, sctx sessionctx.Context, h kv.Handle, old
// Fill values into on-update-now fields, only if they are really changed.
for i, col := range t.Cols() {
if mysql.HasOnUpdateNowFlag(col.GetFlag()) && !modified[i] && !onUpdateSpecified[i] {
if v, err := expression.GetTimeValue(sctx, strings.ToUpper(ast.CurrentTimestamp), col.GetType(), col.GetDecimal()); err == nil {
if v, err := expression.GetTimeValue(sctx, strings.ToUpper(ast.CurrentTimestamp), col.GetType(), col.GetDecimal(), nil); err == nil {
newData[i] = v
modified[i] = true
} else {
Expand Down
6 changes: 3 additions & 3 deletions expression/builtin_cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ func (b *builtinCastRealAsTimeSig) evalTime(row chunk.Row) (types.Time, bool, er
return types.ZeroTime, false, nil
}
sc := b.ctx.GetSessionVars().StmtCtx
res, err := types.ParseTime(sc, fv, b.tp.GetType(), b.tp.GetDecimal())
res, err := types.ParseTime(sc, fv, b.tp.GetType(), b.tp.GetDecimal(), nil)
if err != nil {
return types.ZeroTime, true, handleInvalidTimeError(b.ctx, err)
}
Expand Down Expand Up @@ -1288,7 +1288,7 @@ func (b *builtinCastStringAsTimeSig) evalTime(row chunk.Row) (res types.Time, is
return res, isNull, err
}
sc := b.ctx.GetSessionVars().StmtCtx
res, err = types.ParseTime(sc, val, b.tp.GetType(), b.tp.GetDecimal())
res, err = types.ParseTime(sc, val, b.tp.GetType(), b.tp.GetDecimal(), nil)
if err != nil {
return types.ZeroTime, true, handleInvalidTimeError(b.ctx, err)
}
Expand Down Expand Up @@ -1734,7 +1734,7 @@ func (b *builtinCastJSONAsTimeSig) evalTime(row chunk.Row) (res types.Time, isNu
return res, false, err
}
sc := b.ctx.GetSessionVars().StmtCtx
res, err = types.ParseTime(sc, s, b.tp.GetType(), b.tp.GetDecimal())
res, err = types.ParseTime(sc, s, b.tp.GetType(), b.tp.GetDecimal(), nil)
if err != nil {
return types.ZeroTime, true, handleInvalidTimeError(b.ctx, err)
}
Expand Down
6 changes: 3 additions & 3 deletions expression/builtin_cast_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func (b *builtinCastJSONAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chunk
if err != nil {
return err
}
tm, err := types.ParseTime(stmtCtx, s, b.tp.GetType(), fsp)
tm, err := types.ParseTime(stmtCtx, s, b.tp.GetType(), fsp, nil)
if err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
Expand Down Expand Up @@ -539,7 +539,7 @@ func (b *builtinCastRealAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chunk
times[i] = types.ZeroTime
continue
}
tm, err := types.ParseTime(stmt, fv, b.tp.GetType(), fsp)
tm, err := types.ParseTime(stmt, fv, b.tp.GetType(), fsp, nil)
if err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
Expand Down Expand Up @@ -1692,7 +1692,7 @@ func (b *builtinCastStringAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chu
if result.IsNull(i) {
continue
}
tm, err := types.ParseTime(stmtCtx, buf.GetString(i), b.tp.GetType(), fsp)
tm, err := types.ParseTime(stmtCtx, buf.GetString(i), b.tp.GetType(), fsp, nil)
if err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
Expand Down
14 changes: 7 additions & 7 deletions expression/builtin_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2778,7 +2778,7 @@ func (du *baseDateArithmetical) getDateFromString(ctx sessionctx.Context, args [
}

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

date, err := types.ParseTime(sc, dateStr, dateTp, types.MaxFsp)
date, err := types.ParseTime(sc, dateStr, dateTp, types.MaxFsp, nil)
if err != nil {
err = handleInvalidTimeError(b.ctx, err)
if err != nil {
Expand Down Expand Up @@ -5175,7 +5175,7 @@ func (b *builtinTimestamp1ArgSig) evalTime(row chunk.Row) (types.Time, bool, err
if b.isFloat {
tm, err = types.ParseTimeFromFloatString(sc, s, mysql.TypeDatetime, types.GetFsp(s))
} else {
tm, err = types.ParseTime(sc, s, mysql.TypeDatetime, types.GetFsp(s))
tm, err = types.ParseTime(sc, s, mysql.TypeDatetime, types.GetFsp(s), nil)
}
if err != nil {
return types.ZeroTime, true, handleInvalidTimeError(b.ctx, err)
Expand Down Expand Up @@ -5207,7 +5207,7 @@ func (b *builtinTimestamp2ArgsSig) evalTime(row chunk.Row) (types.Time, bool, er
if b.isFloat {
tm, err = types.ParseTimeFromFloatString(sc, arg0, mysql.TypeDatetime, types.GetFsp(arg0))
} else {
tm, err = types.ParseTime(sc, arg0, mysql.TypeDatetime, types.GetFsp(arg0))
tm, err = types.ParseTime(sc, arg0, mysql.TypeDatetime, types.GetFsp(arg0), nil)
}
if err != nil {
return types.ZeroTime, true, handleInvalidTimeError(b.ctx, err)
Expand Down Expand Up @@ -5258,7 +5258,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, str, mysql.TypeDatetime, types.GetFsp(str))
tm, err := types.ParseTime(ctx.GetSessionVars().StmtCtx, str, mysql.TypeDatetime, types.GetFsp(str), nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -5366,7 +5366,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, d, mysql.TypeDatetime, types.MaxFsp)
arg0, err := types.ParseTime(sc, d, mysql.TypeDatetime, types.MaxFsp, nil)
if err != nil {
// Return a warning regardless of the sql_mode, this is compatible with MySQL.
sc.AppendWarning(err)
Expand Down Expand Up @@ -5403,7 +5403,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, d, mysql.TypeDatetime, types.MaxFsp)
arg0, err := types.ParseTime(sc, d, mysql.TypeDatetime, types.MaxFsp, nil)
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 expression/builtin_time_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2669,7 +2669,7 @@ func (b *builtinTimestamp1ArgSig) vecEvalTime(input *chunk.Chunk, result *chunk.
if b.isFloat {
tm, err = types.ParseTimeFromFloatString(sc, s, mysql.TypeDatetime, types.GetFsp(s))
} else {
tm, err = types.ParseTime(sc, s, mysql.TypeDatetime, types.GetFsp(s))
tm, err = types.ParseTime(sc, s, mysql.TypeDatetime, types.GetFsp(s), nil)
}
if err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
Expand Down Expand Up @@ -2722,7 +2722,7 @@ func (b *builtinTimestamp2ArgsSig) vecEvalTime(input *chunk.Chunk, result *chunk
if b.isFloat {
tm, err = types.ParseTimeFromFloatString(sc, arg0, mysql.TypeDatetime, types.GetFsp(arg0))
} else {
tm, err = types.ParseTime(sc, arg0, mysql.TypeDatetime, types.GetFsp(arg0))
tm, err = types.ParseTime(sc, arg0, mysql.TypeDatetime, types.GetFsp(arg0), nil)
}
if err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions expression/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ 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) (d types.Datum, err error) {
func GetTimeValue(ctx sessionctx.Context, v interface{}, tp byte, fsp int, explicitTz *time.Location) (d types.Datum, err error) {
var value types.Time

sc := ctx.GetSessionVars().StmtCtx
Expand All @@ -99,15 +99,15 @@ func GetTimeValue(ctx sessionctx.Context, v interface{}, tp byte, fsp int) (d ty
value, err = types.ParseTimeFromNum(sc, 0, tp, fsp)
terror.Log(err)
} else {
value, err = types.ParseTime(sc, x, tp, fsp)
value, err = types.ParseTime(sc, x, tp, fsp, explicitTz)
if err != nil {
return d, err
}
}
case *driver.ValueExpr:
switch x.Kind() {
case types.KindString:
value, err = types.ParseTime(sc, x.GetString(), tp, fsp)
value, err = types.ParseTime(sc, x.GetString(), tp, fsp, nil)
if err != nil {
return d, err
}
Expand Down
16 changes: 8 additions & 8 deletions expression/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

func TestGetTimeValue(t *testing.T) {
ctx := mock.NewContext()
v, err := GetTimeValue(ctx, "2012-12-12 00:00:00", mysql.TypeTimestamp, types.MinFsp)
v, err := GetTimeValue(ctx, "2012-12-12 00:00:00", mysql.TypeTimestamp, types.MinFsp, nil)
require.NoError(t, err)

require.Equal(t, types.KindMysqlTime, v.Kind())
Expand All @@ -44,7 +44,7 @@ func TestGetTimeValue(t *testing.T) {
sessionVars := ctx.GetSessionVars()
err = variable.SetSessionSystemVar(sessionVars, "timestamp", "0")
require.NoError(t, err)
v, err = GetTimeValue(ctx, "2012-12-12 00:00:00", mysql.TypeTimestamp, types.MinFsp)
v, err = GetTimeValue(ctx, "2012-12-12 00:00:00", mysql.TypeTimestamp, types.MinFsp, nil)
require.NoError(t, err)

require.Equal(t, types.KindMysqlTime, v.Kind())
Expand All @@ -53,7 +53,7 @@ func TestGetTimeValue(t *testing.T) {

err = variable.SetSessionSystemVar(sessionVars, "timestamp", "0")
require.NoError(t, err)
v, err = GetTimeValue(ctx, "2012-12-12 00:00:00", mysql.TypeTimestamp, types.MinFsp)
v, err = GetTimeValue(ctx, "2012-12-12 00:00:00", mysql.TypeTimestamp, types.MinFsp, nil)
require.NoError(t, err)

require.Equal(t, types.KindMysqlTime, v.Kind())
Expand All @@ -62,7 +62,7 @@ func TestGetTimeValue(t *testing.T) {

err = variable.SetSessionSystemVar(sessionVars, "timestamp", "")
require.Error(t, err, "Incorrect argument type to variable 'timestamp'")
v, err = GetTimeValue(ctx, "2012-12-12 00:00:00", mysql.TypeTimestamp, types.MinFsp)
v, err = GetTimeValue(ctx, "2012-12-12 00:00:00", mysql.TypeTimestamp, types.MinFsp, nil)
require.NoError(t, err)

require.Equal(t, types.KindMysqlTime, v.Kind())
Expand Down Expand Up @@ -100,7 +100,7 @@ func TestGetTimeValue(t *testing.T) {

for i, tbl := range tbls {
comment := fmt.Sprintf("expr: %d", i)
v, err := GetTimeValue(ctx, tbl.Expr, mysql.TypeTimestamp, types.MinFsp)
v, err := GetTimeValue(ctx, tbl.Expr, mysql.TypeTimestamp, types.MinFsp, nil)
require.NoError(t, err)

switch v.Kind() {
Expand All @@ -122,7 +122,7 @@ func TestGetTimeValue(t *testing.T) {
}

for _, tbl := range errTbl {
_, err := GetTimeValue(ctx, tbl.Expr, mysql.TypeTimestamp, types.MinFsp)
_, err := GetTimeValue(ctx, tbl.Expr, mysql.TypeTimestamp, types.MinFsp, nil)
require.Error(t, err)
}
}
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestCurrentTimestampTimeZone(t *testing.T) {
require.NoError(t, err)
err = variable.SetSessionSystemVar(sessionVars, "time_zone", "+00:00")
require.NoError(t, err)
v, err := GetTimeValue(ctx, ast.CurrentTimestamp, mysql.TypeTimestamp, types.MinFsp)
v, err := GetTimeValue(ctx, ast.CurrentTimestamp, mysql.TypeTimestamp, types.MinFsp, nil)
require.NoError(t, err)
require.EqualValues(t, types.NewTime(
types.FromDate(1970, 1, 1, 0, 20, 34, 0),
Expand All @@ -176,7 +176,7 @@ func TestCurrentTimestampTimeZone(t *testing.T) {
// would get different value.
err = variable.SetSessionSystemVar(sessionVars, "time_zone", "+08:00")
require.NoError(t, err)
v, err = GetTimeValue(ctx, ast.CurrentTimestamp, mysql.TypeTimestamp, types.MinFsp)
v, err = GetTimeValue(ctx, ast.CurrentTimestamp, mysql.TypeTimestamp, types.MinFsp, nil)
require.NoError(t, err)
require.EqualValues(t, types.NewTime(
types.FromDate(1970, 1, 1, 8, 20, 34, 0),
Expand Down
2 changes: 1 addition & 1 deletion planner/core/expression_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,7 @@ func (er *expressionRewriter) evalDefaultExpr(v *ast.DefaultExpr) {
var val *expression.Constant
switch {
case isCurrentTimestamp && (col.GetType() == mysql.TypeDatetime || col.GetType() == mysql.TypeTimestamp):
t, err := expression.GetTimeValue(er.sctx, ast.CurrentTimestamp, col.GetType(), col.GetDecimal())
t, err := expression.GetTimeValue(er.sctx, ast.CurrentTimestamp, col.GetType(), col.GetDecimal(), nil)
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion server/statistics_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (sh StatsHistoryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request
defer se.Close()

se.GetSessionVars().StmtCtx.TimeZone = time.Local
t, err := types.ParseTime(se.GetSessionVars().StmtCtx, params[pSnapshot], mysql.TypeTimestamp, 6)
t, err := types.ParseTime(se.GetSessionVars().StmtCtx, params[pSnapshot], mysql.TypeTimestamp, 6, nil)
if err != nil {
writeError(w, err)
return
Expand Down
2 changes: 1 addition & 1 deletion server/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestDumpTextValue(t *testing.T) {
require.NoError(t, err)
sc.TimeZone = losAngelesTz

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

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

t, err := types.ParseTime(s.StmtCtx, sVal, mysql.TypeTimestamp, types.MaxFsp)
t, err := types.ParseTime(s.StmtCtx, sVal, mysql.TypeTimestamp, types.MaxFsp, nil)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit c0ec81b

Please sign in to comment.