From d942a335e3ae1dd8c47356e4422360378023434b Mon Sep 17 00:00:00 2001 From: Chao Wang Date: Mon, 16 Oct 2023 10:48:21 +0800 Subject: [PATCH] json fake context --- br/pkg/lightning/backend/kv/session.go | 1 + pkg/ddl/backfilling_scheduler.go | 7 +------ pkg/expression/builtin_cast.go | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/br/pkg/lightning/backend/kv/session.go b/br/pkg/lightning/backend/kv/session.go index 470bbedaa5b8c..ec8cc154e1065 100644 --- a/br/pkg/lightning/backend/kv/session.go +++ b/br/pkg/lightning/backend/kv/session.go @@ -312,6 +312,7 @@ func NewSession(options *encode.SessionOptions, logger log.Logger) *Session { } } } + vars.StmtCtx.SetTimeZone(vars.Location()) vars.StmtCtx.SetTypeFlags(types.StrictFlags. WithClipNegativeToZero(true), diff --git a/pkg/ddl/backfilling_scheduler.go b/pkg/ddl/backfilling_scheduler.go index 2ad15edcb564c..9e4dd7c02208c 100644 --- a/pkg/ddl/backfilling_scheduler.go +++ b/pkg/ddl/backfilling_scheduler.go @@ -18,7 +18,6 @@ import ( "context" "fmt" "sync" - "time" "github.com/pingcap/errors" "github.com/pingcap/tidb/pkg/ddl/copr" @@ -149,11 +148,6 @@ func initSessCtx( sqlMode mysql.SQLMode, tzLocation *model.TimeZoneLocation, ) error { - // Unify the TimeZone settings in newContext. - if sessCtx.GetSessionVars().StmtCtx.TimeZone() == nil { - tz := *time.UTC - sessCtx.GetSessionVars().StmtCtx.SetTimeZone(&tz) - } // Set the row encode format version. rowFormat := variable.GetDDLReorgRowFormat() sessCtx.GetSessionVars().RowEncoder.Enable = rowFormat != variable.DefTiDBRowFormatV1 @@ -162,6 +156,7 @@ func initSessCtx( if err := setSessCtxLocation(sessCtx, tzLocation); err != nil { return errors.Trace(err) } + sessCtx.GetSessionVars().StmtCtx.SetTimeZone(sessCtx.GetSessionVars().Location()) sessCtx.GetSessionVars().StmtCtx.BadNullAsWarning = !sqlMode.HasStrictMode() sessCtx.GetSessionVars().StmtCtx.TruncateAsWarning = !sqlMode.HasStrictMode() sessCtx.GetSessionVars().StmtCtx.OverflowAsWarning = !sqlMode.HasStrictMode() diff --git a/pkg/expression/builtin_cast.go b/pkg/expression/builtin_cast.go index a2118afba5eff..06044776811c7 100644 --- a/pkg/expression/builtin_cast.go +++ b/pkg/expression/builtin_cast.go @@ -480,7 +480,6 @@ var fakeSctx = newFakeSctx() func newFakeSctx() *stmtctx.StatementContext { sc := stmtctx.NewStmtCtx() - sc.InInsertStmt = true sc.SetTypeFlags(types.StrictFlags. WithClipNegativeToZero(true), )