Documentation ¶
Index ¶
- Constants
- Variables
- func Eval(ctx context.Context, expr ast.ExprNode) (d types.Datum, err error)
- func EvalBool(ctx context.Context, expr ast.ExprNode) (bool, error)
- func EvalSubquery(ctx context.Context, v *ast.SubqueryExpr) error
- func GetTimeValue(ctx context.Context, v interface{}, tp byte, fsp int) (types.Datum, error)
- func IsCurrentTimeExpr(e ast.ExprNode) bool
- type BuiltinFunc
- type Evaluator
- type Func
Constants ¶
View Source
const (
CodeInvalidOperation terror.ErrCode = 1
)
Error codes.
Variables ¶
View Source
var ( // CurrentTimestamp is the keyword getting default value for datetime and timestamp type. CurrentTimestamp = "CURRENT_TIMESTAMP" // ZeroTimestamp shows the zero datetime and timestamp. ZeroTimestamp = "0000-00-00 00:00:00" )
View Source
var DynamicFuncs = map[string]int{ "rand": 0, "connection_id": 0, "current_user": 0, "database": 0, "found_rows": 0, "last_insert_id": 0, "user": 0, "version": 0, "sleep": 0, ast.GetVar: 0, ast.SetVar: 0, }
DynamicFuncs are those functions that use input parameter ctx or return an uncertain result would not be constant folded the value 0 means nothing
View Source
var (
ErrInvalidOperation = terror.ClassEvaluator.New(CodeInvalidOperation, "invalid operation")
)
Error instances.
View Source
var Funcs = map[string]Func{}/* 109 elements not displayed */
Funcs holds all registered builtin functions.
Functions ¶
func EvalSubquery ¶
func EvalSubquery(ctx context.Context, v *ast.SubqueryExpr) error
EvalSubquery evaluates a subquery.
func GetTimeValue ¶
GetTimeValue gets the time value with type tp.
func IsCurrentTimeExpr ¶
IsCurrentTimeExpr returns whether e is CurrentTimeExpr.
Types ¶
type BuiltinFunc ¶
BuiltinFunc is the function signature for builtin functions
func CastFuncFactory ¶
func CastFuncFactory(tp *types.FieldType) (BuiltinFunc, error)
CastFuncFactory produces builtin function according to field types. See https://dev.mysql.com/doc/refman/5.7/en/cast-functions.html
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator is an ast Visitor that evaluates an expression.
type Func ¶
type Func struct { // F is the specific calling function. F BuiltinFunc // MinArgs is the minimal arguments needed, MinArgs int // MaxArgs is the maximal arguments needed, -1 for infinity. MaxArgs int }
Func is for a builtin function.
Click to show internal directories.
Click to hide internal directories.