expression

package
v0.0.0-...-e0c7ee5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Copyright 2015 PingCAP, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	// One stands for a number 1.
	One = &Constant{
		Value:   types.NewDatum(1),
		RetType: types.NewFieldType(mysql.TypeTiny),
	}

	// Zero stands for a number 0.
	Zero = &Constant{
		Value:   types.NewDatum(0),
		RetType: types.NewFieldType(mysql.TypeTiny),
	}

	// Null stands for null constant.
	Null = &Constant{
		Value:   types.NewDatum(nil),
		RetType: types.NewFieldType(mysql.TypeTiny),
	}
)
View Source
var DeferredFunctions = map[string]struct{}{
	ast.Now:              {},
	ast.CurrentTimestamp: {},
	ast.UTCTime:          {},
	ast.Curtime:          {},
	ast.CurrentTime:      {},
	ast.UTCTimestamp:     {},
	ast.UnixTimestamp:    {},
	ast.Sysdate:          {},
	ast.Curdate:          {},
	ast.CurrentDate:      {},
	ast.UTCDate:          {},
	ast.Rand:             {},
	ast.UUID:             {},
}

DeferredFunctions stores non-deterministic functions, which can be deferred only when the plan cache is enabled.

View Source
var DisableFoldFunctions = map[string]struct{}{
	ast.Benchmark: {},
}

DisableFoldFunctions stores functions which prevent child scope functions from being constant folded. Typically, these functions shall also exist in unFoldableFunctions, to stop from being folded when they themselves are in child scope of an outer function, and the outer function is recursively folding its children.

error definitions.

Functions

func CheckArgsNotMultiColumnRow

func CheckArgsNotMultiColumnRow(args ...Expression) error

CheckArgsNotMultiColumnRow checks the args are not multi-column row.

func CompareDecimal

func CompareDecimal(sctx sessionctx.Context, lhsArg, rhsArg Expression, lhsRow, rhsRow chunk.Row) (int64, bool, error)

CompareDecimal compares two decimals.

func CompareInt

func CompareInt(sctx sessionctx.Context, lhsArg, rhsArg Expression, lhsRow, rhsRow chunk.Row) (int64, bool, error)

CompareInt compares two integers.

func CompareReal

func CompareReal(sctx sessionctx.Context, lhsArg, rhsArg Expression, lhsRow, rhsRow chunk.Row) (int64, bool, error)

CompareReal compares two float-point values.

func CompareString

func CompareString(sctx sessionctx.Context, lhsArg, rhsArg Expression, lhsRow, rhsRow chunk.Row) (int64, bool, error)

CompareString compares two strings.

func ConstructPositionExpr

func ConstructPositionExpr(p *driver.ParamMarkerExpr) *ast.PositionExpr

ConstructPositionExpr constructs PositionExpr with the given ParamMarkerExpr.

func ExprFromSchema

func ExprFromSchema(expr Expression, schema *Schema) bool

ExprFromSchema checks if all columns of this expression are from the same schema.

func FindFieldName

func FindFieldName(names types.NameSlice, astCol *ast.ColumnName) (int, error)

FindFieldName finds the column name from NameSlice.

func FindFieldNameIdxByColName

func FindFieldNameIdxByColName(names []*types.FieldName, colName string) int

FindFieldNameIdxByColName finds the index of corresponding name in the given slice. -1 for not found.

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 GetRowLen

func GetRowLen(e Expression) int

GetRowLen gets the length if the func is row, returns 1 if not row.

func GetUint64FromConstant

func GetUint64FromConstant(expr Expression) (uint64, bool, bool)

GetUint64FromConstant gets a uint64 from constant expression.

func InferType4ControlFuncs

func InferType4ControlFuncs(lhs, rhs *types.FieldType) *types.FieldType

InferType4ControlFuncs infer result type for builtin IF, IFNULL, NULLIF, LEAD and LAG.

func IsBinaryLiteral

func IsBinaryLiteral(expr Expression) bool

IsBinaryLiteral checks whether an expression is a binary literal

func IsEQCondFromIn

func IsEQCondFromIn(expr Expression) bool

IsEQCondFromIn checks if an expression is equal condition converted from `[not] in (subq)`.

func IsMutableEffectsExpr

func IsMutableEffectsExpr(expr Expression) bool

IsMutableEffectsExpr checks if expr contains function which is mutable or has side effects.

func SetBinFlagOrBinStr

