tidb: github.com/pingcap/tidb/util Index | Files | Directories

package util

import "github.com/pingcap/tidb/util"

Index

Package Files

misc.go prefix_helper.go processinfo.go random.go

Constants

const (
    // DefaultMaxRetries indicates the max retry count.
    DefaultMaxRetries = 30
    // RetryInterval indicates retry interval.
    RetryInterval uint64 = 500
    // GCTimeFormat is the format that gc_worker used to store times.
    GCTimeFormat = "20060102-15:04:05 -0700"
)
const (
    // InformationSchemaName is the `INFORMATION_SCHEMA` database name.
    InformationSchemaName = "INFORMATION_SCHEMA"
    // InformationSchemaLowerName is the `INFORMATION_SCHEMA` database lower name.
    InformationSchemaLowerName = "information_schema"
    // PerformanceSchemaName is the `PERFORMANCE_SCHEMA` database name.
    PerformanceSchemaName = "PERFORMANCE_SCHEMA"
    // PerformanceSchemaLowerName is the `PERFORMANCE_SCHEMA` database lower name.
    PerformanceSchemaLowerName = "performance_schema"
)

func CompatibleParseGCTime Uses

func CompatibleParseGCTime(value string) (time.Time, error)

CompatibleParseGCTime parses a string with `GCTimeFormat` and returns a time.Time. If `value` can't be parsed as that format, truncate to last space and try again. This function is only useful when loading times that saved by gc_worker. We have changed the format that gc_worker saves time (removed the last field), but when loading times it should be compatible with the old format.

func DelKeyWithPrefix Uses

func DelKeyWithPrefix(rm kv.RetrieverMutator, prefix kv.Key) error

DelKeyWithPrefix deletes keys with prefix.

func GetStack Uses

func GetStack() []byte

GetStack gets the stacktrace.

func IsMemOrSysDB Uses

func IsMemOrSysDB(dbLowerName string) bool

IsMemOrSysDB uses to check whether dbLowerName is memory database or system database.

func RandomBuf Uses

func RandomBuf(size int) []byte

RandomBuf generates a random string using ASCII characters but avoid separator character. See https://github.com/mysql/mysql-server/blob/5.7/mysys_ssl/crypt_genhash_impl.cc#L435

func RowKeyPrefixFilter Uses

func RowKeyPrefixFilter(rowKeyPrefix kv.Key) kv.FnKeyCmp

RowKeyPrefixFilter returns a function which checks whether currentKey has decoded rowKeyPrefix as prefix.

func RunWithRetry Uses

func RunWithRetry(retryCnt int, backoff uint64, f func() (bool, error)) (err error)

RunWithRetry will run the f with backoff and retry. retryCnt: Max retry count backoff: When run f failed, it will sleep backoff * triedCount time.Millisecond. Function f should have two return value. The first one is an bool which indicate if the err if retryable. The second is if the f meet any error.

func ScanMetaWithPrefix Uses

func ScanMetaWithPrefix(retriever kv.Retriever, prefix kv.Key, filter func(kv.Key, []byte) bool) error

ScanMetaWithPrefix scans metadata with the prefix.

func SyntaxError Uses

func SyntaxError(err error) error

SyntaxError converts parser error to TiDB's syntax error.

func SyntaxWarn Uses

func SyntaxWarn(err error) error

SyntaxWarn converts parser warn to TiDB's syntax warn.

func WithRecovery Uses

func WithRecovery(exec func(), recoverFn func(r interface{}))

WithRecovery wraps goroutine startup call with force recovery. it will dump current goroutine stack into log if catch any recover result.

exec:      execute logic function.
recoverFn: handler will be called after recover and before dump stack, passing `nil` means noop.

type ProcessInfo Uses

type ProcessInfo struct {
    ID            uint64
    User          string
    Host          string
    DB            string
    Plan          interface{}
    Time          time.Time
    Info          string
    CurTxnStartTS uint64
    StmtCtx       *stmtctx.StatementContext
    StatsInfo     func(interface{}) map[string]uint64
    // MaxExecutionTime is the timeout for select statement, in milliseconds.
    // If the query takes too long, kill it.
    MaxExecutionTime uint64

    State                     uint16
    Command                   byte
    ExceedExpensiveTimeThresh bool
}

ProcessInfo is a struct used for show processlist statement.

func (*ProcessInfo) ToRow Uses

func (pi *ProcessInfo) ToRow(tz *time.Location) []interface{}

ToRow returns []interface{} for the row data of "SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST".

func (*ProcessInfo) ToRowForShow Uses

func (pi *ProcessInfo) ToRowForShow(full bool) []interface{}

ToRowForShow returns []interface{} for the row data of "SHOW [FULL] PROCESSLIST".

type SessionManager Uses

type SessionManager interface {
    ShowProcessList() map[uint64]*ProcessInfo
    GetProcessInfo(id uint64) (*ProcessInfo, bool)
    Kill(connectionID uint64, query bool)
}

SessionManager is an interface for session manage. Show processlist and kill statement rely on this interface.

Directories

PathSynopsis
admin
arena
chunk
codec
deadlock
disjointset
disk
encrypt
execdetails
expensivequery
filesort
format
gcutil
hack
israce
kvcache
kvencoder
logutil
math
memory
mockPackage mock is just for test only.
mvmap
pdapi
printer
ranger
rowcodec
rowDecoder
set
signal
sqlexec
stmtsummary
stringutil
sys/linux
systimemon
testkit
testleak
testutil
timeutil
tracing

Package util imports 15 packages (graph) and is imported by 299 packages. Updated 2019-09-14. Refresh now. Tools for package owners.