Documentation ¶
Index ¶
- Constants
- Variables
- func AssertLocationWithSessionVars(ctxLoc *time.Location, vars *variable.SessionVars)
- type BuildContext
- type ConstantPropagateCheckContext
- type EvalContext
- type ExprContext
- type NullRejectCheckExprContext
- type OptionalEvalPropDesc
- type OptionalEvalPropKey
- type OptionalEvalPropKeySet
- func (b OptionalEvalPropKeySet) Add(key OptionalEvalPropKey) OptionalEvalPropKeySet
- func (b OptionalEvalPropKeySet) Contains(key OptionalEvalPropKey) bool
- func (b OptionalEvalPropKeySet) IsEmpty() bool
- func (b OptionalEvalPropKeySet) IsFull() bool
- func (b OptionalEvalPropKeySet) Remove(key OptionalEvalPropKey) OptionalEvalPropKeySet
- type OptionalEvalPropProvider
- type ParamValues
- type PlanColumnIDAllocator
- type SimplePlanColumnIDAllocator
- type StaticConvertibleEvalContext
- type StaticConvertibleExprContext
Constants ¶
const OptPropsCnt = int(optPropsCnt)
OptPropsCnt is the count of optional properties.
Variables ¶
var ErrParamIndexExceedParamCounts = errors.New("Param index exceed param counts")
ErrParamIndexExceedParamCounts describes the error that the index exceed the count of all params
Functions ¶
func AssertLocationWithSessionVars ¶
func AssertLocationWithSessionVars(ctxLoc *time.Location, vars *variable.SessionVars)
AssertLocationWithSessionVars asserts the location in the context and session variables are the same. It is only used for testing.
Types ¶
type BuildContext ¶
type BuildContext interface { // GetEvalCtx returns the EvalContext. GetEvalCtx() EvalContext // GetCharsetInfo gets charset and collation for current context. GetCharsetInfo() (string, string) // GetDefaultCollationForUTF8MB4 returns the default collation of UTF8MB4. GetDefaultCollationForUTF8MB4() string // GetBlockEncryptionMode returns the variable `block_encryption_mode`. GetBlockEncryptionMode() string // GetSysdateIsNow returns a bool to determine whether Sysdate is an alias of Now function. // It is the value of variable `tidb_sysdate_is_now`. GetSysdateIsNow() bool // GetNoopFuncsMode returns the noop function mode: OFF/ON/WARN values as 0/1/2. GetNoopFuncsMode() int // Rng is used to generate random values. Rng() *mathutil.MysqlRng // IsUseCache indicates whether to cache the build expression in plan cache. IsUseCache() bool // SetSkipPlanCache sets to skip the plan cache and records the reason. SetSkipPlanCache(reason string) // AllocPlanColumnID allocates column id for plan. AllocPlanColumnID() int64 // IsInNullRejectCheck returns the flag to indicate whether the expression is in null reject check. // It should always return `false` in most implementations because we do not want to do null reject check // in most cases except for the method `isNullRejected` in planner. // See the comments for `isNullRejected` in planner for more details. IsInNullRejectCheck() bool // IsConstantPropagateCheck returns the flag to indicate whether the expression is in constant propagate check. // It should be true only when we are doing constant propagation in rule_predicate_push_down. IsConstantPropagateCheck() bool // ConnectionID indicates the connection ID of the current session. // If the context is not in a session, it should return 0. ConnectionID() uint64 // IsReadonlyUserVar checks whether the user variable is readonly. IsReadonlyUserVar(name string) bool }
BuildContext is used to build an expression
func CtxWithHandleTruncateErrLevel ¶
func CtxWithHandleTruncateErrLevel(ctx BuildContext, level errctx.Level) BuildContext
CtxWithHandleTruncateErrLevel returns a new BuildContext with the specified level for handling truncate error.
type ConstantPropagateCheckContext ¶
type ConstantPropagateCheckContext struct {
ExprContext
}
ConstantPropagateCheckContext is a wrapper to return true for `IsConstantPropagateCheck`.
func WithConstantPropagateCheck ¶
func WithConstantPropagateCheck(ctx ExprContext) *ConstantPropagateCheckContext
WithConstantPropagateCheck returns a new `ConstantPropagateCheckContext` with the given `ExprContext`.
func (*ConstantPropagateCheckContext) IsConstantPropagateCheck ¶
func (ctx *ConstantPropagateCheckContext) IsConstantPropagateCheck() bool
IsConstantPropagateCheck always returns true for `ConstantPropagateCheckContext`
type EvalContext ¶
type EvalContext interface { contextutil.WarnHandler ParamValues // CtxID indicates the id of the context. CtxID() uint64 // SQLMode returns the sql mode SQLMode() mysql.SQLMode // TypeCtx returns the types.Context TypeCtx() types.Context // ErrCtx returns the errctx.Context ErrCtx() errctx.Context // Location returns the timezone info Location() *time.Location // CurrentDB return the current database name CurrentDB() string // CurrentTime returns the current time. // Multiple calls for CurrentTime() should return the same value for the same `CtxID`. CurrentTime() (time.Time, error) // GetMaxAllowedPacket returns the value of the 'max_allowed_packet' system variable. GetMaxAllowedPacket() uint64 // GetTiDBRedactLog returns the value of the 'tidb_redact_log' system variable. GetTiDBRedactLog() string // GetDefaultWeekFormatMode returns the value of the 'default_week_format' system variable. GetDefaultWeekFormatMode() string // GetDivPrecisionIncrement returns the specified value of DivPrecisionIncrement. GetDivPrecisionIncrement() int // GetUserVarsReader returns the `UserVarsReader` to read user vars. GetUserVarsReader() variable.UserVarsReader // GetOptionalPropSet returns the optional properties provided by this context. GetOptionalPropSet() OptionalEvalPropKeySet // GetOptionalPropProvider gets the optional property provider by key GetOptionalPropProvider(OptionalEvalPropKey) (OptionalEvalPropProvider, bool) }
EvalContext is used to evaluate an expression
type ExprContext ¶
type ExprContext interface { BuildContext // GetWindowingUseHighPrecision determines whether to compute window operations without loss of precision. // see https://dev.mysql.com/doc/refman/8.0/en/window-function-optimization.html for more details. GetWindowingUseHighPrecision() bool // GetGroupConcatMaxLen returns the value of the 'group_concat_max_len' system variable. GetGroupConcatMaxLen() uint64 }
ExprContext contains full context for expression building and evaluating. It also provides some additional information for to build aggregate functions.
type NullRejectCheckExprContext ¶
type NullRejectCheckExprContext struct {
ExprContext
}
NullRejectCheckExprContext is a wrapper to return true for `IsInNullRejectCheck`.
func WithNullRejectCheck ¶
func WithNullRejectCheck(ctx ExprContext) *NullRejectCheckExprContext
WithNullRejectCheck returns a new `NullRejectCheckExprContext` with the given `ExprContext`.
func (*NullRejectCheckExprContext) IsInNullRejectCheck ¶
func (ctx *NullRejectCheckExprContext) IsInNullRejectCheck() bool
IsInNullRejectCheck always returns true for `NullRejectCheckExprContext`
type OptionalEvalPropDesc ¶
type OptionalEvalPropDesc struct {
// contains filtered or unexported fields
}
OptionalEvalPropDesc is the description for optional evaluation properties in EvalContext.
func (*OptionalEvalPropDesc) Key ¶
func (desc *OptionalEvalPropDesc) Key() OptionalEvalPropKey
Key returns the property key.
type OptionalEvalPropKey ¶
type OptionalEvalPropKey int
OptionalEvalPropKey is the key for optional evaluation properties in EvalContext.
const ( // OptPropCurrentUser indicates to provide the current user property. OptPropCurrentUser OptionalEvalPropKey = iota // OptPropSessionVars indicates to provide `variable.SessionVariable`. OptPropSessionVars // OptPropInfoSchema indicates to provide the information schema. OptPropInfoSchema // OptPropKVStore indicates to provide the kv store. OptPropKVStore // OptPropSQLExecutor indicates to provide executors to execute sql. OptPropSQLExecutor // OptPropSequenceOperator indicates to provide sequence operators for sequences. OptPropSequenceOperator // OptPropAdvisoryLock indicates to provide advisory lock operations. OptPropAdvisoryLock // OptPropDDLOwnerInfo indicates to provide DDL owner information. OptPropDDLOwnerInfo // OptPropPrivilegeChecker indicates to provide the privilege checker. OptPropPrivilegeChecker )
func (OptionalEvalPropKey) AsPropKeySet ¶
func (k OptionalEvalPropKey) AsPropKeySet() OptionalEvalPropKeySet
AsPropKeySet returns the set only contains the property key.
func (OptionalEvalPropKey) Desc ¶
func (k OptionalEvalPropKey) Desc() *OptionalEvalPropDesc
Desc returns the description for the property key.
func (OptionalEvalPropKey) String ¶
func (k OptionalEvalPropKey) String() string
String implements fmt.Stringer interface.
type OptionalEvalPropKeySet ¶
type OptionalEvalPropKeySet uint64
OptionalEvalPropKeySet is a bit map for optional evaluation properties in EvalContext to indicate whether some properties are set.
func (OptionalEvalPropKeySet) Add ¶
func (b OptionalEvalPropKeySet) Add(key OptionalEvalPropKey) OptionalEvalPropKeySet
Add adds the property key to the set
func (OptionalEvalPropKeySet) Contains ¶
func (b OptionalEvalPropKeySet) Contains(key OptionalEvalPropKey) bool
Contains checks whether the set contains the property
func (OptionalEvalPropKeySet) IsEmpty ¶
func (b OptionalEvalPropKeySet) IsEmpty() bool
IsEmpty checks whether the bit map is empty.
func (OptionalEvalPropKeySet) IsFull ¶
func (b OptionalEvalPropKeySet) IsFull() bool
IsFull checks whether all optional properties are contained in the bit map.
func (OptionalEvalPropKeySet) Remove ¶
func (b OptionalEvalPropKeySet) Remove(key OptionalEvalPropKey) OptionalEvalPropKeySet
Remove removes the property key from the set
type OptionalEvalPropProvider ¶
type OptionalEvalPropProvider interface {
Desc() *OptionalEvalPropDesc
}
OptionalEvalPropProvider is the interface to provide optional properties in EvalContext.
type ParamValues ¶
type ParamValues interface { // GetParamValue returns the value of the parameter by index. GetParamValue(idx int) (types.Datum, error) }
ParamValues is a readonly interface to return param
var EmptyParamValues ParamValues = &emptyParamValues{}
EmptyParamValues is the `ParamValues` which contains nothing
type PlanColumnIDAllocator ¶
type PlanColumnIDAllocator interface { // AllocPlanColumnID allocates column id for plan. AllocPlanColumnID() int64 // GetLastPlanColumnID returns the last column id. GetLastPlanColumnID() int64 }
PlanColumnIDAllocator allocates column id for plan.
type SimplePlanColumnIDAllocator ¶
type SimplePlanColumnIDAllocator struct {
// contains filtered or unexported fields
}
SimplePlanColumnIDAllocator implements PlanColumnIDAllocator
func NewSimplePlanColumnIDAllocator ¶
func NewSimplePlanColumnIDAllocator(offset int64) *SimplePlanColumnIDAllocator
NewSimplePlanColumnIDAllocator creates a new SimplePlanColumnIDAllocator.
func (*SimplePlanColumnIDAllocator) AllocPlanColumnID ¶
func (a *SimplePlanColumnIDAllocator) AllocPlanColumnID() int64
AllocPlanColumnID allocates column id for plan.
func (*SimplePlanColumnIDAllocator) GetLastPlanColumnID ¶
func (a *SimplePlanColumnIDAllocator) GetLastPlanColumnID() int64
GetLastPlanColumnID returns the last column id.
type StaticConvertibleEvalContext ¶
type StaticConvertibleEvalContext interface { EvalContext AllParamValues() []types.Datum GetWarnHandler() contextutil.WarnHandler }
StaticConvertibleEvalContext provides more methods to implement the clone of a `EvalContext`
type StaticConvertibleExprContext ¶
type StaticConvertibleExprContext interface { ExprContext GetStaticConvertibleEvalContext() StaticConvertibleEvalContext GetPlanCacheTracker() *contextutil.PlanCacheTracker GetLastPlanColumnID() int64 }
StaticConvertibleExprContext provides more methods to implement the clone of a `ExprContext`