func SetBinFlagOrBinStr(argTp *types.FieldType, resTp *types.FieldType)

SetBinFlagOrBinStr sets resTp to binary string if argTp is a binary string, if not, sets the binary flag of resTp to true if argTp has binary flag.

Types

type CNFExprs

type CNFExprs []Expression

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

	// VirtualExpr is used to save expression for virtual column
	VirtualExpr Expression

	OrigName string // OrigName usually in format DBName.TableName.ColumnName
	IsHidden bool

	// InOperand indicates whether this column is the inner operand of column equal condition converted
	// from `[not] in (subq)`.
	InOperand      bool
	UseAsThreshold bool
	// contains filtered or unexported fields
}

func ExtractColumns

func ExtractColumns(expr Expression) []*Column

func ExtractColumnsFromExpressions

func ExtractColumnsFromExpressions(result []*Column, exprs []Expression, filter func(*Column) bool) []*Column

ExtractColumnsFromExpressions is a more efficient version of ExtractColumns for batch operation. filter can be nil, or a function to filter the result column. It's often observed that the pattern of the caller like this:

cols := ExtractColumns(...)

for _, col := range cols {
    if xxx(col) {...}
}

Provide an additional filter argument, this can be done in one step. To avoid allocation for cols that not need.

func (*Column) Clone

func (col *Column) Clone() Expression

func (*Column) ConstItem

func (col *Column) ConstItem(_ *stmtctx.StatementContext) bool

ConstItem implements Expression interface.

func (*Column) Decorrelate

func (col *Column) Decorrelate(_ *Schema) Expression

Decorrelate implements Expression interface.

func (*Column) Equal

func (col *Column) Equal(_ sessionctx.Context, expr Expression) bool

func (*Column) Eval

func (col *Column) Eval(row chunk.Row) (types.Datum, error)

Eval implements Expression interface.

func (*Column) EvalDecimal

func (col *Column) EvalDecimal(ctx sessionctx.Context, row chunk.Row) (*types.MyDecimal, bool, error)

EvalDecimal returns decimal representation of Column.

func (*Column) EvalDuration

func (col *Column) EvalDuration(ctx sessionctx.Context, row chunk.Row) (types.Duration, bool, error)

EvalDuration returns Duration representation of Column.

func (*Column) EvalInt

func (col *Column) EvalInt(ctx sessionctx.Context, row chunk.Row) (int64, bool, error)

EvalInt returns int representation of Column.

func (*Column) EvalReal

func (col *Column) EvalReal(ctx sessionctx.Context, row chunk.Row) (float64, bool, error)

EvalReal returns real representation of Column.

func (*Column) EvalString

func (col *Column) EvalString(ctx sessionctx.Context, row chunk.Row) (string, bool, error)

EvalString returns string representation of Column.

func (*Column) EvalTime

func (col *Column) EvalTime(ctx sessionctx.Context, row chunk.Row) (types.Time, bool, error)

EvalTime returns DATE/DATETIME/TIMESTAMP representation of Column.

func (*Column) GetType

func (col *Column) GetType() *types.FieldType

func (*Column) HashCode

func (col *Column) HashCode(_ *stmtctx.StatementContext) []byte

HashCode implements Expression interface.

func (*Column) String

func (col *Column) String() string

type CompareFunc

type CompareFunc = func(sctx sessionctx.Context, lhsArg, rhsArg Expression, lhsRow, rhsRow chunk.Row) (int64, bool, error)

CompareFunc defines the compare function prototype.

func GetCmpFunction

func GetCmpFunction(lhs, rhs Expression) CompareFunc

GetCmpFunction get the compare function according to two arguments.

type Constant

type Constant struct {
	Value   types.Datum
	RetType *types.FieldType
	// DeferredExpr holds deferred function in PlanCache cached plan.
	// it's only used to represent non-deterministic functions(see expression.DeferredFunctions)
	// in PlanCache cached plan, so let them can be evaluated until cached item be used.
	DeferredExpr Expression
	// ParamMarker holds param index inside sessionVars.PreparedParams.
	// It's only used to reference a user variable provided in the `EXECUTE` statement or `COM_EXECUTE` binary protocol.
	ParamMarker *ParamMarker
	// contains filtered or unexported fields
}

Constant stands for a constant value.

func RefineComparedConstant

func RefineComparedConstant(ctx sessionctx.Context, targetFieldType types.FieldType, con *Constant, op opcode.Op) (_ *Constant, isExceptional bool)

