Documentation ¶
Index ¶
- Variables
- func Add(v1, v2 sqltypes.Value) (sqltypes.Value, error)
- func Cast(v sqltypes.Value, typ querypb.Type) (sqltypes.Value, error)
- func CoerceTo(v1, v2 querypb.Type) (querypb.Type, error)
- func Divide(v1, v2 sqltypes.Value) (sqltypes.Value, error)
- func FormatExpr(expr Expr) string
- func FormatFloat(typ querypb.Type, f float64) []byte
- func Max(v1, v2 sqltypes.Value, collation collations.ID) (sqltypes.Value, error)
- func Min(v1, v2 sqltypes.Value, collation collations.ID) (sqltypes.Value, error)
- func Multiply(v1, v2 sqltypes.Value) (sqltypes.Value, error)
- func NullSafeAdd(v1, v2 sqltypes.Value, resultType querypb.Type) (sqltypes.Value, error)
- func NullsafeCompare(v1, v2 sqltypes.Value, collationID collations.ID) (int, error)
- func PrettyPrint(expr Expr) string
- func Subtract(v1, v2 sqltypes.Value) (sqltypes.Value, error)
- func ToFloat64(v sqltypes.Value) (float64, error)
- func ToInt64(v sqltypes.Value) (int64, error)
- func ToNative(v sqltypes.Value) (interface{}, error)
- func ToUint64(v sqltypes.Value) (uint64, error)
- type ArithmeticExpr
- type ArithmeticOp
- type BinaryExpr
- type BindVariable
- type CallExpr
- type CollateExpr
- type Column
- type ComparisonExpr
- type ComparisonOp
- type ConverterLookup
- type EvalResult
- type Expr
- func Convert(e sqlparser.Expr, lookup ConverterLookup) (Expr, error)
- func ConvertEx(e sqlparser.Expr, lookup ConverterLookup, simplify bool) (Expr, error)
- func NewBindVar(key string, collation collations.TypedCollation) Expr
- func NewColumn(offset int, collation collations.TypedCollation) Expr
- func NewLiteralBinaryFromHex(val []byte) (Expr, error)
- func NewLiteralBinaryFromHexNum(val []byte) (Expr, error)
- func NewLiteralDecimalFromBytes(val []byte) (Expr, error)
- func NewLiteralFloat(val float64) Expr
- func NewLiteralFloatFromBytes(val []byte) (Expr, error)
- func NewLiteralInt(i int64) Expr
- func NewLiteralIntegralFromBytes(val []byte) (Expr, error)
- func NewLiteralString(val []byte, collation collations.TypedCollation) Expr
- func NewLiteralUint(i uint64) Expr
- type ExpressionEnv
- type HashCode
- type InExpr
- type IsExpr
- type LikeExpr
- type Literal
- type LogicalExpr
- type LogicalOp
- type LookupDefaultCollation
- type NegateExpr
- type NotExpr
- type OpAddition
- type OpDivision
- type OpLogicalAnd
- type OpMultiplication
- type OpSubstraction
- type TupleExpr
- type UnaryExpr
- type UnsupportedCollationError
- type UnsupportedComparisonError
Constants ¶
This section is empty.
Variables ¶
var ErrConvertExprNotSupported = "expr cannot be converted, not supported"
var NullExpr = &Literal{}
NullExpr is just what you are lead to believe
Functions ¶
func CoerceTo ¶ added in v0.13.0
CoerceTo takes two input types, and decides how they should be coerced before compared
func FormatExpr ¶ added in v0.13.0
func FormatFloat ¶ added in v0.13.0
FormatFloat formats a float64 as a byte string in a similar way to what MySQL does
func Max ¶
Max returns the maximum of v1 and v2. If one of the values is NULL, it returns the other value. If both are NULL, it returns NULL.
func Min ¶
Min returns the minimum of v1 and v2. If one of the values is NULL, it returns the other value. If both are NULL, it returns NULL.
func NullSafeAdd ¶ added in v0.13.0
NullSafeAdd adds two Values in a null-safe manner. A null value is treated as 0. If both values are null, then a null is returned. If both values are not null, a numeric value is built from each input: Signed->int64, Unsigned->uint64, Float->float64. Otherwise the 'best type fit' is chosen for the number: int64 or float64. OpAddition is performed by upgrading types as needed, or in case of overflow: int64->uint64, int64->float64, uint64->float64. Unsigned ints can only be added to positive ints. After the addition, if one of the input types was Decimal, then a Decimal is built. Otherwise, the final type of the result is preserved.
func NullsafeCompare ¶
NullsafeCompare returns 0 if v1==v2, -1 if v1<v2, and 1 if v1>v2. NULL is the lowest value. If any value is numeric, then a numeric comparison is performed after necessary conversions. If none are numeric, then it's a simple binary comparison. Uncomparable values return an error.
func PrettyPrint ¶ added in v0.13.0
Types ¶
type ArithmeticExpr ¶ added in v0.13.0
type ArithmeticExpr struct { BinaryExpr Op ArithmeticOp }
func (*ArithmeticExpr) CachedSize ¶ added in v0.13.0
func (cached *ArithmeticExpr) CachedSize(alloc bool) int64
type ArithmeticOp ¶ added in v0.13.0
type ArithmeticOp interface { String() string // contains filtered or unexported methods }
ArithmeticOp allows arithmetic expressions to not have to evaluate child expressions - this is done by the BinaryExpr
type BinaryExpr ¶
type BinaryExpr struct {
Left, Right Expr
}
func (*BinaryExpr) CachedSize ¶ added in v0.13.0
func (cached *BinaryExpr) CachedSize(alloc bool) int64
type BindVariable ¶
type BindVariable struct { Key string // contains filtered or unexported fields }
func (*BindVariable) CachedSize ¶ added in v0.10.0
func (cached *BindVariable) CachedSize(alloc bool) int64
type CallExpr ¶ added in v0.13.0
type CallExpr struct { Arguments TupleExpr Aliases []sqlparser.ColIdent Method string Call func(*ExpressionEnv, []EvalResult, *EvalResult) }
func (*CallExpr) CachedSize ¶ added in v0.13.0
type CollateExpr ¶ added in v0.13.0
type CollateExpr struct { UnaryExpr TypedCollation collations.TypedCollation }
func (*CollateExpr) CachedSize ¶ added in v0.13.0
func (cached *CollateExpr) CachedSize(alloc bool) int64
type Column ¶
type Column struct { Offset int // contains filtered or unexported fields }
func (*Column) CachedSize ¶ added in v0.10.0
type ComparisonExpr ¶ added in v0.13.0
type ComparisonExpr struct { BinaryExpr Op ComparisonOp }
func (*ComparisonExpr) CachedSize ¶ added in v0.13.0
func (cached *ComparisonExpr) CachedSize(alloc bool) int64
type ComparisonOp ¶ added in v0.13.0
type ComparisonOp interface { String() string // contains filtered or unexported methods }
type ConverterLookup ¶ added in v0.13.0
type ConverterLookup interface { ColumnLookup(col *sqlparser.ColName) (int, error) CollationForExpr(expr sqlparser.Expr) collations.ID DefaultCollation() collations.ID }
type EvalResult ¶
type EvalResult struct {
// contains filtered or unexported fields
}
EvalResult is a lazily computed result of an evaluation
func (*EvalResult) CachedSize ¶ added in v0.10.0
func (cached *EvalResult) CachedSize(alloc bool) int64
func (*EvalResult) ToBooleanStrict ¶ added in v0.8.0
func (er *EvalResult) ToBooleanStrict() (bool, error)
ToBooleanStrict is used when the casting to a boolean has to be minimally forgiving, such as when assigning to a system variable that is expected to be a boolean
func (*EvalResult) TupleValues ¶ added in v0.13.0
func (er *EvalResult) TupleValues() []sqltypes.Value
TupleValues allows for retrieval of the value we expose for public consumption
func (*EvalResult) Value ¶
func (er *EvalResult) Value() sqltypes.Value
Value allows for retrieval of the value we expose for public consumption
type Expr ¶
type Expr interface {
// contains filtered or unexported methods
}
Expr is the interface that all evaluating expressions must implement
func Convert ¶ added in v0.13.0
func Convert(e sqlparser.Expr, lookup ConverterLookup) (Expr, error)
Convert converts between AST expressions and executable expressions
func NewBindVar ¶ added in v0.8.0
func NewBindVar(key string, collation collations.TypedCollation) Expr
NewBindVar returns a bind variable
func NewColumn ¶ added in v0.8.0
func NewColumn(offset int, collation collations.TypedCollation) Expr
NewColumn returns a column expression
func NewLiteralBinaryFromHex ¶ added in v0.13.0
func NewLiteralBinaryFromHexNum ¶ added in v0.13.0
func NewLiteralDecimalFromBytes ¶ added in v0.13.0
func NewLiteralFloat ¶
NewLiteralFloat returns a literal expression
func NewLiteralFloatFromBytes ¶ added in v0.13.0
NewLiteralFloatFromBytes returns a float literal expression from a slice of bytes
func NewLiteralIntegralFromBytes ¶ added in v0.13.0
NewLiteralIntegralFromBytes returns a literal expression. It tries to return an int64, but if the value is too large, it tries with an uint64
func NewLiteralString ¶
func NewLiteralString(val []byte, collation collations.TypedCollation) Expr
NewLiteralString returns a literal expression
func NewLiteralUint ¶ added in v0.13.0
NewLiteralUint returns a literal expression
type ExpressionEnv ¶
type ExpressionEnv struct { BindVars map[string]*querypb.BindVariable Row []sqltypes.Value DefaultCollation collations.ID }
ExpressionEnv contains the environment that the expression evaluates in, such as the current row and bindvars
func EmptyExpressionEnv ¶ added in v0.13.0
func EmptyExpressionEnv() *ExpressionEnv
EmptyExpressionEnv returns a new ExpressionEnv with no bind vars or row
func EnvWithBindVars ¶ added in v0.13.0
func EnvWithBindVars(bindVars map[string]*querypb.BindVariable, coll collations.ID) *ExpressionEnv
EnvWithBindVars returns an expression environment with no current row, but with bindvars
func (*ExpressionEnv) CachedSize ¶ added in v0.13.0
func (cached *ExpressionEnv) CachedSize(alloc bool) int64
func (*ExpressionEnv) Evaluate ¶ added in v0.13.0
func (env *ExpressionEnv) Evaluate(expr Expr) (er EvalResult, err error)
type HashCode ¶ added in v0.13.0
type HashCode = uintptr
HashCode is a type alias to the code easier to read
func NullsafeHashcode ¶ added in v0.9.0
func NullsafeHashcode(v sqltypes.Value, collation collations.ID, coerceType querypb.Type) (HashCode, error)
NullsafeHashcode returns an int64 hashcode that is guaranteed to be the same for two values that are considered equal by `NullsafeCompare`.
type InExpr ¶ added in v0.13.0
type InExpr struct { BinaryExpr Negate bool Hashed map[uintptr]int }
func (*InExpr) CachedSize ¶ added in v0.13.0
type IsExpr ¶ added in v0.13.0
type IsExpr struct { UnaryExpr Op sqlparser.IsExprOperator Check func(*EvalResult) bool }
IsExpr represents the IS expression in MySQL. boolean_primary IS [NOT] {TRUE | FALSE | NULL}
func (*IsExpr) CachedSize ¶ added in v0.13.0
type LikeExpr ¶ added in v0.13.0
type LikeExpr struct { BinaryExpr Negate bool Match collations.WildcardPattern MatchCollation collations.ID }
func (*LikeExpr) CachedSize ¶ added in v0.13.0
type LogicalExpr ¶ added in v0.13.0
type LogicalExpr struct { BinaryExpr // contains filtered or unexported fields }
func (*LogicalExpr) CachedSize ¶ added in v0.13.0
func (cached *LogicalExpr) CachedSize(alloc bool) int64
type LogicalOp ¶ added in v0.13.0
type LogicalOp interface { String() // contains filtered or unexported methods }
type LookupDefaultCollation ¶ added in v0.13.0
type LookupDefaultCollation collations.ID
func (LookupDefaultCollation) CollationForExpr ¶ added in v0.13.0
func (d LookupDefaultCollation) CollationForExpr(_ sqlparser.Expr) collations.ID
func (LookupDefaultCollation) ColumnLookup ¶ added in v0.13.0
func (d LookupDefaultCollation) ColumnLookup(_ *sqlparser.ColName) (int, error)
func (LookupDefaultCollation) DefaultCollation ¶ added in v0.13.0
func (d LookupDefaultCollation) DefaultCollation() collations.ID
type NegateExpr ¶ added in v0.13.0
type NegateExpr struct {
UnaryExpr
}
func (*NegateExpr) CachedSize ¶ added in v0.13.1
func (cached *NegateExpr) CachedSize(alloc bool) int64
type NotExpr ¶ added in v0.13.0
type NotExpr struct {
UnaryExpr
}
func (*NotExpr) CachedSize ¶ added in v0.13.0
type OpAddition ¶ added in v0.13.0
type OpAddition struct{}
func (*OpAddition) String ¶ added in v0.13.0
func (a *OpAddition) String() string
type OpDivision ¶ added in v0.13.0
type OpDivision struct{}
func (*OpDivision) String ¶ added in v0.13.0
func (d *OpDivision) String() string
type OpLogicalAnd ¶ added in v0.13.0
type OpLogicalAnd struct{}
type OpMultiplication ¶ added in v0.13.0
type OpMultiplication struct{}
func (*OpMultiplication) String ¶ added in v0.13.0
func (m *OpMultiplication) String() string
type OpSubstraction ¶ added in v0.13.0
type OpSubstraction struct{}
func (*OpSubstraction) String ¶ added in v0.13.0
func (s *OpSubstraction) String() string
type TupleExpr ¶ added in v0.13.0
type TupleExpr []Expr
func NewTupleExpr ¶ added in v0.13.0
NewTupleExpr returns a tuple expression
type UnaryExpr ¶ added in v0.13.0
type UnaryExpr struct {
Inner Expr
}
func (*UnaryExpr) CachedSize ¶ added in v0.13.0
type UnsupportedCollationError ¶ added in v0.13.0
type UnsupportedCollationError struct {
ID collations.ID
}
UnsupportedCollationError represents the error where the comparison using provided collation is unsupported on vitess
func (UnsupportedCollationError) Error ¶ added in v0.13.0
func (err UnsupportedCollationError) Error() string
Error function implements the error interface
type UnsupportedComparisonError ¶ added in v0.10.0
UnsupportedComparisonError represents the error where the comparison between the two types is unsupported on vitess
func (UnsupportedComparisonError) Error ¶ added in v0.10.0
func (err UnsupportedComparisonError) Error() string
Error function implements the error interface
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package decimal provides a high-performance, arbitrary precision, floating-point decimal library.
|
Package decimal provides a high-performance, arbitrary precision, floating-point decimal library. |
internal/arith
Package arith provides performance-sensitive arithmetic operations.
|
Package arith provides performance-sensitive arithmetic operations. |
internal/c
Package c provides internal constants.
|
Package c provides internal constants. |