Documentation ¶
Index ¶
- Constants
- Variables
- func BootstrapSession(store kv.Storage) (*domain.Domain, error)
- func BootstrapSession4DistExecution(store kv.Storage) (*domain.Domain, error)
- func CreateSession(store kv.Storage) (types.Session, error)
- func CreateSession4Test(store kv.Storage) (types.Session, error)
- func CreateSession4TestWithOpt(store kv.Storage, opt *Opt) (types.Session, error)
- func CreateSessionAndSetID(t *testing.T, store kv.Storage) sessiontypes.Session
- func CreateSessionWithDomain(store kv.Storage, dom *domain.Domain) (*session, error)
- func CreateSessionWithOpt(store kv.Storage, opt *Opt) (types.Session, error)
- func CreateStoreAndBootstrap(t *testing.T) (kv.Storage, *domain.Domain)
- func DisableRunBootstrapSQLFileInTest()
- func DisableStats4Test()
- func ExecRestrictedStmt4Test(ctx context.Context, s types.Session, stmtNode ast.StmtNode, ...) ([]chunk.Row, []*resolve.ResultField, error)
- func GetDBNames(seVar *variable.SessionVars) []string
- func GetDomain(store kv.Storage) (*domain.Domain, error)
- func GetPlanReplayerGCLease() time.Duration
- func GetRows4Test(ctx context.Context, _ sessionctx.Context, rs sqlexec.RecordSet) ([]chunk.Row, error)
- func GetStartTSFromSession(se any) (startTS, processInfoID uint64)
- func HandleNonTransactionalDML(ctx context.Context, stmt *ast.NonTransactionalDMLStmt, ...) (sqlexec.RecordSet, error)
- func InitDDLJobTables(store kv.Storage, targetVer meta.DDLTableVersion) error
- func InitMDLTable(store kv.Storage) error
- func InitMDLVariable(store kv.Storage) error
- func InitMDLVariableForBootstrap(store kv.Storage) error
- func InitMDLVariableForUpgrade(store kv.Storage) (bool, error)
- func InitTiDBSchemaCacheSize(store kv.Storage) error
- func IsUpgradingClusterState(s sessionctx.Context) (bool, error)
- func KeyNeedToLock(k, v []byte, flags kv.KeyFlags) bool
- func MustExec(t *testing.T, se sessiontypes.Session, sql string, args ...any)
- func MustExecToRecodeSet(t *testing.T, se sessiontypes.Session, sql string, args ...any) sqlexec.RecordSet
- func Parse(ctx sessionctx.Context, src string) ([]ast.StmtNode, error)
- func ParseWithParams4Test(ctx context.Context, s types.Session, sql string, args ...any) (ast.StmtNode, error)
- func RegisterMockUpgradeFlag(fSet *flag.FlagSet)
- func RemoveLockDDLJobs(s types.Session, job2ver map[int64]int64, job2ids map[int64]string, ...)
- func ResetMockAutoRandIDRetryCount(failTimes int64)
- func ResetStoreForWithTiKVTest(store kv.Storage)
- func ResultSetToStringSlice(ctx context.Context, s types.Session, rs sqlexec.RecordSet) ([][]string, error)
- func SetPlanReplayerGCLease(lease time.Duration)
- func SetSchemaLease(lease time.Duration)
- func SetStatsLease(lease time.Duration)
- func SyncNormalRunning(s sessionctx.Context) error
- func SyncUpgradeState(s sessionctx.Context, timeout time.Duration) error
- type BaseCallback
- type Callback
- type ExecStmtVarKeyType
- type LazyTxn
- func (txn *LazyTxn) CacheTableInfo(id int64, info *model.TableInfo)
- func (txn *LazyTxn) CancelFairLocking(ctx context.Context) error
- func (txn *LazyTxn) Commit(ctx context.Context) error
- func (txn *LazyTxn) DoneFairLocking(ctx context.Context) error
- func (txn *LazyTxn) GetOption(opt int) any
- func (txn *LazyTxn) GetTableInfo(id int64) *model.TableInfo
- func (txn *LazyTxn) GoString() string
- func (txn *LazyTxn) IsInFairLockingMode() bool
- func (txn *LazyTxn) KeysNeedToLock() ([]kv.Key, error)
- func (txn *LazyTxn) LockKeys(ctx context.Context, lockCtx *kv.LockCtx, keys ...kv.Key) error
- func (txn *LazyTxn) LockKeysFunc(ctx context.Context, lockCtx *kv.LockCtx, fn func(), keys ...kv.Key) error
- func (txn *LazyTxn) Mem() uint64
- func (txn *LazyTxn) MemHookSet() bool
- func (txn *LazyTxn) RetryFairLocking(ctx context.Context) error
- func (txn *LazyTxn) Rollback() error
- func (txn *LazyTxn) RollbackMemDBToCheckpoint(savepoint *tikv.MemDBCheckpoint)
- func (txn *LazyTxn) SetMemoryFootprintChangeHook(hook func(uint64))
- func (txn *LazyTxn) Size() int
- func (txn *LazyTxn) StartFairLocking() error
- func (txn *LazyTxn) String() string
- func (txn *LazyTxn) Valid() bool
- func (txn *LazyTxn) Wait(ctx context.Context, sctx sessionctx.Context) (kv.Transaction, error)
- type Opt
- type StmtHistory
- type TestCallback
Constants ¶
const ( // CreateUserTable is the SQL statement creates User table in system db. // WARNING: There are some limitations on altering the schema of mysql.user table. // Adding columns that are nullable or have default values is permitted. // But operations like dropping or renaming columns may break the compatibility with BR. // REFERENCE ISSUE: https://github.com/pingcap/tidb/issues/38785 CreateUserTable = `` /* 2307-byte string literal not displayed */ // CreateGlobalPrivTable is the SQL statement creates Global scope privilege table in system db. CreateGlobalPrivTable = "CREATE TABLE IF NOT EXISTS mysql.global_priv (" + "Host CHAR(255) NOT NULL DEFAULT ''," + "User CHAR(80) NOT NULL DEFAULT ''," + "Priv LONGTEXT NOT NULL DEFAULT ''," + "PRIMARY KEY (Host, User)" + ")" // CreateDBPrivTable is the SQL statement creates DB scope privilege table in system db. CreateDBPrivTable = `` /* 1206-byte string literal not displayed */ // CreateTablePrivTable is the SQL statement creates table scope privilege table in system db. CreateTablePrivTable = `` /* 528-byte string literal not displayed */ // CreateColumnPrivTable is the SQL statement creates column scope privilege table in system db. CreateColumnPrivTable = `` /* 443-byte string literal not displayed */ // CreateGlobalVariablesTable is the SQL statement creates global variable table in system db. // TODO: MySQL puts GLOBAL_VARIABLES table in INFORMATION_SCHEMA db. // INFORMATION_SCHEMA is a virtual db in TiDB. So we put this table in system db. // Maybe we will put it back to INFORMATION_SCHEMA. CreateGlobalVariablesTable = `` /* 148-byte string literal not displayed */ // CreateTiDBTable is the SQL statement creates a table in system db. // This table is a key-value struct contains some information used by TiDB. // Currently we only put bootstrapped in it which indicates if the system is already bootstrapped. CreateTiDBTable = `` /* 164-byte string literal not displayed */ // CreateHelpTopic is the SQL statement creates help_topic table in system db. // See: https://dev.mysql.com/doc/refman/5.5/en/system-database.html#system-database-help-tables CreateHelpTopic = `` /* 418-byte string literal not displayed */ // CreateStatsMetaTable stores the meta of table statistics. CreateStatsMetaTable = `` /* 335-byte string literal not displayed */ // CreateStatsColsTable stores the statistics of table columns. CreateStatsColsTable = `` /* 647-byte string literal not displayed */ // CreateStatsBucketsTable stores the histogram info for every table columns. CreateStatsBucketsTable = `` /* 405-byte string literal not displayed */ // CreateGCDeleteRangeTable stores schemas which can be deleted by DeleteRange. CreateGCDeleteRangeTable = `` /* 398-byte string literal not displayed */ // CreateGCDeleteRangeDoneTable stores schemas which are already deleted by DeleteRange. CreateGCDeleteRangeDoneTable = `` /* 408-byte string literal not displayed */ // CreateStatsFeedbackTable stores the feedback info which is used to update stats. // NOTE: Feedback is deprecated, but we still need to create this table for compatibility. CreateStatsFeedbackTable = `` /* 220-byte string literal not displayed */ // CreateBindInfoTable stores the sql bind info which is used to update globalBindCache. CreateBindInfoTable = `` /* 655-byte string literal not displayed */ // CreateRoleEdgesTable stores the role and user relationship information. CreateRoleEdgesTable = `` /* 445-byte string literal not displayed */ // CreateDefaultRolesTable stores the active roles for a user. CreateDefaultRolesTable = `` /* 366-byte string literal not displayed */ // CreateStatsTopNTable stores topn data of a cmsketch with top n. CreateStatsTopNTable = `` /* 249-byte string literal not displayed */ // CreateStatsFMSketchTable stores FMSketch data of a column histogram. CreateStatsFMSketchTable = `` /* 213-byte string literal not displayed */ // CreateExprPushdownBlacklist stores the expressions which are not allowed to be pushed down. CreateExprPushdownBlacklist = `` /* 177-byte string literal not displayed */ // CreateOptRuleBlacklist stores the list of disabled optimizing operations. CreateOptRuleBlacklist = `CREATE TABLE IF NOT EXISTS mysql.opt_rule_blacklist ( name CHAR(100) NOT NULL );` // CreateStatsExtended stores the registered extended statistics. CreateStatsExtended = `` /* 376-byte string literal not displayed */ // CreateSchemaIndexUsageTable stores the index usage information. CreateSchemaIndexUsageTable = `` /* 217-byte string literal not displayed */ // CreateGlobalGrantsTable stores dynamic privs CreateGlobalGrantsTable = `` /* 251-byte string literal not displayed */ // CreateCapturePlanBaselinesBlacklist stores the baseline capture filter rules. CreateCapturePlanBaselinesBlacklist = `` /* 291-byte string literal not displayed */ // CreateColumnStatsUsageTable stores the column stats usage information. CreateColumnStatsUsageTable = `` /* 224-byte string literal not displayed */ // CreateTableCacheMetaTable stores the cached table meta lock information. CreateTableCacheMetaTable = `` /* 273-byte string literal not displayed */ // CreateAnalyzeOptionsTable stores the analyze options used by analyze and auto analyze. CreateAnalyzeOptionsTable = `` /* 398-byte string literal not displayed */ // CreateStatsHistory stores the historical stats. CreateStatsHistory = `` /* 493-byte string literal not displayed */ // CreateStatsMetaHistory stores the historical meta stats. CreateStatsMetaHistory = `` /* 463-byte string literal not displayed */ // CreateAnalyzeJobs stores the analyze jobs. CreateAnalyzeJobs = `` /* 925-byte string literal not displayed */ // CreateAdvisoryLocks stores the advisory locks (get_lock, release_lock). CreateAdvisoryLocks = `CREATE TABLE IF NOT EXISTS mysql.advisory_locks ( lock_name VARCHAR(64) NOT NULL PRIMARY KEY );` // CreateMDLView is a view about metadata locks. CreateMDLView = `` /* 774-byte string literal not displayed */ // CreatePlanReplayerStatusTable is a table about plan replayer status CreatePlanReplayerStatusTable = `` /* 365-byte string literal not displayed */ // CreatePlanReplayerTaskTable is a table about plan replayer capture task CreatePlanReplayerTaskTable = `` /* 255-byte string literal not displayed */ // CreateStatsTableLocked stores the locked tables CreateStatsTableLocked = `` /* 246-byte string literal not displayed */ // CreatePasswordHistory is a table save history passwd. CreatePasswordHistory = `` /* 356-byte string literal not displayed */ // CreateTTLTableStatus is a table about TTL job schedule CreateTTLTableStatus = `` /* 851-byte string literal not displayed */ // CreateTTLTask is a table about parallel ttl tasks CreateTTLTask = `` /* 526-byte string literal not displayed */ // CreateTTLJobHistory is a table that stores ttl job's history CreateTTLJobHistory = `` /* 695-byte string literal not displayed */ // CreateGlobalTask is a table about global task. CreateGlobalTask = `` /* 541-byte string literal not displayed */ // CreateGlobalTaskHistory is a table about history global task. CreateGlobalTaskHistory = `` /* 549-byte string literal not displayed */ // CreateDistFrameworkMeta create a system table that distributed task framework use to store meta information CreateDistFrameworkMeta = `` /* 218-byte string literal not displayed */ // CreateRunawayTable stores the query which is identified as runaway or quarantined because of in watch list. CreateRunawayTable = `` /* 632-byte string literal not displayed */ // CreateRunawayWatchTable stores the condition which is used to check whether query should be quarantined. CreateRunawayWatchTable = `` /* 666-byte string literal not displayed */ // CreateDoneRunawayWatchTable stores the condition which is used to check whether query should be quarantined. CreateDoneRunawayWatchTable = `` /* 529-byte string literal not displayed */ // CreateRequestUnitByGroupTable stores the historical RU consumption by resource group. CreateRequestUnitByGroupTable = `` /* 287-byte string literal not displayed */ // CreateImportJobs is a table that IMPORT INTO uses. CreateImportJobs = `` /* 681-byte string literal not displayed */ // CreatePITRIDMap is a table that records the id map from upstream to downstream for PITR. CreatePITRIDMap = `` /* 297-byte string literal not displayed */ // DropMySQLIndexUsageTable removes the table `mysql.schema_index_usage` DropMySQLIndexUsageTable = "DROP TABLE IF EXISTS mysql.schema_index_usage" // CreateSysSchema creates a new schema called `sys`. CreateSysSchema = `CREATE DATABASE IF NOT EXISTS sys;` // CreateSchemaUnusedIndexesView creates a view to use `information_schema.tidb_index_usage` to get the unused indexes. CreateSchemaUnusedIndexesView = `` /* 403-byte string literal not displayed */ // CreateIndexAdvisorTable is a table to store the index advisor results. CreateIndexAdvisorTable = `` /* 901-byte string literal not displayed */ // CreateKernelOptionsTable is a table to store kernel options for tidb. CreateKernelOptionsTable = `` /* 257-byte string literal not displayed */ )
const (
// MockSimpleUpgradeToVerLatest is used to indicate the use of the simple mock bootstrapVersion, this is just a few simple DDL operations.
MockSimpleUpgradeToVerLatest = 1
)
const StoreBootstrappedKey = "bootstrap"
StoreBootstrappedKey is used by store.G/SetOption to store related bootstrap context for kv.Storage.
const (
// TidbNewCollationEnabled The variable name in mysql.tidb table and it will indicate if the new collations are enabled in the TiDB cluster.
TidbNewCollationEnabled = "new_collation_enabled"
)
Variables ¶
var ( // DDLJobTables is a list of tables definitions used in concurrent DDL. DDLJobTables = []tableBasicInfo{ {ddl.JobTableSQL, ddl.JobTableID}, {ddl.ReorgTableSQL, ddl.ReorgTableID}, {ddl.HistoryTableSQL, ddl.HistoryTableID}, } // BackfillTables is a list of tables definitions used in dist reorg DDL. BackfillTables = []tableBasicInfo{ {ddl.BackgroundSubtaskTableSQL, ddl.BackgroundSubtaskTableID}, {ddl.BackgroundSubtaskHistoryTableSQL, ddl.BackgroundSubtaskHistoryTableID}, } // DDLNotifierTables contains the table definitions used in DDL notifier. // It only contains the notifier table. // Put it here to reuse a unified initialization function and make it easier to find. DDLNotifierTables = []tableBasicInfo{ {ddl.NotifierTableSQL, ddl.NotifierTableID}, } )
var ( // GetBootstrapVersion is used in test GetBootstrapVersion = getBootstrapVersion // CurrentBootstrapVersion is used in test CurrentBootstrapVersion = currentBootstrapVersion )
var CreateTimers = timertable.CreateTimerTableSQL("mysql", "tidb_timers")
CreateTimers is a table to store all timers for tidb
var (
ErrForUpdateCantRetry = dbterror.ClassSession.NewStd(errno.ErrForUpdateCantRetry)
)
Session errors.
var ErrNonTransactionalJobFailure = dbterror.ClassSession.NewStd(errno.ErrNonTransactionalJobFailure)
ErrNonTransactionalJobFailure is the error when a non-transactional job fails. The error is returned and following jobs are canceled.
var MockUpgradeToVerLatestKind = defaultMockUpgradeToVerLatest
MockUpgradeToVerLatestKind is used to indicate the use of different mock bootstrapVersion.
var SchemaChangedWithoutRetry uint32
SchemaChangedWithoutRetry is used for testing.
var ( // SupportUpgradeHTTPOpVer is exported for testing. // The minimum version of the upgrade by paused user DDL can be notified through the HTTP API. SupportUpgradeHTTPOpVer int64 = version174 )
var TestHook = TestCallback{}
TestHook is exported for testing.
var WithMockUpgrade *bool
WithMockUpgrade is a flag identify whether tests run with mock upgrading.
Functions ¶
func BootstrapSession ¶
BootstrapSession bootstrap session and domain.
func BootstrapSession4DistExecution ¶
BootstrapSession4DistExecution bootstrap session and dom for Distributed execution test, only for unit testing.
func CreateSession ¶
CreateSession creates a new session environment.
func CreateSession4Test ¶
CreateSession4Test creates a new session environment for test.
func CreateSession4TestWithOpt ¶
CreateSession4TestWithOpt creates a new session environment for test.
func CreateSessionAndSetID ¶
CreateSessionAndSetID creates a session and set connection ID.
func CreateSessionWithDomain ¶
CreateSessionWithDomain creates a new Session and binds it with a Domain. We need this because when we start DDL in Domain, the DDL need a session to change some system tables. But at that time, we have been already in a lock context, which cause we can't call createSession directly.
func CreateSessionWithOpt ¶
CreateSessionWithOpt creates a new session environment with option. Use default option if opt is nil.
func CreateStoreAndBootstrap ¶
CreateStoreAndBootstrap creates a mock store and bootstrap it.
func DisableRunBootstrapSQLFileInTest ¶
func DisableRunBootstrapSQLFileInTest()
DisableRunBootstrapSQLFileInTest only used for test
func ExecRestrictedStmt4Test ¶
func ExecRestrictedStmt4Test(ctx context.Context, s types.Session, stmtNode ast.StmtNode, opts ...sqlexec.OptionFuncAlias) ( []chunk.Row, []*resolve.ResultField, error)
ExecRestrictedStmt4Test wrapper `(s *session) ExecRestrictedStmt` for test.
func GetDBNames ¶
func GetDBNames(seVar *variable.SessionVars) []string
GetDBNames gets the sql layer database names from the session.
func GetPlanReplayerGCLease ¶
GetPlanReplayerGCLease returns the plan replayer gc lease time.
func GetRows4Test ¶
func GetRows4Test(ctx context.Context, _ sessionctx.Context, rs sqlexec.RecordSet) ([]chunk.Row, error)
GetRows4Test gets all the rows from a RecordSet, only used for test.
func GetStartTSFromSession ¶
GetStartTSFromSession returns the startTS in the session `se`
func HandleNonTransactionalDML ¶
func HandleNonTransactionalDML(ctx context.Context, stmt *ast.NonTransactionalDMLStmt, se sessiontypes.Session) (sqlexec.RecordSet, error)
HandleNonTransactionalDML is the entry point for a non-transactional DML statement
func InitDDLJobTables ¶
func InitDDLJobTables(store kv.Storage, targetVer meta.DDLTableVersion) error
InitDDLJobTables creates system tables that DDL uses. Because CREATE TABLE is also a DDL, we must directly modify KV data to create these tables.
func InitMDLTable ¶
InitMDLTable is to create tidb_mdl_info, which is used for metadata lock.
func InitMDLVariable ¶
InitMDLVariable initializes the metadata lock variable.
func InitMDLVariableForBootstrap ¶
InitMDLVariableForBootstrap initializes the metadata lock variable.
func InitMDLVariableForUpgrade ¶
InitMDLVariableForUpgrade initializes the metadata lock variable.
func InitTiDBSchemaCacheSize ¶
InitTiDBSchemaCacheSize initializes the tidb schema cache size.
func IsUpgradingClusterState ¶
func IsUpgradingClusterState(s sessionctx.Context) (bool, error)
IsUpgradingClusterState checks whether the global state is upgrading.
func KeyNeedToLock ¶
KeyNeedToLock returns true if the key need to lock.
func MustExecToRecodeSet ¶
func MustExecToRecodeSet(t *testing.T, se sessiontypes.Session, sql string, args ...any) sqlexec.RecordSet
MustExecToRecodeSet executes a sql statement and asserts no error occurs.
func ParseWithParams4Test ¶
func ParseWithParams4Test(ctx context.Context, s types.Session, sql string, args ...any) (ast.StmtNode, error)
ParseWithParams4Test wrapper (s *session) ParseWithParams for test
func RegisterMockUpgradeFlag ¶
RegisterMockUpgradeFlag registers the mock upgrade flag.
func RemoveLockDDLJobs ¶
func RemoveLockDDLJobs(s types.Session, job2ver map[int64]int64, job2ids map[int64]string, printLog bool)
RemoveLockDDLJobs removes the DDL jobs which doesn't get the metadata lock from job2ver.
func ResetMockAutoRandIDRetryCount ¶
func ResetMockAutoRandIDRetryCount(failTimes int64)
ResetMockAutoRandIDRetryCount set the number of occurrences of `kv.ErrTxnRetryable` when calling TxnState.Commit().
func ResetStoreForWithTiKVTest ¶
ResetStoreForWithTiKVTest is only used in the test code. TODO: Remove domap and storeBootstrapped. Use store.SetOption() to do it.
func ResultSetToStringSlice ¶
func ResultSetToStringSlice(ctx context.Context, s types.Session, rs sqlexec.RecordSet) ([][]string, error)
ResultSetToStringSlice changes the RecordSet to [][]string.
func SetPlanReplayerGCLease ¶
SetPlanReplayerGCLease changes the default plan repalyer gc lease time.
func SetSchemaLease ¶
SetSchemaLease changes the default schema lease time for DDL. This function is very dangerous, don't use it if you really know what you do. SetSchemaLease only affects not local storage after bootstrapped.
func SetStatsLease ¶
SetStatsLease changes the default stats lease time for loading stats info.
func SyncNormalRunning ¶
func SyncNormalRunning(s sessionctx.Context) error
SyncNormalRunning syncs normal state to etcd.
func SyncUpgradeState ¶
func SyncUpgradeState(s sessionctx.Context, timeout time.Duration) error
SyncUpgradeState syncs upgrade state to etcd.
Types ¶
type BaseCallback ¶
type BaseCallback struct{}
BaseCallback implements Callback interfaces.
func (*BaseCallback) OnBootstrap ¶
func (*BaseCallback) OnBootstrap(types.Session)
OnBootstrap implements Callback interface.
func (*BaseCallback) OnBootstrapAfter ¶
func (*BaseCallback) OnBootstrapAfter(types.Session)
OnBootstrapAfter implements Callback interface.
func (*BaseCallback) OnBootstrapBefore ¶
func (*BaseCallback) OnBootstrapBefore(types.Session)
OnBootstrapBefore implements Callback interface.
type Callback ¶
type Callback interface { // OnBootstrapBefore is called before doing bootstrap. OnBootstrapBefore(s types.Session) // OnBootstrap is called doing bootstrap. OnBootstrap(s types.Session) // OnBootstrapAfter is called after doing bootstrap. OnBootstrapAfter(s types.Session) }
Callback is used for Test.
type ExecStmtVarKeyType ¶
type ExecStmtVarKeyType int
ExecStmtVarKeyType is a dummy type to avoid naming collision in context.
const ExecStmtVarKey ExecStmtVarKeyType = 0
ExecStmtVarKey is a variable key for ExecStmt.
func (ExecStmtVarKeyType) String ¶
func (ExecStmtVarKeyType) String() string
String defines a Stringer function for debugging and pretty printing.
type LazyTxn ¶
type LazyTxn struct { // States of a LazyTxn should be one of the followings: // Invalid: kv.Transaction == nil && txnFuture == nil // Pending: kv.Transaction == nil && txnFuture != nil // Valid: kv.Transaction != nil && txnFuture == nil kv.Transaction // contains filtered or unexported fields }
LazyTxn wraps kv.Transaction to provide a new kv.Transaction. 1. It holds all statement related modification in the buffer before flush to the txn, so if execute statement meets error, the txn won't be made dirty. 2. It's a lazy transaction, that means it's a txnFuture before StartTS() is really need.
func (*LazyTxn) CacheTableInfo ¶
CacheTableInfo caches the index name.
func (*LazyTxn) CancelFairLocking ¶
CancelFairLocking wraps the inner transaction to support using fair locking with lazy initialization.
func (*LazyTxn) DoneFairLocking ¶
DoneFairLocking wraps the inner transaction to support using fair locking with lazy initialization.
func (*LazyTxn) GetTableInfo ¶
GetTableInfo returns the cached index name.
func (*LazyTxn) IsInFairLockingMode ¶
IsInFairLockingMode wraps the inner transaction to support using fair locking with lazy initialization.
func (*LazyTxn) KeysNeedToLock ¶
KeysNeedToLock returns the keys need to be locked.
func (*LazyTxn) LockKeysFunc ¶
func (txn *LazyTxn) LockKeysFunc(ctx context.Context, lockCtx *kv.LockCtx, fn func(), keys ...kv.Key) error
LockKeysFunc Wrap the inner transaction's `LockKeys` to record the status
func (*LazyTxn) MemHookSet ¶
MemHookSet returns whether the memory footprint change hook is set.
func (*LazyTxn) RetryFairLocking ¶
RetryFairLocking wraps the inner transaction to support using fair locking with lazy initialization.
func (*LazyTxn) RollbackMemDBToCheckpoint ¶
func (txn *LazyTxn) RollbackMemDBToCheckpoint(savepoint *tikv.MemDBCheckpoint)
RollbackMemDBToCheckpoint overrides the Transaction interface.
func (*LazyTxn) SetMemoryFootprintChangeHook ¶
SetMemoryFootprintChangeHook sets the hook to be called when the memory footprint of this transaction changes.
func (*LazyTxn) StartFairLocking ¶
StartFairLocking wraps the inner transaction to support using fair locking with lazy initialization.
func (*LazyTxn) Wait ¶
func (txn *LazyTxn) Wait(ctx context.Context, sctx sessionctx.Context) (kv.Transaction, error)
Wait converts pending txn to valid
type Opt ¶
type Opt struct {
PreparedPlanCache sessionctx.SessionPlanCache
}
Opt describes the option for creating session
type StmtHistory ¶
type StmtHistory struct {
// contains filtered or unexported fields
}
StmtHistory holds all histories of statements in a txn.
func GetHistory ¶
func GetHistory(ctx sessionctx.Context) *StmtHistory
GetHistory get all stmtHistory in current txn. Exported only for test. If stmtHistory is nil, will create a new one for current txn.
func (*StmtHistory) Add ¶
func (h *StmtHistory) Add(st sqlexec.Statement, stmtCtx *stmtctx.StatementContext)
Add appends a stmt to history list.
func (*StmtHistory) Count ¶
func (h *StmtHistory) Count() int
Count returns the count of the history.
type TestCallback ¶
type TestCallback struct { *BaseCallback Cnt *atomicutil.Int32 OnBootstrapBeforeExported func(s types.Session) OnBootstrapExported func(s types.Session) OnBootstrapAfterExported func(s types.Session) }
TestCallback is used to customize user callback themselves.
func (*TestCallback) OnBootstrap ¶
func (tc *TestCallback) OnBootstrap(s types.Session)
OnBootstrap mocks the same behavior with the main bootstrap hook.
func (*TestCallback) OnBootstrapAfter ¶
func (tc *TestCallback) OnBootstrapAfter(s types.Session)
OnBootstrapAfter mocks the same behavior with the main bootstrap hook.
func (*TestCallback) OnBootstrapBefore ¶
func (tc *TestCallback) OnBootstrapBefore(s types.Session)
OnBootstrapBefore mocks the same behavior with the main bootstrap hook.