Documentation
¶
Index ¶
- Constants
- Variables
- func CheckSupportX509NameOneline(oneline string) (err error)
- func ColumnToProto(c *model.ColumnInfo) *tipb.ColumnInfo
- func ColumnsToProto(columns []*model.ColumnInfo, pkIsHandle bool) []*tipb.ColumnInfo
- func ComposeURL(address, path string) string
- func DelKeyWithPrefix(rm kv.RetrieverMutator, prefix kv.Key) error
- func GetGOGC() int
- func GetLocalIP() string
- func GetStack() []byte
- func HasCancelled(ctx context.Context) (cancel bool)
- func InternalHTTPClient() *http.Client
- func InternalHTTPSchema() string
- func IsMemDB(dbLowerName string) bool
- func IsMemOrSysDB(dbLowerName string) bool
- func IsSysDB(dbLowerName string) bool
- func IsSystemView(dbLowerName string) bool
- func IsTLSExpiredError(err error) bool
- func LoadTLSCertificates(ca, key, cert string, autoTLS bool, rsaKeySize int) (tlsConfig *tls.Config, autoReload bool, err error)
- func MockPkixAttribute(name, value string) pkix.AttributeTypeAndValue
- func ParseAndCheckSAN(san string) (map[SANType][]string, error)
- func QueryStrForLog(query string) string
- func Recover(metricsLabel, funcInfo string, recoverFn func(), quit bool)
- func RowKeyPrefixFilter(rowKeyPrefix kv.Key) kv.FnKeyCmp
- func RunWithRetry(retryCnt int, backoff uint64, f func() (bool, error)) (err error)
- func ScanMetaWithPrefix(retriever kv.Retriever, prefix kv.Key, filter func(kv.Key, []byte) bool) error
- func SetGOGC(val int)
- func SyntaxError(err error) error
- func SyntaxWarn(err error) error
- func TLSCipher2String(n uint16) string
- func WithRecovery(exec func(), recoverFn func(r interface{}))
- func X509NameOnline(n pkix.Name) string
- type GlobalConnID
- type OscProcessInfo
- type ProcessInfo
- type ProcessOperation
- type SANType
- type SequenceTable
- type SessionManager
Constants ¶
const ( // DefaultMaxRetries indicates the max retry count. DefaultMaxRetries = 30 // RetryInterval indicates retry interval. RetryInterval uint64 = 500 )
const ( // Country is type name for country. Country = "C" // Organization is type name for organization. Organization = "O" // OrganizationalUnit is type name for organizational unit. OrganizationalUnit = "OU" // Locality is type name for locality. Locality = "L" // Email is type name for email. Email = "emailAddress" // CommonName is type name for common name. CommonName = "CN" // Province is type name for province or state. Province = "ST" )
const ( // URI indicates uri info in SAN. URI = SANType("URI") // DNS indicates dns info in SAN. DNS = SANType("DNS") // IP indicates ip info in SAN. IP = SANType("IP") )
const (
// MaxServerID is maximum serverID.
MaxServerID = 1<<22 - 1
)
Variables ¶
var ( // InformationSchemaName is the `INFORMATION_SCHEMA` database name. InformationSchemaName = model.NewCIStr("INFORMATION_SCHEMA") // PerformanceSchemaName is the `PERFORMANCE_SCHEMA` database name. PerformanceSchemaName = model.NewCIStr("PERFORMANCE_SCHEMA") // MetricSchemaName is the `METRICS_SCHEMA` database name. MetricSchemaName = model.NewCIStr("METRICS_SCHEMA") // ClusterTableInstanceColumnName is the `INSTANCE` column name of the cluster table. ClusterTableInstanceColumnName = "INSTANCE" )
var GetSequenceByName func(is interface{}, schema, sequence model.CIStr) (SequenceTable, error)
GetSequenceByName could be used in expression package without import cycle problem.
var PgCatalogName = model.NewCIStr("pg_catalog")
PgCatalogName is the `pg_catalog` database name.
var SupportCipher = make(map[string]struct{}, len(tlsCipherString))
SupportCipher maintains cipher supported by TiDB.
Functions ¶
func CheckSupportX509NameOneline ¶
CheckSupportX509NameOneline parses and validate input str is X509_NAME_oneline format and precheck check-item is supported by TiDB https://www.openssl.org/docs/manmaster/man3/X509_NAME_oneline.html
func ColumnToProto ¶
func ColumnToProto(c *model.ColumnInfo) *tipb.ColumnInfo
ColumnToProto converts model.ColumnInfo to tipb.ColumnInfo.
func ColumnsToProto ¶
func ColumnsToProto(columns []*model.ColumnInfo, pkIsHandle bool) []*tipb.ColumnInfo
ColumnsToProto converts a slice of model.ColumnInfo to a slice of tipb.ColumnInfo.
func ComposeURL ¶
ComposeURL adds HTTP schema if missing and concats address with path
func DelKeyWithPrefix ¶
func DelKeyWithPrefix(rm kv.RetrieverMutator, prefix kv.Key) error
DelKeyWithPrefix deletes keys with prefix.
func GetLocalIP ¶
func GetLocalIP() string
GetLocalIP will return a local IP(non-loopback, non 0.0.0.0), if there is one
func HasCancelled ¶
HasCancelled checks whether context has be cancelled.
func InternalHTTPClient ¶
InternalHTTPClient is used by TiDB-Server to request other components.
func InternalHTTPSchema ¶
func InternalHTTPSchema() string
InternalHTTPSchema specifies use http or https to request other components.
func IsMemOrSysDB ¶
IsMemOrSysDB uses to check whether dbLowerName is memory database or system database.
func IsSystemView ¶
IsSystemView is similar to IsMemOrSyDB, but does not include the mysql schema
func IsTLSExpiredError ¶
IsTLSExpiredError checks error is caused by TLS expired.
func LoadTLSCertificates ¶
func LoadTLSCertificates(ca, key, cert string, autoTLS bool, rsaKeySize int) (tlsConfig *tls.Config, autoReload bool, err error)
LoadTLSCertificates loads CA/KEY/CERT for special paths.
func MockPkixAttribute ¶
func MockPkixAttribute(name, value string) pkix.AttributeTypeAndValue
MockPkixAttribute generates mock AttributeTypeAndValue. only used for test.
func ParseAndCheckSAN ¶
ParseAndCheckSAN parses and check SAN str.
func QueryStrForLog ¶
QueryStrForLog trim the query if the query length more than 4096
func Recover ¶
Recover includes operations such as recovering, clearing,and printing information. It will dump current goroutine stack into log if catch any recover result.
metricsLabel: The label of PanicCounter metrics. funcInfo: Some information for the panic function. recoverFn: Handler will be called after recover and before dump stack, passing `nil` means noop. quit: If this value is true, the current program exits after recovery.
func RowKeyPrefixFilter ¶
RowKeyPrefixFilter returns a function which checks whether currentKey has decoded rowKeyPrefix as prefix.
func RunWithRetry ¶
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 ¶
func ScanMetaWithPrefix(retriever kv.Retriever, prefix kv.Key, filter func(kv.Key, []byte) bool) error
ScanMetaWithPrefix scans metadata with the prefix.
func SyntaxError ¶
SyntaxError converts parser error to TiDB's syntax error.
func SyntaxWarn ¶
SyntaxWarn converts parser warn to TiDB's syntax warn.
func TLSCipher2String ¶
TLSCipher2String convert tls num to string. Taken from https://testssl.sh/openssl-rfc.mapping.html .
func WithRecovery ¶
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.
func X509NameOnline ¶
X509NameOnline prints pkix.Name into old X509_NAME_oneline format. https://www.openssl.org/docs/manmaster/man3/X509_NAME_oneline.html
Types ¶
type GlobalConnID ¶
type GlobalConnID struct {
ServerID uint64
LocalConnID uint64
Is64bits bool
ServerIDGetter func() uint64
}
GlobalConnID is the global connection ID, providing UNIQUE connection IDs across the whole TiDB cluster. 64 bits version:
63 62 41 40 1 0
+--+---------------------+--------------------------------------+------+ | | serverId | local connId |markup| |=0| (22b) | (40b) | =1 | +--+---------------------+--------------------------------------+------+ 32 bits version(coming soon):
31 1 0
+-----------------------------+------+ | ??? |markup| | ??? | =0 | +-----------------------------+------+
func ParseGlobalConnID ¶
func ParseGlobalConnID(id uint64) (g GlobalConnID, isTruncated bool, err error)
ParseGlobalConnID parses an uint64 to GlobalConnID.
`isTruncated` indicates that older versions of the client truncated the 64-bit GlobalConnID to 32-bit.
func (*GlobalConnID) NextID ¶
func (g *GlobalConnID) NextID() uint64
NextID returns next connection id
type OscProcessInfo ¶
type OscProcessInfo struct {
ID uint64
// 连接ID
ConnID uint64
Schema string
Table string
Command string
Sqlsha1 string
Percent int
RemainTime string
Info string
Killed bool
IsGhost bool
Pause bool
PanicAbort chan ProcessOperation
// gh-ost serve-socket-file
SocketFile string
RW *sync.RWMutex
}
OscProcessInfo is a struct used for show osc processlist statement.
type ProcessInfo ¶
type ProcessInfo struct {
ID uint64
User string
Host string
Port string
DB string
Digest string
Plan interface{}
PlanExplainRows [][]string
RuntimeStatsColl *execdetails.RuntimeStatsColl
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
RedactSQL bool
// 操作目标信息
DestUser string
DestHost string
DestPort int
// 当前操作状态
OperState string
// 操作进度. 审核/执行/备份时自动计算
Percent float64
}
ProcessInfo is a struct used for show processlist statement.
func (*ProcessInfo) ToRow ¶
func (pi *ProcessInfo) ToRow(tz *time.Location) []interface{}
ToRow returns []interface{} for the row data of "SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST".
func (*ProcessInfo) ToRowForShow ¶
func (pi *ProcessInfo) ToRowForShow(full bool) []interface{}
ToRowForShow returns []interface{} for the row data of "SHOW [FULL] PROCESSLIST".
type ProcessOperation ¶
type ProcessOperation int
ProcessOperation Process operation
const ( ProcessOperationNone ProcessOperation = iota ProcessOperationKill ProcessOperationPause ProcessOperationResume )
Process operation.
type SequenceTable ¶
type SequenceTable interface {
GetSequenceID() int64
GetSequenceNextVal(ctx interface{}, dbName, seqName string) (int64, error)
SetSequenceVal(ctx interface{}, newVal int64, dbName, seqName string) (int64, bool, error)
}
SequenceTable is implemented by tableCommon, and it is specialised in handling sequence operation. Otherwise calling table will cause import cycle problem.
type SessionManager ¶
type SessionManager interface {
ShowProcessList() map[uint64]*ProcessInfo
ShowTxnList() []*txninfo.TxnInfo
GetProcessInfo(id uint64) (*ProcessInfo, bool)
Kill(connectionID uint64, query bool)
KillAllConnections()
UpdateTLSConfig(cfg *tls.Config)
ServerID() uint64
// 添加osc进程
AddOscProcess(p *OscProcessInfo)
// 返回osc进程列表
ShowOscProcessList() map[string]*OscProcessInfo
ShowOscProcessListWithWrite() map[string]*OscProcessInfo
OscLock()
OscUnLock()
// Kill当前会话的Osc进程
KillOscProcess(connectionID uint64)
}
SessionManager is an interface for session manage. Show processlist and kill statement rely on this interface.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mock is just for test only.
|
Package mock is just for test only. |
|
sys
|
|