exprstatic

package
v1.1.0-beta.0...-652cee2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EvalContext

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

EvalContext implements `EvalContext` to provide a static context for expression evaluation. The "static" means comparing with `EvalContext`, its internal state does not relay on the session or other complex contexts that keeps immutable for most fields.

func MakeEvalContextStatic

func MakeEvalContextStatic(ctx exprctx.StaticConvertibleEvalContext) *EvalContext

MakeEvalContextStatic converts the `exprctx.StaticConvertibleEvalContext` to `EvalContext`.

func NewEvalContext

func NewEvalContext(opt ...EvalCtxOption) *EvalContext

NewEvalContext creates a new `EvalContext` with the given options.

func (*EvalContext) AllParamValues

func (ctx *EvalContext) AllParamValues() []types.Datum

AllParamValues implements context.StaticConvertibleEvalContext.

func (*EvalContext) AppendNote

func (ctx *EvalContext) AppendNote(err error)

AppendNote appends notes to the context.

func (*EvalContext) AppendWarning

func (ctx *EvalContext) AppendWarning(err error)

AppendWarning append warnings to the context.

func (*EvalContext) Apply

func (ctx *EvalContext) Apply(opt ...EvalCtxOption) *EvalContext

Apply returns a new `EvalContext` with the fields updated according to the given options.

func (*EvalContext) CopyWarnings

func (ctx *EvalContext) CopyWarnings(dst []contextutil.SQLWarn) []contextutil.SQLWarn

CopyWarnings copies warnings to dst slice.

func (*EvalContext) CtxID

func (ctx *EvalContext) CtxID() uint64

CtxID returns the context ID.

func (*EvalContext) CurrentDB

func (ctx *EvalContext) CurrentDB() string

CurrentDB return the current database name

func (*EvalContext) CurrentTime

func (ctx *EvalContext) CurrentTime() (tm time.Time, err error)

CurrentTime return the current time

func (*EvalContext) ErrCtx

func (ctx *EvalContext) ErrCtx() errctx.Context

ErrCtx returns the errctx.Context

func (*EvalContext) GetDefaultWeekFormatMode

func (ctx *EvalContext) GetDefaultWeekFormatMode() string

GetDefaultWeekFormatMode returns the value of the 'default_week_format' system variable.

func (*EvalContext) GetDivPrecisionIncrement

func (ctx *EvalContext) GetDivPrecisionIncrement() int

GetDivPrecisionIncrement returns the specified value of DivPrecisionIncrement.

func (*EvalContext) GetMaxAllowedPacket

func (ctx *EvalContext) GetMaxAllowedPacket() uint64

GetMaxAllowedPacket returns the value of the 'max_allowed_packet' system variable.

func (*EvalContext) GetOptionalPropProvider

func (ctx *EvalContext) GetOptionalPropProvider(key exprctx.OptionalEvalPropKey) (exprctx.OptionalEvalPropProvider, bool)

GetOptionalPropProvider gets the optional property provider by key

func (*EvalContext) GetOptionalPropSet

func (ctx *EvalContext) GetOptionalPropSet() exprctx.OptionalEvalPropKeySet

GetOptionalPropSet gets the optional property set from context

func (*EvalContext) GetParamValue

func (ctx *EvalContext) GetParamValue(idx int) (types.Datum, error)

GetParamValue returns the value of the parameter by index.

func (*EvalContext) GetTiDBRedactLog

func (ctx *EvalContext) GetTiDBRedactLog() string

GetTiDBRedactLog returns the value of the 'tidb_redact_log' system variable.

func (*EvalContext) GetUserVarsReader

func (ctx *EvalContext) GetUserVarsReader() variable.UserVarsReader

GetUserVarsReader returns the user variables.

func (*EvalContext) GetWarnHandler

func (ctx *EvalContext) GetWarnHandler() contextutil.WarnHandler

GetWarnHandler implements context.StaticConvertibleEvalContext.

func (*EvalContext) LoadSystemVars

func (ctx *EvalContext) LoadSystemVars(sysVars map[string]string) (*EvalContext, error)

LoadSystemVars loads system variables and returns a new `EvalContext` with system variables loaded.

func (*EvalContext) Location

func (ctx *EvalContext) Location() *time.Location

Location returns the timezone info

func (*EvalContext) SQLMode

func (ctx *EvalContext) SQLMode() mysql.SQLMode

SQLMode returns the sql mode

func (*EvalContext) TruncateWarnings

func (ctx *EvalContext) TruncateWarnings(start int) []contextutil.SQLWarn

TruncateWarnings truncates warnings begin from start and returns the truncated warnings.

func (*EvalContext) TypeCtx

func (ctx *EvalContext) TypeCtx() types.Context

TypeCtx returns the types.Context

func (*EvalContext) WarningCount

func (ctx *EvalContext) WarningCount() int

WarningCount gets warning count.

type EvalCtxOption

type EvalCtxOption func(*evalCtxState)

EvalCtxOption is the option to set `EvalContext`.

