Documentation
¶
Index ¶
- Variables
- type CausetNetVars
- type MockGlobalAccessor
- type RetryInfo
- type RewritePhaseInfo
- type SequenceState
- type TableSnapshot
- type TransactionContext
- func (tc *TransactionContext) AddUnchangedRowKey(key []byte)
- func (tc *TransactionContext) Cleanup()
- func (tc *TransactionContext) ClearDelta()
- func (tc *TransactionContext) CollectUnchangedRowKeys(buf []ekv.Key) []ekv.Key
- func (tc *TransactionContext) GetForUpdateTS() uint64
- func (tc *TransactionContext) GetKeyInPessimisticLockCache(key ekv.Key) (val []byte, ok bool)
- func (tc *TransactionContext) GetShard(shardRowIDBits uint64, typeBitsLength uint64, reserveSignBit bool, count int) int64
- func (tc *TransactionContext) GetStmtFutureForRC() oracle.Future
- func (tc *TransactionContext) SetForUpdateTS(forUpdateTS uint64)
- func (tc *TransactionContext) SetPessimisticLockCache(key ekv.Key, val []byte)
- func (tc *TransactionContext) SetStmtFutureForRC(future oracle.Future)
- func (tc *TransactionContext) UpdateDeltaForTable(physicalTableID int64, delta int64, count int64, colSize map[int64]int64)
- type WriteStmtBufs
Constants ¶
This section is empty.
Variables ¶
var ( ErrCantSetToNull = terror.ClassVariable.New(mysql.ErrCantSetToNull, mysql.MySQLErrName[mysql.ErrCantSetToNull]) ErrSnapshotTooOld = terror.ClassVariable.New(mysql.ErrSnapshotTooOld, mysql.MySQLErrName[mysql.ErrSnapshotTooOld]) ErrUnsupportedValueForVar = terror.ClassVariable.New(mysql.ErrUnsupportedValueForVar, mysql.MySQLErrName[mysql.ErrUnsupportedValueForVar]) ErrUnknownSystemVar = terror.ClassVariable.New(mysql.ErrUnknownSystemVariable, mysql.MySQLErrName[mysql.ErrUnknownSystemVariable]) ErrIncorrectScope = terror.ClassVariable.New(mysql.ErrIncorrectGlobalLocalVar, mysql.MySQLErrName[mysql.ErrIncorrectGlobalLocalVar]) ErrUnknownTimeZone = terror.ClassVariable.New(mysql.ErrUnknownTimeZone, mysql.MySQLErrName[mysql.ErrUnknownTimeZone]) ErrReadOnly = terror.ClassVariable.New(mysql.ErrVariableIsReadonly, mysql.MySQLErrName[mysql.ErrVariableIsReadonly]) ErrWrongValueForVar = terror.ClassVariable.New(mysql.ErrWrongValueForVar, mysql.MySQLErrName[mysql.ErrWrongValueForVar]) ErrWrongTypeForVar = terror.ClassVariable.New(mysql.ErrWrongTypeForVar, mysql.MySQLErrName[mysql.ErrWrongTypeForVar]) ErrTruncatedWrongValue = terror.ClassVariable.New(mysql.ErrTruncatedWrongValue, mysql.MySQLErrName[mysql.ErrTruncatedWrongValue]) ErrMaxPreparedStmtCountReached = terror.ClassVariable.New(mysql.ErrMaxPreparedStmtCountReached, mysql.MySQLErrName[mysql.ErrMaxPreparedStmtCountReached]) ErrUnsupportedIsolationLevel = terror.ClassVariable.New(mysql.ErrUnsupportedIsolationLevel, mysql.MySQLErrName[mysql.ErrUnsupportedIsolationLevel]) )
Error instances.
Functions ¶
This section is empty.
Types ¶
type CausetNetVars ¶
type CausetNetVars struct {
Concurrency
MemQuota
BatchSize
RetryLimit int64
DisableTxnAutoRetry bool
// UsersLock is a lock for user defined variables.
UsersLock sync.RWMutex
// Users are user defined variables.
Users map[string]types.Datum
// SysWarningCount is the system variable "warning_count", because it is on the hot path, so we extract it from the systems
SysWarningCount int
// SysErrorCount is the system variable "error_count", because it is on the hot path, so we extract it from the systems
SysErrorCount uint16
// PreparedStmts stores prepared statement.
PreparedStmts map[uint32]interface{}
PreparedStmtNameToID map[string]uint32
// PreparedParams params for prepared statements
PreparedParams PreparedParams
// ActiveRoles stores active roles for current user
ActiveRoles []*auth.RoleIdentity
RetryInfo *RetryInfo
// TxnCtx Should be reset on transaction finished.
TxnCtx *TransactionContext
// KVVars is the variables for KV storage.
KVVars *ekv.Variables
// Status stands for the CausetNet status. e.g. in transaction or not, auto commit is on or off, and so on.
Status uint16
// ClientCapability is client's capability.
ClientCapability uint32
// TLSConnectionState is the TLS connection state (nil if not using TLS).
TLSConnectionState *tls.ConnectionState
// ConnectionID is the connection id of the current CausetNet.
ConnectionID uint64
// PlanID is the unique id of logical and physical plan.
PlanID int
// PlanColumnID is the unique id for column when building plan.
PlanColumnID int64
// User is the user identity with which the CausetNet login.
User *auth.UserIdentity
// CurrentDB is the default database of this CausetNet.
CurrentDB string
// StrictSQLMode indicates if the CausetNet is in strict mode.
StrictSQLMode bool
// CommonGlobalLoaded indicates if common global variable has been loaded for this CausetNet.
CommonGlobalLoaded bool
// InRestrictedSQL indicates if the CausetNet is handling restricted SQL execution.
InRestrictedSQL bool
// SnapshotTS is used for reading history data. For simplicity, SnapshotTS only supports distsql request.
SnapshotTS uint64
// Snapshotschemareplicant is used with SnapshotTS, when the schema version at snapshotTS less than current schema
// version, we load an old version schema for query.
Snapshotschemareplicant interface{}
// BinlogClient is used to write binlog.
BinlogClient *pumpcli.PumpsClient
// GlobalVarsAccessor is used to set and get global variables.
GlobalVarsAccessor GlobalVarAccessor
// LastFoundRows is the number of found rows of last query statement
LastFoundRows uint64
// StmtCtx holds variables for current executing statement.
StmtCtx *stmtctx.StatementContext
// AllowAggPushDown can be set to false to forbid aggregation push down.
AllowAggPushDown bool
// AllowDistinctAggPushDown can be set true to allow agg with distinct push down to einsteindb/Noether.
AllowDistinctAggPushDown bool
// AllowWriteRowID can be set to false to forbid write data to _MilevaDB_rowid.
// This variable is currently not recommended to be turned on.
AllowWriteRowID bool
// AllowBatchCop means if we should send batch coprocessor to Noether. Default value is 1, means to use batch cop in case of aggregation and join.
// If value is set to 2 , which means to force to send batch cop for any query. Value is set to 0 means never use batch cop.
AllowBatchCop int
// MilevaDBAllowAutoRandExplicitInsert indicates whether explicit insertion on auto_random column is allowed.
AllowAutoRandExplicitInsert bool
// CorrelationThreshold is the guard to enable row count estimation using column order correlation.
CorrelationThreshold float64
// CorrelationExpFactor is used to control the heuristic approach of row count estimation when CorrelationThreshold is not met.
CorrelationExpFactor int
// CPUFactor is the CPU cost of processing one expression for one row.
CPUFactor float64
// CopCPUFactor is the CPU cost of processing one expression for one row in coprocessor.
CopCPUFactor float64
// NetworkFactor is the network cost of transferring 1 byte data.
NetworkFactor float64
// ScanFactor is the IO cost of scanning 1 byte data on EinsteinDB and Noether.
ScanFactor float64
// DescScanFactor is the IO cost of scanning 1 byte data on EinsteinDB and Noether in desc order.
DescScanFactor float64
// SeekFactor is the IO cost of seeking the start value of a range in EinsteinDB or Noether.
SeekFactor float64
// MemoryFactor is the memory cost of storing one tuple.
MemoryFactor float64
// DiskFactor is the IO cost of reading/writing one byte to temporary disk.
DiskFactor float64
// ConcurrencyFactor is the CPU cost of additional one goroutine.
ConcurrencyFactor float64
// CurrInsertValues is used to record current ValuesExpr's values.
// See http://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_values
CurrInsertValues chunk.Row
// Per-connection time zones. Each client that connects has its own time zone setting, given by the CausetNet time_zone variable.
// See https://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html
TimeZone *time.Location
SQLMode mysql.SQLMode
// AutoIncrementIncrement and AutoIncrementOffset indicates the autoID's start value and increment.
AutoIncrementIncrement int
AutoIncrementOffset int
// SkipASCIICheck check on input value.
SkipASCIICheck bool
// SkipUTF8Check check on input value.
SkipUTF8Check bool
// BatchInsert indicates if we should split insert data into multiple batches.
BatchInsert bool
// BatchDelete indicates if we should split delete data into multiple batches.
BatchDelete bool
// BatchCommit indicates if we should split the transaction into multiple batches.
BatchCommit bool
// IDAllocator is provided by kvEncoder, if it is provided, we will use it to alloc auto id instead of using
// Table.alloc.
IDAllocator autoid.Allocator
// OptimizerSelectivityLevel defines the level of the selectivity estimation in plan.
OptimizerSelectivityLevel int
// EnableTablePartition enables table partition feature.
EnableTablePartition string
// EnableCascadesPlanner enables the cascades planner.
EnableCascadesPlanner bool
// EnableWindowFunction enables the window function.
EnableWindowFunction bool
// EnableVectorizedExpression enables the vectorized expression evaluation.
EnableVectorizedExpression bool
// DBSReorgPriority is the operation priority of adding indices.
DBSReorgPriority int
// WaitSplitRegionFinish defines the split region behaviour is sync or async.
WaitSplitRegionFinish bool
// WaitSplitRegionTimeout defines the split region timeout.
WaitSplitRegionTimeout uint64
// EnableStreaming indicates whether the coprocessor request can use streaming API.
// TODO: remove this after MilevaDB-server configuration "enable-streaming' removed.
EnableStreaming bool
// EnableChunkRPC indicates whether the coprocessor request can use chunk API.
EnableChunkRPC bool
// L2CacheSize indicates the size of CPU L2 cache, using byte as unit.
L2CacheSize int
// EnableRadixJoin indicates whether to use radix hash join to execute
// HashJoin.
EnableRadixJoin bool
// ConstraintCheckInPlace indicates whether to check the constraint when the SQL executing.
ConstraintCheckInPlace bool
// CommandValue indicates which command current CausetNet is doing.
CommandValue uint32
// MilevaDBOptJoinReorderThreshold defines the minimal number of join nodes
// to use the greedy join reorder algorithm.
MilevaDBOptJoinReorderThreshold int
// SlowQueryFile indicates which slow query log file for SLOW_QUERY table to parse.
SlowQueryFile string
// EnableFastAnalyze indicates whether to take fast analyze.
EnableFastAnalyze bool
// TxnMode indicates should be pessimistic or optimistic.
TxnMode string
// LowResolutionTSO is used for reading data with low resolution TSO which is updated once every two seconds.
LowResolutionTSO bool
// MaxExecutionTime is the timeout for select statement, in milliseconds.
// If the value is 0, timeouts are not enabled.
// See https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_execution_time
MaxExecutionTime uint64
// Killed is a flag to indicate that this query is killed.
Killed uint32
// ConnectionInfo indicates current connection info used by current CausetNet, only be lazy assigned by plugin.
ConnectionInfo *ConnectionInfo
// use noop funcs or not
EnableNoopFuncs bool
// StartTime is the start time of the last query.
StartTime time.Time
// DurationParse is the duration of parsing SQL string to AST of the last query.
DurationParse time.Duration
// DurationCompile is the duration of compiling AST to execution plan of the last query.
DurationCompile time.Duration
// RewritePhaseInfo records all information about the rewriting phase.
RewritePhaseInfo
// DurationOptimization is the duration of optimizing a query.
DurationOptimization time.Duration
// DurationWaitTS is the duration of waiting for a snapshot TS
DurationWaitTS time.Duration
// PrevStmt is used to store the previous executed statement in the current CausetNet.
PrevStmt fmt.Stringer
// AllowRemoveAutoInc indicates whether a user can drop the auto_increment column attribute or not.
AllowRemoveAutoInc bool
// UsePlanBaselines indicates whether we will use plan baselines to adjust plan.
UsePlanBaselines bool
// EvolvePlanBaselines indicates whether we will evolve the plan baselines.
EvolvePlanBaselines bool
// IsolationReadEngines is used to isolation read, MilevaDB only read from the stores whose engine type is in the engines.
IsolationReadEngines map[ekv.StoreType]struct{}
PlannerSelectBlockAsName []ast.HintTable
// LockWaitTimeout is the duration waiting for pessimistic lock in milliseconds
// negative value means nowait, 0 means default behavior, others means actual wait time
LockWaitTimeout int64
// MetricSchemaStep indicates the step when query metric schema.
MetricSchemaStep int64
// MetricSchemaRangeDuration indicates the step when query metric schema.
MetricSchemaRangeDuration int64
// Some data of cluster-level memory tables will be retrieved many times in different inspection rules,
// and the cost of retrieving some data is expensive. We use the `TableSnapshot` to cache those data
// and obtain them lazily, and provide a consistent view of inspection tables for each inspection rules.
// All cached snapshots will be released at the end of retrieving
InspectionTableCache map[string]TableSnapshot
// RowEncoder is reused in CausetNet for encode row data.
RowEncoder rowcodec.Encoder
// SequenceState cache all sequence's latest value accessed by lastval() builtins. It's a CausetNet scoped
// variable, and all public methods of SequenceState are currently-safe.
SequenceState *SequenceState
// WindowingUseHighPrecision 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.
WindowingUseHighPrecision bool
// FoundInPlanCache indicates whether this statement was found in plan cache.
FoundInPlanCache bool
// PrevFoundInPlanCache indicates whether the last statement was found in plan cache.
PrevFoundInPlanCache bool
// OptimizerUseInvisibleIndexes indicates whether optimizer can use invisible index
OptimizerUseInvisibleIndexes bool
// SelectLimit limits the max counts of select statement's output
SelectLimit uint64
// EnableClusteredIndex indicates whether to enable clustered index when creating a new table.
EnableClusteredIndex bool
// EnableSlowLogMasking indicates that whether masking the query data when log slow query.
EnableSlowLogMasking bool
// ShardAllocateStep indicates the max size of continuous rowid shard in one transaction.
ShardAllocateStep int64
// contains filtered or unexported fields
}
CausetNetVars is to handle user-defined or global variables in the current CausetNet.
type MockGlobalAccessor ¶
type MockGlobalAccessor struct {
}
MockGlobalAccessor implements GlobalVarAccessor interface. it's used in tests
func NewMockGlobalAccessor ¶
func NewMockGlobalAccessor() *MockGlobalAccessor
NewMockGlobalAccessor implements GlobalVarAccessor interface.
func (*MockGlobalAccessor) GetAllSysVars ¶
func (m *MockGlobalAccessor) GetAllSysVars() (map[string]string, error)
GetAllSysVars implements GlobalVarAccessor.GetAllSysVars interface.
func (*MockGlobalAccessor) GetGlobalSysVar ¶
func (m *MockGlobalAccessor) GetGlobalSysVar(name string) (string, error)
GetGlobalSysVar implements GlobalVarAccessor.GetGlobalSysVar interface.
func (*MockGlobalAccessor) SetGlobalSysVar ¶
func (m *MockGlobalAccessor) SetGlobalSysVar(name string, value string) error
SetGlobalSysVar implements GlobalVarAccessor.SetGlobalSysVar interface.
type RetryInfo ¶
type RetryInfo struct {
Retrying bool
DroppedPreparedStmtIDs []uint32
// contains filtered or unexported fields
}
RetryInfo saves retry information.
func (*RetryInfo) AddAutoIncrementID ¶
AddAutoIncrementID adds id to autoIncrementIDs.
func (*RetryInfo) AddAutoRandomID ¶
AddAutoRandomID adds id to autoRandomIDs.
func (*RetryInfo) GetCurrAutoIncrementID ¶
GetCurrAutoIncrementID gets current autoIncrementID.
func (*RetryInfo) GetCurrAutoRandomID ¶
GetCurrAutoRandomID gets current AutoRandomID.
func (*RetryInfo) ResetOffset ¶
func (r *RetryInfo) ResetOffset()
ResetOffset resets the current retry offset.
type RewritePhaseInfo ¶
type RewritePhaseInfo struct {
// DurationRewrite is the duration of rewriting the SQL.
DurationRewrite time.Duration
// DurationPreprocessSubQuery is the duration of pre-processing sub-queries.
DurationPreprocessSubQuery time.Duration
// PreprocessSubQueries is the number of pre-processed sub-queries.
PreprocessSubQueries int
}
RewritePhaseInfo records some information about the rewrite phase
func (*RewritePhaseInfo) Reset ¶
func (r *RewritePhaseInfo) Reset()
Reset resets all fields in RewritePhaseInfo.
type SequenceState ¶
type SequenceState struct {
// contains filtered or unexported fields
}
SequenceState cache all sequence's latest value accessed by lastval() builtins. It's a CausetNet scoped variable, and all public methods of SequenceState are currently-safe.
func NewSequenceState ¶
func NewSequenceState() *SequenceState
NewSequenceState creates a SequenceState.
func (*SequenceState) GetLastValue ¶
func (ss *SequenceState) GetLastValue(sequenceID int64) (int64, bool, error)
GetLastValue will return last value of the specified sequenceID, bool(true) indicates the sequenceID is not in the cache map and NULL will be returned.
func (*SequenceState) UpdateState ¶
func (ss *SequenceState) UpdateState(sequenceID, value int64)
UpdateState will update the last value of specified sequenceID in a CausetNet.
type TableSnapshot ¶
TableSnapshot represents a data snapshot of the table contained in `information_schema`.
type TransactionContext ¶
type TransactionContext struct {
DirtyDB interface{}
Binlog interface{}
History interface{}
SchemaVersion int64
StartTS uint64
// ShardStep indicates the max size of continuous rowid shard in one transaction.
ShardStep int
// TableDeltaMap is used in the schema validator for DBS changes in one table not to block others.
// It's also used in the statistias updating.
// Note: for the partitionted table, it stores all the partition IDs.
TableDeltaMap map[int64]TableDelta
PessimisticCacheHit int
// CreateTime For metrics.
CreateTime time.Time
StatementCount int
ForUpdate bool
CouldRetry bool
IsPessimistic bool
Isolation string
LockExpire uint32
// contains filtered or unexported fields
}
TransactionContext is used to store variables that has transaction scope.
func (*TransactionContext) AddUnchangedRowKey ¶
func (tc *TransactionContext) AddUnchangedRowKey(key []byte)
AddUnchangedRowKey adds an unchanged row key in update statement for pessimistic lock.
func (*TransactionContext) Cleanup ¶
func (tc *TransactionContext) Cleanup()
Cleanup clears up transaction info that no longer use.
func (*TransactionContext) ClearDelta ¶
func (tc *TransactionContext) ClearDelta()
ClearDelta clears the delta map.
func (*TransactionContext) CollectUnchangedRowKeys ¶
func (tc *TransactionContext) CollectUnchangedRowKeys(buf []ekv.Key) []ekv.Key
CollectUnchangedRowKeys collects unchanged row keys for pessimistic lock.
func (*TransactionContext) GetForUpdateTS ¶
func (tc *TransactionContext) GetForUpdateTS() uint64
GetForUpdateTS returns the ts for update.
func (*TransactionContext) GetKeyInPessimisticLockCache ¶
func (tc *TransactionContext) GetKeyInPessimisticLockCache(key ekv.Key) (val []byte, ok bool)
GetKeyInPessimisticLockCache gets a key in pessimistic lock cache.
func (*TransactionContext) GetShard ¶
func (tc *TransactionContext) GetShard(shardRowIDBits uint64, typeBitsLength uint64, reserveSignBit bool, count int) int64
GetShard returns the shard prefix for the next `count` rowids.
func (*TransactionContext) GetStmtFutureForRC ¶
func (tc *TransactionContext) GetStmtFutureForRC() oracle.Future
GetStmtFutureForRC gets the stmtFuture.
func (*TransactionContext) SetForUpdateTS ¶
func (tc *TransactionContext) SetForUpdateTS(forUpdateTS uint64)
SetForUpdateTS sets the ts for update.
func (*TransactionContext) SetPessimisticLockCache ¶
func (tc *TransactionContext) SetPessimisticLockCache(key ekv.Key, val []byte)
SetPessimisticLockCache sets a key value pair into pessimistic lock cache.
func (*TransactionContext) SetStmtFutureForRC ¶
func (tc *TransactionContext) SetStmtFutureForRC(future oracle.Future)
SetStmtFutureForRC sets the stmtFuture .
func (*TransactionContext) UpdateDeltaForTable ¶
func (tc *TransactionContext) UpdateDeltaForTable(physicalTableID int64, delta int64, count int64, colSize map[int64]int64)
UpdateDeltaForTable updates the delta info for some table.
type WriteStmtBufs ¶
type WriteStmtBufs struct {
// RowValBuf is used by tablecodec.EncodeRow, to reduce runtime.growslice.
RowValBuf []byte
// AddRowValues use to store temp insert rows value, to reduce memory allocations when importing data.
AddRowValues []types.Datum
// IndexValsBuf is used by index.FetchValues
IndexValsBuf []types.Datum
// IndexKeyBuf is used by index.GenIndexKey
IndexKeyBuf []byte
}
WriteStmtBufs can be used by insert/replace/delete/update statement. TODO: use a common memory pool to replace this.