From 0e3a62b35fbf84c53e12f82beb281ca786eddbd1 Mon Sep 17 00:00:00 2001 From: crazycs520 Date: Thu, 17 Jan 2019 21:18:49 +0800 Subject: [PATCH 1/3] model: add version number to TableInfo --- model/model.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/model/model.go b/model/model.go index a5ebab0eb..da37f760f 100644 --- a/model/model.go +++ b/model/model.go @@ -137,6 +137,13 @@ const ExtraHandleID = -1 // ExtraHandleName is the name of ExtraHandle Column. var ExtraHandleName = NewCIStr("_tidb_rowid") +const ( + // TableInfoVersion0 means the table info version is 0. + TableInfoVersion0 = uint64(0) + // TableInfoVersion1 means the table info version is 1. + TableInfoVersion1 = uint64(1) +) + // TableInfo provides meta data describing a DB table. type TableInfo struct { ID int64 `json:"id"` @@ -172,6 +179,12 @@ type TableInfo struct { Compression string `json:"compression"` View *ViewInfo `json:"view"` + // Version means the version of the table info. + // Version = 0: For ColumnInfo.OriginDefaultValue and ColumnInfo.DefaultValue of timestamp column will stores the default time in system time zone. + // There will be bug if multiple TiDB server in different system time zone. + // Version = 1: For ColumnInfo.OriginDefaultValue and ColumnInfo.DefaultValue of timestamp column will stores the default time in UTC time zone. + // This will fix bug in version 0. For compatibility with version 0, we add version field in table info struct. + Version uint64 `json:"version"` } // GetPartitionInfo returns the partition information. From d4e90e647da0d774e3462f97cc646538ef48e89a Mon Sep 17 00:00:00 2001 From: crazycs Date: Fri, 18 Jan 2019 00:35:13 +0800 Subject: [PATCH 2/3] add version field in ColumnInfo --- model/model.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/model/model.go b/model/model.go index da37f760f..18327edbe 100644 --- a/model/model.go +++ b/model/model.go @@ -62,6 +62,13 @@ func (s SchemaState) String() string { } } +const ( + // ColumnInfoVersion0 means the column info version is 0. + ColumnInfoVersion0 = uint64(0) + // ColumnInfoVersion1 means the column info version is 1. + ColumnInfoVersion1 = uint64(1) +) + // ColumnInfo provides meta data describing of a table column. type ColumnInfo struct { ID int64 `json:"id"` @@ -76,6 +83,12 @@ type ColumnInfo struct { types.FieldType `json:"type"` State SchemaState `json:"state"` Comment string `json:"comment"` + // Version means the version of the column info. + // Version = 0: For OriginDefaultValue and DefaultValue of timestamp column will stores the default time in system time zone. + // There will be bug if multiple TiDB server in different system time zone. + // Version = 1: For OriginDefaultValue and DefaultValue of timestamp column will stores the default time in UTC time zone. + // This will fix bug in version 0. For compatibility with version 0, we add version field in column info struct. + Version uint64 `json:"version"` } // Clone clones ColumnInfo. @@ -137,13 +150,6 @@ const ExtraHandleID = -1 // ExtraHandleName is the name of ExtraHandle Column. var ExtraHandleName = NewCIStr("_tidb_rowid") -const ( - // TableInfoVersion0 means the table info version is 0. - TableInfoVersion0 = uint64(0) - // TableInfoVersion1 means the table info version is 1. - TableInfoVersion1 = uint64(1) -) - // TableInfo provides meta data describing a DB table. type TableInfo struct { ID int64 `json:"id"` @@ -179,12 +185,6 @@ type TableInfo struct { Compression string `json:"compression"` View *ViewInfo `json:"view"` - // Version means the version of the table info. - // Version = 0: For ColumnInfo.OriginDefaultValue and ColumnInfo.DefaultValue of timestamp column will stores the default time in system time zone. - // There will be bug if multiple TiDB server in different system time zone. - // Version = 1: For ColumnInfo.OriginDefaultValue and ColumnInfo.DefaultValue of timestamp column will stores the default time in UTC time zone. - // This will fix bug in version 0. For compatibility with version 0, we add version field in table info struct. - Version uint64 `json:"version"` } // GetPartitionInfo returns the partition information. From dca3cf4e25131041e35621ff6b8980f2c0ecb4e1 Mon Sep 17 00:00:00 2001 From: crazycs520 Date: Sun, 20 Jan 2019 15:44:42 +0800 Subject: [PATCH 3/3] address comment --- model/model.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/model.go b/model/model.go index 18327edbe..2dbfaf1cf 100644 --- a/model/model.go +++ b/model/model.go @@ -85,7 +85,7 @@ type ColumnInfo struct { Comment string `json:"comment"` // Version means the version of the column info. // Version = 0: For OriginDefaultValue and DefaultValue of timestamp column will stores the default time in system time zone. - // There will be bug if multiple TiDB server in different system time zone. + // That is a bug if multiple TiDB servers in different system time zone. // Version = 1: For OriginDefaultValue and DefaultValue of timestamp column will stores the default time in UTC time zone. // This will fix bug in version 0. For compatibility with version 0, we add version field in column info struct. Version uint64 `json:"version"`