xeval

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FlagIgnoreTruncate indicates if truncate error should be ignored.
	// Read-only statements should ignore truncate error, write statements should not ignore truncate error.
	FlagIgnoreTruncate uint64 = 1
	// FlagTruncateAsWarning indicates if truncate error should be returned as warning.
	// This flag only matters if FlagIgnoreTruncate is not set, in strict sql mode, truncate error should
	// be returned as error, in non-strict sql mode, truncate error should be saved as warning.
	FlagTruncateAsWarning uint64 = 1 << 1
)

Flags are used by tipb.SelectRequest.Flags to handle execution mode, like how to handle truncate error.

View Source
const (
	CodeInvalid = 3
)

Error codes.

Variables

View Source
var (
	ErrInvalid = terror.ClassXEval.New(CodeInvalid, "invalid operation")
)

Error instances.

Functions

func ComputeArithmetic

func ComputeArithmetic(sc *variable.StatementContext, op tipb.ExprType, left types.Datum, right types.Datum) (types.Datum, error)

ComputeArithmetic computes the arithmetic operation on two datums.

func ComputeBit

func ComputeBit(sc *variable.StatementContext, op tipb.ExprType, left, right types.Datum) (types.Datum, error)

ComputeBit computes the bitwise operation on two datums.

func FlagsToStatementContext

func FlagsToStatementContext(flags uint64) *variable.StatementContext

FlagsToStatementContext creates a StatementContext from a `tipb.SelectRequest.Flags`.

Types

type Evaluator

type Evaluator struct {
	Row map[int64]types.Datum // TODO: Remove this field after refactor cop_handler.

	ColVals     []types.Datum
	ColIDs      map[int64]int
	ColumnInfos []*tipb.ColumnInfo

	StatementCtx *variable.StatementContext
	TimeZone     *time.Location
	// contains filtered or unexported fields
}

Evaluator evaluates tipb.Expr.

func NewEvaluator

func NewEvaluator(sc *variable.StatementContext, timeZone *time.Location) *Evaluator

NewEvaluator creates a new Evaluator instance.

func (*Evaluator) Eval

func (e *Evaluator) Eval(expr *tipb.Expr) (types.Datum, error)

Eval evaluates expr to a Datum.

func (*Evaluator) SetColumnInfos

func (e *Evaluator) SetColumnInfos(cols []*tipb.ColumnInfo)

SetColumnInfos sets ColumnInfos.

func (*Evaluator) SetRowValue

func (e *Evaluator) SetRowValue(handle int64, row [][]byte, relatedColIDs map[int64]int) error

SetRowValue puts row value into evaluator, the values will be used for expr evaluation.

Jump to

Keyboard shortcuts

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