RefineComparedConstant changes a non-integer constant argument to its ceiling or floor result by the given op. isExceptional indicates whether the 'int column cmp const' might be true/false. If isExceptional is true, ExecptionalVal is returned. Or, CorrectVal is returned. CorrectVal: The computed result. If the constant can be converted to int without exception, return the val. Else return 'con'(the input). ExceptionalVal : It is used to get more information to check whether 'int column cmp const' is true/false

If the op == LT,LE,GT,GE and it gets an Overflow when converting, return inf/-inf.
If the op == EQ,NullEQ and the constant can never be equal to the int column, return ‘con’(the input, a non-int c     onstant).

func (*Constant) Clone

func (c *Constant) Clone() Expression

Clone implements Expression interface.

func (*Constant) ConstItem

func (c *Constant) ConstItem(sc *stmtctx.StatementContext) bool

ConstItem implements Expression interface.

func (*Constant) Decorrelate

func (c *Constant) Decorrelate(_ *Schema) Expression

Decorrelate implements Expression interface.

func (*Constant) Equal

func (c *Constant) Equal(ctx sessionctx.Context, b Expression) bool

Equal implements Expression interface.

func (*Constant) Eval

func (c *Constant) Eval(_ chunk.Row) (types.Datum, error)

Eval implements Expression interface.

func (*Constant) EvalDecimal

func (c *Constant) EvalDecimal(ctx sessionctx.Context, _ chunk.Row) (*types.MyDecimal, bool, error)

EvalDecimal returns decimal representation of Constant.

func (*Constant) EvalDuration

func (c *Constant) EvalDuration(ctx sessionctx.Context, _ chunk.Row) (val types.Duration, isNull bool, err error)

EvalDuration returns Duration representation of Constant.

func (*Constant) EvalInt

func (c *Constant) EvalInt(ctx sessionctx.Context, _ chunk.Row) (int64, bool, error)

EvalInt returns int representation of Constant.

func (*Constant) EvalReal

func (c *Constant) EvalReal(ctx sessionctx.Context, _ chunk.Row) (float64, bool, error)

EvalReal returns real representation of Constant.

func (*Constant) EvalString

func (c *Constant) EvalString(ctx sessionctx.Context, _ chunk.Row) (string, bool, error)

EvalString returns string representation of Constant.

func (*Constant) EvalTime

func (c *Constant) EvalTime(ctx sessionctx.Context, _ chunk.Row) (val types.Time, isNull bool, err error)

EvalTime returns DATE/DATETIME/TIMESTAMP representation of Constant.

func (*Constant) GetType

func (c *Constant) GetType() *types.FieldType

GetType implements Expression interface.

func (*Constant) HashCode

func (c *Constant) HashCode(sc *stmtctx.StatementContext) []byte

HashCode implements Expression interface.

func (*Constant) String

func (c *Constant) String() string

String implements fmt.Stringer interface.

type CorrelatedColumn

type CorrelatedColumn struct {
	Column

	Data *types.Datum
}

CorrelatedColumn stands for a column in a correlated sub query.

func ExtractCorColumns

func ExtractCorColumns(expr Expression) (cols []*CorrelatedColumn)

ExtractCorColumns extracts correlated column from given expression.

type ExprConverter

type ExprConverter struct {
}

ExprConverter converts expression to expr node

func (ExprConverter) ConvertExpressionToExprNode

func (c ExprConverter) ConvertExpressionToExprNode(dialect format.Dialect, expr Expression, prec int, idToExpr map[int64]ast.ExprNode) (ast.ExprNode, error)

type Expression

