diff --git a/mysql/type.go b/mysql/type.go index 9ea32f90d..418e9b7d3 100644 --- a/mysql/type.go +++ b/mysql/type.go @@ -15,17 +15,17 @@ package mysql // MySQL type information. const ( - TypeDecimal byte = 0 - TypeTiny byte = 1 - TypeShort byte = 2 - TypeLong byte = 3 - TypeFloat byte = 4 - TypeDouble byte = 5 - TypeNull byte = 6 - TypeTimestamp byte = 7 - TypeLonglong byte = 8 - TypeInt24 byte = 9 - TypeDate byte = 10 + TypeUnspecified byte = 0 + TypeTiny byte = 1 + TypeShort byte = 2 + TypeLong byte = 3 + TypeFloat byte = 4 + TypeDouble byte = 5 + TypeNull byte = 6 + TypeTimestamp byte = 7 + TypeLonglong byte = 8 + TypeInt24 byte = 9 + TypeDate byte = 10 /* TypeDuration original name was TypeTime, renamed to TypeDuration to resolve the conflict with Go type Time.*/ TypeDuration byte = 11 TypeDatetime byte = 12 @@ -47,9 +47,6 @@ const ( TypeGeometry byte = 0xff ) -// TypeUnspecified is an uninitialized type. TypeDecimal is not used in MySQL. -const TypeUnspecified = TypeDecimal - // Flag information. const ( NotNullFlag uint = 1 << 0 /* Field can't be NULL */ diff --git a/types/etc.go b/types/etc.go index 5925d6764..8696557bc 100644 --- a/types/etc.go +++ b/types/etc.go @@ -41,33 +41,33 @@ func IsTypeChar(tp byte) bool { } var type2Str = map[byte]string{ - mysql.TypeBit: "bit", - mysql.TypeBlob: "text", - mysql.TypeDate: "date", - mysql.TypeDatetime: "datetime", - mysql.TypeDecimal: "unspecified", - mysql.TypeNewDecimal: "decimal", - mysql.TypeDouble: "double", - mysql.TypeEnum: "enum", - mysql.TypeFloat: "float", - mysql.TypeGeometry: "geometry", - mysql.TypeInt24: "mediumint", - mysql.TypeJSON: "json", - mysql.TypeLong: "int", - mysql.TypeLonglong: "bigint", - mysql.TypeLongBlob: "longtext", - mysql.TypeMediumBlob: "mediumtext", - mysql.TypeNull: "null", - mysql.TypeSet: "set", - mysql.TypeShort: "smallint", - mysql.TypeString: "char", - mysql.TypeDuration: "time", - mysql.TypeTimestamp: "timestamp", - mysql.TypeTiny: "tinyint", - mysql.TypeTinyBlob: "tinytext", - mysql.TypeVarchar: "varchar", - mysql.TypeVarString: "var_string", - mysql.TypeYear: "year", + mysql.TypeBit: "bit", + mysql.TypeBlob: "text", + mysql.TypeDate: "date", + mysql.TypeDatetime: "datetime", + mysql.TypeUnspecified: "unspecified", + mysql.TypeNewDecimal: "decimal", + mysql.TypeDouble: "double", + mysql.TypeEnum: "enum", + mysql.TypeFloat: "float", + mysql.TypeGeometry: "geometry", + mysql.TypeInt24: "mediumint", + mysql.TypeJSON: "json", + mysql.TypeLong: "int", + mysql.TypeLonglong: "bigint", + mysql.TypeLongBlob: "longtext", + mysql.TypeMediumBlob: "mediumtext", + mysql.TypeNull: "null", + mysql.TypeSet: "set", + mysql.TypeShort: "smallint", + mysql.TypeString: "char", + mysql.TypeDuration: "time", + mysql.TypeTimestamp: "timestamp", + mysql.TypeTiny: "tinyint", + mysql.TypeTinyBlob: "tinytext", + mysql.TypeVarchar: "varchar", + mysql.TypeVarString: "var_string", + mysql.TypeYear: "year", } // TypeStr converts tp to a string. diff --git a/types/field_type.go b/types/field_type.go index 8864a6d73..8d9da67f6 100644 --- a/types/field_type.go +++ b/types/field_type.go @@ -218,7 +218,7 @@ func (ft *FieldType) Restore(ctx *format.RestoreCtx) error { ctx.WritePlain(")") case mysql.TypeTimestamp, mysql.TypeDatetime, mysql.TypeDuration: precision = ft.Decimal - case mysql.TypeDecimal, mysql.TypeFloat, mysql.TypeDouble, mysql.TypeNewDecimal: + case mysql.TypeUnspecified, mysql.TypeFloat, mysql.TypeDouble, mysql.TypeNewDecimal: precision = ft.Flen scale = ft.Decimal default: