Documentation ¶
Index ¶
- Constants
- func CompareDuration(x, y time.Duration) int
- func CompareFloat64(x, y float64) int
- func CompareInt64(x, y int64) int
- func CompareString(x, y, collation string) int
- func CompareUint64(x, y uint64) int
- func ConvertDecimalToUint(sc *stmtctx.StatementContext, d *MyDecimal, upperBound uint64, tp byte) (uint64, error)
- func ConvertFloatToInt(fval float64, lowerBound, upperBound int64, tp byte) (int64, error)
- func ConvertFloatToUint(sc *stmtctx.StatementContext, fval float64, upperBound uint64, tp byte) (uint64, error)
- func ConvertIntToInt(val int64, lowerBound int64, upperBound int64, tp byte) (int64, error)
- func ConvertIntToUint(sc *stmtctx.StatementContext, val int64, upperBound uint64, tp byte) (uint64, error)
- func ConvertJSONToFloat(sc *stmtctx.StatementContext, j json.BinaryJSON) (float64, error)
- func ConvertJSONToInt(sc *stmtctx.StatementContext, j json.BinaryJSON, unsigned bool) (int64, error)
- func ConvertUintToInt(val uint64, upperBound int64, tp byte) (int64, error)
- func ConvertUintToUint(val uint64, upperBound uint64, tp byte) (uint64, error)
- func DatumsToStrNoErr(datums []Datum) string
- func DatumsToString(datums []Datum, handleSpecialValue bool) (string, error)
- func EqualDatums(sc *stmtctx.StatementContext, a []Datum, b []Datum) (bool, error)
- func EstimatedMemUsage(array []Datum, numOfRows int) int64
- func IntergerSignedLowerBound(intType byte) int64
- func IntergerSignedUpperBound(intType byte) int64
- func IntergerUnsignedUpperBound(intType byte) uint64
- func ProduceFloatWithSpecifiedTp(f float64, target *FieldType, sc *stmtctx.StatementContext) (_ float64, err error)
- func ProduceStrWithSpecifiedTp(s string, tp *FieldType, sc *stmtctx.StatementContext, padZero bool) (_ string, err error)
- func SortDatums(sc *stmtctx.StatementContext, datums []Datum) error
- func StrToDuration(sc *stmtctx.StatementContext, str string, fsp int8) (d Duration, t Time, isDuration bool, err error)
- func StrToFloat(sc *stmtctx.StatementContext, str string, isFuncCast bool) (float64, error)
- func StrToInt(sc *stmtctx.StatementContext, str string, isFuncCast bool) (int64, error)
- func StrToUint(sc *stmtctx.StatementContext, str string, isFuncCast bool) (uint64, error)
- func ToString(value interface{}) (string, error)
- func VecCompareII(x, y, res []int64)
- func VecCompareIU(x []int64, y []uint64, res []int64)
- func VecCompareUI(x []uint64, y, res []int64)
- func VecCompareUU(x, y []uint64, res []int64)
- type Datum
- func ChangeReverseResultByUpperLowerBound(sc *stmtctx.StatementContext, retType *FieldType, res Datum, ...) (Datum, error)
- func CloneRow(dr []Datum) []Datum
- func GetMaxValue(ft *FieldType) (max Datum)
- func GetMinValue(ft *FieldType) (min Datum)
- func MakeDatums(args ...interface{}) []Datum
- func MaxValueDatum() Datum
- func MinNotNullDatum() Datum
- func NewBinaryLiteralDatum(b BinaryLiteral) (d Datum)
- func NewBytesDatum(b []byte) (d Datum)
- func NewCollateMysqlEnumDatum(e Enum, collation string) (d Datum)
- func NewCollationStringDatum(s string, collation string, length int) (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 NewJSONDatum(j json.BinaryJSON) (d Datum)
- func NewMysqlBitDatum(b BinaryLiteral) (d Datum)
- func NewMysqlEnumDatum(e Enum) (d Datum)
- func NewMysqlSetDatum(e Set, collation string) (d Datum)
- func NewStringDatum(s string) (d Datum)
- func NewTimeDatum(t Time) (d Datum)
- func NewUintDatum(i uint64) (d Datum)
- func (d *Datum) Clone() *Datum
- func (d *Datum) Collation() string
- func (d *Datum) CompareDatum(sc *stmtctx.StatementContext, ad *Datum) (int, error)
- func (d *Datum) ConvertTo(sc *stmtctx.StatementContext, target *FieldType) (Datum, error)
- func (d *Datum) Copy(dst *Datum)
- func (d *Datum) Frac() int
- func (d *Datum) GetBinaryLiteral() BinaryLiteral
- 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() BinaryLiteral
- func (d *Datum) GetMysqlDecimal() *MyDecimal
- func (d *Datum) GetMysqlDuration() Duration
- func (d *Datum) GetMysqlEnum() Enum
- func (d *Datum) GetMysqlJSON() json.BinaryJSON
- func (d *Datum) GetMysqlSet() Set
- func (d *Datum) GetMysqlTime() Time
- func (d *Datum) GetRaw() []byte
- 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) SetAutoID(id int64, flag uint)
- func (d *Datum) SetBinaryLiteral(b BinaryLiteral)
- func (d *Datum) SetBytes(b []byte)
- func (d *Datum) SetBytesAsString(b []byte, collation string, length uint32)
- 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) SetMinNotNull()
- func (d *Datum) SetMysqlBit(b BinaryLiteral)
- func (d *Datum) SetMysqlDecimal(b *MyDecimal)
- func (d *Datum) SetMysqlDuration(b Duration)
- func (d *Datum) SetMysqlEnum(b Enum, collation string)
- func (d *Datum) SetMysqlJSON(b json.BinaryJSON)
- func (d *Datum) SetMysqlSet(b Set, collation string)
- func (d *Datum) SetMysqlTime(b Time)
- func (d *Datum) SetNull()
- func (d *Datum) SetRaw(b []byte)
- func (d *Datum) SetString(s string, collation string)
- func (d *Datum) SetUint64(i uint64)
- func (d *Datum) SetValue(val interface{}, tp *types.FieldType)
- func (d *Datum) SetValueWithDefaultCollation(val interface{})
- func (d Datum) String() string
- func (d *Datum) ToBool(sc *stmtctx.StatementContext) (int64, error)
- func (d *Datum) ToBytes() ([]byte, error)
- func (d *Datum) ToDecimal(sc *stmtctx.StatementContext) (*MyDecimal, error)
- func (d *Datum) ToFloat64(sc *stmtctx.StatementContext) (float64, error)
- func (d *Datum) ToInt64(sc *stmtctx.StatementContext) (int64, error)
- func (d *Datum) ToMysqlJSON() (j json.BinaryJSON, err error)
- func (d *Datum) ToString() (string, error)
- type RoundingType
Constants ¶
const ( KindNull byte = 0 KindInt64 byte = 1 KindUint64 byte = 2 KindFloat32 byte = 3 KindFloat64 byte = 4 KindString byte = 5 KindBytes byte = 6 KindBinaryLiteral byte = 7 // Used for BIT / HEX literals. KindMysqlDecimal byte = 8 KindMysqlDuration byte = 9 KindMysqlEnum byte = 10 KindMysqlBit byte = 11 // Used for BIT table column values. KindMysqlSet byte = 12 KindMysqlTime byte = 13 KindInterface byte = 14 KindMinNotNull byte = 15 KindMaxValue byte = 16 KindRaw byte = 17 KindMysqlJSON byte = 18 )
Kind constants.
Variables ¶
This section is empty.
Functions ¶
func CompareDuration ¶
CompareDuration returns an integer comparing the duration x to y.
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 with the specified collation and length.
func CompareUint64 ¶
CompareUint64 returns an integer comparing the uint64 x to y.
func ConvertDecimalToUint ¶
func ConvertDecimalToUint(sc *stmtctx.StatementContext, d *MyDecimal, upperBound uint64, tp byte) (uint64, error)
ConvertDecimalToUint converts a decimal to a uint by converting it to a string first to avoid float overflow (#10181).
func ConvertFloatToInt ¶
ConvertFloatToInt converts a float64 value to a int value. `tp` is used in err msg, if there is overflow, this func will report err according to `tp`
func ConvertFloatToUint ¶
func ConvertFloatToUint(sc *stmtctx.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 ¶
func ConvertIntToUint(sc *stmtctx.StatementContext, val int64, upperBound uint64, tp byte) (uint64, error)
ConvertIntToUint converts an int value to an uint value.
func ConvertJSONToFloat ¶
func ConvertJSONToFloat(sc *stmtctx.StatementContext, j json.BinaryJSON) (float64, error)
ConvertJSONToFloat casts JSON into float64.
func ConvertJSONToInt ¶
func ConvertJSONToInt(sc *stmtctx.StatementContext, j json.BinaryJSON, unsigned bool) (int64, error)
ConvertJSONToInt casts JSON into int64.
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 DatumsToStrNoErr ¶
DatumsToStrNoErr converts some datums to a formatted string. If an error occurs, it will print a log instead of returning an error.
func DatumsToString ¶
DatumsToString converts several datums to formatted string.
func EqualDatums ¶
EqualDatums compare if a and b contains the same datum values.
func EstimatedMemUsage ¶
EstimatedMemUsage returns the estimated bytes consumed of a one-dimensional or two-dimensional datum array.
func IntergerSignedLowerBound ¶
IntergerSignedLowerBound indicates the min int64 values of different mysql types.
func IntergerSignedUpperBound ¶
IntergerSignedUpperBound indicates the max int64 values of different mysql types.
func IntergerUnsignedUpperBound ¶
IntergerUnsignedUpperBound indicates the max uint64 values of different mysql types.
func ProduceFloatWithSpecifiedTp ¶
func ProduceFloatWithSpecifiedTp(f float64, target *FieldType, sc *stmtctx.StatementContext) (_ float64, err error)
ProduceFloatWithSpecifiedTp produces a new float64 according to `flen` and `decimal`.
func ProduceStrWithSpecifiedTp ¶
func ProduceStrWithSpecifiedTp(s string, tp *FieldType, sc *stmtctx.StatementContext, padZero bool) (_ string, err error)
ProduceStrWithSpecifiedTp produces a new string according to `flen` and `chs`. Param `padZero` indicates whether we should pad `\0` for `binary(flen)` type.
func SortDatums ¶
func SortDatums(sc *stmtctx.StatementContext, datums []Datum) error
SortDatums sorts a slice of datum.
func StrToDuration ¶
func StrToDuration(sc *stmtctx.StatementContext, str string, fsp int8) (d Duration, t Time, isDuration bool, err error)
StrToDuration converts str to Duration. It returns Duration in normal case, and returns Time when str is in datetime format. when isDuration is true, the d is returned, when it is false, the t is returned. See https://dev.mysql.com/doc/refman/5.5/en/date-and-time-literals.html.
func StrToFloat ¶
StrToFloat converts a string to a float64 at the best-effort.
func VecCompareII ¶
func VecCompareII(x, y, res []int64)
VecCompareII returns []int64 comparing the []int64 x to []int64 y
func VecCompareIU ¶
VecCompareIU returns []int64 comparing the []int64 x to []uint64y
func VecCompareUI ¶
VecCompareUI returns []int64 comparing the []uint64 x to []int64y
func VecCompareUU ¶
VecCompareUU returns []int64 comparing the []uint64 x to []uint64 y
Types ¶
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 ChangeReverseResultByUpperLowerBound ¶
func ChangeReverseResultByUpperLowerBound( sc *stmtctx.StatementContext, retType *FieldType, res Datum, rType RoundingType) (Datum, error)
ChangeReverseResultByUpperLowerBound is for expression's reverse evaluation. Here is an example for what's effort for the function: CastRealAsInt(t.a),
if the type of column `t.a` is mysql.TypeDouble, and there is a row that t.a == MaxFloat64 then the cast function will arrive a result MaxInt64. But when we do the reverse evaluation, if the result is MaxInt64, and the rounding type is ceiling. Then we should get the MaxFloat64 instead of float64(MaxInt64).
Another example: cast(1.1 as signed) = 1,
when we get the answer 1, we can only reversely evaluate 1.0 as the column value. So in this case, we should judge whether the rounding type are ceiling. If it is, then we should plus one for 1.0 and get the reverse result 2.0.
func GetMaxValue ¶
func GetMaxValue(ft *FieldType) (max Datum)
GetMaxValue returns the max value datum for each type.
func GetMinValue ¶
func GetMinValue(ft *FieldType) (min Datum)
GetMinValue returns the min value datum for each type.
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 NewBinaryLiteralDatum ¶
func NewBinaryLiteralDatum(b BinaryLiteral) (d Datum)
NewBinaryLiteralDatum creates a new BinaryLiteral Datum for a BinaryLiteral value.
func NewBytesDatum ¶
NewBytesDatum creates a new Datum from a byte slice.
func NewCollateMysqlEnumDatum ¶
NewCollateMysqlEnumDatum create a new MysqlEnum Datum for a Enum value with collation information.
func NewCollationStringDatum ¶
NewCollationStringDatum creates a new Datum from a string with collation and length info.
func NewDatum ¶
func NewDatum(in interface{}) (d Datum)
NewDatum creates a new Datum from an interface{}.
func NewDecimalDatum ¶
func NewDecimalDatum(dec *MyDecimal) (d Datum)
NewDecimalDatum creates a new Datum from a MyDecimal value.
func NewDurationDatum ¶
func NewDurationDatum(dur Duration) (d Datum)
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 NewJSONDatum ¶
func NewJSONDatum(j json.BinaryJSON) (d Datum)
NewJSONDatum creates a new Datum from a BinaryJSON value
func NewMysqlBitDatum ¶
func NewMysqlBitDatum(b BinaryLiteral) (d Datum)
NewMysqlBitDatum creates a new MysqlBit Datum for a BinaryLiteral value.
func NewMysqlEnumDatum ¶
func NewMysqlEnumDatum(e Enum) (d Datum)
NewMysqlEnumDatum creates a new MysqlEnum Datum for a Enum value.
func NewMysqlSetDatum ¶
NewMysqlSetDatum creates a new MysqlSet Datum for a Enum value.
func NewStringDatum ¶
NewStringDatum creates a new Datum from a string.
func NewTimeDatum ¶
func NewTimeDatum(t Time) (d Datum)
NewTimeDatum creates a new Time from a Time value.
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) ConvertTo ¶
func (d *Datum) ConvertTo(sc *stmtctx.StatementContext, target *FieldType) (Datum, error)
ConvertTo converts a datum to the target field type. change this method need sync modification to type2Kind in rowcodec/types.go
func (*Datum) GetBinaryLiteral ¶
func (d *Datum) GetBinaryLiteral() BinaryLiteral
GetBinaryLiteral gets Bit value
func (*Datum) GetInterface ¶
func (d *Datum) GetInterface() interface{}
GetInterface gets interface value.
func (*Datum) GetMysqlBit ¶
func (d *Datum) GetMysqlBit() BinaryLiteral
GetMysqlBit gets MysqlBit value
func (*Datum) GetMysqlDecimal ¶
func (d *Datum) GetMysqlDecimal() *MyDecimal
GetMysqlDecimal gets Decimal value
func (*Datum) GetMysqlDuration ¶
func (d *Datum) GetMysqlDuration() Duration
GetMysqlDuration gets Duration value
func (*Datum) GetMysqlJSON ¶
func (d *Datum) GetMysqlJSON() json.BinaryJSON
GetMysqlJSON gets json.BinaryJSON value
func (*Datum) GetValue ¶
func (d *Datum) GetValue() interface{}
GetValue gets the value of the datum of any kind.
func (*Datum) SetBinaryLiteral ¶
func (d *Datum) SetBinaryLiteral(b BinaryLiteral)
SetBinaryLiteral sets Bit value
func (*Datum) SetBytesAsString ¶
SetBytesAsString sets bytes value to datum as string type.
func (*Datum) SetInterface ¶
func (d *Datum) SetInterface(x interface{})
SetInterface sets interface to datum.
func (*Datum) SetMinNotNull ¶
func (d *Datum) SetMinNotNull()
SetMinNotNull sets datum to minNotNull value.
func (*Datum) SetMysqlBit ¶
func (d *Datum) SetMysqlBit(b BinaryLiteral)
SetMysqlBit sets MysqlBit value
func (*Datum) SetMysqlDecimal ¶
func (d *Datum) SetMysqlDecimal(b *MyDecimal)
SetMysqlDecimal sets Decimal value
func (*Datum) SetMysqlDuration ¶
func (d *Datum) SetMysqlDuration(b Duration)
SetMysqlDuration sets Duration value
func (*Datum) SetMysqlEnum ¶
SetMysqlEnum sets Enum value
func (*Datum) SetMysqlJSON ¶
func (d *Datum) SetMysqlJSON(b json.BinaryJSON)
SetMysqlJSON sets json.BinaryJSON value
func (*Datum) SetMysqlSet ¶
SetMysqlSet sets Set value
func (*Datum) SetMysqlTime ¶
func (d *Datum) SetMysqlTime(b Time)
SetMysqlTime sets types.Time value
func (*Datum) SetValueWithDefaultCollation ¶
func (d *Datum) SetValueWithDefaultCollation(val interface{})
SetValueWithDefaultCollation sets any kind of value.
func (Datum) String ¶
String returns a human-readable description of Datum. It is intended only for debugging.
func (*Datum) ToBool ¶
func (d *Datum) ToBool(sc *stmtctx.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 *stmtctx.StatementContext) (*MyDecimal, error)
ToDecimal converts to a decimal.
func (*Datum) ToFloat64 ¶
func (d *Datum) ToFloat64(sc *stmtctx.StatementContext) (float64, error)
ToFloat64 converts to a float64
func (*Datum) ToInt64 ¶
func (d *Datum) ToInt64(sc *stmtctx.StatementContext) (int64, error)
ToInt64 converts to a int64.
func (*Datum) ToMysqlJSON ¶
func (d *Datum) ToMysqlJSON() (j json.BinaryJSON, err error)
ToMysqlJSON is similar to convertToMysqlJSON, except the latter parses from string, but the former uses it as primitive.
type RoundingType ¶
type RoundingType uint8
RoundingType is used to indicate the rounding type for reversing evaluation.
const ( // Ceiling means rounding up. Ceiling RoundingType = iota // Floor means rounding down. Floor )