type Expression interface {
	fmt.Stringer

	// Eval evaluates an expression through a row.
	Eval(row chunk.Row) (types.Datum, error)

	// EvalInt returns the int64 representation of expression.
	EvalInt(ctx sessionctx.Context, row chunk.Row) (val int64, isNull bool, err error)

	// EvalReal returns the float64 representation of expression.
	EvalReal(ctx sessionctx.Context, row chunk.Row) (val float64, isNull bool, err error)

	// EvalString returns the string representation of expression.
	EvalString(ctx sessionctx.Context, row chunk.Row) (val string, isNull bool, err error)

	// EvalDecimal returns the decimal representation of expression.
	EvalDecimal(ctx sessionctx.Context, row chunk.Row) (val *types.MyDecimal, isNull bool, err error)

	// EvalTime returns the DATE/DATETIME/TIMESTAMP representation of expression.
	EvalTime(ctx sessionctx.Context, row chunk.Row) (val types.Time, isNull bool, err error)

	// EvalDuration returns the duration representation of expression.
	EvalDuration(ctx sessionctx.Context, row chunk.Row) (val types.Duration, isNull bool, err error)

	GetType() *types.FieldType

	// Clone copies an expression totally.
	Clone() Expression

	// Equal checks whether two expressions are equal.
	Equal(ctx sessionctx.Context, e Expression) bool

	// ConstItem checks if this expression is constant item, regardless of query evaluation state.
	// An expression is constant item if it:
	// refers no tables.
	// refers no correlated column.
	// refers no subqueries that refers any tables.
	// refers no non-deterministic functions.
	// refers no statement parameters.
	// refers no param markers when prepare plan cache is enabled.
	ConstItem(sc *stmtctx.StatementContext) bool

	// Decorrelate try to decorrelate the expression by schema.
	Decorrelate(schema *Schema) Expression

	// HashCode creates the hashcode for expression which can be used to identify itself from other expression.
	// It generated as the following:
	// Constant: ConstantFlag+encoded value
	// Column: ColumnFlag+encoded value
	// ScalarFunction: SFFlag+encoded function name + encoded arg_1 + encoded arg_2 + ...
	HashCode(sc *stmtctx.StatementContext) []byte
}

func BuildCastFunction

func BuildCastFunction(ctx sessionctx.Context, expr Expression, tp *types.FieldType) (res Expression)

BuildCastFunction builds a CAST ScalarFunction from the Expression.

func BuildCastFunction4Union

func BuildCastFunction4Union(ctx sessionctx.Context, expr Expression, tp *types.FieldType) (res Expression)

BuildCastFunction4Union build a implicitly CAST ScalarFunction from the Union Expression.

func Column2Exprs

func Column2Exprs(cols []*Column) []Expression

Column2Exprs will transfer column slice to expression slice.

func ColumnSubstitute

func ColumnSubstitute(expr Expression, schema *Schema, newExprs []Expression) Expression

ColumnSubstitute substitutes the columns in filter to expressions in select fields. e.g. select * from (select b as a from t) k where a < 10 => select * from (select b as a from t where b < 10) k.

func ColumnSubstituteImpl

func ColumnSubstituteImpl(expr Expression, schema *Schema, newExprs []Expression) (bool, Expression)

ColumnSubstituteImpl tries to substitute column expr using newExprs, the newFunctionInternal is only called if its child is substituted

func ComposeCNFCondition

func ComposeCNFCondition(ctx sessionctx.Context, conditions ...Expression) Expression

ComposeCNFCondition composes CNF items into a balance deep CNF tree, which benefits a lot for pb decoder/encoder.

func ComposeDNFCondition

func ComposeDNFCondition(ctx sessionctx.Context, conditions ...Expression) Expression

ComposeDNFCondition composes DNF items into a balance deep DNF tree.

func EvaluateExprWithNull

func EvaluateExprWithNull(ctx sessionctx.Context, schema *Schema, expr Expression) Expression

EvaluateExprWithNull sets columns in schema as null and calculate the final result of the scalar function. If the Expression is a non-constant value, it means the result is unknown.

func ExtractFiltersFromDNFs

func ExtractFiltersFromDNFs(ctx sessionctx.Context, conditions []Expression) []Expression

ExtractFiltersFromDNFs checks whether the cond is DNF. If so, it will get the extracted part and the remained part. The original DNF will be replaced by the remained part or just be deleted if remained part is nil. And the extracted part will be appended to the end of the original slice.

func FlattenDNFConditions

func FlattenDNFConditions(DNFCondition *ScalarFunction) []Expression

FlattenDNFConditions extracts DNF expression's leaf item. e.g. or(or(a=1, a=2), or(a=3, a=4)), we'll get [a=1, a=2, a=3, a=4].

func GetFuncArg

func GetFuncArg(e Expression, idx int) Expression

GetFuncArg gets the argument of the function at idx.

func NewFunction

