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, stmtctx, *: use ZeroDate, ZeroInDate and InvalidDate related flags to replace variable in statement context #47794

Merged
merged 5 commits into from
Oct 27, 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
7 changes: 4 additions & 3 deletions br/pkg/lightning/backend/kv/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,12 @@ func NewSession(options *encode.SessionOptions, logger log.Logger) *Session {
vars.StmtCtx.BatchCheck = true
vars.StmtCtx.BadNullAsWarning = !sqlMode.HasStrictMode()
vars.StmtCtx.OverflowAsWarning = !sqlMode.HasStrictMode()
vars.StmtCtx.AllowInvalidDate = sqlMode.HasAllowInvalidDatesMode()
vars.StmtCtx.IgnoreZeroInDate = !sqlMode.HasStrictMode() || sqlMode.HasAllowInvalidDatesMode()
vars.SQLMode = sqlMode

typeFlags := vars.StmtCtx.TypeFlags().WithTruncateAsWarning(!sqlMode.HasStrictMode())
typeFlags := vars.StmtCtx.TypeFlags().
WithTruncateAsWarning(!sqlMode.HasStrictMode()).
WithIgnoreInvalidDateErr(sqlMode.HasAllowInvalidDatesMode()).
WithIgnoreZeroInDate(!sqlMode.HasStrictMode() || sqlMode.HasAllowInvalidDatesMode())
vars.StmtCtx.SetTypeFlags(typeFlags)
if options.SysVars != nil {
for k, v := range options.SysVars {
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/task/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,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, ts, mysql.TypeTimestamp, types.MaxFsp, nil)
t, err := types.ParseTime(sc.TypeCtx(), ts, mysql.TypeTimestamp, types.MaxFsp, nil)
if err != nil {
return 0, errors.Trace(err)
}
Expand Down
15 changes: 9 additions & 6 deletions pkg/ddl/backfilling_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ func initSessCtx(
sessCtx.GetSessionVars().StmtCtx.SetTimeZone(sessCtx.GetSessionVars().Location())
sessCtx.GetSessionVars().StmtCtx.BadNullAsWarning = !sqlMode.HasStrictMode()
sessCtx.GetSessionVars().StmtCtx.OverflowAsWarning = !sqlMode.HasStrictMode()
sessCtx.GetSessionVars().StmtCtx.AllowInvalidDate = sqlMode.HasAllowInvalidDatesMode()
sessCtx.GetSessionVars().StmtCtx.DividedByZeroAsWarning = !sqlMode.HasStrictMode()
sessCtx.GetSessionVars().StmtCtx.IgnoreZeroInDate = !sqlMode.HasStrictMode() || sqlMode.HasAllowInvalidDatesMode()
sessCtx.GetSessionVars().StmtCtx.NoZeroDate = sqlMode.HasStrictMode()
sessCtx.GetSessionVars().StmtCtx.SetTypeFlags(types.StrictFlags.
WithTruncateAsWarning(!sqlMode.HasStrictMode()),
)

typeFlags := types.StrictFlags.
WithTruncateAsWarning(!sqlMode.HasStrictMode()).
WithIgnoreInvalidDateErr(sqlMode.HasAllowInvalidDatesMode()).
WithIgnoreZeroInDate(!sqlMode.HasStrictMode() || sqlMode.HasAllowInvalidDatesMode())
sessCtx.GetSessionVars().StmtCtx.SetTypeFlags(typeFlags)

// Prevent initializing the mock context in the workers concurrently.
// For details, see https://github.com/pingcap/tidb/issues/40879.
Expand Down Expand Up @@ -217,6 +217,9 @@ func (b *txnBackfillScheduler) adjustWorkerSize() error {
case typeUpdateColumnWorker:
// Setting InCreateOrAlterStmt tells the difference between SELECT casting and ALTER COLUMN casting.
sessCtx.GetSessionVars().StmtCtx.InCreateOrAlterStmt = true
sessCtx.GetSessionVars().StmtCtx.SetTypeFlags(
sessCtx.GetSessionVars().StmtCtx.TypeFlags().
WithIgnoreZeroDateErr(!reorgInfo.ReorgMeta.SQLMode.HasStrictMode()))
updateWorker := newUpdateColumnWorker(sessCtx, i, b.tbl, b.decodeColMap, reorgInfo, jc)
runner = newBackfillWorker(jc.ddlJobCtx, updateWorker)
worker = updateWorker
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, vv, col.GetType(), col.GetDecimal(), nil)
t, err := types.ParseTime(ctx.GetSessionVars().StmtCtx.TypeCtx(), vv, col.GetType(), col.GetDecimal(), nil)
if err != nil {
return defaultVal, errors.Trace(err)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/domain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ go_test(
"//pkg/parser/terror",
"//pkg/server",
"//pkg/session",
"//pkg/sessionctx/stmtctx",
"//pkg/sessionctx/variable",
"//pkg/store/mockstore",
"//pkg/testkit",
Expand Down
3 changes: 1 addition & 2 deletions pkg/domain/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/sessionctx/stmtctx"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/store/mockstore"
"github.com/pingcap/tidb/pkg/types"
Expand Down Expand Up @@ -196,7 +195,7 @@ func TestStatWorkRecoverFromPanic(t *testing.T) {
require.Equal(t, expiredTimeStamp, ts)

// set expiredTimeStamp4PC to "2023-08-02 12:15:00"
ts, _ = types.ParseTimestamp(stmtctx.NewStmtCtxWithTimeZone(time.UTC), "2023-08-02 12:15:00")
ts, _ = types.ParseTimestamp(types.DefaultStmtNoWarningContext, "2023-08-02 12:15:00")
dom.SetExpiredTimeStamp4PC(ts)
expiredTimeStamp = dom.ExpiredTimeStamp4PC()
require.Equal(t, expiredTimeStamp, ts)
Expand Down
1 change: 0 additions & 1 deletion pkg/executor/aggfuncs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ go_test(
"//pkg/parser/mysql",
"//pkg/planner/util",
"//pkg/sessionctx",
"//pkg/sessionctx/stmtctx",
"//pkg/sessionctx/variable",
"//pkg/testkit",
"//pkg/testkit/testsetup",
Expand Down
3 changes: 1 addition & 2 deletions pkg/executor/aggfuncs/func_count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/pingcap/tidb/pkg/executor/aggfuncs"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/sessionctx/stmtctx"
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util/hack"
"github.com/pingcap/tidb/pkg/util/mock"
Expand Down Expand Up @@ -158,7 +157,7 @@ func TestMemCount(t *testing.T) {
}

func TestWriteTime(t *testing.T) {
tt, err := types.ParseDate(stmtctx.NewStmtCtx(), "2020-11-11")
tt, err := types.ParseDate(types.DefaultStmtNoWarningContext, "2020-11-11")
require.NoError(t, err)

buf := make([]byte, 16)
Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/brie.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (bq *brieQueue) clearTask(sc *stmtctx.StatementContext) {

bq.tasks.Range(func(key, value interface{}) bool {
item := value.(*brieQueueItem)
if d := currTime.Sub(sc, &item.info.finishTime); d.Compare(outdatedDuration) > 0 {
if d := currTime.Sub(sc.TypeCtx(), &item.info.finishTime); d.Compare(outdatedDuration) > 0 {
bq.tasks.Delete(key)
}
return true
Expand All @@ -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, ts, mysql.TypeTimestamp, types.MaxFsp, nil)
t, err := types.ParseTime(sc.TypeCtx(), ts, mysql.TypeTimestamp, types.MaxFsp, nil)
if err != nil {
return 0, err
}
Expand Down
78 changes: 47 additions & 31 deletions pkg/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2101,16 +2101,22 @@ func ResetContextOfStmt(ctx sessionctx.Context, s ast.StmtNode) (err error) {
sc.IgnoreNoPartition = stmt.IgnoreErr
sc.ErrAutoincReadFailedAsWarning = stmt.IgnoreErr
sc.DividedByZeroAsWarning = !vars.StrictSQLMode || stmt.IgnoreErr
sc.AllowInvalidDate = vars.SQLMode.HasAllowInvalidDatesMode()
sc.IgnoreZeroInDate = !vars.SQLMode.HasNoZeroInDateMode() || !vars.SQLMode.HasNoZeroDateMode() || !vars.StrictSQLMode || stmt.IgnoreErr || sc.AllowInvalidDate
sc.Priority = stmt.Priority
sc.SetTypeFlags(sc.TypeFlags().WithTruncateAsWarning(!vars.StrictSQLMode || stmt.IgnoreErr))
sc.SetTypeFlags(sc.TypeFlags().
WithTruncateAsWarning(!vars.StrictSQLMode || stmt.IgnoreErr).
WithIgnoreInvalidDateErr(vars.SQLMode.HasAllowInvalidDatesMode()).
WithIgnoreZeroInDate(!vars.SQLMode.HasNoZeroInDateMode() ||
!vars.SQLMode.HasNoZeroDateMode() || !vars.StrictSQLMode || stmt.IgnoreErr ||
vars.SQLMode.HasAllowInvalidDatesMode()))
case *ast.CreateTableStmt, *ast.AlterTableStmt:
sc.InCreateOrAlterStmt = true
sc.AllowInvalidDate = vars.SQLMode.HasAllowInvalidDatesMode()
sc.IgnoreZeroInDate = !vars.SQLMode.HasNoZeroInDateMode() || !vars.StrictSQLMode || sc.AllowInvalidDate
sc.NoZeroDate = vars.SQLMode.HasNoZeroDateMode()
sc.SetTypeFlags(sc.TypeFlags().WithTruncateAsWarning(!vars.StrictSQLMode))
sc.SetTypeFlags(sc.TypeFlags().
WithTruncateAsWarning(!vars.StrictSQLMode).
WithIgnoreInvalidDateErr(vars.SQLMode.HasAllowInvalidDatesMode()).
WithIgnoreZeroInDate(!vars.SQLMode.HasNoZeroInDateMode() || !vars.StrictSQLMode ||
vars.SQLMode.HasAllowInvalidDatesMode()).
WithIgnoreZeroDateErr(!vars.SQLMode.HasNoZeroDateMode() || !vars.StrictSQLMode))

case *ast.LoadDataStmt:
sc.InLoadDataStmt = true
// return warning instead of error when load data meet no partition for value
Expand All @@ -2125,9 +2131,10 @@ func ResetContextOfStmt(ctx sessionctx.Context, s ast.StmtNode) (err error) {
sc.OverflowAsWarning = true

// Return warning for truncate error in selection.
sc.SetTypeFlags(sc.TypeFlags().WithTruncateAsWarning(true))
sc.IgnoreZeroInDate = true
sc.AllowInvalidDate = vars.SQLMode.HasAllowInvalidDatesMode()
sc.SetTypeFlags(sc.TypeFlags().
WithTruncateAsWarning(true).
WithIgnoreZeroInDate(true).
WithIgnoreInvalidDateErr(vars.SQLMode.HasAllowInvalidDatesMode()))
if opts := stmt.SelectStmtOpts; opts != nil {
sc.Priority = opts.Priority
sc.NotFillCache = !opts.SQLCache
Expand All @@ -2136,30 +2143,35 @@ func ResetContextOfStmt(ctx sessionctx.Context, s ast.StmtNode) (err error) {
case *ast.SetOprStmt:
sc.InSelectStmt = true
sc.OverflowAsWarning = true
sc.SetTypeFlags(sc.TypeFlags().WithTruncateAsWarning(true))
sc.IgnoreZeroInDate = true
sc.AllowInvalidDate = vars.SQLMode.HasAllowInvalidDatesMode()
sc.SetTypeFlags(sc.TypeFlags().
WithTruncateAsWarning(true).
WithIgnoreZeroInDate(true).
WithIgnoreInvalidDateErr(vars.SQLMode.HasAllowInvalidDatesMode()))
case *ast.ShowStmt:
sc.SetTypeFlags(sc.TypeFlags().WithIgnoreTruncateErr(true))
sc.IgnoreZeroInDate = true
sc.AllowInvalidDate = vars.SQLMode.HasAllowInvalidDatesMode()
sc.SetTypeFlags(sc.TypeFlags().
WithIgnoreTruncateErr(true).
WithIgnoreZeroInDate(true).
WithIgnoreInvalidDateErr(vars.SQLMode.HasAllowInvalidDatesMode()))
if stmt.Tp == ast.ShowWarnings || stmt.Tp == ast.ShowErrors || stmt.Tp == ast.ShowSessionStates {
sc.InShowWarning = true
sc.SetWarnings(vars.StmtCtx.GetWarnings())
}
case *ast.SplitRegionStmt:
sc.SetTypeFlags(sc.TypeFlags().WithIgnoreTruncateErr(false))
sc.IgnoreZeroInDate = true
sc.AllowInvalidDate = vars.SQLMode.HasAllowInvalidDatesMode()
sc.SetTypeFlags(sc.TypeFlags().
WithIgnoreTruncateErr(false).
WithIgnoreZeroInDate(true).
WithIgnoreInvalidDateErr(vars.SQLMode.HasAllowInvalidDatesMode()))
case *ast.SetSessionStatesStmt:
sc.InSetSessionStatesStmt = true
sc.SetTypeFlags(sc.TypeFlags().WithIgnoreTruncateErr(true))
sc.IgnoreZeroInDate = true
sc.AllowInvalidDate = vars.SQLMode.HasAllowInvalidDatesMode()
sc.SetTypeFlags(sc.TypeFlags().
WithIgnoreTruncateErr(true).
WithIgnoreZeroInDate(true).
WithIgnoreInvalidDateErr(vars.SQLMode.HasAllowInvalidDatesMode()))
default:
sc.SetTypeFlags(sc.TypeFlags().WithIgnoreTruncateErr(true))
sc.IgnoreZeroInDate = true
sc.AllowInvalidDate = vars.SQLMode.HasAllowInvalidDatesMode()
sc.SetTypeFlags(sc.TypeFlags().
WithIgnoreTruncateErr(true).
WithIgnoreZeroInDate(true).
WithIgnoreInvalidDateErr(vars.SQLMode.HasAllowInvalidDatesMode()))
}

sc.SetTypeFlags(sc.TypeFlags().
Expand Down Expand Up @@ -2221,11 +2233,13 @@ func ResetUpdateStmtCtx(sc *stmtctx.StatementContext, stmt *ast.UpdateStmt, vars
sc.DupKeyAsWarning = stmt.IgnoreErr
sc.BadNullAsWarning = !vars.StrictSQLMode || stmt.IgnoreErr
sc.DividedByZeroAsWarning = !vars.StrictSQLMode || stmt.IgnoreErr
sc.AllowInvalidDate = vars.SQLMode.HasAllowInvalidDatesMode()
sc.IgnoreZeroInDate = !vars.SQLMode.HasNoZeroInDateMode() || !vars.SQLMode.HasNoZeroDateMode() || !vars.StrictSQLMode || stmt.IgnoreErr || sc.AllowInvalidDate
sc.Priority = stmt.Priority
sc.IgnoreNoPartition = stmt.IgnoreErr
sc.SetTypeFlags(sc.TypeFlags().WithTruncateAsWarning(!vars.StrictSQLMode || stmt.IgnoreErr))
sc.SetTypeFlags(sc.TypeFlags().
WithTruncateAsWarning(!vars.StrictSQLMode || stmt.IgnoreErr).
WithIgnoreInvalidDateErr(vars.SQLMode.HasAllowInvalidDatesMode()).
WithIgnoreZeroInDate(!vars.SQLMode.HasNoZeroInDateMode() || !vars.SQLMode.HasNoZeroDateMode() ||
!vars.StrictSQLMode || stmt.IgnoreErr || vars.SQLMode.HasAllowInvalidDatesMode()))
}

// ResetDeleteStmtCtx resets statement context for DeleteStmt.
Expand All @@ -2234,10 +2248,12 @@ func ResetDeleteStmtCtx(sc *stmtctx.StatementContext, stmt *ast.DeleteStmt, vars
sc.DupKeyAsWarning = stmt.IgnoreErr
sc.BadNullAsWarning = !vars.StrictSQLMode || stmt.IgnoreErr
sc.DividedByZeroAsWarning = !vars.StrictSQLMode || stmt.IgnoreErr
sc.AllowInvalidDate = vars.SQLMode.HasAllowInvalidDatesMode()
sc.IgnoreZeroInDate = !vars.SQLMode.HasNoZeroInDateMode() || !vars.SQLMode.HasNoZeroDateMode() || !vars.StrictSQLMode || stmt.IgnoreErr || sc.AllowInvalidDate
sc.Priority = stmt.Priority
sc.SetTypeFlags(sc.TypeFlags().WithTruncateAsWarning(!vars.StrictSQLMode || stmt.IgnoreErr))
sc.SetTypeFlags(sc.TypeFlags().
WithTruncateAsWarning(!vars.StrictSQLMode || stmt.IgnoreErr).
WithIgnoreInvalidDateErr(vars.SQLMode.HasAllowInvalidDatesMode()).
WithIgnoreZeroInDate(!vars.SQLMode.HasNoZeroInDateMode() || !vars.SQLMode.HasNoZeroDateMode() ||
!vars.StrictSQLMode || stmt.IgnoreErr || vars.SQLMode.HasAllowInvalidDatesMode()))
}

func setOptionForTopSQL(sc *stmtctx.StatementContext, snapshot kv.Snapshot) {
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, str, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(se.GetSessionVars().StmtCtx.TypeCtx(), str, mysql.TypeDatetime, types.MaxFsp, nil)
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, s, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp, nil)
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, s, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp, nil)
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, s, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp, nil)
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, s, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp, nil)
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, s, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp, nil)
require.NoError(t, err)
return time
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestCalibrateResource(t *testing.T) {
}()

datetime := func(s string) types.Time {
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx, s, mysql.TypeDatetime, types.MaxFsp, nil)
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx.TypeCtx(), s, mysql.TypeDatetime, types.MaxFsp, nil)
require.NoError(t, err)
return time
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/executor/test/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2671,23 +2671,23 @@ func TestAdminShowDDLJobs(t *testing.T) {
tk.MustExec(`set @@time_zone = 'Asia/Shanghai'`)
re = tk.MustQuery("admin show ddl jobs where end_time is not NULL")
row = re.Rows()[0]
createTime, err := types.ParseDatetime(nil, row[8].(string))
createTime, err := types.ParseDatetime(types.DefaultStmtNoWarningContext, row[8].(string))
require.NoError(t, err)
startTime, err := types.ParseDatetime(nil, row[9].(string))
startTime, err := types.ParseDatetime(types.DefaultStmtNoWarningContext, row[9].(string))
require.NoError(t, err)
endTime, err := types.ParseDatetime(nil, row[10].(string))
endTime, err := types.ParseDatetime(types.DefaultStmtNoWarningContext, row[10].(string))
require.NoError(t, err)
tk.MustExec(`set @@time_zone = 'Europe/Amsterdam'`)
re = tk.MustQuery("admin show ddl jobs where end_time is not NULL")
row2 := re.Rows()[0]
require.NotEqual(t, row[8], row2[8])
require.NotEqual(t, row[9], row2[9])
require.NotEqual(t, row[10], row2[10])
createTime2, err := types.ParseDatetime(nil, row2[8].(string))
createTime2, err := types.ParseDatetime(types.DefaultStmtNoWarningContext, row2[8].(string))
require.NoError(t, err)
startTime2, err := types.ParseDatetime(nil, row2[9].(string))
startTime2, err := types.ParseDatetime(types.DefaultStmtNoWarningContext, row2[9].(string))
require.NoError(t, err)
endTime2, err := types.ParseDatetime(nil, row2[10].(string))
endTime2, err := types.ParseDatetime(types.DefaultStmtNoWarningContext, row2[10].(string))
require.NoError(t, err)
loc, err := time.LoadLocation("Asia/Shanghai")
require.NoError(t, err)
Expand Down
Loading
Loading