func WithCurrentDB

func WithCurrentDB(db string) EvalCtxOption

WithCurrentDB sets the current database name for the `EvalContext`.

func WithCurrentTime

func WithCurrentTime(fn func() (time.Time, error)) EvalCtxOption

WithCurrentTime sets the current time for the `EvalContext`.

func WithDefaultWeekFormatMode

func WithDefaultWeekFormatMode(mode string) EvalCtxOption

WithDefaultWeekFormatMode sets the value of the 'default_week_format' system variable.

func WithDivPrecisionIncrement

func WithDivPrecisionIncrement(inc int) EvalCtxOption

WithDivPrecisionIncrement sets the value of the 'div_precision_increment' system variable.

func WithEnableRedactLog

func WithEnableRedactLog(enableRedactLog string) EvalCtxOption

WithEnableRedactLog sets the value of the 'tidb_redact_log' system variable.

func WithErrLevelMap

func WithErrLevelMap(level errctx.LevelMap) EvalCtxOption

WithErrLevelMap sets the error level map for the `EvalContext`.

func WithLocation

func WithLocation(loc *time.Location) EvalCtxOption

WithLocation sets the timezone info for the `EvalContext`.

func WithMaxAllowedPacket

func WithMaxAllowedPacket(size uint64) EvalCtxOption

WithMaxAllowedPacket sets the value of the 'max_allowed_packet' system variable.

func WithOptionalProperty

func WithOptionalProperty(providers ...exprctx.OptionalEvalPropProvider) EvalCtxOption

WithOptionalProperty sets the optional property providers

func WithParamList

func WithParamList(params *variable.PlanCacheParamList) EvalCtxOption

WithParamList sets the param list for the `EvalContext`.

func WithSQLMode

func WithSQLMode(sqlMode mysql.SQLMode) EvalCtxOption

WithSQLMode sets the sql mode for the `EvalContext`.

func WithTypeFlags

func WithTypeFlags(flags types.Flags) EvalCtxOption

WithTypeFlags sets the type flags for the `EvalContext`.

func WithUserVarsReader

func WithUserVarsReader(vars variable.UserVarsReader) EvalCtxOption

WithUserVarsReader set the user variables reader for the `EvalContext`.

func WithWarnHandler

func WithWarnHandler(h contextutil.WarnHandler) EvalCtxOption

WithWarnHandler sets the warn handler for the `EvalContext`.

type ExprContext

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

ExprContext implements the `exprctx.ExprContext` interface. The "static" means comparing with `ExprContext`, its internal state does not relay on the session or other complex contexts that keeps immutable for most fields.

func MakeExprContextStatic

func MakeExprContextStatic(ctx exprctx.StaticConvertibleExprContext) *ExprContext

MakeExprContextStatic converts the `exprctx.StaticConvertibleExprContext` to `ExprContext`.

func NewExprContext

func NewExprContext(opts ...ExprCtxOption) *ExprContext

NewExprContext creates a new ExprContext

func (*ExprContext) AllocPlanColumnID

func (ctx *ExprContext) AllocPlanColumnID() int64

AllocPlanColumnID implements the `ExprContext.AllocPlanColumnID`.

func (*ExprContext) Apply

func (ctx *ExprContext) Apply(opts ...ExprCtxOption) *ExprContext

Apply returns a new `ExprContext` with the fields updated according to the given options.

func (*ExprContext) ConnectionID

func (ctx *ExprContext) ConnectionID() uint64

ConnectionID implements the `ExprContext.ConnectionID`.

func (*ExprContext) GetBlockEncryptionMode

func (ctx *ExprContext) GetBlockEncryptionMode() string

GetBlockEncryptionMode implements the `ExprContext.GetBlockEncryptionMode`.

func (*ExprContext) GetCharsetInfo

func (ctx *ExprContext) GetCharsetInfo() (string, string)

GetCharsetInfo implements the `ExprContext.GetCharsetInfo`.

func (*ExprContext) GetDefaultCollationForUTF8MB4

func (ctx *ExprContext) GetDefaultCollationForUTF8MB4() string

GetDefaultCollationForUTF8MB4 implements the `ExprContext.GetDefaultCollationForUTF8MB4`.

func (*ExprContext) GetEvalCtx

func (ctx *ExprContext) GetEvalCtx() exprctx.EvalContext

GetEvalCtx implements the `ExprContext.GetEvalCtx`.

func (*ExprContext) GetGroupConcatMaxLen

func (ctx *ExprContext) GetGroupConcatMaxLen() uint64

GetGroupConcatMaxLen implements the `ExprContext.GetGroupConcatMaxLen`.

func (*ExprContext) GetLastPlanColumnID

func (ctx *ExprContext) GetLastPlanColumnID() int64

GetLastPlanColumnID implements context.StaticConvertibleExprContext.

func (*ExprContext) GetNoopFuncsMode

func (ctx *ExprContext) GetNoopFuncsMode() int

GetNoopFuncsMode implements the `ExprContext.GetNoopFuncsMode`.

