diff --git a/ddl/ddl_api.go b/ddl/ddl_api.go index c1a75e66bea35..27f7c8d13733c 100644 --- a/ddl/ddl_api.go +++ b/ddl/ddl_api.go @@ -4390,7 +4390,6 @@ func (d *ddl) getModifiableColumnJob(ctx context.Context, sctx sessionctx.Contex SQLMode: sctx.GetSessionVars().SQLMode, Warnings: make(map[errors.ErrorID]*terror.Error), WarningsCount: make(map[errors.ErrorID]int64), - Location: sctx.GetSessionVars().Location(), }, Args: []interface{}{&newCol, originalColName, spec.Position, modifyColumnTp, newAutoRandBits}, } @@ -4630,7 +4629,6 @@ func (d *ddl) RenameColumn(ctx sessionctx.Context, ident ast.Ident, spec *ast.Al SQLMode: ctx.GetSessionVars().SQLMode, Warnings: make(map[errors.ErrorID]*terror.Error), WarningsCount: make(map[errors.ErrorID]int64), - Location: ctx.GetSessionVars().Location(), }, Args: []interface{}{&newCol, oldColName, spec.Position, 0}, } @@ -5442,7 +5440,6 @@ func (d *ddl) CreatePrimaryKey(ctx sessionctx.Context, ti ast.Ident, indexName m SQLMode: ctx.GetSessionVars().SQLMode, Warnings: make(map[errors.ErrorID]*terror.Error), WarningsCount: make(map[errors.ErrorID]int64), - Location: ctx.GetSessionVars().Location(), }, Args: []interface{}{unique, indexName, indexPartSpecifications, indexOption, sqlMode, nil, global}, Priority: ctx.GetSessionVars().DDLReorgPriority, @@ -5630,7 +5627,6 @@ func (d *ddl) CreateIndex(ctx sessionctx.Context, ti ast.Ident, keyType ast.Inde SQLMode: ctx.GetSessionVars().SQLMode, Warnings: make(map[errors.ErrorID]*terror.Error), WarningsCount: make(map[errors.ErrorID]int64), - Location: ctx.GetSessionVars().Location(), }, Args: []interface{}{unique, indexName, indexPartSpecifications, indexOption, hiddenCols, global}, Priority: ctx.GetSessionVars().DDLReorgPriority, diff --git a/ddl/reorg.go b/ddl/reorg.go index 54cda19a7974d..6670e1cea756f 100644 --- a/ddl/reorg.go +++ b/ddl/reorg.go @@ -199,7 +199,6 @@ func (w *worker) runReorgJob(t *meta.Meta, reorgInfo *reorgInfo, tblInfo *model. SQLMode: mysql.ModeNone, Warnings: make(map[errors.ErrorID]*terror.Error), WarningsCount: make(map[errors.ErrorID]int64), - Location: time.Local, } } if w.reorgCtx.doneCh == nil { diff --git a/parser/model/ddl.go b/parser/model/ddl.go index 0636556120a5a..12433473a6712 100644 --- a/parser/model/ddl.go +++ b/parser/model/ddl.go @@ -222,7 +222,13 @@ type DDLReorgMeta struct { SQLMode mysql.SQLMode `json:"sql_mode"` Warnings map[errors.ErrorID]*terror.Error `json:"warnings"` WarningsCount map[errors.ErrorID]int64 `json:"warnings_count"` - Location *time.Location `json:"time_location"` + Location *TimeZone `json:"time_zone"` +} + +// TimeZone represents a single time zone. +type TimeZone struct { + Name string + Offset int // seconds east of UTC } // NewDDLReorgMeta new a DDLReorgMeta. diff --git a/parser/model/model_test.go b/parser/model/model_test.go index 508eaa2713858..f3e9ec2a400d7 100644 --- a/parser/model/model_test.go +++ b/parser/model/model_test.go @@ -150,12 +150,16 @@ func TestJobCodec(t *testing.T) { type A struct { Name string } + tzName, tzOffset := time.Now().In(time.UTC).Zone() job := &Job{ ID: 1, TableID: 2, SchemaID: 1, BinlogInfo: &HistoryInfo{}, Args: []interface{}{NewCIStr("a"), A{Name: "abc"}}, + ReorgMeta: &DDLReorgMeta{ + Location: &TimeZone{Name: tzName, Offset: tzOffset}, + }, } job.BinlogInfo.AddDBInfo(123, &DBInfo{ID: 1, Name: NewCIStr("test_history_db")}) job.BinlogInfo.AddTableInfo(123, &TableInfo{ID: 1, Name: NewCIStr("test_history_tbl")}) @@ -204,6 +208,8 @@ func TestJobCodec(t *testing.T) { require.Equal(t, NewCIStr(""), name) require.Equal(t, A{Name: ""}, a) require.Greater(t, len(newJob.String()), 0) + require.Equal(t, newJob.ReorgMeta.Location.Name, tzName) + require.Equal(t, newJob.ReorgMeta.Location.Offset, tzOffset) job.BinlogInfo.Clean() b1, err := job.Encode(true)