Documentation ¶
Index ¶
- Variables
- func Add(v1, v2 sqltypes.Value) (sqltypes.Value, error)
- func Divide(v1, v2 sqltypes.Value) (sqltypes.Value, error)
- func FormatExpr(expr Expr) string
- func Multiply(v1, v2 sqltypes.Value) (sqltypes.Value, error)
- func NullSafeAdd(v1, v2 sqltypes.Value, resultType sqltypes.Type) (sqltypes.Value, error)
- func NullsafeCompare(v1, v2 sqltypes.Value, collationID collations.ID) (int, error)
- func NullsafeHashcode128(hash *vthash.Hasher, v sqltypes.Value, collation collations.ID, ...) error
- func Subtract(v1, v2 sqltypes.Value) (sqltypes.Value, error)
- func WeightString(dst []byte, v sqltypes.Value, coerceTo sqltypes.Type, col collations.ID, ...) ([]byte, bool, error)
- type Arena
- type ArithmeticExpr
- type BinaryExpr
- type BindVariable
- type BitwiseExpr
- type BitwiseNotExpr
- type CallExpr
- type CaseExpr
- type CollateExpr
- type Column
- type ColumnResolver
- type ComparisonExpr
- type ComparisonOp
- type CompiledExpr
- type CompilerLog
- type Config
- type ConvertExpr
- type ConvertUsingExpr
- type EvalResult
- func (er EvalResult) Collation() collations.ID
- func (er EvalResult) MustBoolean() bool
- func (er EvalResult) String() string
- func (er EvalResult) ToBoolean() bool
- func (er EvalResult) ToBooleanStrict() (bool, error)
- func (er EvalResult) TupleValues() []sqltypes.Value
- func (er EvalResult) Value(id collations.ID) sqltypes.Value
- type Expr
- type ExpressionEnv
- type FieldResolver
- type FilterExpr
- type HashCode
- type InExpr
- type IntervalExpr
- type IntroducerExpr
- type IsExpr
- type LikeExpr
- type Literal
- func NewLiteralBinary(val []byte) *Literal
- func NewLiteralBinaryFromBit(val []byte) (*Literal, error)
- func NewLiteralBinaryFromHex(val []byte) (*Literal, error)
- func NewLiteralBinaryFromHexNum(val []byte) (*Literal, error)
- func NewLiteralBool(b bool) *Literal
- func NewLiteralDateFromBytes(val []byte) (*Literal, error)
- func NewLiteralDatetimeFromBytes(val []byte) (*Literal, error)
- func NewLiteralDecimalFromBytes(val []byte) (*Literal, error)
- func NewLiteralFloat(val float64) *Literal
- func NewLiteralFloatFromBytes(val []byte) (*Literal, error)
- func NewLiteralInt(i int64) *Literal
- func NewLiteralIntegralFromBytes(val []byte) (*Literal, error)
- func NewLiteralString(val []byte, collation collations.TypedCollation) *Literal
- func NewLiteralTimeFromBytes(val []byte) (*Literal, error)
- func NewLiteralUint(i uint64) *Literal
- type LogicalExpr
- type MinMax
- type NegateExpr
- type NotExpr
- type OptimizationLevel
- type Sum
- type TupleExpr
- type TypeResolver
- type UnaryExpr
- type UnsupportedCollationError
- type UnsupportedComparisonError
- type VCursor
- type WhenThen
Constants ¶
This section is empty.
Variables ¶
var ErrAmbiguousType = errors.New("the type of this expression cannot be statically computed")
var ErrEvaluatedExprNotSupported = "expr cannot be evaluated, not supported"
var ErrHashCoercionIsNotExact = vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "cannot coerce into target type without losing precision")
var ErrTranslateExprNotSupported = "expr cannot be translated, not supported"
var NullExpr = &Literal{}
NullExpr is just what you are lead to believe
var SystemTime = time.Now
var UnsupportedCollationHashError = vterrors.Errorf(vtrpcpb.Code_INTERNAL, "text type with an unknown/unsupported collation cannot be hashed")
UnsupportedCollationHashError is returned when we try to get the hash value and are missing the collation to use
Functions ¶
func FormatExpr ¶ added in v0.13.0
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. opArithAdd 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 NullsafeHashcode128 ¶ added in v0.17.0
func NullsafeHashcode128(hash *vthash.Hasher, v sqltypes.Value, collation collations.ID, coerceTo sqltypes.Type) error
NullsafeHashcode128 returns a 128-bit hashcode that is guaranteed to be the same for two values that are considered equal by `NullsafeCompare`. This can be used to avoid having to do comparison checks after a hash, since we consider the 128 bits of entropy enough to guarantee uniqueness.
func WeightString ¶ added in v0.18.0
func WeightString(dst []byte, v sqltypes.Value, coerceTo sqltypes.Type, col collations.ID, length, precision int) ([]byte, bool, error)
WeightString returns the weight string for a value. It appends to dst if an existing slice is given, otherwise it returns a new one. The returned boolean indicates whether the weight string is a fixed-width weight string, such as for fixed size integer values. Our WeightString implementation supports more types that MySQL externally communicates with the `WEIGHT_STRING` function, so that we can also use this to order / sort other types like Float and Decimal as well.
Types ¶
type Arena ¶ added in v0.17.0
type Arena struct {
// contains filtered or unexported fields
}
Arena is an arena memory allocator for eval types. It allocates the types from reusable slices to prevent heap allocations. After each evaluation execution, (*Arena).reset() should be called to reset the arena.
type ArithmeticExpr ¶ added in v0.13.0
type ArithmeticExpr struct { BinaryExpr Op opArith }
func (*ArithmeticExpr) CachedSize ¶ added in v0.13.0
func (cached *ArithmeticExpr) CachedSize(alloc bool) int64
type BinaryExpr ¶
type BinaryExpr struct {
Left, Right Expr
}
func (*BinaryExpr) CachedSize ¶ added in v0.13.0
func (cached *BinaryExpr) CachedSize(alloc bool) int64
func (*BinaryExpr) LeftExpr ¶ added in v0.15.0
func (expr *BinaryExpr) LeftExpr() Expr
func (*BinaryExpr) RightExpr ¶ added in v0.15.0
func (expr *BinaryExpr) RightExpr() Expr
type BindVariable ¶
type BindVariable struct { Key string Type sqltypes.Type Collation collations.TypedCollation }
func NewBindVar ¶ added in v0.8.0
func NewBindVar(key string, typ sqltypes.Type, col collations.ID) *BindVariable
NewBindVar returns a bind variable
func NewBindVarTuple ¶ added in v0.17.0
func NewBindVarTuple(key string, col collations.ID) *BindVariable
NewBindVarTuple returns a bind variable containing a tuple
func (*BindVariable) CachedSize ¶ added in v0.10.0
func (cached *BindVariable) CachedSize(alloc bool) int64
type BitwiseExpr ¶ added in v0.14.0
type BitwiseExpr struct { BinaryExpr Op opBit }
func (*BitwiseExpr) CachedSize ¶ added in v0.14.0
func (cached *BitwiseExpr) CachedSize(alloc bool) int64
type BitwiseNotExpr ¶ added in v0.14.0
type BitwiseNotExpr struct {
UnaryExpr
}
func (*BitwiseNotExpr) CachedSize ¶ added in v0.14.0
func (cached *BitwiseNotExpr) CachedSize(alloc bool) int64
type CallExpr ¶ added in v0.13.0
func (*CallExpr) CachedSize ¶ added in v0.13.0
type CaseExpr ¶ added in v0.14.0
type CaseExpr struct { Else Expr // contains filtered or unexported fields }
func (*CaseExpr) CachedSize ¶ added in v0.14.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 Type sqltypes.Type Collation collations.TypedCollation }
func (*Column) CachedSize ¶ added in v0.10.0
type ColumnResolver ¶ added in v0.17.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 CompiledExpr ¶ added in v0.17.0
type CompiledExpr struct {
// contains filtered or unexported fields
}
func (*CompiledExpr) CachedSize ¶ added in v0.17.0
func (cached *CompiledExpr) CachedSize(alloc bool) int64
type CompilerLog ¶ added in v0.17.0
type Config ¶ added in v0.17.0
type Config struct { ResolveColumn ColumnResolver ResolveType TypeResolver Collation collations.ID Optimization OptimizationLevel CompilerErr error }
type ConvertExpr ¶ added in v0.14.0
type ConvertExpr struct { UnaryExpr Type string Length, Scale int HasLength, HasScale bool Collation collations.ID }
func (*ConvertExpr) CachedSize ¶ added in v0.14.0
func (cached *ConvertExpr) CachedSize(alloc bool) int64
type ConvertUsingExpr ¶ added in v0.14.0
type ConvertUsingExpr struct { UnaryExpr Collation collations.ID }
func (*ConvertUsingExpr) CachedSize ¶ added in v0.14.0
func (cached *ConvertUsingExpr) CachedSize(alloc bool) int64
type EvalResult ¶
type EvalResult struct {
// contains filtered or unexported fields
}
func (EvalResult) Collation ¶ added in v0.14.0
func (er EvalResult) Collation() collations.ID
func (EvalResult) MustBoolean ¶ added in v0.15.0
func (er EvalResult) MustBoolean() bool
func (EvalResult) String ¶ added in v0.14.0
func (er EvalResult) String() string
func (EvalResult) ToBoolean ¶ added in v0.15.5
func (er EvalResult) ToBoolean() bool
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(id collations.ID) sqltypes.Value
Value allows for retrieval of the value we expose for public consumption. It will be converted to the passed in collation which is the connection collation and what the client expects the result to be in.
type Expr ¶
type Expr interface {
// contains filtered or unexported methods
}
Expr is the interface that all evaluating expressions must implement
func Deoptimize ¶ added in v0.17.0
type ExpressionEnv ¶
type ExpressionEnv struct { BindVars map[string]*querypb.BindVariable Row []sqltypes.Value // contains filtered or unexported fields }
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 NewExpressionEnv ¶ added in v0.17.0
func NewExpressionEnv(ctx context.Context, bindVars map[string]*querypb.BindVariable, vc VCursor) *ExpressionEnv
NewExpressionEnv returns an expression environment with no current row, but with bindvars
func (*ExpressionEnv) Evaluate ¶ added in v0.13.0
func (env *ExpressionEnv) Evaluate(expr Expr) (EvalResult, error)
func (*ExpressionEnv) EvaluateVM ¶ added in v0.17.0
func (env *ExpressionEnv) EvaluateVM(p *CompiledExpr) (EvalResult, error)
type FieldResolver ¶ added in v0.17.0
func (FieldResolver) Column ¶ added in v0.17.0
func (fields FieldResolver) Column(col *sqlparser.ColName) (int, error)
func (FieldResolver) Type ¶ added in v0.17.0
func (fields FieldResolver) Type(expr sqlparser.Expr) (sqltypes.Type, collations.ID, bool)
type FilterExpr ¶ added in v0.17.0
type FilterExpr interface { BinaryExpr // contains filtered or unexported methods }
type HashCode ¶ added in v0.13.0
type HashCode = uint64
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 sqltypes.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 }
func (*InExpr) CachedSize ¶ added in v0.13.0
type IntervalExpr ¶ added in v0.17.0
type IntervalExpr struct {
CallExpr
}
func (*IntervalExpr) CachedSize ¶ added in v0.17.0
func (cached *IntervalExpr) CachedSize(alloc bool) int64
type IntroducerExpr ¶ added in v0.17.2
type IntroducerExpr struct { UnaryExpr TypedCollation collations.TypedCollation }
func (*IntroducerExpr) CachedSize ¶ added in v0.17.2
func (cached *IntroducerExpr) CachedSize(alloc bool) int64
type IsExpr ¶ added in v0.13.0
type IsExpr struct { UnaryExpr Op sqlparser.IsExprOperator Check func(eval) 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 colldata.WildcardPattern MatchCollation collations.ID }
func (*LikeExpr) CachedSize ¶ added in v0.13.0
type Literal ¶
type Literal struct {
// contains filtered or unexported fields
}
func NewLiteralBinary ¶ added in v0.14.0
func NewLiteralBinaryFromBit ¶ added in v0.17.0
func NewLiteralBinaryFromHex ¶ added in v0.13.0
func NewLiteralBinaryFromHexNum ¶ added in v0.13.0
func NewLiteralBool ¶ added in v0.17.0
func NewLiteralDateFromBytes ¶ added in v0.15.0
NewLiteralDateFromBytes returns a literal expression.
func NewLiteralDatetimeFromBytes ¶ added in v0.15.0
NewLiteralDatetimeFromBytes returns a literal expression. it validates the datetime by parsing it and checking the error.
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 NewLiteralInt ¶
NewLiteralInt returns a literal expression
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) *Literal
NewLiteralString returns a literal expression
func NewLiteralTimeFromBytes ¶ added in v0.15.0
NewLiteralTimeFromBytes returns a literal expression. it validates the time by parsing it and checking the error.
func NewLiteralUint ¶ added in v0.13.0
NewLiteralUint returns a literal expression
func (*Literal) CachedSize ¶ added in v0.10.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 MinMax ¶ added in v0.18.0
type MinMax interface { Min(value sqltypes.Value) error Max(value sqltypes.Value) error Result() sqltypes.Value Reset() }
MinMax implements a MIN() or MAX() aggregation
func NewAggregationMinMax ¶ added in v0.18.0
func NewAggregationMinMax(type_ sqltypes.Type, collation collations.ID) MinMax
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 OptimizationLevel ¶ added in v0.17.0
type OptimizationLevel int8
const ( OptimizationLevelDefault OptimizationLevel = iota OptimizationLevelSimplify OptimizationLevelCompile OptimizationLevelCompilerDebug OptimizationLevelMax OptimizationLevelNone OptimizationLevel = -1 )
type Sum ¶ added in v0.18.0
Sum implements a SUM() aggregation
func NewAggregationSum ¶ added in v0.18.0
func NewSumOfCounts ¶ added in v0.18.0
func NewSumOfCounts() Sum
type TupleExpr ¶ added in v0.13.0
type TupleExpr []Expr
func NewTupleExpr ¶ added in v0.13.0
NewTupleExpr returns a tuple expression
type TypeResolver ¶ added in v0.17.0
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 ¶
- api_aggregation.go
- api_arithmetic.go
- api_compare.go
- api_hash.go
- api_literal.go
- arena.go
- arithmetic.go
- cached_size.go
- collation.go
- compare.go
- compiler.go
- compiler_asm.go
- compiler_asm_push.go
- compiler_fn.go
- eval.go
- eval_bytes.go
- eval_json.go
- eval_numeric.go
- eval_result.go
- eval_temporal.go
- eval_tuple.go
- expr.go
- expr_arithmetic.go
- expr_bit.go
- expr_bvar.go
- expr_call.go
- expr_collate.go
- expr_column.go
- expr_compare.go
- expr_convert.go
- expr_env.go
- expr_literal.go
- expr_logical.go
- expr_tuple.go
- fn_base64.go
- fn_bit.go
- fn_compare.go
- fn_crypto.go
- fn_hex.go
- fn_info.go
- fn_json.go
- fn_misc.go
- fn_numeric.go
- fn_regexp.go
- fn_string.go
- fn_time.go
- format.go
- translate.go
- translate_builtin.go
- translate_card.go
- translate_convert.go
- translate_simplify.go
- vm.go
- weights.go