Documentation ¶
Index ¶
- Constants
- Variables
- func AddInt64(a int64, b int64) (int64, error)
- func AddInteger(a uint64, b int64) (uint64, error)
- func AddUint64(a uint64, b uint64) (uint64, error)
- func AdjustYear(y int64) (int64, error)
- func CompareFloat64(x, y float64) int
- func CompareInt64(x, y int64) int
- func CompareString(x, y string) int
- func CompareUint64(x, y uint64) int
- func ConvertFloatToInt(sc *variable.StatementContext, fval float64, lowerBound, upperBound int64, ...) (int64, error)
- func ConvertFloatToUint(sc *variable.StatementContext, fval float64, upperBound uint64, tp byte) (uint64, error)
- func ConvertIntToInt(val int64, lowerBound int64, upperBound int64, tp byte) (int64, error)
- func ConvertIntToUint(val int64, upperBound uint64, tp byte) (uint64, error)
- func ConvertUintToInt(val uint64, upperBound int64, tp byte) (int64, error)
- func ConvertUintToUint(val uint64, upperBound uint64, tp byte) (uint64, error)
- func DateDiff(startTime, endTime TimeInternal) int
- func DateFSP(date string) (fsp int)
- func DatumsToInterfaces(datums []Datum) []interface{}
- func DatumsToString(datums []Datum) (string, error)
- func DecimalAdd(from1, from2, to *MyDecimal) error
- func DecimalDiv(from1, from2, to *MyDecimal, fracIncr int) error
- func DecimalMod(from1, from2, to *MyDecimal) error
- func DecimalMul(from1, from2, to *MyDecimal) error
- func DecimalPeak(b []byte) (int, error)
- func DecimalSub(from1, from2, to *MyDecimal) error
- func DefaultCharsetForType(tp byte) (string, string)
- func DefaultTypeForValue(value interface{}, tp *FieldType)
- func DivInt64(a int64, b int64) (int64, error)
- func DivIntWithUint(a int64, b uint64) (uint64, error)
- func DivUintWithInt(a uint64, b int64) (uint64, error)
- func EOFAsNil(err error) error
- func EqualDatums(sc *variable.StatementContext, a []Datum, b []Datum) (bool, error)
- func ExtractTimeNum(unit string, t Time) (int64, error)
- func ExtractTimeValue(unit string, format string) (int64, int64, int64, gotime.Duration, error)
- func InvOp2(x, y interface{}, o opcode.Op) (interface{}, error)
- func IsBinaryStr(ft *FieldType) bool
- func IsClockUnit(unit string) bool
- func IsDateFormat(format string) bool
- func IsTypeBlob(tp byte) bool
- func IsTypeChar(tp byte) bool
- func IsTypeFractionable(tp byte) bool
- func IsTypePrefixable(tp byte) bool
- func IsTypeTime(tp byte) bool
- func IsTypeVarchar(tp byte) bool
- func MergeFieldType(a byte, b byte) byte
- func MulInt64(a int64, b int64) (int64, error)
- func MulInteger(a uint64, b int64) (uint64, error)
- func MulUint64(a uint64, b uint64) (uint64, error)
- func ParseHexStr(s string) (string, error)
- func ParseStringToBitValue(s string, width int) (uint64, error)
- func ParseYear(str string) (int16, error)
- func ProduceFloatWithSpecifiedTp(f float64, target *FieldType, sc *variable.StatementContext) (_ float64, err error)
- func ProduceStrWithSpecifiedTp(s string, tp *FieldType, sc *variable.StatementContext) (_ string, err error)
- func Round(f float64, dec int) float64
- func RoundFloat(f float64) float64
- func RoundFrac(t gotime.Time, fsp int) (gotime.Time, error)
- func SetBinChsClnFlag(ft *FieldType)
- func SortDatums(sc *variable.StatementContext, datums []Datum) error
- func StrToFloat(sc *variable.StatementContext, str string) (float64, error)
- func StrToInt(sc *variable.StatementContext, str string) (int64, error)
- func StrToUint(sc *variable.StatementContext, str string) (uint64, error)
- func SubInt64(a int64, b int64) (int64, error)
- func SubIntWithUint(a int64, b uint64) (uint64, error)
- func SubUint64(a uint64, b uint64) (uint64, error)
- func SubUintWithInt(a uint64, b int64) (uint64, error)
- func TimestampDiff(unit string, t1 Time, t2 Time) int64
- func ToString(value interface{}) (string, error)
- func Truncate(f float64, dec int) float64
- func TruncateFloat(f float64, flen int, decimal int) (float64, error)
- func TypeStr(tp byte) (r string)
- func TypeToStr(tp byte, cs string) (r string)
- type Bit
- type ColumnRange
- type Datum
- func CoerceArithmetic(sc *variable.StatementContext, a Datum) (d Datum, err error)
- func CoerceDatum(sc *variable.StatementContext, a, b Datum) (x, y Datum, err error)
- func ComputeBitAnd(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
- func ComputeBitNeg(sc *variable.StatementContext, a Datum) (d Datum, err error)
- func ComputeBitOr(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
- func ComputeBitXor(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
- func ComputeDiv(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
- func ComputeIntDiv(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
- func ComputeLeftShift(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
- func ComputeMinus(a, b Datum) (d Datum, err error)
- func ComputeMod(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
- func ComputeMul(a, b Datum) (d Datum, err error)
- func ComputePlus(a, b Datum) (d Datum, err error)
- func ComputeRightShift(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
- func MakeDatums(args ...interface{}) []Datum
- func MaxValueDatum() Datum
- func MinNotNullDatum() Datum
- func NewBytesDatum(b []byte) (d Datum)
- func NewDatum(in interface{}) (d Datum)
- func NewDecimalDatum(dec *MyDecimal) (d Datum)
- func NewDurationDatum(dur Duration) (d Datum)
- func NewFloat32Datum(f float32) (d Datum)
- func NewFloat64Datum(f float64) (d Datum)
- func NewIntDatum(i int64) (d Datum)
- func NewRawDatum(b []byte) (d Datum)
- func NewStringDatum(s string) (d Datum)
- func NewUintDatum(i uint64) (d Datum)
- func (d *Datum) Cast(sc *variable.StatementContext, target *FieldType) (ad Datum, err error)
- func (d *Datum) Collation() byte
- func (d *Datum) CompareDatum(sc *variable.StatementContext, ad Datum) (int, error)
- func (d *Datum) ConvertTo(sc *variable.StatementContext, target *FieldType) (Datum, error)
- func (d *Datum) Frac() int
- func (d *Datum) GetBytes() []byte
- func (d *Datum) GetFloat32() float32
- func (d *Datum) GetFloat64() float64
- func (d *Datum) GetInt64() int64
- func (d *Datum) GetInterface() interface{}
- func (d *Datum) GetMysqlBit() Bit
- func (d *Datum) GetMysqlDecimal() *MyDecimal
- func (d *Datum) GetMysqlDuration() Duration
- func (d *Datum) GetMysqlEnum() Enum
- func (d *Datum) GetMysqlHex() Hex
- func (d *Datum) GetMysqlJSON() json.JSON
- func (d *Datum) GetMysqlSet() Set
- func (d *Datum) GetMysqlTime() Time
- func (d *Datum) GetRaw() []byte
- func (d *Datum) GetRow() []Datum
- func (d *Datum) GetString() string
- func (d *Datum) GetUint64() uint64
- func (d *Datum) GetValue() interface{}
- func (d *Datum) IsNull() bool
- func (d *Datum) Kind() byte
- func (d *Datum) Length() int
- func (d *Datum) SetBytes(b []byte)
- func (d *Datum) SetBytesAsString(b []byte)
- func (d *Datum) SetCollation(collation byte)
- func (d *Datum) SetFloat32(f float32)
- func (d *Datum) SetFloat64(f float64)
- func (d *Datum) SetFrac(frac int)
- func (d *Datum) SetInt64(i int64)
- func (d *Datum) SetInterface(x interface{})
- func (d *Datum) SetLength(l int)
- func (d *Datum) SetMysqlBit(b Bit)
- func (d *Datum) SetMysqlDecimal(b *MyDecimal)
- func (d *Datum) SetMysqlDuration(b Duration)
- func (d *Datum) SetMysqlEnum(b Enum)
- func (d *Datum) SetMysqlHex(b Hex)
- func (d *Datum) SetMysqlJSON(b json.JSON)
- func (d *Datum) SetMysqlSet(b Set)
- func (d *Datum) SetMysqlTime(b Time)
- func (d *Datum) SetNull()
- func (d *Datum) SetRaw(b []byte)
- func (d *Datum) SetRow(ds []Datum)
- func (d *Datum) SetString(s string)
- func (d *Datum) SetUint64(i uint64)
- func (d *Datum) SetValue(val interface{})
- func (d *Datum) ToBool(sc *variable.StatementContext) (int64, error)
- func (d *Datum) ToBytes() ([]byte, error)
- func (d *Datum) ToDecimal(sc *variable.StatementContext) (*MyDecimal, error)
- func (d *Datum) ToFloat64(sc *variable.StatementContext) (float64, error)
- func (d *Datum) ToInt64(sc *variable.StatementContext) (int64, error)
- func (d *Datum) ToMysqlJSON() (j json.JSON, err error)
- func (d *Datum) ToString() (string, error)
- type Duration
- func (d Duration) Add(v Duration) (Duration, error)
- func (d Duration) Compare(o Duration) int
- func (d Duration) CompareString(str string) (int, error)
- func (d Duration) ConvertToTime(tp uint8) (Time, error)
- func (d Duration) Hour() int
- func (d Duration) MicroSecond() int
- func (d Duration) Minute() int
- func (d Duration) RoundFrac(fsp int) (Duration, error)
- func (d Duration) Second() int
- func (d Duration) String() string
- func (d Duration) Sub(v Duration) (Duration, error)
- func (d Duration) ToNumber() *MyDecimal
- type Enum
- type FieldType
- type Hex
- type IndexRange
- func (ir *IndexRange) Align(numColumns int)
- func (ir *IndexRange) Convert2ColumnRange() *ColumnRange
- func (ir *IndexRange) Convert2IndexRange() *IndexRange
- func (ir *IndexRange) Convert2IntRange() IntColumnRange
- func (ir *IndexRange) IsPoint(sc *variable.StatementContext) bool
- func (ir *IndexRange) PrefixEqualLen(sc *variable.StatementContext) (int, error)
- func (ir *IndexRange) String() string
- type IntColumnRange
- type MyDecimal
- func ConvertDatumToDecimal(sc *variable.StatementContext, d Datum) (*MyDecimal, error)
- func NewDecFromFloatForTest(f float64) *MyDecimal
- func NewDecFromInt(i int64) *MyDecimal
- func NewDecFromStringForTest(s string) *MyDecimal
- func NewDecFromUint(i uint64) *MyDecimal
- func NewMaxOrMinDec(negative bool, prec, frac int) *MyDecimal
- func ProduceDecWithSpecifiedTp(dec *MyDecimal, tp *FieldType, sc *variable.StatementContext) (_ *MyDecimal, err error)
- func (d *MyDecimal) Compare(to *MyDecimal) int
- func (d *MyDecimal) FromBin(bin []byte, precision, frac int) (binSize int, err error)
- func (d *MyDecimal) FromFloat64(f float64) error
- func (d *MyDecimal) FromInt(val int64) *MyDecimal
- func (d *MyDecimal) FromString(str []byte) error
- func (d *MyDecimal) FromUint(val uint64) *MyDecimal
- func (d *MyDecimal) GetDigitsFrac() int8
- func (d *MyDecimal) IsNegative() bool
- func (d *MyDecimal) IsZero() bool
- func (d *MyDecimal) PrecisionAndFrac() (precision, frac int)
- func (d *MyDecimal) Round(to *MyDecimal, frac int, roundMode RoundMode) (err error)
- func (d *MyDecimal) Shift(shift int) error
- func (d *MyDecimal) String() string
- func (d *MyDecimal) ToBin(precision, frac int) ([]byte, error)
- func (d *MyDecimal) ToFloat64() (float64, error)
- func (d *MyDecimal) ToInt() (int64, error)
- func (d *MyDecimal) ToString() (str []byte)
- func (d *MyDecimal) ToUint() (uint64, error)
- type Range
- type RoundMode
- type Set
- type Time
- func CurrentTime(tp uint8) Time
- func ParseDate(str string) (Time, error)
- func ParseDateFromNum(num int64) (Time, error)
- func ParseDatetime(str string) (Time, error)
- func ParseDatetimeFromNum(num int64) (Time, error)
- func ParseTime(str string, tp byte, fsp int) (Time, error)
- func ParseTimeFromInt64(num int64) (Time, error)
- func ParseTimeFromNum(num int64, tp byte, fsp int) (Time, error)
- func ParseTimestamp(str string) (Time, error)
- func ParseTimestampFromNum(num int64) (Time, error)
- func TimeFromDays(num int64) Time
- func (t *Time) Add(d Duration) Duration
- func (t *Time) Check() error
- func (t Time) Clock() (hour int, minute int, second int)
- func (t Time) Compare(o Time) int
- func (t Time) CompareString(str string) (int, error)
- func (t Time) Convert(tp uint8) (Time, error)
- func (t *Time) ConvertTimeZone(from, to *gotime.Location) error
- func (t Time) ConvertToDuration() (Duration, error)
- func (t Time) DateFormat(layout string) (string, error)
- func (t *Time) FromPackedUint(packed uint64) error
- func (t Time) InvalidZero() bool
- func (t Time) IsZero() bool
- func (t Time) RoundFrac(fsp int) (Time, error)
- func (t *Time) StrToDate(date, format string) bool
- func (t Time) String() string
- func (t *Time) Sub(t1 *Time) Duration
- func (t Time) ToNumber() *MyDecimal
- func (t Time) ToPackedUint() (uint64, error)
- type TimeInternal
- type TypeClass
Constants ¶
const ( MinBitWidth = 1 MaxBitWidth = 64 // UnspecifiedBitWidth is the unspecified with if you want to calculate bit width dynamically. UnspecifiedBitWidth = -1 )
Min and Max bit width.
const ( KindNull byte = 0 KindInt64 byte = 1 KindUint64 byte = 2 KindFloat32 byte = 3 KindFloat64 byte = 4 KindString byte = 5 KindBytes byte = 6 KindMysqlBit byte = 7 KindMysqlDecimal byte = 8 KindMysqlDuration byte = 9 KindMysqlEnum byte = 10 KindMysqlHex byte = 11 KindMysqlSet byte = 12 KindMysqlTime byte = 13 KindRow byte = 14 KindInterface byte = 15 KindMinNotNull byte = 16 KindMaxValue byte = 17 KindRaw byte = 18 KindMysqlJSON byte = 19 )
Kind constants.
const ( // UnspecifiedFsp is the unspecified fractional seconds part. UnspecifiedFsp int = -1 // MaxFsp is the maximum digit of fractional seconds part. MaxFsp int = 6 // MinFsp is the minimum digit of fractional seconds part. MinFsp int = 0 // DefaultFsp is the default digit of fractional seconds part. // MySQL use 0 as the default Fsp. DefaultFsp int = 0 )
const ( MaxFraction = 30 DivFracIncr = 4 // ModeHalfEven rounds normally. ModeHalfEven RoundMode = "ModeHalfEven" // Truncate just truncates the decimal. ModeTruncate RoundMode = "Truncate" )
constant values.
const ( DateFormat = "2006-01-02" TimeFormat = "2006-01-02 15:04:05" // TimeFSPFormat is time format with fractional seconds precision. TimeFSPFormat = "2006-01-02 15:04:05.000000" )
Time format without fractional seconds precision.
const ( // MinYear is the minimum for mysql year type. MinYear int16 = 1901 // MaxYear is the maximum for mysql year type. MaxYear int16 = 2155 // MinTime is the minimum for mysql time type. MinTime = -gotime.Duration(838*3600+59*60+59) * gotime.Second // MaxTime is the maximum for mysql time type. MaxTime = gotime.Duration(838*3600+59*60+59) * gotime.Second )
const (
UnspecifiedLength int = -1
)
UnspecifiedLength is unspecified length.
Variables ¶
var ( // ErrDataTooLong is returned when converts a string value that is longer than field type length. ErrDataTooLong = terror.ClassTypes.New(codeDataTooLong, "Data Too Long") // ErrTruncated is returned when data has been truncated during conversion. ErrTruncated = terror.ClassTypes.New(codeTruncated, "Data Truncated") // ErrOverflow is returned when data is out of range for a field type. ErrOverflow = terror.ClassTypes.New(codeOverflow, msgOverflow) // ErrDivByZero is return when do division by 0. ErrDivByZero = terror.ClassTypes.New(codeDivByZero, "Division by 0") // ErrBadNumber is return when parsing an invalid binary decimal number. ErrBadNumber = terror.ClassTypes.New(codeBadNumber, "Bad Number") )
var ( ErrInvalidTimeFormat = errors.New("invalid time format") ErrInvalidYearFormat = errors.New("invalid year format") ErrInvalidYear = errors.New("invalid year") )
Portable analogs of some common call errors.
var ( // ZeroDuration is the zero value for Duration type. ZeroDuration = Duration{Duration: gotime.Duration(0), Fsp: DefaultFsp} // ZeroTime is the zero value for TimeInternal type. ZeroTime = mysqlTime{} // ZeroDatetime is the zero value for datetime Time. ZeroDatetime = Time{ Time: ZeroTime, Type: mysql.TypeDatetime, Fsp: DefaultFsp, } // ZeroTimestamp is the zero value for timestamp Time. ZeroTimestamp = Time{ Time: ZeroTime, Type: mysql.TypeTimestamp, Fsp: DefaultFsp, } // ZeroDate is the zero value for date Time. ZeroDate = Time{ Time: ZeroTime, Type: mysql.TypeDate, Fsp: DefaultFsp, } )
Zero values for different types.
var ( // WeekdayNames lists names of weekdays, which are used in builtin time function `dayname`. WeekdayNames = []string{ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", } // MonthNames lists names of months, which are used in builtin time function `monthname`. MonthNames = []string{ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", } )
var SignedLowerBound = map[byte]int64{ mysql.TypeTiny: math.MinInt8, mysql.TypeShort: math.MinInt16, mysql.TypeInt24: mysql.MinInt24, mysql.TypeLong: math.MinInt32, mysql.TypeLonglong: math.MinInt64, }
SignedLowerBound indicates the min int64 values of different mysql types.
var SignedUpperBound = map[byte]int64{ mysql.TypeTiny: math.MaxInt8, mysql.TypeShort: math.MaxInt16, mysql.TypeInt24: mysql.MaxInt24, mysql.TypeLong: math.MaxInt32, mysql.TypeLonglong: math.MaxInt64, }
SignedUpperBound indicates the max int64 values of different mysql types.
var UnsignedUpperBound = map[byte]uint64{ mysql.TypeTiny: math.MaxUint8, mysql.TypeShort: math.MaxUint16, mysql.TypeInt24: mysql.MaxUint24, mysql.TypeLong: math.MaxUint32, mysql.TypeLonglong: math.MaxUint64, mysql.TypeBit: math.MaxUint64, mysql.TypeEnum: math.MaxUint64, mysql.TypeSet: math.MaxUint64, }
UnsignedUpperBound indicates the max uint64 values of different mysql types.
Functions ¶
func AddInteger ¶
AddInteger adds uint64 a and int64 b and returns uint64 if no overflow error.
func AdjustYear ¶
AdjustYear is used for adjusting year and checking its validation.
func CompareFloat64 ¶
CompareFloat64 returns an integer comparing the float64 x to y.
func CompareInt64 ¶
CompareInt64 returns an integer comparing the int64 x to y.
func CompareString ¶
CompareString returns an integer comparing the string x to y.
func CompareUint64 ¶
CompareUint64 returns an integer comparing the uint64 x to y.
func ConvertFloatToInt ¶
func ConvertFloatToInt(sc *variable.StatementContext, fval float64, lowerBound, upperBound int64, tp byte) (int64, error)
ConvertFloatToInt converts a float64 value to a int value.
func ConvertFloatToUint ¶
func ConvertFloatToUint(sc *variable.StatementContext, fval float64, upperBound uint64, tp byte) (uint64, error)
ConvertFloatToUint converts a float value to an uint value.
func ConvertIntToInt ¶
ConvertIntToInt converts an int value to another int value of different precision.
func ConvertIntToUint ¶
ConvertIntToUint converts an int value to an uint value.
func ConvertUintToInt ¶
ConvertUintToInt converts an uint value to an int value.
func ConvertUintToUint ¶
ConvertUintToUint converts an uint value to another uint value of different precision.
func DateDiff ¶
func DateDiff(startTime, endTime TimeInternal) int
DateDiff calculates number of days between two days.
func DatumsToInterfaces ¶
func DatumsToInterfaces(datums []Datum) []interface{}
DatumsToInterfaces converts a datum slice to interface slice.
func DatumsToString ¶
DatumsToString converts several datums to formatted string.
func DecimalAdd ¶
DecimalAdd adds two decimals, sets the result to 'to'.
func DecimalDiv ¶
DecimalDiv does division of two decimals.
from1 - dividend from2 - divisor to - quotient fracIncr - increment of fraction
func DecimalMod ¶
DecimalMod does modulus of two decimals.
from1 - dividend from2 - divisor to - modulus RETURN VALUE E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW/E_DEC_DIV_ZERO; NOTES see do_div_mod() DESCRIPTION the modulus R in R = M mod N is defined as 0 <= |R| < |M| sign R == sign M R = M - k*N, where k is integer thus, there's no requirement for M or N to be integers
func DecimalMul ¶
DecimalMul multiplies two decimals.
from1, from2 - factors to - product RETURN VALUE E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW; NOTES in this implementation, with wordSize=4 we have digitsPerWord=9, and 63-digit number will take only 7 words (basically a 7-digit "base 999999999" number). Thus there's no need in fast multiplication algorithms, 7-digit numbers can be multiplied with a naive O(n*n) method. XXX if this library is to be used with huge numbers of thousands of digits, fast multiplication must be implemented.
func DecimalPeak ¶
DecimalPeak returns the length of the encoded decimal.
func DecimalSub ¶
DecimalSub subs one decimal from another, sets the result to 'to'.
func DefaultCharsetForType ¶
DefaultCharsetForType returns the default charset/collation for mysql type.
func DefaultTypeForValue ¶
func DefaultTypeForValue(value interface{}, tp *FieldType)
DefaultTypeForValue returns the default FieldType for the value.
func DivInt64 ¶
DivInt64 divides int64 a with b, returns int64 if no overflow error. It just checks overflow, if b is zero, a "divide by zero" panic throws.
func DivIntWithUint ¶
DivIntWithUint divides int64 a with uint64 b, returns uint64 if no overflow error. It just checks overflow, if b is zero, a "divide by zero" panic throws.
func DivUintWithInt ¶
DivUintWithInt divides uint64 a with int64 b, returns uint64 if no overflow error. It just checks overflow, if b is zero, a "divide by zero" panic throws.
func EqualDatums ¶
EqualDatums compare if a and b contains the same datum values.
func ExtractTimeNum ¶
ExtractTimeNum extracts time value number from time unit and format.
func ExtractTimeValue ¶
ExtractTimeValue extracts time value from time unit and format.
func IsBinaryStr ¶
IsBinaryStr returns a boolean indicating whether the field type is a binary string type.
func IsClockUnit ¶
IsClockUnit returns true when unit is interval unit with hour, minute or second.
func IsDateFormat ¶
IsDateFormat returns true when the specified time format could contain only date.
func IsTypeBlob ¶
IsTypeBlob returns a boolean indicating whether the tp is a blob type.
func IsTypeChar ¶
IsTypeChar returns a boolean indicating whether the tp is the char type like a string type or a varchar type.
func IsTypeFractionable ¶
IsTypeFractionable returns a boolean indicating whether the tp can has time fraction.
func IsTypePrefixable ¶
IsTypePrefixable returns a boolean indicating whether an index on a column with the tp can be defined with a prefix.
func IsTypeTime ¶
IsTypeTime returns a boolean indicating whether the tp is time type like datetime, date or timestamp.
func IsTypeVarchar ¶
IsTypeVarchar returns a boolean indicating whether the tp is the varchar type like a varstring type or a varchar type.
func MergeFieldType ¶
MergeFieldType merges two MySQL type to a new type. This is used in hybrid field type expression. For example "select case c when 1 then 2 when 2 then 'tidb' from t;" The result field type of the case expression is the merged type of the two when clause. See https://github.com/mysql/mysql-server/blob/5.7/sql/field.cc#L1042
func MulInteger ¶
MulInteger multiplies uint64 a and int64 b, and returns uint64 if no overflow error.
func ParseHexStr ¶
ParseHexStr parses hexadecimal literal as string. See https://dev.mysql.com/doc/refman/5.7/en/hexadecimal-literals.html
func ParseStringToBitValue ¶
ParseStringToBitValue parses the string for bit type into uint64.
func ProduceFloatWithSpecifiedTp ¶
func ProduceFloatWithSpecifiedTp(f float64, target *FieldType, sc *variable.StatementContext) (_ float64, err error)
ProduceFloatWithSpecifiedTp produces a new float64 according to `flen` and `decimal`.
func ProduceStrWithSpecifiedTp ¶
func ProduceStrWithSpecifiedTp(s string, tp *FieldType, sc *variable.StatementContext) (_ string, err error)
ProduceStrWithSpecifiedTp produces a new string according to `flen` and `chs`.
func Round ¶
Round rounds the argument f to dec decimal places. dec defaults to 0 if not specified. dec can be negative to cause dec digits left of the decimal point of the value f to become zero.
func RoundFloat ¶
RoundFloat rounds float val to the nearest integer value with float64 format, like MySQL Round function. RoundFloat uses default rounding mode, see https://dev.mysql.com/doc/refman/5.7/en/precision-math-rounding.html so rounding use "round half away from zero". e.g, 1.5 -> 2, -1.5 -> -2.
func RoundFrac ¶
RoundFrac rounds fractional seconds precision with new fsp and returns a new one. We will use the “round half up” rule, e.g, >= 0.5 -> 1, < 0.5 -> 0, so 2011:11:11 10:10:10.888888 round 0 -> 2011:11:11 10:10:11 and 2011:11:11 10:10:10.111111 round 0 -> 2011:11:11 10:10:10
func SetBinChsClnFlag ¶
func SetBinChsClnFlag(ft *FieldType)
SetBinChsClnFlag sets charset, collation as 'binary' and adds binaryFlag to FieldType.
func SortDatums ¶
func SortDatums(sc *variable.StatementContext, datums []Datum) error
SortDatums sorts a slice of datum.
func StrToFloat ¶
func StrToFloat(sc *variable.StatementContext, str string) (float64, error)
StrToFloat converts a string to a float64 at the best-effort.
func StrToInt ¶
func StrToInt(sc *variable.StatementContext, str string) (int64, error)
StrToInt converts a string to an integer at the best-effort.
func StrToUint ¶
func StrToUint(sc *variable.StatementContext, str string) (uint64, error)
StrToUint converts a string to an unsigned integer at the best-effortt.
func SubIntWithUint ¶
SubIntWithUint subtracts int64 a with uint64 b and returns uint64 if no overflow error.
func SubUintWithInt ¶
SubUintWithInt subtracts uint64 a with int64 b and returns uint64 if no overflow error.
func TimestampDiff ¶
TimestampDiff returns t2 - t1 where t1 and t2 are date or datetime expressions. The unit for the result (an integer) is given by the unit argument. The legal values for unit are "YEAR" "QUARTER" "MONTH" "DAY" "HOUR" "SECOND" and so on.
func Truncate ¶
Truncate truncates the argument f to dec decimal places. dec defaults to 0 if not specified. dec can be negative to cause dec digits left of the decimal point of the value f to become zero.
func TruncateFloat ¶
TruncateFloat tries to truncate f. If the result exceeds the max/min float that flen/decimal allowed, returns the max/min float allowed.
Types ¶
type Bit ¶
type Bit struct { // Value holds the value for bit type. Value uint64 // Width is the display with for bit value. // e.g, with is 8, 0 is for 0b00000000. Width int }
Bit is for mysql bit type.
func ParseBit ¶
ParseBit parses bit string. The string format can be b'val', B'val' or 0bval, val must be 0 or 1. Width is the display width for bit representation. -1 means calculating width dynamically, using following algorithm: (len("011101") + 7) & ^7, e.g, if bit string is 0b01, the above will return 8 for its bit width.
type ColumnRange ¶
ColumnRange represents a range for a column.
func (*ColumnRange) Convert2ColumnRange ¶
func (cr *ColumnRange) Convert2ColumnRange() *ColumnRange
Convert2ColumnRange implements the Convert2ColumnRange interface.
func (*ColumnRange) Convert2IndexRange ¶
func (cr *ColumnRange) Convert2IndexRange() *IndexRange
Convert2IndexRange implements the Convert2IndexRange interface.
func (*ColumnRange) Convert2IntRange ¶
func (cr *ColumnRange) Convert2IntRange() IntColumnRange
Convert2IntRange implements the Convert2IntRange interface.
func (*ColumnRange) String ¶
func (cr *ColumnRange) String() string
type Datum ¶
type Datum struct {
// contains filtered or unexported fields
}
Datum is a data box holds different kind of data. It has better performance and is easier to use than `interface{}`.
func CoerceArithmetic ¶
func CoerceArithmetic(sc *variable.StatementContext, a Datum) (d Datum, err error)
CoerceArithmetic converts datum to appropriate datum for arithmetic computing.
func CoerceDatum ¶
func CoerceDatum(sc *variable.StatementContext, a, b Datum) (x, y Datum, err error)
CoerceDatum changes type. If a or b is Float, changes the both to Float. Else if a or b is Decimal, changes the both to Decimal. Else if a or b is Uint and op is not div, mod, or intDiv changes the both to Uint.
func ComputeBitAnd ¶
func ComputeBitAnd(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
ComputeBitAnd computes the result of a & b.
func ComputeBitNeg ¶
func ComputeBitNeg(sc *variable.StatementContext, a Datum) (d Datum, err error)
ComputeBitNeg computes the result of ~a.
func ComputeBitOr ¶
func ComputeBitOr(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
ComputeBitOr computes the result of a | b.
func ComputeBitXor ¶
func ComputeBitXor(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
ComputeBitXor computes the result of a ^ b.
func ComputeDiv ¶
func ComputeDiv(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
ComputeDiv computes the result of a/b.
func ComputeIntDiv ¶
func ComputeIntDiv(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
ComputeIntDiv computes the result of a / b, both a and b are integer.
func ComputeLeftShift ¶
func ComputeLeftShift(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
ComputeLeftShift computes the result of a >> b.
func ComputeMinus ¶
ComputeMinus computes the result of a-b.
func ComputeMod ¶
func ComputeMod(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
ComputeMod computes the result of a mod b.
func ComputeMul ¶
ComputeMul computes the result of a*b.
func ComputePlus ¶
ComputePlus computes the result of a+b.
func ComputeRightShift ¶
func ComputeRightShift(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
ComputeRightShift computes the result of a << b.
func MakeDatums ¶
func MakeDatums(args ...interface{}) []Datum
MakeDatums creates datum slice from interfaces.
func MinNotNullDatum ¶
func MinNotNullDatum() Datum
MinNotNullDatum returns a datum represents minimum not null value.
func NewBytesDatum ¶
NewBytesDatum creates a new Datum from a byte slice.
func NewDatum ¶
func NewDatum(in interface{}) (d Datum)
NewDatum creates a new Datum from an interface{}.
func NewDecimalDatum ¶
NewDecimalDatum creates a new Datum form a MyDecimal value.
func NewDurationDatum ¶
NewDurationDatum creates a new Datum from a Duration value.
func NewFloat32Datum ¶
NewFloat32Datum creates a new Datum from a float32 value.
func NewFloat64Datum ¶
NewFloat64Datum creates a new Datum from a float64 value.
func NewIntDatum ¶
NewIntDatum creates a new Datum from an int64 value.
func NewRawDatum ¶
NewRawDatum create a new Datum that is not decoded.
func NewStringDatum ¶
NewStringDatum creates a new Datum from a string.
func NewUintDatum ¶
NewUintDatum creates a new Datum from an uint64 value.
func (*Datum) CompareDatum ¶
CompareDatum compares datum to another datum. TODO: return error properly.
func (*Datum) GetInterface ¶
func (d *Datum) GetInterface() interface{}
GetInterface gets interface value.
func (*Datum) GetMysqlDecimal ¶
GetMysqlDecimal gets Decimal value
func (*Datum) GetMysqlDuration ¶
GetMysqlDuration gets Duration value
func (*Datum) GetMysqlJSON ¶
GetMysqlJSON gets json.JSON value
func (*Datum) GetValue ¶
func (d *Datum) GetValue() interface{}
GetValue gets the value of the datum of any kind.
func (*Datum) SetBytesAsString ¶
SetBytesAsString sets bytes value to datum as string type.
func (*Datum) SetCollation ¶
SetCollation sets the collation of the datum.
func (*Datum) SetInterface ¶
func (d *Datum) SetInterface(x interface{})
SetInterface sets interface to datum.
func (*Datum) SetMysqlDecimal ¶
SetMysqlDecimal sets Decimal value
func (*Datum) SetMysqlDuration ¶
SetMysqlDuration sets Duration value
func (*Datum) SetMysqlJSON ¶
SetMysqlJSON sets json.JSON value
func (*Datum) SetMysqlTime ¶
SetMysqlTime sets types.Time value
func (*Datum) ToBool ¶
func (d *Datum) ToBool(sc *variable.StatementContext) (int64, error)
ToBool converts to a bool. We will use 1 for true, and 0 for false.
func (*Datum) ToDecimal ¶
func (d *Datum) ToDecimal(sc *variable.StatementContext) (*MyDecimal, error)
ToDecimal converts to a decimal.
func (*Datum) ToFloat64 ¶
func (d *Datum) ToFloat64(sc *variable.StatementContext) (float64, error)
ToFloat64 converts to a float64
func (*Datum) ToInt64 ¶
func (d *Datum) ToInt64(sc *variable.StatementContext) (int64, error)
ToInt64 converts to a int64.
func (*Datum) ToMysqlJSON ¶
ToMysqlJSON is similar to convertToMysqlJSON, except the latter parses from string, but the former uses it as primitive.
type Duration ¶
type Duration struct { gotime.Duration // Fsp is short for Fractional Seconds Precision. // See http://dev.mysql.com/doc/refman/5.7/en/fractional-seconds.html Fsp int }
Duration is the type for MySQL time type.
func ParseDuration ¶
ParseDuration parses the time form a formatted string with a fractional seconds part, returns the duration type Time value. See http://dev.mysql.com/doc/refman/5.7/en/fractional-seconds.html
func (Duration) Compare ¶
Compare returns an integer comparing the Duration instant t to o. If d is after o, return 1, equal o, return 0, before o, return -1.
func (Duration) CompareString ¶
CompareString is like Compare, but parses str to Duration then compares.
func (Duration) ConvertToTime ¶
ConvertToTime converts duration to Time. Tp is TypeDatetime, TypeTimestamp and TypeDate.
func (Duration) MicroSecond ¶
MicroSecond returns current microsecond. e.g, hour("11:11:11.11") -> 110000
func (Duration) RoundFrac ¶
RoundFrac rounds fractional seconds precision with new fsp and returns a new one. We will use the “round half up” rule, e.g, >= 0.5 -> 1, < 0.5 -> 0, so 10:10:10.999999 round 0 -> 10:10:11 and 10:10:10.000000 round 0 -> 10:10:10
type Enum ¶
Enum is for MySQL enum type.
func ParseEnumName ¶
ParseEnumName creates a Enum with item name.
func ParseEnumValue ¶
ParseEnumValue creates a Enum with special number.
type FieldType ¶
type FieldType struct { Tp byte Flag uint Flen int Decimal int Charset string Collate string // Elems is the element list for enum and set type. Elems []string }
FieldType records field type information.
func NewFieldType ¶
NewFieldType returns a FieldType, with a type and other information about field type.
func (*FieldType) CompactStr ¶
CompactStr only considers Tp/CharsetBin/Flen/Deimal. This is used for showing column type in infoschema.
type Hex ¶
type Hex struct { // Value holds numeric value for hexadecimal literal. Value int64 }
Hex is for mysql hexadecimal literal type.
func ParseHex ¶
ParseHex parses hexadecimal literal string. The string format can be X'val', x'val' or 0xval. val must in (0...9, a...f, A...F).
type IndexRange ¶
type IndexRange struct { LowVal []Datum HighVal []Datum LowExclude bool // Low value is exclusive. HighExclude bool // High value is exclusive. }
IndexRange represents a range for an index.
func (*IndexRange) Align ¶
func (ir *IndexRange) Align(numColumns int)
Align appends low value and high value up to the number of columns with max value, min not null value or null value.
func (*IndexRange) Convert2ColumnRange ¶
func (ir *IndexRange) Convert2ColumnRange() *ColumnRange
Convert2ColumnRange implements the Convert2ColumnRange interface.
func (*IndexRange) Convert2IndexRange ¶
func (ir *IndexRange) Convert2IndexRange() *IndexRange
Convert2IndexRange implements the Convert2IndexRange interface.
func (*IndexRange) Convert2IntRange ¶
func (ir *IndexRange) Convert2IntRange() IntColumnRange
Convert2IntRange implements the Convert2IntRange interface.
func (*IndexRange) IsPoint ¶
func (ir *IndexRange) IsPoint(sc *variable.StatementContext) bool
IsPoint returns if the index range is a point.
func (*IndexRange) PrefixEqualLen ¶
func (ir *IndexRange) PrefixEqualLen(sc *variable.StatementContext) (int, error)
PrefixEqualLen tells you how long the prefix of the range is a point. e.g. If this range is (1 2 3, 1 2 +inf), then the return value is 2.
func (*IndexRange) String ¶
func (ir *IndexRange) String() string
Convert2IndexRange implements the Convert2IndexRange interface.
type IntColumnRange ¶
IntColumnRange represents a range for a integer column, both low and high are inclusive.
func (IntColumnRange) Convert2ColumnRange ¶
func (tr IntColumnRange) Convert2ColumnRange() *ColumnRange
Convert2ColumnRange implements the Convert2ColumnRange interface.
func (IntColumnRange) Convert2IndexRange ¶
func (tr IntColumnRange) Convert2IndexRange() *IndexRange
Convert2IndexRange implements the Convert2IndexRange interface.
func (IntColumnRange) Convert2IntRange ¶
func (tr IntColumnRange) Convert2IntRange() IntColumnRange
Convert2IntRange implements the Convert2IntRange interface.
func (*IntColumnRange) IsPoint ¶
func (tr *IntColumnRange) IsPoint() bool
IsPoint returns if the table range is a point.
func (IntColumnRange) String ¶
func (tr IntColumnRange) String() string
type MyDecimal ¶
type MyDecimal struct {
// contains filtered or unexported fields
}
MyDecimal represents a decimal value.
func ConvertDatumToDecimal ¶
func ConvertDatumToDecimal(sc *variable.StatementContext, d Datum) (*MyDecimal, error)
ConvertDatumToDecimal converts datum to decimal.
func NewDecFromFloatForTest ¶
NewDecFromFloatForTest creates a MyDecimal from float, as it returns no error, it should only be used in test.
func NewDecFromInt ¶
NewDecFromInt creates a MyDecimal from int.
func NewDecFromStringForTest ¶
NewDecFromStringForTest creates a MyDecimal from string, as it returns no error, it should only be used in test.
func NewDecFromUint ¶
NewDecFromUint creates a MyDecimal from uint.
func NewMaxOrMinDec ¶
NewMaxOrMinDec returns the max or min value decimal for given precision and fraction.
func ProduceDecWithSpecifiedTp ¶
func ProduceDecWithSpecifiedTp(dec *MyDecimal, tp *FieldType, sc *variable.StatementContext) (_ *MyDecimal, err error)
ProduceDecWithSpecifiedTp produces a new decimal according to `flen` and `decimal`.
func (*MyDecimal) FromFloat64 ¶
FromFloat64 creates a decimal from float64 value.
func (*MyDecimal) FromString ¶
FromString parses decimal from string.
func (*MyDecimal) GetDigitsFrac ¶
GetDigitsFrac returns the digitsFrac.
func (*MyDecimal) IsNegative ¶
IsNegative returns whether a decimal is negative.
func (*MyDecimal) PrecisionAndFrac ¶
PrecisionAndFrac returns the internal precision and frac number.
func (*MyDecimal) Round ¶
Round rounds the decimal to "frac" digits.
to - result buffer. d == to is allowed frac - to what position after fraction point to round. can be negative! roundMode - round to nearest even or truncate ModeHalfEven rounds normally. Truncate just truncates the decimal.
NOTES
scale can be negative ! one TRUNCATED error (line XXX below) isn't treated very logical :(
RETURN VALUE
eDecOK/eDecTruncated
func (*MyDecimal) Shift ¶
Shift shifts decimal digits in given number (with rounding if it need), shift > 0 means shift to left shift, shift < 0 means right shift. In fact it is multiplying on 10^shift.
RETURN
eDecOK OK eDecOverflow operation lead to overflow, number is untoched eDecTruncated number was rounded to fit into buffer
func (*MyDecimal) ToBin ¶
ToBin converts decimal to its binary fixed-length representation two representations of the same length can be compared with memcmp with the correct -1/0/+1 result
PARAMS precision/frac - if precision is 0, internal value of the decimal will be used, then the encoded value is not memory comparable. NOTE the buffer is assumed to be of the size decimalBinSize(precision, frac) RETURN VALUE bin - binary value errCode - eDecOK/eDecTruncate/eDecOverflow DESCRIPTION for storage decimal numbers are converted to the "binary" format. This format has the following properties: 1. length of the binary representation depends on the {precision, frac} as provided by the caller and NOT on the digitsInt/digitsFrac of the decimal to convert. 2. binary representations of the same {precision, frac} can be compared with memcmp - with the same result as DecimalCompare() of the original decimals (not taking into account possible precision loss during conversion). This binary format is as follows: 1. First the number is converted to have a requested precision and frac. 2. Every full digitsPerWord digits of digitsInt part are stored in 4 bytes as is 3. The first digitsInt % digitesPerWord digits are stored in the reduced number of bytes (enough bytes to store this number of digits - see dig2bytes) 4. same for frac - full word are stored as is, the last frac % digitsPerWord digits - in the reduced number of bytes. 5. If the number is negative - every byte is inversed. 5. The very first bit of the resulting byte array is inverted (because memcmp compares unsigned bytes, see property 2 above) Example: 1234567890.1234 internally is represented as 3 words 1 234567890 123400000 (assuming we want a binary representation with precision=14, frac=4) in hex it's 00-00-00-01 0D-FB-38-D2 07-5A-EF-40 now, middle word is full - it stores 9 decimal digits. It goes into binary representation as is: ........... 0D-FB-38-D2 ............ First word has only one decimal digit. We can store one digit in one byte, no need to waste four: 01 0D-FB-38-D2 ............ now, last word. It's 123400000. We can store 1234 in two bytes: 01 0D-FB-38-D2 04-D2 So, we've packed 12 bytes number in 7 bytes. And now we invert the highest bit to get the final result: 81 0D FB 38 D2 04 D2 And for -1234567890.1234 it would be 7E F2 04 C7 2D FB 2D
type Range ¶
type Range interface { fmt.Stringer Convert2IntRange() IntColumnRange Convert2ColumnRange() *ColumnRange Convert2IndexRange() *IndexRange }
Range is the interface of the three type of range.
type Set ¶
Set is for MySQL Set type.
func ParseSetName ¶
ParseSetName creates a Set with name.
func ParseSetValue ¶
ParseSetValue creates a Set with special number.
type Time ¶
type Time struct { Time TimeInternal Type uint8 // Fsp is short for Fractional Seconds Precision. // See http://dev.mysql.com/doc/refman/5.7/en/fractional-seconds.html Fsp int // TODO: Define a type for timestamp, remove its representation from here. // TimeZone is valid when Type is mysql.Timestamp, it's meaningless for date/datetime. TimeZone *gotime.Location }
Time is the struct for handling datetime, timestamp and date. TODO: check if need a NewTime function to set Fsp default value?
func ParseDateFromNum ¶
ParseDateFromNum is a helper function wrapping ParseTimeFromNum with date type.
func ParseDatetime ¶
ParseDatetime is a helper function wrapping ParseTime with datetime type and default fsp.
func ParseDatetimeFromNum ¶
ParseDatetimeFromNum is a helper function wrapping ParseTimeFromNum with datetime type and default fsp.
func ParseTime ¶
ParseTime parses a formatted string with type tp and specific fsp. Type is TypeDatetime, TypeTimestamp and TypeDate. Fsp is in range [0, 6]. MySQL supports many valid datatime format, but still has some limitation. If delimiter exists, the date part and time part is separated by a space or T, other punctuation character can be used as the delimiter between date parts or time parts. If no delimiter, the format must be YYYYMMDDHHMMSS or YYMMDDHHMMSS If we have fractional seconds part, we must use decimal points as the delimiter. The valid datetime range is from '1000-01-01 00:00:00.000000' to '9999-12-31 23:59:59.999999'. The valid timestamp range is from '1970-01-01 00:00:01.000000' to '2038-01-19 03:14:07.999999'. The valid date range is from '1000-01-01' to '9999-12-31'
func ParseTimeFromInt64 ¶
ParseTimeFromInt64 parses mysql time value from int64.
func ParseTimeFromNum ¶
ParseTimeFromNum parses a formatted int64, returns the value which type is tp.
func ParseTimestamp ¶
ParseTimestamp is a helper function wrapping ParseTime with timestamp type and default fsp.
func ParseTimestampFromNum ¶
ParseTimestampFromNum is a helper function wrapping ParseTimeFromNum with timestamp type and default fsp.
func (*Time) Add ¶
Add adds d to t, returns a duration value. Note that add should not be done on different time types.
func (Time) Compare ¶
Compare returns an integer comparing the time instant t to o. If t is after o, return 1, equal o, return 0, before o, return -1.
func (Time) CompareString ¶
CompareString is like Compare, but parses string to Time then compares.
func (*Time) ConvertTimeZone ¶
ConvertTimeZone converts the time value from one timezone to another. The input time should be a valid timestamp.
func (Time) ConvertToDuration ¶
ConvertToDuration converts mysql datetime, timestamp and date to mysql time type. e.g, 2012-12-12T10:10:10 -> 10:10:10 2012-12-12 -> 0
func (Time) DateFormat ¶
DateFormat returns a textual representation of the time value formatted according to layout. See http://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_date-format
func (*Time) FromPackedUint ¶
FromPackedUint decodes Time from a packed uint64 value.
func (Time) InvalidZero ¶
InvalidZero returns a boolean indicating whether the month or day is zero.
func (*Time) StrToDate ¶
StrToDate converts date string according to format. See https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_date-format
func (*Time) Sub ¶
Sub subtracts t1 from t, returns a duration value. Note that sub should not be done on different time types.
func (Time) ToNumber ¶
ToNumber returns a formatted number. e.g, 2012-12-12 -> 20121212 2012-12-12T10:10:10 -> 20121212101010 2012-12-12T10:10:10.123456 -> 20121212101010.123456
func (Time) ToPackedUint ¶
ToPackedUint encodes Time to a packed uint64 value.
1 bit 0 17 bits year*13+month (year 0-9999, month 0-12) 5 bits day (0-31) 5 bits hour (0-23) 6 bits minute (0-59) 6 bits second (0-59) 24 bits microseconds (0-999999) Total: 64 bits = 8 bytes 0YYYYYYY.YYYYYYYY.YYdddddh.hhhhmmmm.mmssssss.ffffffff.ffffffff.ffffffff
type TimeInternal ¶
type TimeInternal interface { Year() int Month() int Day() int Hour() int Minute() int Second() int Weekday() gotime.Weekday YearDay() int YearWeek(mode int) (int, int) Week(mode int) int Microsecond() int GoTime(*gotime.Location) (gotime.Time, error) }
TimeInternal is the internal representation for mysql time in TiDB.
func FromDate ¶
func FromDate(year int, month int, day int, hour int, minute int, second int, microsecond int) TimeInternal
FromDate makes a internal time representation from the given date.
func FromGoTime ¶
func FromGoTime(t gotime.Time) TimeInternal
FromGoTime translates time.Time to mysql time internal representation.