Documentation ¶
Index ¶
- type ColumnInfo
- type CorsHandler
- type FrameItem
- type IDriver
- type IndexRegions
- type PreparedStatement
- type QueryCtx
- type RegionDetail
- type RegionFrameRange
- type RegionMeta
- type ResultSet
- type Server
- func (s *Server) Close()
- func (s *Server) ConnectionCount() int
- func (s *Server) GetProcessInfo(id uint64) (*util.ProcessInfo, bool)
- func (s *Server) GracefulDown(ctx context.Context, done chan struct{})
- func (s *Server) Kill(connectionID uint64, query bool)
- func (s *Server) KillAllConnections()
- func (s *Server) Run() error
- func (s *Server) ShowProcessList() map[uint64]*util.ProcessInfo
- func (s *Server) TryGracefulDown()
- type StatsHandler
- type StatsHistoryHandler
- type TableRegions
- type TiDBContext
- func (tc *TiDBContext) AffectedRows() uint64
- func (tc *TiDBContext) Auth(user *auth.UserIdentity, auth []byte, salt []byte) bool
- func (tc *TiDBContext) Close() error
- func (tc *TiDBContext) CommitTxn(ctx context.Context) error
- func (tc *TiDBContext) CurrentDB() string
- func (tc *TiDBContext) Execute(ctx context.Context, sql string) (rs []ResultSet, err error)
- func (tc *TiDBContext) FieldList(table string) (columns []*ColumnInfo, err error)
- func (tc *TiDBContext) GetSessionVars() *variable.SessionVars
- func (tc *TiDBContext) GetStatement(stmtID int) PreparedStatement
- func (tc *TiDBContext) LastInsertID() uint64
- func (tc *TiDBContext) LastMessage() string
- func (tc *TiDBContext) Prepare(sql string) (statement PreparedStatement, columns, params []*ColumnInfo, err error)
- func (tc *TiDBContext) RollbackTxn()
- func (tc *TiDBContext) SetClientCapability(flags uint32)
- func (tc *TiDBContext) SetCommandValue(command byte)
- func (tc *TiDBContext) SetProcessInfo(sql string, t time.Time, command byte, maxExecutionTime uint64)
- func (tc *TiDBContext) SetSessionManager(sm util.SessionManager)
- func (tc *TiDBContext) SetValue(key fmt.Stringer, value interface{})
- func (tc *TiDBContext) ShowProcess() *util.ProcessInfo
- func (tc *TiDBContext) Status() uint16
- func (tc *TiDBContext) Value(key fmt.Stringer) interface{}
- 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 []types.Datum) (rs ResultSet, err error)
- func (ts *TiDBStatement) GetParamsType() []byte
- func (ts *TiDBStatement) GetResultSet() ResultSet
- func (ts *TiDBStatement) ID() int
- func (ts *TiDBStatement) NumParams() int
- func (ts *TiDBStatement) Reset()
- func (ts *TiDBStatement) SetParamsType(paramsType []byte)
- func (ts *TiDBStatement) StoreResultSet(rs ResultSet)
- type Token
- type TokenLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColumnInfo ¶
type ColumnInfo struct { Schema string Table string OrgTable string Name string OrgName string ColumnLength uint32 Charset uint16 Flag uint16 Decimal uint8 Type uint8 DefaultValueLength uint64 DefaultValue []byte }
ColumnInfo contains information of a column
func (*ColumnInfo) Dump ¶
func (column *ColumnInfo) Dump(buffer []byte) []byte
Dump dumps ColumnInfo to bytes.
type CorsHandler ¶
type CorsHandler struct {
// contains filtered or unexported fields
}
CorsHandler adds Cors Header if `cors` config is set.
func (CorsHandler) ServeHTTP ¶
func (h CorsHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type FrameItem ¶
type FrameItem struct { DBName string `json:"db_name"` TableName string `json:"table_name"` TableID int64 `json:"table_id"` IsRecord bool `json:"is_record"` RecordID int64 `json:"record_id,omitempty"` IndexName string `json:"index_name,omitempty"` IndexID int64 `json:"index_id,omitempty"` IndexValues []string `json:"index_values,omitempty"` }
FrameItem includes a index's or record's meta data with table's info.
func NewFrameItemFromRegionKey ¶
NewFrameItemFromRegionKey creates a FrameItem with region's startKey or endKey, returns err when key is illegal.
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) (QueryCtx, error) }
IDriver opens IContext.
type IndexRegions ¶
type IndexRegions struct { Name string `json:"name"` ID int64 `json:"id"` Regions []RegionMeta `json:"regions"` }
IndexRegions is the region info for one index.
type PreparedStatement ¶
type PreparedStatement interface { // ID returns statement ID ID() int // Execute executes the statement. Execute(context.Context, []types.Datum) (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) // GetResultSet gets ResultSet associated this statement GetResultSet() ResultSet // Reset removes all bound parameters. Reset() // Close closes the statement. Close() error }
PreparedStatement is the interface to use a prepared statement.
type QueryCtx ¶
type QueryCtx interface { // Status returns server status code. Status() uint16 // LastInsertID returns last inserted ID. LastInsertID() uint64 // LastMessage returns last info message generated by some commands LastMessage() string // AffectedRows returns affected rows of last executed command. AffectedRows() uint64 // Value returns the value associated with this context for key. Value(key fmt.Stringer) interface{} // SetValue saves a value associated with this context for key. SetValue(key fmt.Stringer, value interface{}) SetProcessInfo(sql string, t time.Time, command byte, maxExecutionTime uint64) // CommitTxn commits the transaction operations. CommitTxn(ctx context.Context) error // RollbackTxn undoes the transaction operations. RollbackTxn() // WarningCount returns warning count of last executed command. WarningCount() uint16 // CurrentDB returns current DB. CurrentDB() string // Execute executes a SQL statement. Execute(ctx context.Context, sql string) ([]ResultSet, error) // SetClientCapability sets client capability flags SetClientCapability(uint32) // Prepare prepares a statement. Prepare(sql string) (statement PreparedStatement, columns, params []*ColumnInfo, err error) // GetStatement gets PreparedStatement by statement ID. GetStatement(stmtID int) PreparedStatement // FieldList returns columns of a table. FieldList(tableName string) (columns []*ColumnInfo, err error) // Close closes the QueryCtx. Close() error // Auth verifies user's authentication. Auth(user *auth.UserIdentity, auth []byte, salt []byte) bool // ShowProcess shows the information about the session. ShowProcess() *util.ProcessInfo // GetSessionVars return SessionVars. GetSessionVars() *variable.SessionVars SetCommandValue(command byte) SetSessionManager(util.SessionManager) }
QueryCtx is the interface to execute command.
type RegionDetail ¶
type RegionDetail struct { RegionID uint64 `json:"region_id"` StartKey []byte `json:"start_key"` EndKey []byte `json:"end_key"` Frames []*helper.FrameItem `json:"frames"` }
RegionDetail is the response data for get region by ID it includes indices and records detail in current region.
type RegionFrameRange ¶
type RegionFrameRange struct {
// contains filtered or unexported fields
}
RegionFrameRange contains a frame range info which the region covered.
type RegionMeta ¶
type RegionMeta struct { ID uint64 `json:"region_id"` Leader *metapb.Peer `json:"leader"` Peers []*metapb.Peer `json:"peers"` RegionEpoch *metapb.RegionEpoch `json:"region_epoch"` }
RegionMeta contains a region's peer detail
type ResultSet ¶
type ResultSet interface { Columns() []*ColumnInfo NewChunk() *chunk.Chunk Next(context.Context, *chunk.Chunk) error StoreFetchedRows(rows []chunk.Row) GetFetchedRows() []chunk.Row Close() error }
ResultSet is the result set of an query.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the MySQL protocol server
func (*Server) ConnectionCount ¶
ConnectionCount gets current connection count.
func (*Server) GetProcessInfo ¶
func (s *Server) GetProcessInfo(id uint64) (*util.ProcessInfo, bool)
GetProcessInfo implements the SessionManager interface.
func (*Server) GracefulDown ¶
GracefulDown waits all clients to close.
func (*Server) KillAllConnections ¶
func (s *Server) KillAllConnections()
KillAllConnections kills all connections when server is not gracefully shutdown.
func (*Server) ShowProcessList ¶
func (s *Server) ShowProcessList() map[uint64]*util.ProcessInfo
ShowProcessList implements the SessionManager interface.
func (*Server) TryGracefulDown ¶
func (s *Server) TryGracefulDown()
TryGracefulDown will try to gracefully close all connection first with timeout. if timeout, will close all connection directly.
type StatsHandler ¶
type StatsHandler struct {
// contains filtered or unexported fields
}
StatsHandler is the handler for dumping statistics.
func (StatsHandler) ServeHTTP ¶
func (sh StatsHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type StatsHistoryHandler ¶
type StatsHistoryHandler struct {
// contains filtered or unexported fields
}
StatsHistoryHandler is the handler for dumping statistics.
func (StatsHistoryHandler) ServeHTTP ¶
func (sh StatsHistoryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type TableRegions ¶
type TableRegions struct { TableName string `json:"name"` TableID int64 `json:"id"` RecordRegions []RegionMeta `json:"record_regions"` Indices []IndexRegions `json:"indices"` }
TableRegions is the response data for list table's regions. It contains regions list for record and indices.
type TiDBContext ¶
type TiDBContext struct {
// contains filtered or unexported fields
}
TiDBContext implements QueryCtx.
func (*TiDBContext) AffectedRows ¶
func (tc *TiDBContext) AffectedRows() uint64
AffectedRows implements QueryCtx AffectedRows method.
func (*TiDBContext) Auth ¶
func (tc *TiDBContext) Auth(user *auth.UserIdentity, auth []byte, salt []byte) bool
Auth implements QueryCtx Auth method.
func (*TiDBContext) Close ¶
func (tc *TiDBContext) Close() error
Close implements QueryCtx Close method.
func (*TiDBContext) CommitTxn ¶
func (tc *TiDBContext) CommitTxn(ctx context.Context) error
CommitTxn implements QueryCtx CommitTxn method.
func (*TiDBContext) CurrentDB ¶
func (tc *TiDBContext) CurrentDB() string
CurrentDB implements QueryCtx CurrentDB method.
func (*TiDBContext) FieldList ¶
func (tc *TiDBContext) FieldList(table string) (columns []*ColumnInfo, err error)
FieldList implements QueryCtx FieldList method.
func (*TiDBContext) GetSessionVars ¶
func (tc *TiDBContext) GetSessionVars() *variable.SessionVars
GetSessionVars return SessionVars.
func (*TiDBContext) GetStatement ¶
func (tc *TiDBContext) GetStatement(stmtID int) PreparedStatement
GetStatement implements QueryCtx GetStatement method.
func (*TiDBContext) LastInsertID ¶
func (tc *TiDBContext) LastInsertID() uint64
LastInsertID implements QueryCtx LastInsertID method.
func (*TiDBContext) LastMessage ¶
func (tc *TiDBContext) LastMessage() string
LastMessage implements QueryCtx LastMessage method.
func (*TiDBContext) Prepare ¶
func (tc *TiDBContext) Prepare(sql string) (statement PreparedStatement, columns, params []*ColumnInfo, err error)
Prepare implements QueryCtx Prepare method.
func (*TiDBContext) RollbackTxn ¶
func (tc *TiDBContext) RollbackTxn()
RollbackTxn implements QueryCtx RollbackTxn method.
func (*TiDBContext) SetClientCapability ¶
func (tc *TiDBContext) SetClientCapability(flags uint32)
SetClientCapability implements QueryCtx SetClientCapability method.
func (*TiDBContext) SetCommandValue ¶
func (tc *TiDBContext) SetCommandValue(command byte)
SetCommandValue implements QueryCtx SetCommandValue method.
func (*TiDBContext) SetProcessInfo ¶
func (tc *TiDBContext) SetProcessInfo(sql string, t time.Time, command byte, maxExecutionTime uint64)
SetProcessInfo implements QueryCtx SetProcessInfo method.
func (*TiDBContext) SetSessionManager ¶
func (tc *TiDBContext) SetSessionManager(sm util.SessionManager)
SetSessionManager implements the QueryCtx interface.
func (*TiDBContext) SetValue ¶
func (tc *TiDBContext) SetValue(key fmt.Stringer, value interface{})
SetValue implements QueryCtx SetValue method.
func (*TiDBContext) ShowProcess ¶
func (tc *TiDBContext) ShowProcess() *util.ProcessInfo
ShowProcess implements QueryCtx ShowProcess method.
func (*TiDBContext) Status ¶
func (tc *TiDBContext) Status() uint16
Status implements QueryCtx Status method.
func (*TiDBContext) Value ¶
func (tc *TiDBContext) Value(key fmt.Stringer) interface{}
Value implements QueryCtx Value 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.
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) GetParamsType ¶
func (ts *TiDBStatement) GetParamsType() []byte
GetParamsType implements PreparedStatement GetParamsType method.
func (*TiDBStatement) GetResultSet ¶
func (ts *TiDBStatement) GetResultSet() ResultSet
GetResultSet gets ResultSet associated this 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()
Reset implements PreparedStatement Reset method.
func (*TiDBStatement) SetParamsType ¶
func (ts *TiDBStatement) SetParamsType(paramsType []byte)
SetParamsType implements PreparedStatement SetParamsType method.
func (*TiDBStatement) StoreResultSet ¶
func (ts *TiDBStatement) StoreResultSet(rs ResultSet)
StoreResultSet stores ResultSet for stmt fetching
type TokenLimiter ¶
type TokenLimiter struct {
// contains filtered or unexported fields
}
TokenLimiter is used to limit the number of concurrent tasks.
func NewTokenLimiter ¶
func NewTokenLimiter(count uint) *TokenLimiter
NewTokenLimiter creates a TokenLimiter with count tokens.