forked from pingcap/tidb-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
33 lines (27 loc) · 745 Bytes
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package dbutil
import (
"github.com/pingcap/parser/mysql"
)
// IsNumberType returns true if tp is number type
func IsNumberType(tp byte) bool {
switch tp {
case mysql.TypeTiny, mysql.TypeShort, mysql.TypeLong, mysql.TypeLonglong, mysql.TypeInt24, mysql.TypeYear:
return true
}
return false
}
// IsFloatType returns true if tp is float type
func IsFloatType(tp byte) bool {
switch tp {
case mysql.TypeFloat, mysql.TypeDouble, mysql.TypeNewDecimal:
return true
}
return false
}
// IsTimeTypeAndNeedDecode returns true if tp is time type and encoded in tidb buckets.
func IsTimeTypeAndNeedDecode(tp byte) bool {
if tp == mysql.TypeDatetime || tp == mysql.TypeTimestamp || tp == mysql.TypeDate {
return true
}
return false
}