func NewFunction(ctx sessionctx.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 sessionctx.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 sessionctx.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 PopRowFirstArg

func PopRowFirstArg(ctx sessionctx.Context, e Expression) (ret Expression, err error)

PopRowFirstArg pops the first element and returns the rest of row. e.g. After this function (1, 2, 3) becomes (2, 3).

func RemoveDupExprs

func RemoveDupExprs(ctx sessionctx.Context, exprs []Expression) []Expression

RemoveDupExprs removes identical exprs. Not that if expr contains functions which are mutable or have side effects, we cannot remove it even if it has duplicates.

func ScalarFuncs2Exprs

func ScalarFuncs2Exprs(funcs []*ScalarFunction) []Expression

ScalarFuncs2Exprs converts []*ScalarFunction to []Expression.

func SplitCNFItems

func SplitCNFItems(onExpr Expression) []Expression

SplitCNFItems splits CNF items. CNF means conjunctive normal form, e.g. "a and b and c".

func TransferDateFuncIntervalToSeconds

func TransferDateFuncIntervalToSeconds(funcArgs []Expression) ([]Expression, error)

func WrapWithCastAsDecimal

func WrapWithCastAsDecimal(ctx sessionctx.Context, expr Expression) Expression

WrapWithCastAsDecimal wraps `expr` with `cast` if the return type of expr is not type decimal, otherwise, returns `expr` directly.

func WrapWithCastAsDuration

func WrapWithCastAsDuration(ctx sessionctx.Context, expr Expression) Expression

WrapWithCastAsDuration wraps `expr` with `cast` if the return type of expr is not type duration, otherwise, returns `expr` directly.

func WrapWithCastAsInt

func WrapWithCastAsInt(ctx sessionctx.Context, expr Expression) Expression

WrapWithCastAsInt wraps `expr` with `cast` if the return type of expr is not type int, otherwise, returns `expr` directly.

func WrapWithCastAsJSON

func WrapWithCastAsJSON(ctx sessionctx.Context, expr Expression) Expression

WrapWithCastAsJSON wraps `expr` with `cast` if the return type of expr is not type json, otherwise, returns `expr` directly.

func WrapWithCastAsReal

func WrapWithCastAsReal(ctx sessionctx.Context, expr Expression) Expression

WrapWithCastAsReal wraps `expr` with `cast` if the return type of expr is not type real, otherwise, returns `expr` directly.

func WrapWithCastAsString

func WrapWithCastAsString(ctx sessionctx.Context, expr Expression) Expression

WrapWithCastAsString wraps `expr` with `cast` if the return type of expr is not type string, otherwise, returns `expr` directly.

func WrapWithCastAsTime

func WrapWithCastAsTime(ctx sessionctx.Context, expr Expression, tp *types.FieldType) Expression

WrapWithCastAsTime wraps `expr` with `cast` if the return type of expr is not same as type of the specified `tp` , otherwise, returns `expr` directly.

type KeyInfo

type KeyInfo []*Column

KeyInfo stores the columns of one unique key or primary key.

func (KeyInfo) Clone

func (ki KeyInfo) Clone() KeyInfo

Clone copies the entire UniqueKey.

type MysqlRng

type MysqlRng struct {
	// contains filtered or unexported fields
}

MysqlRng is random number generator and this implementation is ported from MySQL. See https://github.com/tikv/tikv/pull/6117#issuecomment-562489078.

func NewWithSeed

func NewWithSeed(seed int64) *MysqlRng

NewWithSeed create a rng with random seed.

func NewWithTime

func NewWithTime() *MysqlRng

NewWithTime create a rng with time stamp.

func (*MysqlRng) Gen

func (rng *MysqlRng) Gen() float64

Gen will generate random number.

type ParamMarker

type ParamMarker struct {
	// contains filtered or unexported fields
}

ParamMarker indicates param provided by COM_STMT_EXECUTE.

func (*ParamMarker) GetUserVar

func (d *ParamMarker) GetUserVar() types.Datum

GetUserVar returns the corresponding user variable presented in the `EXECUTE` statement or `COM_EXECUTE` command.

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
	// contains filtered or unexported fields
}

ScalarFunction is the function that returns a value.

func (*ScalarFunction) Clone

func (sf *ScalarFunction) Clone() Expression

Clone implements Expression interface.

func (*ScalarFunction) ConstItem

func (sf *ScalarFunction) ConstItem(sc *stmtctx.StatementContext) bool

ConstItem implements Expression interface.

func (*ScalarFunction) Decorrelate

func (sf *ScalarFunction) Decorrelate(schema *Schema) Expression

Decorrelate implements Expression interface.

func (*ScalarFunction) Equal

func (sf *ScalarFunction) Equal(ctx sessionctx.Context, e Expression) bool

