Skip to content

Commit

Permalink
fix: remove TypeDecimal (#944)
Browse files Browse the repository at this point in the history
Signed-off-by: Wang Ruichao <[email protected]>
  • Loading branch information
wangggong authored Jul 27, 2020
1 parent 4bb6b1f commit 1259bef
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 42 deletions.
25 changes: 11 additions & 14 deletions mysql/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */
Expand Down
54 changes: 27 additions & 27 deletions types/etc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion types/field_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 1259bef

Please sign in to comment.