Skip to content

Commit 5a30540

Browse files
authored
ddl: use the correct timezone to encode record for adding index (#46055)
close #46033
1 parent f73b21b commit 5a30540

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

ddl/index_cop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func getRestoreData(tblInfo *model.TableInfo, targetIdx, pkIdx *model.IndexInfo,
484484

485485
func buildDAGPB(sCtx sessionctx.Context, tblInfo *model.TableInfo, colInfos []*model.ColumnInfo) (*tipb.DAGRequest, error) {
486486
dagReq := &tipb.DAGRequest{}
487-
dagReq.TimeZoneName, dagReq.TimeZoneOffset = timeutil.Zone(sCtx.GetSessionVars().Location())
487+
_, dagReq.TimeZoneOffset = timeutil.Zone(sCtx.GetSessionVars().Location())
488488
sc := sCtx.GetSessionVars().StmtCtx
489489
dagReq.Flags = sc.PushDownFlags()
490490
for i := range colInfos {

ddl/ingest/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ go_test(
6565
embed = [":ingest"],
6666
flaky = True,
6767
race = "on",
68-
shard_count = 14,
68+
shard_count = 15,
6969
deps = [
7070
"//config",
7171
"//ddl",

ddl/ingest/integration_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,22 @@ func TestAddIndexIngestRecoverPartition(t *testing.T) {
323323
tk.MustExec("alter table t add index idx(b);")
324324
tk.MustExec("admin check table t;")
325325
}
326+
327+
func TestAddIndexIngestTimezone(t *testing.T) {
328+
store := testkit.CreateMockStore(t)
329+
tk := testkit.NewTestKit(t, store)
330+
tk.MustExec("use test;")
331+
defer injectMockBackendMgr(t, store)()
332+
333+
tk.MustExec("SET time_zone = '-06:00';")
334+
tk.MustExec("create table t (`src` varchar(48),`t` timestamp,`timezone` varchar(100));")
335+
tk.MustExec("insert into t values('2000-07-29 23:15:30','2000-07-29 23:15:30','-6:00');")
336+
tk.MustExec("alter table t add index idx(t);")
337+
tk.MustExec("admin check table t;")
338+
339+
tk.MustExec("alter table t drop index idx;")
340+
tk.MustExec("SET time_zone = 'Asia/Shanghai';")
341+
tk.MustExec("insert into t values('2000-07-29 23:15:30','2000-07-29 23:15:30', '+8:00');")
342+
tk.MustExec("alter table t add index idx(t);")
343+
tk.MustExec("admin check table t;")
344+
}

0 commit comments

Comments
 (0)