Equal implements Expression interface.

func (*ScalarFunction) Eval

func (sf *ScalarFunction) Eval(row chunk.Row) (d types.Datum, err error)

Eval implements Expression interface.

func (*ScalarFunction) EvalDecimal

func (sf *ScalarFunction) EvalDecimal(ctx sessionctx.Context, row chunk.Row) (*types.MyDecimal, bool, error)

EvalDecimal implements Expression interface.

func (*ScalarFunction) EvalDuration

func (sf *ScalarFunction) EvalDuration(ctx sessionctx.Context, row chunk.Row) (types.Duration, bool, error)

EvalDuration implements Expression interface.

func (*ScalarFunction) EvalInt

func (sf *ScalarFunction) EvalInt(ctx sessionctx.Context, row chunk.Row) (int64, bool, error)

EvalInt implements Expression interface.

func (*ScalarFunction) EvalReal

func (sf *ScalarFunction) EvalReal(ctx sessionctx.Context, row chunk.Row) (float64, bool, error)

EvalReal implements Expression interface.

func (*ScalarFunction) EvalString

func (sf *ScalarFunction) EvalString(ctx sessionctx.Context, row chunk.Row) (string, bool, error)

EvalString implements Expression interface.

func (*ScalarFunction) EvalTime

func (sf *ScalarFunction) EvalTime(ctx sessionctx.Context, row chunk.Row) (types.Time, bool, error)

EvalTime implements Expression interface.

func (*ScalarFunction) GetArgs

func (sf *ScalarFunction) GetArgs() []Expression

GetArgs gets arguments of function.

func (*ScalarFunction) GetCtx

func (sf *ScalarFunction) GetCtx() sessionctx.Context

GetCtx gets the context of function.

func (*ScalarFunction) GetType

func (sf *ScalarFunction) GetType() *types.FieldType

func (*ScalarFunction) HashCode

func (sf *ScalarFunction) HashCode(sc *stmtctx.StatementContext) []byte

HashCode implements Expression interface.

func (*ScalarFunction) String

func (sf *ScalarFunction) String() string

String implements fmt.Stringer interface.

type Schema

type Schema struct {
	Columns []*Column
	Keys    []KeyInfo
}

Schema stands for the row schema and unique key information get from input.

func MergeSchema

func MergeSchema(lSchema, rSchema *Schema) *Schema

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 NewSchema

func NewSchema(cols ...*Column) *Schema

NewSchema returns a schema made by its parameter.

func (*Schema) Append

func (s *Schema) Append(col ...*Column)

Append append new column to the columns stored in schema.

func (*Schema) Clone

func (s *Schema) Clone() *Schema

Clone copies the total schema.

func (*Schema) ColumnIndex

func (s *Schema) ColumnIndex(col *Column) int

ColumnIndex finds the index for a column.

func (*Schema) ColumnsByIndices

func (s *Schema) ColumnsByIndices(offsets []int) []*Column

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

func (s *Schema) ColumnsIndices(cols []*Column) (ret []int)

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) Contains

func (s *Schema) Contains(col *Column) bool

Contains checks if the schema contains the column.

func (*Schema) IsUniqueKey

func (s *Schema) IsUniqueKey(col *Column) bool

IsUniqueKey checks if this column is a unique key.

func (*Schema) Len

func (s *Schema) Len() int

Len returns the number of columns in schema.

func (*Schema) RetrieveColumn

func (s *Schema) RetrieveColumn(col *Column) *Column

RetrieveColumn retrieves column in expression from the columns in schema.

func (*Schema) SetUniqueKeys

func (s *Schema) SetUniqueKeys(keys []KeyInfo)

SetUniqueKeys will set the value of Schema.Keys.

func (*Schema) String

func (s *Schema) String() string

String implements fmt.Stringer interface.

type VarAssignment

type VarAssignment struct {
	Name        string
	Expr        Expression
	IsDefault   bool
	IsGlobal    bool
	IsSystem    bool
	ExtendValue *Constant
}

VarAssignment represents a variable assignment in Set, such as set global a = 1.

type WildcardPattern

type WildcardPattern interface {
	// Compile compiles the patternStr with specified escape character.
	Compile(patternStr string, escape byte)
	// DoMatch tries to match the str with compiled pattern, `Compile()` must be called before calling it.
	DoMatch(str string) bool
}

WildcardPattern is the interface used for wildcard pattern match.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL