@@ -63,7 +63,8 @@ type KafkaRunner struct {
6363 BinlogFile string
6464 BinlogPos int64
6565
66- location * time.Location
66+ // Only for Datetime column type. Not for
67+ dateTimeLocation * time.Location
6768
6869 chBinlogEntries chan * common.DataEntries
6970 chDumpEntry chan * common.DumpEntry
@@ -108,7 +109,7 @@ func NewKafkaRunner(execCtx *common.ExecContext, logger g.LoggerType, storeManag
108109 chDumpEntry : make (chan * common.DumpEntry , 2 ),
109110 chBinlogEntries : make (chan * common.DataEntries , 2 ),
110111
111- location : time .UTC , // default value
112+ dateTimeLocation : time .UTC , // default value
112113
113114 memory1 : new (int64 ),
114115 memory2 : new (int64 ),
@@ -280,8 +281,8 @@ func (kr *KafkaRunner) Run() {
280281 return
281282 }
282283
283- if kr .kafkaConfig .TimeZone != "" {
284- kr .location , err = time .LoadLocation (kr .kafkaConfig .TimeZone )
284+ if kr .kafkaConfig .DateTimeZone != "" {
285+ kr .dateTimeLocation , err = time .LoadLocation (kr .kafkaConfig .DateTimeZone )
285286 if err != nil {
286287 kr .onError (common .TaskStateDead , errors .Wrap (err , "LoadLocation" ))
287288 return
@@ -318,7 +319,7 @@ func (kr *KafkaRunner) getOrSetTable(schemaName string, tableName string,
318319 } else {
319320 kr .logger .Debug ("new table info" , "schemaName" , schemaName , "tableName" , tableName )
320321 tableIdent := fmt .Sprintf ("%v.%v.%v" , kr .kafkaMgr .Cfg .Topic , table .TableSchema , table .TableName )
321- colDefs , keyColDefs := kafkaColumnListToColDefs (table .OriginalTableColumns , kr .location )
322+ colDefs , keyColDefs := kafkaColumnListToColDefs (table .OriginalTableColumns , kr .dateTimeLocation )
322323 keySchema := & SchemaJson {
323324 schema : NewKeySchema (tableIdent , keyColDefs ),
324325 }
@@ -793,7 +794,7 @@ func (kr *KafkaRunner) kafkaTransformSnapshotData(
793794 value = base64 .StdEncoding .EncodeToString ([]byte (valueStr ))
794795 case mysqlconfig .DateTimeColumnType :
795796 if valueStr != "" {
796- value = DateTimeValue (valueStr , kr .location )
797+ value = DateTimeValue (valueStr , kr .dateTimeLocation )
797798 }
798799 case mysqlconfig .DateColumnType :
799800 if valueStr != "" {
@@ -1088,7 +1089,7 @@ func (kr *KafkaRunner) kafkaConvertArg(column *mysqlconfig.Column, theValue inte
10881089 }
10891090 case mysqlconfig .DateTimeColumnType :
10901091 if theValue != nil {
1091- theValue = DateTimeValue (theValue .(string ), kr .location )
1092+ theValue = DateTimeValue (theValue .(string ), kr .dateTimeLocation )
10921093 }
10931094 case mysqlconfig .VarbinaryColumnType :
10941095 if theValue != nil {
@@ -1224,7 +1225,7 @@ func reverseBytes(bytes []byte) string {
12241225 return value
12251226}
12261227
1227- func kafkaColumnListToColDefs (colList * common.ColumnList , loc * time.Location ) (valColDefs ColDefs , keyColDefs ColDefs ) {
1228+ func kafkaColumnListToColDefs (colList * common.ColumnList , dateTimeLoc * time.Location ) (valColDefs ColDefs , keyColDefs ColDefs ) {
12281229 cols := colList .ColumnList ()
12291230 for i , _ := range cols {
12301231 var field * Schema
@@ -1304,7 +1305,7 @@ func kafkaColumnListToColDefs(colList *common.ColumnList, loc *time.Location) (v
13041305 case mysqlconfig .YearColumnType :
13051306 field = NewYearField (SCHEMA_TYPE_INT32 , optional , fieldName , defaultValue )
13061307 case mysqlconfig .DateTimeColumnType :
1307- field = NewDateTimeField (optional , fieldName , defaultValue , loc )
1308+ field = NewDateTimeField (optional , fieldName , defaultValue , dateTimeLoc )
13081309 case mysqlconfig .TimeColumnType :
13091310 field = NewTimeField (optional , fieldName , defaultValue )
13101311 case mysqlconfig .TimestampColumnType :
0 commit comments