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

ddl: fix DST times for adding index #47425

Merged
merged 5 commits into from
Oct 8, 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
10 changes: 5 additions & 5 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ func TestGetTimeZone(t *testing.T) {
offset int
err string
}{
{"set time_zone = '+00:00'", "", "UTC", 0, ""},
{"set time_zone = '-00:00'", "", "UTC", 0, ""},
{"set time_zone = '+00:00'", "", "", 0, ""},
{"set time_zone = '-00:00'", "", "", 0, ""},
{"set time_zone = 'UTC'", "UTC", "UTC", 0, ""},
{"set time_zone = '+05:00'", "", "UTC", 18000, ""},
{"set time_zone = '-08:00'", "", "UTC", -28800, ""},
{"set time_zone = '+08:00'", "", "UTC", 28800, ""},
{"set time_zone = '+05:00'", "", "", 18000, ""},
{"set time_zone = '-08:00'", "", "", -28800, ""},
{"set time_zone = '+08:00'", "", "", 28800, ""},
{"set time_zone = 'Asia/Shanghai'", "Asia/Shanghai", "Asia/Shanghai", 0, ""},
{"set time_zone = 'SYSTEM'", "Asia/Shanghai", "Asia/Shanghai", 0, ""},
{"set time_zone = DEFAULT", "Asia/Shanghai", "Asia/Shanghai", 0, ""},
Expand Down
2 changes: 1 addition & 1 deletion ddl/index_cop.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func getRestoreData(tblInfo *model.TableInfo, targetIdx, pkIdx *model.IndexInfo,

func buildDAGPB(sCtx sessionctx.Context, tblInfo *model.TableInfo, colInfos []*model.ColumnInfo) (*tipb.DAGRequest, error) {
dagReq := &tipb.DAGRequest{}
_, dagReq.TimeZoneOffset = timeutil.Zone(sCtx.GetSessionVars().Location())
dagReq.TimeZoneName, dagReq.TimeZoneOffset = timeutil.Zone(sCtx.GetSessionVars().Location())
sc := sCtx.GetSessionVars().StmtCtx
dagReq.Flags = sc.PushDownFlags()
for i := range colInfos {
Expand Down
3 changes: 3 additions & 0 deletions ddl/ingest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,15 @@ func TestAddIndexIngestTimezone(t *testing.T) {
tk.MustExec("SET time_zone = '-06:00';")
tk.MustExec("create table t (`src` varchar(48),`t` timestamp,`timezone` varchar(100));")
tk.MustExec("insert into t values('2000-07-29 23:15:30','2000-07-29 23:15:30','-6:00');")
// Test Daylight time.
tk.MustExec("insert into t values('1991-07-21 00:00:00','1991-07-21 00:00:00','-6:00');")
tk.MustExec("alter table t add index idx(t);")
tk.MustExec("admin check table t;")

tk.MustExec("alter table t drop index idx;")
tk.MustExec("SET time_zone = 'Asia/Shanghai';")
tk.MustExec("insert into t values('2000-07-29 23:15:30','2000-07-29 23:15:30', '+8:00');")
tk.MustExec("insert into t values('1991-07-21 00:00:00','1991-07-21 00:00:00','+8:00');")
tk.MustExec("alter table t add index idx(t);")
tk.MustExec("admin check table t;")
}
Expand Down
2 changes: 1 addition & 1 deletion ddl/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func GetTimeZone(sctx sessionctx.Context) (string, int) {
}
}
_, offset := time.Now().In(loc).Zone()
return "UTC", offset
return "", offset
}

// enableEmulatorGC means whether to enable emulator GC. The default is enable.
Expand Down