Documentation ¶
Overview ¶
Package mock is just for test only.
Index ¶
- Variables
- type Client
- type Context
- func (*Context) AddTableLock(_ []model.TableLockTpInfo)
- func (c *Context) Cancel()
- func (*Context) CheckTableLocked(_ int64) (bool, pmodel.TableLockType)
- func (c *Context) ClearValue(key fmt.Stringer)
- func (*Context) Close()
- func (c *Context) CommitTxn(ctx context.Context) error
- func (*Context) DecodeSessionStates(context.Context, sessionctx.Context, *sessionstates.SessionStates) error
- func (c *Context) DisableSandBoxMode()
- func (c *Context) EnableSandBoxMode()
- func (*Context) EncodeSessionStates(context.Context, sessionctx.Context, *sessionstates.SessionStates) error
- func (*Context) ExecRestrictedSQL(_ context.Context, _ []sqlexec.OptionFuncAlias, _ string, _ ...any) ([]chunk.Row, []*resolve.ResultField, error)
- func (*Context) ExecRestrictedStmt(_ context.Context, _ ast.StmtNode, _ ...sqlexec.OptionFuncAlias) ([]chunk.Row, []*resolve.ResultField, error)
- func (*Context) Execute(_ context.Context, _ string) ([]sqlexec.RecordSet, error)
- func (*Context) ExecuteInternal(_ context.Context, _ string, _ ...any) (sqlexec.RecordSet, error)
- func (*Context) ExecuteStmt(_ context.Context, _ ast.StmtNode) (sqlexec.RecordSet, error)
- func (*Context) GetAdvisoryLock(_ string, _ int64) error
- func (*Context) GetAllTableLocks() []model.TableLockTpInfo
- func (c *Context) GetBuildPBCtx() *planctx.BuildPBContext
- func (*Context) GetBuiltinFunctionUsage() map[string]uint32
- func (c *Context) GetClient() kv.Client
- func (*Context) GetCommitWaitGroup() *sync.WaitGroup
- func (*Context) GetCursorTracker() cursor.Tracker
- func (c *Context) GetDistSQLCtx() *distsqlctx.DistSQLContext
- func (c *Context) GetDomainInfoSchema() infoschema.MetaOnlyInfoSchema
- func (c *Context) GetExprCtx() exprctx.ExprContext
- func (*Context) GetExtensions() *extension.SessionExtensions
- func (*Context) GetGlobalSysVar(_ sessionctx.Context, name string) (string, error)
- func (c *Context) GetInfoSchema() infoschema.MetaOnlyInfoSchema
- func (c *Context) GetMPPClient() kv.MPPClient
- func (c *Context) GetNullRejectCheckExprCtx() exprctx.ExprContext
- func (c *Context) GetPlanCtx() planctx.PlanContext
- func (c *Context) GetPreparedTxnFuture() sessionctx.TxnFuture
- func (c *Context) GetRangerCtx() *rangerctx.RangerContext
- func (c *Context) GetRestrictedSQLExecutor() sqlexec.RestrictedSQLExecutor
- func (c *Context) GetSQLExecutor() sqlexec.SQLExecutor
- func (c *Context) GetSessionManager() util.SessionManager
- func (c *Context) GetSessionPlanCache() sessionctx.SessionPlanCache
- func (c *Context) GetSessionVars() *variable.SessionVars
- func (*Context) GetStmtStats() *stmtstats.StatementStats
- func (c *Context) GetStore() kv.Storage
- func (c *Context) GetTableCtx() tblctx.MutateContext
- func (*Context) GetTxnWriteThroughputSLI() *sli.TxnWriteThroughputSLI
- func (c *Context) GoCtx() context.Context
- func (*Context) HasDirtyContent(_ int64) bool
- func (*Context) HasLockedTables() bool
- func (c *Context) InSandBoxMode() bool
- func (c *Context) IsDDLOwner() bool
- func (*Context) IsUsedAdvisoryLock(_ string) uint64
- func (c *Context) NewStaleTxnWithStartTS(ctx context.Context, _ uint64) error
- func (*Context) NewStmtIndexUsageCollector() *indexusage.StmtIndexUsageCollector
- func (c *Context) NewTxn(context.Context) error
- func (*Context) ParseWithParams(_ context.Context, _ string, _ ...any) (ast.StmtNode, error)
- func (c *Context) PrepareTSFuture(_ context.Context, future oracle.Future, _ string) error
- func (c *Context) RefreshTxnCtx(ctx context.Context) error
- func (*Context) ReleaseAdvisoryLock(_ string) bool
- func (*Context) ReleaseAllAdvisoryLocks() int
- func (*Context) ReleaseAllTableLocks()
- func (*Context) ReleaseTableLockByTableIDs(_ []int64)
- func (*Context) ReleaseTableLocks(_ []model.TableLockTpInfo)
- func (*Context) ReportUsageStats()
- func (c *Context) ResetSessionAndStmtTimeZone(tz *time.Location)
- func (c *Context) RollbackTxn(_ context.Context)
- func (*Context) SetGlobalSysVar(_ sessionctx.Context, name string, value string) error
- func (c *Context) SetInfoSchema(is infoschema.MetaOnlyInfoSchema)
- func (c *Context) SetIsDDLOwner(isOwner bool)
- func (c *Context) SetSessionManager(sm util.SessionManager)
- func (c *Context) SetValue(key fmt.Stringer, value any)
- func (*Context) ShowProcess() *util.ProcessInfo
- func (*Context) StmtCommit(context.Context)
- func (*Context) StmtRollback(context.Context, bool)
- func (*Context) StoreIndexUsage(_ int64, _ int64, _ int64)
- func (c *Context) Txn(bool) (kv.Transaction, error)
- func (*Context) UpdateColStatsUsage(_ iter.Seq[model.TableItemID])
- func (c *Context) Value(key fmt.Stringer) any
- type HookKeyForTest
- type MetricsCounter
- type MockedIter
- type SliceIter
- type Store
- func (*Store) Begin(_ ...tikv.TxnOption) (kv.Transaction, error)
- func (*Store) Close() error
- func (*Store) CurrentVersion(_ string) (kv.Version, error)
- func (*Store) Describe() string
- func (s *Store) GetClient() kv.Client
- func (*Store) GetCodec() tikv.Codec
- func (*Store) GetLockWaits() ([]*deadlockpb.WaitForEntry, error)
- func (*Store) GetMPPClient() kv.MPPClient
- func (*Store) GetMemCache() kv.MemManager
- func (*Store) GetMinSafeTS(_ string) uint64
- func (*Store) GetOracle() oracle.Oracle
- func (*Store) GetSnapshot(_ kv.Version) kv.Snapshot
- func (*Store) Name() string
- func (*Store) ShowStatus(_ context.Context, _ string) (any, error)
- func (*Store) SupportDeleteRange() bool
- func (*Store) UUID() string
Constants ¶
This section is empty.
Variables ¶
var MockInfoschema func(tbList []*model.TableInfo) infoschema.MetaOnlyInfoSchema
MockInfoschema only serves for test.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { kv.RequestTypeSupportedChecker MockResponse kv.Response }
Client implement kv.Client interface, mocked from "CopClient" defined in "store/tikv/copprocessor.go".
type Context ¶
type Context struct { planctx.EmptyPlanContextExtended *sessionexpr.ExprContext Store kv.Storage // mock global variable // contains filtered or unexported fields }
Context represents mocked sessionctx.Context.
func NewContext ¶
func NewContext() *Context
NewContext creates a new mocked sessionctx.Context. This function should only be used for testing.
func NewContextDeprecated ¶
func NewContextDeprecated() *Context
NewContextDeprecated creates a new mocked sessionctx.Context. Deprecated: This method is only used for some legacy code. DO NOT use mock.Context in new production code, and use the real Context instead.
func (*Context) AddTableLock ¶
func (*Context) AddTableLock(_ []model.TableLockTpInfo)
AddTableLock implements the sessionctx.Context interface.
func (*Context) CheckTableLocked ¶
func (*Context) CheckTableLocked(_ int64) (bool, pmodel.TableLockType)
CheckTableLocked implements the sessionctx.Context interface.
func (*Context) ClearValue ¶
ClearValue implements sessionctx.Context ClearValue interface.
func (*Context) DecodeSessionStates ¶
func (*Context) DecodeSessionStates(context.Context, sessionctx.Context, *sessionstates.SessionStates) error
DecodeSessionStates implements sessionctx.Context DecodeSessionStates interface.
func (*Context) DisableSandBoxMode ¶
func (c *Context) DisableSandBoxMode()
DisableSandBoxMode enable the sandbox mode.
func (*Context) EnableSandBoxMode ¶
func (c *Context) EnableSandBoxMode()
EnableSandBoxMode enable the sandbox mode.
func (*Context) EncodeSessionStates ¶
func (*Context) EncodeSessionStates(context.Context, sessionctx.Context, *sessionstates.SessionStates) error
EncodeSessionStates implements sessionctx.Context EncodeSessionStates interface.
func (*Context) ExecRestrictedSQL ¶
func (*Context) ExecRestrictedSQL(_ context.Context, _ []sqlexec.OptionFuncAlias, _ string, _ ...any) ([]chunk.Row, []*resolve.ResultField, error)
ExecRestrictedSQL implements sqlexec.RestrictedSQLExecutor ExecRestrictedSQL interface.
func (*Context) ExecRestrictedStmt ¶
func (*Context) ExecRestrictedStmt(_ context.Context, _ ast.StmtNode, _ ...sqlexec.OptionFuncAlias) ([]chunk.Row, []*resolve.ResultField, error)
ExecRestrictedStmt implements sqlexec.RestrictedSQLExecutor ExecRestrictedStmt interface.
func (*Context) ExecuteInternal ¶
ExecuteInternal implements sqlexec.SQLExecutor ExecuteInternal interface.
func (*Context) ExecuteStmt ¶
ExecuteStmt implements sqlexec.SQLExecutor ExecuteStmt interface.
func (*Context) GetAdvisoryLock ¶
GetAdvisoryLock acquires an advisory lock
func (*Context) GetAllTableLocks ¶
func (*Context) GetAllTableLocks() []model.TableLockTpInfo
GetAllTableLocks implements the sessionctx.Context interface.
func (*Context) GetBuildPBCtx ¶
func (c *Context) GetBuildPBCtx() *planctx.BuildPBContext
GetBuildPBCtx returns the `ToPB` context of the session
func (*Context) GetBuiltinFunctionUsage ¶
GetBuiltinFunctionUsage implements sessionctx.Context GetBuiltinFunctionUsage interface.
func (*Context) GetCommitWaitGroup ¶
GetCommitWaitGroup implements the sessionctx.Context interface
func (*Context) GetCursorTracker ¶
GetCursorTracker implements the sessionctx.Context interface
func (*Context) GetDistSQLCtx ¶
func (c *Context) GetDistSQLCtx() *distsqlctx.DistSQLContext
GetDistSQLCtx returns the distsql context of the session
func (*Context) GetDomainInfoSchema ¶
func (c *Context) GetDomainInfoSchema() infoschema.MetaOnlyInfoSchema
GetDomainInfoSchema returns the latest information schema in domain
func (*Context) GetExprCtx ¶
func (c *Context) GetExprCtx() exprctx.ExprContext
GetExprCtx returns the expression context of the session.
func (*Context) GetExtensions ¶
func (*Context) GetExtensions() *extension.SessionExtensions
GetExtensions returns the `*extension.SessionExtensions` object
func (*Context) GetGlobalSysVar ¶
GetGlobalSysVar implements GlobalVarAccessor GetGlobalSysVar interface.
func (*Context) GetInfoSchema ¶
func (c *Context) GetInfoSchema() infoschema.MetaOnlyInfoSchema
GetInfoSchema implements sessionctx.Context GetInfoSchema interface.
func (*Context) GetMPPClient ¶
GetMPPClient implements sessionctx.Context GetMPPClient interface.
func (*Context) GetNullRejectCheckExprCtx ¶
func (c *Context) GetNullRejectCheckExprCtx() exprctx.ExprContext
GetNullRejectCheckExprCtx gets the expression context with null rejected check.
func (*Context) GetPlanCtx ¶
func (c *Context) GetPlanCtx() planctx.PlanContext
GetPlanCtx returns the PlanContext.
func (*Context) GetPreparedTxnFuture ¶
func (c *Context) GetPreparedTxnFuture() sessionctx.TxnFuture
GetPreparedTxnFuture returns the TxnFuture if it is prepared. It returns nil otherwise.
func (*Context) GetRangerCtx ¶
func (c *Context) GetRangerCtx() *rangerctx.RangerContext
GetRangerCtx returns the context used in `ranger` related functions
func (*Context) GetRestrictedSQLExecutor ¶
func (c *Context) GetRestrictedSQLExecutor() sqlexec.RestrictedSQLExecutor
GetRestrictedSQLExecutor returns the RestrictedSQLExecutor.
func (*Context) GetSQLExecutor ¶
func (c *Context) GetSQLExecutor() sqlexec.SQLExecutor
GetSQLExecutor returns the SQLExecutor.
func (*Context) GetSessionManager ¶
func (c *Context) GetSessionManager() util.SessionManager
GetSessionManager implements the sessionctx.Context interface.
func (*Context) GetSessionPlanCache ¶
func (c *Context) GetSessionPlanCache() sessionctx.SessionPlanCache
GetSessionPlanCache implements the sessionctx.Context interface.
func (*Context) GetSessionVars ¶
func (c *Context) GetSessionVars() *variable.SessionVars
GetSessionVars implements the sessionctx.Context GetSessionVars interface.
func (*Context) GetStmtStats ¶
func (*Context) GetStmtStats() *stmtstats.StatementStats
GetStmtStats implements the sessionctx.Context interface.
func (*Context) GetTableCtx ¶
func (c *Context) GetTableCtx() tblctx.MutateContext
GetTableCtx returns the table.MutateContext
func (*Context) GetTxnWriteThroughputSLI ¶
func (*Context) GetTxnWriteThroughputSLI() *sli.TxnWriteThroughputSLI
GetTxnWriteThroughputSLI implements the sessionctx.Context interface.
func (*Context) GoCtx ¶
GoCtx returns standard sessionctx.Context that bind with current transaction.
func (*Context) HasDirtyContent ¶
HasDirtyContent implements sessionctx.Context ClearValue interface.
func (*Context) HasLockedTables ¶
HasLockedTables implements the sessionctx.Context interface.
func (*Context) InSandBoxMode ¶
InSandBoxMode indicates that this Session is in sandbox mode
func (*Context) IsDDLOwner ¶
IsDDLOwner checks whether this session is DDL owner.
func (*Context) IsUsedAdvisoryLock ¶
IsUsedAdvisoryLock check if a lock name is in use
func (*Context) NewStaleTxnWithStartTS ¶
NewStaleTxnWithStartTS implements the sessionctx.Context interface.
func (*Context) NewStmtIndexUsageCollector ¶
func (*Context) NewStmtIndexUsageCollector() *indexusage.StmtIndexUsageCollector
NewStmtIndexUsageCollector implements the sessionctx.Context interface
func (*Context) ParseWithParams ¶
ParseWithParams implements sqlexec.RestrictedSQLExecutor ParseWithParams interface.
func (*Context) PrepareTSFuture ¶
PrepareTSFuture implements the sessionctx.Context interface.
func (*Context) RefreshTxnCtx ¶
RefreshTxnCtx implements the sessionctx.Context interface.
func (*Context) ReleaseAdvisoryLock ¶
ReleaseAdvisoryLock releases an advisory lock
func (*Context) ReleaseAllAdvisoryLocks ¶
ReleaseAllAdvisoryLocks releases all advisory locks
func (*Context) ReleaseAllTableLocks ¶
func (*Context) ReleaseAllTableLocks()
ReleaseAllTableLocks implements the sessionctx.Context interface.
func (*Context) ReleaseTableLockByTableIDs ¶
ReleaseTableLockByTableIDs implements the sessionctx.Context interface.
func (*Context) ReleaseTableLocks ¶
func (*Context) ReleaseTableLocks(_ []model.TableLockTpInfo)
ReleaseTableLocks implements the sessionctx.Context interface.
func (*Context) ReportUsageStats ¶
func (*Context) ReportUsageStats()
ReportUsageStats implements the sessionctx.Context interface.
func (*Context) ResetSessionAndStmtTimeZone ¶
ResetSessionAndStmtTimeZone resets the timezone for session and statement.
func (*Context) RollbackTxn ¶
RollbackTxn indicates an expected call of RollbackTxn.
func (*Context) SetGlobalSysVar ¶
SetGlobalSysVar implements GlobalVarAccessor SetGlobalSysVar interface.
func (*Context) SetInfoSchema ¶
func (c *Context) SetInfoSchema(is infoschema.MetaOnlyInfoSchema)
SetInfoSchema is to set info shema for the test.
func (*Context) SetIsDDLOwner ¶
SetIsDDLOwner sets return value of IsDDLOwner.
func (*Context) SetSessionManager ¶
func (c *Context) SetSessionManager(sm util.SessionManager)
SetSessionManager set the session manager.
func (*Context) ShowProcess ¶
func (*Context) ShowProcess() *util.ProcessInfo
ShowProcess implements sessionctx.Context ShowProcess interface.
func (*Context) StmtCommit ¶
StmtCommit implements the sessionctx.Context interface.
func (*Context) StmtRollback ¶
StmtRollback implements the sessionctx.Context interface.
func (*Context) StoreIndexUsage ¶
StoreIndexUsage strores the index usage information.
func (*Context) Txn ¶
func (c *Context) Txn(bool) (kv.Transaction, error)
Txn implements sessionctx.Context Txn interface.
func (*Context) UpdateColStatsUsage ¶
func (*Context) UpdateColStatsUsage(_ iter.Seq[model.TableItemID])
UpdateColStatsUsage updates the column stats usage.
type HookKeyForTest ¶
type HookKeyForTest string
HookKeyForTest is as alias, used by context.WithValue. golint forbits using string type as key in context.WithValue.
type MetricsCounter ¶
type MetricsCounter struct { prometheus.Counter // contains filtered or unexported fields }
MetricsCounter is a mock for metrics counter
type MockedIter ¶
MockedIter is a mocked iter for test
func NewMockIterFromRecords ¶
NewMockIterFromRecords creates a new MockedIter
func (*MockedIter) FailOnMultiClose ¶
func (i *MockedIter) FailOnMultiClose(fail bool)
FailOnMultiClose set if should fail when Close is invoked more than once
func (*MockedIter) GetInjectedNextError ¶
func (i *MockedIter) GetInjectedNextError() error
GetInjectedNextError get the injected error
func (*MockedIter) InjectNextError ¶
func (i *MockedIter) InjectNextError(err error)
InjectNextError injects error to its Next
type SliceIter ¶
type SliceIter struct {
// contains filtered or unexported fields
}
SliceIter is used to iterate slice
func NewSliceIter ¶
NewSliceIter creates a new SliceIter
type Store ¶
Store implements kv.Storage interface.
func (*Store) CurrentVersion ¶
CurrentVersion implements kv.Storage interface.
func (*Store) GetLockWaits ¶
func (*Store) GetLockWaits() ([]*deadlockpb.WaitForEntry, error)
GetLockWaits implements kv.Storage interface.
func (*Store) GetMPPClient ¶
GetMPPClient implements kv.Storage interface.
func (*Store) GetMemCache ¶
func (*Store) GetMemCache() kv.MemManager
GetMemCache implements kv.Storage interface
func (*Store) GetMinSafeTS ¶
GetMinSafeTS implements kv.Storage interface.
func (*Store) GetSnapshot ¶
GetSnapshot implements kv.Storage interface.
func (*Store) ShowStatus ¶
ShowStatus implements kv.Storage interface.
func (*Store) SupportDeleteRange ¶
SupportDeleteRange implements kv.Storage interface.