Documentation
¶
Index ¶
- Variables
- func ClearOSUserForAuthSocket()
- func MockOSUserForAuthSocket(uname string)
- func NewRPCServer(config *config.Config, dom *domain.Domain, sm sessmgr.Manager) *grpc.Server
- type Ballast
- type DetailStatus
- type IDriver
- type MockConn
- type PreparedStatement
- type Server
- func (s *Server) BitwiseOrAssignCapability(capability uint32)
- func (s *Server) BitwiseXorCapability(capability uint32)
- func (s *Server) CheckOldRunningTxn(jobs map[int64]*mdldef.JobMDL)
- func (s *Server) Close()
- func (s *Server) ConnectionCount() int
- func (s *Server) ContainsInternalSession(se any) bool
- func (s *Server) DeleteInternalSession(se any)
- func (s *Server) DrainClients(drainWait time.Duration, cancelWait time.Duration)
- func (s *Server) GetClientCapabilityList() map[uint64]uint32
- func (s *Server) GetConAttrs(user *auth.UserIdentity) map[uint64]map[string]string
- func (s *Server) GetInternalSessionStartTSList() []uint64
- func (s *Server) GetNormalClosedConn(keyspaceName, connID string) string
- func (s *Server) GetProcessInfo(id uint64) (*sessmgr.ProcessInfo, bool)
- func (*Server) GetScope(_ string) vardef.ScopeFlag
- func (s *Server) GetStatusServerAddr() (on bool, addr string)
- func (s *Server) GetStatusVars() map[uint64]map[string]string
- func (s *Server) GetTLSConfig() *tls.Config
- func (s *Server) GetUserProcessList() map[uint64]*sessmgr.ProcessInfo
- func (s *Server) Health() bool
- func (s *Server) InternalSessionCount() int
- func (s *Server) InternalSessionExists(se any) bool
- func (s *Server) Kill(connectionID uint64, query bool, maxExecutionTime bool, runaway bool)
- func (s *Server) KillAllConnections()
- func (s *Server) KillNonFlashbackClusterConn()
- func (s *Server) KillSysProcesses()
- func (s *Server) ListenAddr() net.Addr
- func (s *Server) Listener() net.Listener
- func (s *Server) NewTikvHandlerTool() *handler.TikvHandlerTool
- func (s *Server) Run(dom *domain.Domain) error
- func (s *Server) ServerID() uint64
- func (s *Server) SetCNChecker(tlsConfig *tls.Config) *tls.Config
- func (s *Server) SetDomain(dom *domain.Domain)
- func (s *Server) SetNormalClosedConn(keyspaceName, connID, msg string)
- func (s *Server) ShowProcessList() map[uint64]*sessmgr.ProcessInfo
- func (s *Server) ShowTxnList() []*txninfo.TxnInfo
- func (s *Server) Socket() net.Listener
- func (s *Server) Stats(_ *variable.SessionVars) (map[string]any, error)
- func (s *Server) StatusListenerAddr() net.Addr
- func (s *Server) StoreInternalSession(se any)
- func (s *Server) UpdateProcessCPUTime(connID uint64, sqlID uint64, cpuTime time.Duration)
- func (s *Server) UpdateTLSConfig(cfg *tls.Config)
- type StandbyController
- type Status
- type TiDBContext
- func (tc *TiDBContext) Close() error
- func (tc *TiDBContext) DecodeSessionStates(ctx context.Context, _ sessionctx.Context, ...) error
- func (tc *TiDBContext) EncodeSessionStates(_ context.Context, _ sessionctx.Context, ...) error
- func (tc *TiDBContext) ExecuteStmt(ctx context.Context, stmt ast.StmtNode) (resultset.ResultSet, error)
- func (tc *TiDBContext) FieldList(table string) (columns []*column.Info, err error)
- func (tc *TiDBContext) GetStatement(stmtID int) PreparedStatement
- func (tc *TiDBContext) GetStmtStats() *stmtstats.StatementStats
- func (tc *TiDBContext) GetWarnings() []contextutil.SQLWarn
- func (tc *TiDBContext) Prepare(sql string) (statement PreparedStatement, columns, params []*column.Info, err error)
- func (tc *TiDBContext) WarningCount() uint16
- type TiDBDriver
- type TiDBStatement
- func (ts *TiDBStatement) AppendParam(paramID int, data []byte) error
- func (ts *TiDBStatement) BoundParams() [][]byte
- func (ts *TiDBStatement) Close() error
- func (ts *TiDBStatement) Execute(ctx context.Context, args []expression.Expression) (rs resultset.ResultSet, err error)
- func (ts *TiDBStatement) GetCursorActive() bool
- func (ts *TiDBStatement) GetParamsType() []byte
- func (ts *TiDBStatement) GetResultSet() resultset.CursorResultSet
- func (ts *TiDBStatement) GetRowContainer() *chunk.RowContainer
- func (ts *TiDBStatement) ID() int
- func (ts *TiDBStatement) NumParams() int
- func (ts *TiDBStatement) Reset() error
- func (ts *TiDBStatement) SetCursorActive(fetchEnd bool)
- func (ts *TiDBStatement) SetParamsType(paramsType []byte)
- func (ts *TiDBStatement) StoreResultSet(rs resultset.CursorResultSet)
- func (ts *TiDBStatement) StoreRowContainer(c *chunk.RowContainer)
Constants ¶
This section is empty.
Variables ¶
var ( // RunInGoTest represents whether we are run code in test. RunInGoTest bool // RunInGoTestChan is used to control the RunInGoTest. RunInGoTestChan chan struct{} )
var ( // ConnectionInMemCounterForTest is a variable to count live connection object ConnectionInMemCounterForTest = atomic.Int64{} )
Functions ¶
func ClearOSUserForAuthSocket ¶
func ClearOSUserForAuthSocket()
ClearOSUserForAuthSocket clears the mocked OS user for AUTH_SOCKET plugin
func MockOSUserForAuthSocket ¶
func MockOSUserForAuthSocket(uname string)
MockOSUserForAuthSocket mocks the OS user for AUTH_SOCKET plugin
Types ¶
type Ballast ¶
type Ballast struct {
// contains filtered or unexported fields
}
Ballast try to reduce the GC frequency by using Ballast Object
func (*Ballast) GenHTTPHandler ¶
func (b *Ballast) GenHTTPHandler() func(w http.ResponseWriter, r *http.Request)
GenHTTPHandler generate a HTTP handler to get/set the size of this ballast object
type DetailStatus ¶
type DetailStatus struct {
InitStatsPercentage float64 `json:"init_stats_percentage"`
}
DetailStatus is to show the detail status of TiDB. for example the init stats percentage.
type IDriver ¶
type IDriver interface {
// OpenCtx opens an IContext with connection id, client capability, collation, dbname and optionally the tls state.
OpenCtx(connID uint64, capability uint32, collation uint8, dbname string, tlsState *tls.ConnectionState, extensions *extension.SessionExtensions) (*TiDBContext, error)
}
IDriver opens IContext.
type MockConn ¶
type MockConn interface {
// HandleQuery executes a statement
HandleQuery(ctx context.Context, sql string) error
// Context gets the TiDBContext
Context() *TiDBContext
// Dispatch executes command according to the command type
Dispatch(ctx context.Context, data []byte) error
// Close releases resources
Close()
// ID returns the connection ID.
ID() uint64
// GetOutbound replaces the internal outbound endpoint with a empty buffer, and return it
GetOutput() *bytes.Buffer
}
MockConn is a mock connection.
type PreparedStatement ¶
type PreparedStatement interface {
// ID returns statement ID
ID() int
// Execute executes the statement.
Execute(context.Context, []expression.Expression) (resultset.ResultSet, error)
// AppendParam appends parameter to the statement.
AppendParam(paramID int, data []byte) error
// NumParams returns number of parameters.
NumParams() int
// BoundParams returns bound parameters.
BoundParams() [][]byte
// SetParamsType sets type for parameters.
SetParamsType([]byte)
// GetParamsType returns the type for parameters.
GetParamsType() []byte
// StoreResultSet stores ResultSet for subsequent stmt fetching
StoreResultSet(rs resultset.CursorResultSet)
// GetResultSet gets ResultSet associated this statement
GetResultSet() resultset.CursorResultSet
// Reset removes all bound parameters and opened resultSet/rowContainer.
Reset() error
// Close closes the statement.
Close() error
// GetCursorActive returns whether the statement has active cursor
GetCursorActive() bool
// SetCursorActive sets whether the statement has active cursor
SetCursorActive(active bool)
// StoreRowContainer stores a row container into the prepared statement. The `rowContainer` is used to be closed at
// appropriate time. It's actually not used to read, because an iterator of it has been stored in the result set.
StoreRowContainer(container *chunk.RowContainer)
// GetRowContainer returns the row container of the statement
GetRowContainer() *chunk.RowContainer
}
PreparedStatement is the interface to use a prepared statement.
type Server ¶
type Server struct {
StandbyController
// contains filtered or unexported fields
}
Server is the MySQL protocol server
func CreateMockServer ¶
CreateMockServer creates a mock server.
func NewTestServer ¶
NewTestServer creates a new Server for test.
func (*Server) BitwiseOrAssignCapability ¶
BitwiseOrAssignCapability adds the capability to the server.
func (*Server) BitwiseXorCapability ¶
BitwiseXorCapability gets the capability of the server.
func (*Server) CheckOldRunningTxn ¶
CheckOldRunningTxn implements SessionManager interface.
func (*Server) ConnectionCount ¶
ConnectionCount gets current connection count.
func (*Server) ContainsInternalSession ¶
ContainsInternalSession implements SessionManager interface.
func (*Server) DeleteInternalSession ¶
DeleteInternalSession implements SessionManager interface. @param addr The address of a session.session struct variable
func (*Server) DrainClients ¶
DrainClients drain all connections in drainWait. After drainWait duration, we kill all connections still not quit explicitly and wait for cancelWait.
func (*Server) GetClientCapabilityList ¶
GetClientCapabilityList returns all client capability.
func (*Server) GetConAttrs ¶
GetConAttrs returns the connection attributes
func (*Server) GetInternalSessionStartTSList ¶
GetInternalSessionStartTSList implements SessionManager interface.
func (*Server) GetNormalClosedConn ¶
GetNormalClosedConn gets the normal closed connection message.
func (*Server) GetProcessInfo ¶
func (s *Server) GetProcessInfo(id uint64) (*sessmgr.ProcessInfo, bool)
GetProcessInfo implements the SessionManager interface.
func (*Server) GetStatusServerAddr ¶
GetStatusServerAddr gets statusServer address for MppCoordinatorManager usage
func (*Server) GetStatusVars ¶
GetStatusVars is getting the per process status variables from the server
func (*Server) GetTLSConfig ¶
GetTLSConfig implements the SessionManager interface.
func (*Server) GetUserProcessList ¶
func (s *Server) GetUserProcessList() map[uint64]*sessmgr.ProcessInfo
GetUserProcessList returns all process info that are created by user.
func (*Server) InternalSessionCount ¶
InternalSessionCount implements sessionmgr.InfoSchemaCoordinator interface.
func (*Server) InternalSessionExists ¶
InternalSessionExists is used for test
func (*Server) KillAllConnections ¶
func (s *Server) KillAllConnections()
KillAllConnections implements the SessionManager interface. KillAllConnections kills all connections.
func (*Server) KillNonFlashbackClusterConn ¶
func (s *Server) KillNonFlashbackClusterConn()
KillNonFlashbackClusterConn implements SessionManager interface.
func (*Server) KillSysProcesses ¶
func (s *Server) KillSysProcesses()
KillSysProcesses kill sys processes such as auto analyze.
func (*Server) ListenAddr ¶
ListenAddr returns the server's listener's network address.
func (*Server) NewTikvHandlerTool ¶
func (s *Server) NewTikvHandlerTool() *handler.TikvHandlerTool
NewTikvHandlerTool checks and prepares for tikv handler. It would panic when any error happens.
func (*Server) SetCNChecker ¶
SetCNChecker set the CN checker for server.
func (*Server) SetNormalClosedConn ¶
SetNormalClosedConn sets the normal closed connection message by specified connID.
func (*Server) ShowProcessList ¶
func (s *Server) ShowProcessList() map[uint64]*sessmgr.ProcessInfo
ShowProcessList implements the SessionManager interface.
func (*Server) ShowTxnList ¶
ShowTxnList shows all txn info for displaying in `TIDB_TRX`. Internal sessions are not taken into consideration.
func (*Server) StatusListenerAddr ¶
StatusListenerAddr returns the server's status listener's network address.
func (*Server) StoreInternalSession ¶
StoreInternalSession implements SessionManager interface. @param addr The address of a session.session struct variable
func (*Server) UpdateProcessCPUTime ¶
UpdateProcessCPUTime updates specific process's tidb CPU time when the process is still running It implements ProcessCPUTimeUpdater interface
func (*Server) UpdateTLSConfig ¶
UpdateTLSConfig implements the SessionManager interface.
type StandbyController ¶
type StandbyController interface {
// WaitForActivate starts to wait for the active signal before server starts.
WaitForActivate()
// EndStandby ends the standby mode. Controller implements this method to do the necessary cleanup.
EndStandby(error)
// Handler returns the handler for the standby server. It will be registered to the status server.
Handler(svr *Server) (pathPrefix string, mux *http.ServeMux)
// OnConnActive is called when a new connection is established or a connection successfully executes a command.
OnConnActive()
// OnServerCreated is called when the server is created.
OnServerCreated(svr *Server)
}
StandbyController is the interface for standby module.
type Status ¶
type Status struct {
Connections int `json:"connections"`
Version string `json:"version"`
GitHash string `json:"git_hash"`
Status DetailStatus `json:"status"`
}
Status of TiDB.
type TiDBContext ¶
type TiDBContext struct {
sessionapi.Session
// contains filtered or unexported fields
}
TiDBContext implements QueryCtx.
func (*TiDBContext) Close ¶
func (tc *TiDBContext) Close() error
Close implements QueryCtx Close method.
func (*TiDBContext) DecodeSessionStates ¶
func (tc *TiDBContext) DecodeSessionStates(ctx context.Context, _ sessionctx.Context, sessionStates *sessionstates.SessionStates) error
DecodeSessionStates implements SessionStatesHandler.DecodeSessionStates interface.
func (*TiDBContext) EncodeSessionStates ¶
func (tc *TiDBContext) EncodeSessionStates(_ context.Context, _ sessionctx.Context, sessionStates *sessionstates.SessionStates) error
EncodeSessionStates implements SessionStatesHandler.EncodeSessionStates interface.
func (*TiDBContext) ExecuteStmt ¶
func (tc *TiDBContext) ExecuteStmt(ctx context.Context, stmt ast.StmtNode) (resultset.ResultSet, error)
ExecuteStmt implements QueryCtx interface.
func (*TiDBContext) FieldList ¶
func (tc *TiDBContext) FieldList(table string) (columns []*column.Info, err error)
FieldList implements QueryCtx FieldList method.
func (*TiDBContext) GetStatement ¶
func (tc *TiDBContext) GetStatement(stmtID int) PreparedStatement
GetStatement implements QueryCtx GetStatement method.
func (*TiDBContext) GetStmtStats ¶
func (tc *TiDBContext) GetStmtStats() *stmtstats.StatementStats
GetStmtStats implements the sessionctx.Context interface.
func (*TiDBContext) GetWarnings ¶
func (tc *TiDBContext) GetWarnings() []contextutil.SQLWarn
GetWarnings implements QueryCtx GetWarnings method.
func (*TiDBContext) Prepare ¶
func (tc *TiDBContext) Prepare(sql string) (statement PreparedStatement, columns, params []*column.Info, err error)
Prepare implements QueryCtx Prepare method.
func (*TiDBContext) WarningCount ¶
func (tc *TiDBContext) WarningCount() uint16
WarningCount implements QueryCtx WarningCount method.
type TiDBDriver ¶
type TiDBDriver struct {
// contains filtered or unexported fields
}
TiDBDriver implements IDriver.
func NewTiDBDriver ¶
func NewTiDBDriver(store kv.Storage) *TiDBDriver
NewTiDBDriver creates a new TiDBDriver.
func (*TiDBDriver) OpenCtx ¶
func (qd *TiDBDriver) OpenCtx(connID uint64, capability uint32, collation uint8, _ string, tlsState *tls.ConnectionState, extensions *extension.SessionExtensions) (*TiDBContext, error)
OpenCtx implements IDriver.
type TiDBStatement ¶
type TiDBStatement struct {
// contains filtered or unexported fields
}
TiDBStatement implements PreparedStatement.
func (*TiDBStatement) AppendParam ¶
func (ts *TiDBStatement) AppendParam(paramID int, data []byte) error
AppendParam implements PreparedStatement AppendParam method.
func (*TiDBStatement) BoundParams ¶
func (ts *TiDBStatement) BoundParams() [][]byte
BoundParams implements PreparedStatement BoundParams method.
func (*TiDBStatement) Close ¶
func (ts *TiDBStatement) Close() error
Close implements PreparedStatement Close method.
func (*TiDBStatement) Execute ¶
func (ts *TiDBStatement) Execute(ctx context.Context, args []expression.Expression) (rs resultset.ResultSet, err error)
Execute implements PreparedStatement Execute method.
func (*TiDBStatement) GetCursorActive ¶
func (ts *TiDBStatement) GetCursorActive() bool
GetCursorActive implements PreparedStatement GetCursorActive method.
func (*TiDBStatement) GetParamsType ¶
func (ts *TiDBStatement) GetParamsType() []byte
GetParamsType implements PreparedStatement GetParamsType method.
func (*TiDBStatement) GetResultSet ¶
func (ts *TiDBStatement) GetResultSet() resultset.CursorResultSet
GetResultSet gets ResultSet associated this statement
func (*TiDBStatement) GetRowContainer ¶
func (ts *TiDBStatement) GetRowContainer() *chunk.RowContainer
GetRowContainer returns the row container of the statement
func (*TiDBStatement) ID ¶
func (ts *TiDBStatement) ID() int
ID implements PreparedStatement ID method.
func (*TiDBStatement) NumParams ¶
func (ts *TiDBStatement) NumParams() int
NumParams implements PreparedStatement NumParams method.
func (*TiDBStatement) Reset ¶
func (ts *TiDBStatement) Reset() error
Reset implements PreparedStatement Reset method.
func (*TiDBStatement) SetCursorActive ¶
func (ts *TiDBStatement) SetCursorActive(fetchEnd bool)
SetCursorActive implements PreparedStatement SetCursorActive method.
func (*TiDBStatement) SetParamsType ¶
func (ts *TiDBStatement) SetParamsType(paramsType []byte)
SetParamsType implements PreparedStatement SetParamsType method.
func (*TiDBStatement) StoreResultSet ¶
func (ts *TiDBStatement) StoreResultSet(rs resultset.CursorResultSet)
StoreResultSet stores ResultSet for stmt fetching
func (*TiDBStatement) StoreRowContainer ¶
func (ts *TiDBStatement) StoreRowContainer(c *chunk.RowContainer)
StoreRowContainer stores a row container into the prepared statement