diff --git a/parser/charset/charset.go b/parser/charset/charset.go index 091800dd63003..0fdff1b75c13e 100644 --- a/parser/charset/charset.go +++ b/parser/charset/charset.go @@ -18,8 +18,10 @@ import ( "strings" "github.com/pingcap/errors" + "github.com/pingcap/log" "github.com/pingcap/tidb/parser/mysql" "github.com/pingcap/tidb/parser/terror" + "go.uber.org/zap" ) var ( @@ -158,11 +160,10 @@ func GetCharsetInfoByID(coID int) (string, string, error) { return collation.CharsetName, collation.Name, nil } - // TODO: uncomment it when issue #29697 be closed - // log.Warn( - // "Unable to get collation name from collation ID, return default charset and collation instead.", - // zap.Int("ID", coID), - // zap.Stack("stack")) + log.Warn( + "unable to get collation name from collation ID, return default charset and collation instead", + zap.Int("ID", coID), + zap.Stack("stack")) return mysql.DefaultCharset, mysql.DefaultCollationName, errors.Errorf("Unknown collation id %d", coID) } diff --git a/parser/model/model.go b/parser/model/model.go index 49d7cbc351194..20e770c607149 100644 --- a/parser/model/model.go +++ b/parser/model/model.go @@ -22,6 +22,7 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/tidb/parser/auth" + "github.com/pingcap/tidb/parser/charset" "github.com/pingcap/tidb/parser/mysql" "github.com/pingcap/tidb/parser/types" ) @@ -628,6 +629,7 @@ func NewExtraHandleColInfo() *ColumnInfo { colInfo.Flag = mysql.PriKeyFlag | mysql.NotNullFlag colInfo.Tp = mysql.TypeLonglong colInfo.Flen, colInfo.Decimal = mysql.GetDefaultFieldLengthAndDecimal(mysql.TypeLonglong) + colInfo.Charset, colInfo.Collate = charset.CharsetBin, charset.CollationBin return colInfo } diff --git a/parser/model/model_test.go b/parser/model/model_test.go index 190932628c391..8c2365ea47ca4 100644 --- a/parser/model/model_test.go +++ b/parser/model/model_test.go @@ -19,6 +19,7 @@ import ( "testing" "time" + "github.com/pingcap/tidb/parser/charset" "github.com/pingcap/tidb/parser/mysql" "github.com/pingcap/tidb/parser/types" "github.com/stretchr/testify/require" @@ -134,6 +135,8 @@ func TestModelBasic(t *testing.T) { extraPK := NewExtraHandleColInfo() require.Equal(t, mysql.NotNullFlag|mysql.PriKeyFlag, extraPK.Flag) + require.Equal(t, charset.CharsetBin, extraPK.Charset) + require.Equal(t, charset.CollationBin, extraPK.Collate) } func TestJobStartTime(t *testing.T) {