func (*ExprContext) GetPlanCacheTracker

func (ctx *ExprContext) GetPlanCacheTracker() *contextutil.PlanCacheTracker

GetPlanCacheTracker implements context.StaticConvertibleExprContext.

func (*ExprContext) GetStaticConvertibleEvalContext

func (ctx *ExprContext) GetStaticConvertibleEvalContext() exprctx.StaticConvertibleEvalContext

GetStaticConvertibleEvalContext implements context.StaticConvertibleExprContext.

func (*ExprContext) GetStaticEvalCtx

func (ctx *ExprContext) GetStaticEvalCtx() *EvalContext

GetStaticEvalCtx returns the inner `EvalContext`.

func (*ExprContext) GetSysdateIsNow

func (ctx *ExprContext) GetSysdateIsNow() bool

GetSysdateIsNow implements the `ExprContext.GetSysdateIsNow`.

func (*ExprContext) GetWindowingUseHighPrecision

func (ctx *ExprContext) GetWindowingUseHighPrecision() bool

GetWindowingUseHighPrecision implements the `ExprContext.GetWindowingUseHighPrecision`.

func (*ExprContext) IsConstantPropagateCheck

func (ctx *ExprContext) IsConstantPropagateCheck() bool

IsConstantPropagateCheck implements the `ExprContext.IsConstantPropagateCheck` and should always return false.

func (*ExprContext) IsInNullRejectCheck

func (ctx *ExprContext) IsInNullRejectCheck() bool

IsInNullRejectCheck implements the `ExprContext.IsInNullRejectCheck` and should always return false.

func (*ExprContext) IsReadonlyUserVar

func (ctx *ExprContext) IsReadonlyUserVar(name string) bool

IsReadonlyUserVar implements the `BuildContext.IsReadonlyUserVar`. This method always returns false for simplicity, ensuring the safest behavior across all scenarios.

func (*ExprContext) IsUseCache

func (ctx *ExprContext) IsUseCache() bool

IsUseCache implements the `ExprContext.IsUseCache`.

func (*ExprContext) LoadSystemVars

func (ctx *ExprContext) LoadSystemVars(sysVars map[string]string) (*ExprContext, error)

LoadSystemVars loads system variables and returns a new `EvalContext` with system variables loaded.

func (*ExprContext) Rng

func (ctx *ExprContext) Rng() *mathutil.MysqlRng

Rng implements the `ExprContext.Rng`.

func (*ExprContext) SetSkipPlanCache

func (ctx *ExprContext) SetSkipPlanCache(reason string)

SetSkipPlanCache implements the `ExprContext.SetSkipPlanCache`.

type ExprCtxOption

type ExprCtxOption func(*exprCtxState)

ExprCtxOption is the option to create or update the `ExprContext`

func WithBlockEncryptionMode

func WithBlockEncryptionMode(mode string) ExprCtxOption

WithBlockEncryptionMode sets the block encryption mode for `ExprContext`.

func WithCharset

func WithCharset(charset, collation string) ExprCtxOption

WithCharset sets the charset and collation for `ExprContext`.

func WithColumnIDAllocator

func WithColumnIDAllocator(allocator exprctx.PlanColumnIDAllocator) ExprCtxOption

WithColumnIDAllocator sets the column id allocator for `ExprContext`.

func WithConnectionID

func WithConnectionID(id uint64) ExprCtxOption

WithConnectionID sets the connection id for `ExprContext`.

func WithDefaultCollationForUTF8MB4

func WithDefaultCollationForUTF8MB4(collation string) ExprCtxOption

WithDefaultCollationForUTF8MB4 sets the default collation for utf8mb4 for `ExprContext`.

func WithEvalCtx

func WithEvalCtx(ctx *EvalContext) ExprCtxOption

WithEvalCtx sets the `EvalContext` for `ExprContext`.

func WithGroupConcatMaxLen

func WithGroupConcatMaxLen(maxLen uint64) ExprCtxOption

WithGroupConcatMaxLen sets the group concat max len for `ExprContext`.

func WithNoopFuncsMode

func WithNoopFuncsMode(mode int) ExprCtxOption

WithNoopFuncsMode sets the noop funcs mode for `ExprContext`.

func WithPlanCacheTracker

func WithPlanCacheTracker(tracker *contextutil.PlanCacheTracker) ExprCtxOption

WithPlanCacheTracker sets the plan cache tracker for `ExprContext`.

func WithRng

func WithRng(rng *mathutil.MysqlRng) ExprCtxOption

WithRng sets the rng for `ExprContext`.

func WithSysDateIsNow

func WithSysDateIsNow(now bool) ExprCtxOption

WithSysDateIsNow sets the sysdate is now for `ExprContext`.

func WithWindowingUseHighPrecision

func WithWindowingUseHighPrecision(useHighPrecision bool) ExprCtxOption

WithWindowingUseHighPrecision sets the windowing use high precision for `ExprContext`.

Jump to

Keyboard shortcuts

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