Documentation ¶
Index ¶
- Variables
- func CompareInt(sctx sctx.Context, lhsArg, rhsArg Expression, lhsRow, rhsRow chunk.Row) (int64, bool, error)
- func CompareStringWithCollationInfo(sctx sctx.Context, lhsArg, rhsArg Expression, lhsRow, rhsRow chunk.Row, ...) (int64, bool, error)
- func EvalBool(ctx sctx.Context, exprList CNFExprs, row chunk.Row) (bool, bool, error)
- func FindFieldName(names types.NameSlice, astCol *ast.ColumnName) (int, error)
- func GetAccurateCmpType(lhs, rhs Expression) types.EvalType
- func GetBuiltinList() []string
- func GetRowLen(e Expression) int
- func GetUsedList(usedCols []*Column, schema *Schema) []bool
- func IsFunctionSupported(name string) bool
- type CNFExprs
- type Coercibility
- type CollationInfo
- type Column
- func (col *Column) Clone() Expression
- func (col *Column) Equal(_ sctx.Context, expr Expression) bool
- func (col *Column) Eval(row chunk.Row) (types.Datum, error)
- func (col *Column) EvalInt(ctx sctx.Context, row chunk.Row) (int64, bool, error)
- func (col *Column) EvalString(ctx sctx.Context, row chunk.Row) (string, bool, error)
- func (col *Column) GetType() *types.FieldType
- func (col *Column) String() string
- func (col *Column) ToColumnMeta() *model.ColumnMeta
- type CompareFunc
- type Constant
- func (c *Constant) Clone() Expression
- func (c *Constant) Equal(ctx sctx.Context, b Expression) bool
- func (c *Constant) Eval(row chunk.Row) (types.Datum, error)
- func (c *Constant) EvalInt(ctx sctx.Context, row chunk.Row) (int64, bool, error)
- func (c *Constant) EvalString(ctx sctx.Context, row chunk.Row) (string, bool, error)
- func (c *Constant) GetType() *types.FieldType
- type Expression
- func NewFunction(ctx sctx.Context, funcName string, retType *types.FieldType, ...) (Expression, error)
- func NewFunctionBase(ctx sctx.Context, funcName string, retType *types.FieldType, ...) (Expression, error)
- func NewFunctionInternal(ctx sctx.Context, funcName string, retType *types.FieldType, ...) Expression
- func ScalarFuncs2Exprs(funcs []*ScalarFunction) []Expression
- type KeyInfo
- type ScalarFunction
- func (sf *ScalarFunction) Clone() Expression
- func (sf *ScalarFunction) Equal(ctx sctx.Context, e Expression) bool
- func (sf *ScalarFunction) Eval(row chunk.Row) (d types.Datum, err error)
- func (sf *ScalarFunction) EvalInt(ctx sctx.Context, row chunk.Row) (int64, bool, error)
- func (sf *ScalarFunction) EvalString(ctx sctx.Context, row chunk.Row) (string, bool, error)
- func (sf *ScalarFunction) GetArgs() []Expression
- func (sf *ScalarFunction) GetCtx() sctx.Context
- func (sf *ScalarFunction) GetType() *types.FieldType
- func (sf *ScalarFunction) MarshalJSON() ([]byte, error)
- type Schema
- func (s *Schema) Append(col ...*Column)
- func (s *Schema) Clone() *Schema
- func (s *Schema) ColumnIndex(col *Column) int
- func (s *Schema) ColumnsByIndices(offsets []int) []*Column
- func (s *Schema) ColumnsIndices(cols []*Column) (ret []int)
- func (s *Schema) Contains(col *Column) bool
- func (s *Schema) Len() int
- func (s *Schema) RetrieveColumn(col *Column) *Column
- func (s *Schema) SetUniqueKeys(keys []KeyInfo)
- func (s *Schema) String() string
- type VarAssignment
Constants ¶
This section is empty.
Variables ¶
var ( // All the exported errors are defined here: ErrIncorrectParameterCount = terror.ClassExpression.New(mysql.ErrWrongParamcountToNativeFct, mysql.MySQLErrName[mysql.ErrWrongParamcountToNativeFct]) ErrDivisionByZero = terror.ClassExpression.New(mysql.ErrDivisionByZero, mysql.MySQLErrName[mysql.ErrDivisionByZero]) ErrRegexp = terror.ClassExpression.New(mysql.ErrRegexp, mysql.MySQLErrName[mysql.ErrRegexp]) ErrOperandColumns = terror.ClassExpression.New(mysql.ErrOperandColumns, mysql.MySQLErrName[mysql.ErrOperandColumns]) ErrCutValueGroupConcat = terror.ClassExpression.New(mysql.ErrCutValueGroupConcat, mysql.MySQLErrName[mysql.ErrCutValueGroupConcat]) ErrFunctionsNoopImpl = terror.ClassExpression.New(mysql.ErrNotSupportedYet, "function %s has only noop implementation in tidb now, use tidb_enable_noop_functions to enable these functions") ErrIncorrectType = terror.ClassExpression.New(mysql.ErrIncorrectType, mysql.MySQLErrName[mysql.ErrIncorrectType]) )
Error instances.
var ( // CollationStrictness indicates the strictness of comparison of the collation. The unequal order in a weak collation also holds in a strict collation. // For example, if a < b in a weak collation(e.g. general_ci), then there must be a < b in a strict collation(e.g. _bin). CollationStrictness = map[string]int{ "utf8_general_ci": 0, "utf8mb4_general_ci": 0, charset.CollationASCII: 1, charset.CollationLatin1: 1, charset.CollationUTF8: 1, charset.CollationUTF8MB4: 1, charset.CollationBin: 2, } )
var (
ErrNoDB = terror.ClassOptimizer.New(mysql.ErrNoDB, mysql.MySQLErrName[mysql.ErrNoDB])
)
error definitions.
Functions ¶
func CompareInt ¶
func CompareInt(sctx sctx.Context, lhsArg, rhsArg Expression, lhsRow, rhsRow chunk.Row) (int64, bool, error)
CompareInt compares two integers.
func CompareStringWithCollationInfo ¶
func CompareStringWithCollationInfo(sctx sctx.Context, lhsArg, rhsArg Expression, lhsRow, rhsRow chunk.Row, collation string) (int64, bool, error)
CompareStringWithCollationInfo compares two strings with the specified collation information.
func EvalBool ¶
EvalBool evaluates expression list to a boolean value. The first returned value indicates bool result of the expression list, the second returned value indicates whether the result of the expression list is null, it can only be true when the first returned values is false.
func FindFieldName ¶
FindFieldName finds the column name from NameSlice.
func GetAccurateCmpType ¶
func GetAccurateCmpType(lhs, rhs Expression) types.EvalType
GetAccurateCmpType uses a more complex logic to decide the EvalType of the two args when compare with each other than getBaseCmpType does.
func GetBuiltinList ¶
func GetBuiltinList() []string
GetBuiltinList returns a list of builtin functions
func GetRowLen ¶
func GetRowLen(e Expression) int
GetRowLen gets the length if the func is row, returns 1 if not row.
func GetUsedList ¶
GetUsedList shows whether each column in schema is contained in usedCols.
func IsFunctionSupported ¶
IsFunctionSupported check if given function name is a builtin sql function.
Types ¶
type Coercibility ¶
type Coercibility int
Coercibility values are used to check whether the collation of one item can be coerced to the collation of other. See https://dev.mysql.com/doc/refman/8.0/en/charset-collation-coercibility.html
const ( // CoercibilityExplicit is derived from an explicit COLLATE clause. CoercibilityExplicit Coercibility = 0 // CoercibilityNone is derived from the concatenation of two strings with different collations. CoercibilityNone Coercibility = 1 // CoercibilityImplicit is derived from a column or a stored routine parameter or local variable. CoercibilityImplicit Coercibility = 2 // CoercibilitySysconst is derived from a “system constant” (the string returned by functions such as USER() or VERSION()). CoercibilitySysconst Coercibility = 3 // CoercibilityCoercible is derived from a literal. CoercibilityCoercible Coercibility = 4 // CoercibilityNumeric is derived from a numeric or temporal value. CoercibilityNumeric Coercibility = 5 // CoercibilityIgnorable is derived from NULL or an expression that is derived from NULL. CoercibilityIgnorable Coercibility = 6 )
type CollationInfo ¶
type CollationInfo interface { // HasCoercibility returns if the Coercibility value is initialized. HasCoercibility() bool // Coercibility returns the coercibility value which is used to check collations. Coercibility() Coercibility // SetCoercibility sets a specified coercibility for this expression. SetCoercibility(val Coercibility) // CharsetAndCollation ... CharsetAndCollation(ctx sessionctx.Context) (string, string) // SetCharsetAndCollation ... SetCharsetAndCollation(chs, coll string) }
CollationInfo contains all interfaces about dealing with collation.
type Column ¶
type Column struct { RetType *types.FieldType // ID is used to specify whether this column is ExtraHandleColumn or to access histogram. // We'll try to remove it in the future. ID int64 // UniqueID is the unique id of this column. UniqueID int64 // Index is used for execution, to tell the column's position in the given row. Index int OrigName string IsHidden bool //collationInfo Family string // contains filtered or unexported fields }
Column represents a column.
func ExtractColumns ¶
func ExtractColumns(expr Expression) []*Column
ExtractColumns extracts all columns from an expression.
func (*Column) Equal ¶
func (col *Column) Equal(_ sctx.Context, expr Expression) bool
Equal implements Expression interface.
func (*Column) EvalString ¶
EvalString returns string representation of Column.
func (*Column) ToColumnMeta ¶
func (col *Column) ToColumnMeta() *model.ColumnMeta
type CompareFunc ¶
type CompareFunc = func(sctx sctx.Context, lhsArg, rhsArg Expression, lhsRow, rhsRow chunk.Row) (int64, bool, error)
CompareFunc defines the compare function prototype.
type Constant ¶
type Constant struct { Value types.Datum RetType *types.FieldType // contains filtered or unexported fields }
Constant stands for a constant value.
func DatumToConstant ¶
DatumToConstant generates a Constant expression from a Datum.
func (*Constant) Clone ¶
func (c *Constant) Clone() Expression
Clone implements Expression interface.
func (*Constant) Equal ¶
func (c *Constant) Equal(ctx sctx.Context, b Expression) bool
Equal implements Expression interface.
func (*Constant) EvalString ¶
EvalString returns string representation of Constant.
type Expression ¶
type Expression interface { // Eval evaluates an expression through a row. Eval(row chunk.Row) (types.Datum, error) // EvalInt returns the int64 representation of expression. EvalInt(ctx sctx.Context, row chunk.Row) (val int64, isNull bool, err error) // EvalString returns the string representation of expression. EvalString(ctx sctx.Context, row chunk.Row) (val string, isNull bool, err error) // GetType gets the type that the expression returns. GetType() *types.FieldType // Equal checks whether two expressions are equal. Equal(ctx sctx.Context, e Expression) bool // Clone copies an expression totally. Clone() Expression }
Expression represents all scalar expression in SQL.
func NewFunction ¶
func NewFunction(ctx sctx.Context, funcName string, retType *types.FieldType, args ...Expression) (Expression, error)
NewFunction creates a new scalar function or constant via a constant folding.
func NewFunctionBase ¶
func NewFunctionBase(ctx sctx.Context, funcName string, retType *types.FieldType, args ...Expression) (Expression, error)
NewFunctionBase creates a new scalar function with no constant folding.
func NewFunctionInternal ¶
func NewFunctionInternal(ctx sctx.Context, funcName string, retType *types.FieldType, args ...Expression) Expression
NewFunctionInternal is similar to NewFunction, but do not returns error, should only be used internally.
func ScalarFuncs2Exprs ¶
func ScalarFuncs2Exprs(funcs []*ScalarFunction) []Expression
ScalarFuncs2Exprs converts []*ScalarFunction to []Expression.
type ScalarFunction ¶
type ScalarFunction struct { FuncName model.CIStr // RetType is the type that ScalarFunction returns. // TODO: Implement type inference here, now we use ast's return type temporarily. RetType *types.FieldType Function builtinFunc }
ScalarFunction is the function that returns a value.
func (*ScalarFunction) Clone ¶
func (sf *ScalarFunction) Clone() Expression
Clone implements Expression interface.
func (*ScalarFunction) Equal ¶
func (sf *ScalarFunction) Equal(ctx sctx.Context, e Expression) bool
Equal implements Expression interface.
func (*ScalarFunction) EvalString ¶
EvalString implements Expression interface.
func (*ScalarFunction) GetArgs ¶
func (sf *ScalarFunction) GetArgs() []Expression
GetArgs gets arguments of function.
func (*ScalarFunction) GetCtx ¶
func (sf *ScalarFunction) GetCtx() sctx.Context
GetCtx gets the context of function.
func (*ScalarFunction) GetType ¶
func (sf *ScalarFunction) GetType() *types.FieldType
GetType implements Expression interface.
func (*ScalarFunction) MarshalJSON ¶
func (sf *ScalarFunction) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
type Schema ¶
Schema stands for the row schema and unique key information get from input.
func MergeSchema ¶
MergeSchema will merge two schema into one schema. We shouldn't need to consider unique keys. That will be processed in build_key_info.go.
func (*Schema) ColumnIndex ¶
ColumnIndex finds the index for a column.
func (*Schema) ColumnsByIndices ¶
ColumnsByIndices returns columns by multiple offsets. Callers should guarantee that all the offsets provided should be valid, which means offset should: 1. not smaller than 0, and 2. not exceed len(s.Columns)
func (*Schema) ColumnsIndices ¶
ColumnsIndices will return a slice which contains the position of each column in schema. If there is one column that doesn't match, nil will be returned.
func (*Schema) RetrieveColumn ¶
RetrieveColumn retrieves column in expression from the columns in schema.
func (*Schema) SetUniqueKeys ¶
SetUniqueKeys will set the value of Schema.Keys.