Documentation
¶
Index ¶
- func NewRPCServer(config *config.Config, dom *domain.Domain, sm util.SessionManager) *grpc.Server
- type Ballast
- type ColumnInfo
- type CorsHandler
- type DatabaseMode
- type FrameItem
- type IDriver
- type IndexRegions
- type PlanReplayerHandler
- type PreparedStatement
- type RangeDetail
- type RegionDetail
- type RegionMeta
- type ResultSet
- type Server
- func (s *Server) AddOscProcess(p *util.OscProcessInfo)
- func (s *Server) Close()
- func (s *Server) ConnectionCount() int
- func (s *Server) GetProcessInfo(id uint64) (*util.ProcessInfo, bool)
- func (s *Server) GetScope(status string) variable.ScopeFlag
- func (s *Server) GracefulDown(ctx context.Context, done chan struct{})
- func (s *Server) InitGlobalConnID(serverIDGetter func() uint64)
- func (s *Server) InitOscProcessList()
- func (s *Server) Kill(connectionID uint64, query bool)
- func (s *Server) KillAllConnections()
- func (s *Server) KillOscProcess(connectionID uint64)
- func (s *Server) OscLock()
- func (s *Server) OscUnLock()
- func (s *Server) Run() error
- func (s *Server) ServerID() uint64
- func (s *Server) SetDomain(dom *domain.Domain)
- func (s *Server) ShowOscProcessList() map[string]*util.OscProcessInfo
- func (s *Server) ShowOscProcessListWithWrite() map[string]*util.OscProcessInfo
- func (s *Server) ShowProcessList() map[uint64]*util.ProcessInfo
- func (s *Server) ShowTxnList() []*txninfo.TxnInfo
- func (s *Server) Stats(vars *variable.SessionVars) (map[string]interface{}, error)
- func (s *Server) TryGracefulDown()
- func (s *Server) UpdateTLSConfig(cfg *tls.Config)
- type StatsHandler
- type StatsHistoryHandler
- type TableRanges
- type TableRegions
- type TiDBContext
- func (tc *TiDBContext) Close() error
- func (tc *TiDBContext) CurrentDB() string
- func (tc *TiDBContext) Execute(ctx context.Context, sql string) (rs []ResultSet, err error)
- func (tc *TiDBContext) ExecuteStmt(ctx context.Context, stmt ast.StmtNode) (ResultSet, error)
- func (tc *TiDBContext) FieldList(table string) (columns []*ColumnInfo, err error)
- func (tc *TiDBContext) GetStatement(stmtID int) PreparedStatement
- func (tc *TiDBContext) GetWarnings() []stmtctx.SQLWarn
- func (tc *TiDBContext) MysqlPrepare(sql string) (statement PreparedStatement, columns, params []*ColumnInfo, err error)
- func (tc *TiDBContext) NeedPassword(user *auth.UserIdentity) bool
- func (tc *TiDBContext) Prepare(sql string, name string) (statement PreparedStatement, columns, params []*ColumnInfo, 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 []types.Datum) (rs ResultSet, err error)
- func (ts *TiDBStatement) GetArgs() []types.Datum
- func (ts *TiDBStatement) GetColumnInfo() []*ColumnInfo
- func (ts *TiDBStatement) GetOIDs() []uint32
- func (ts *TiDBStatement) GetParamsType() []byte
- func (ts *TiDBStatement) GetResultFormat() []int16
- func (ts *TiDBStatement) GetResultSet() ResultSet
- func (ts *TiDBStatement) ID() int
- func (ts *TiDBStatement) NumParams() int
- func (ts *TiDBStatement) Reset()
- func (ts *TiDBStatement) SetArgs(args []types.Datum)
- func (ts *TiDBStatement) SetColumnInfo(columns []*ColumnInfo)
- func (ts *TiDBStatement) SetOIDs(pgOIDs []uint32)
- func (ts *TiDBStatement) SetParamsType(paramsType []byte)
- func (ts *TiDBStatement) SetResultFormat(rf []int16)
- func (ts *TiDBStatement) StoreResultSet(rs ResultSet)
- type Token
- type TokenLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRPCServer ¶
NewRPCServer creates a new rpc server.
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 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, d *resultEncoder) []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 DatabaseMode ¶
type DatabaseMode int
const ( DatabaseModeNone DatabaseMode = iota DatabaseModeMySQL DatabaseModePostgreSQL )
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.
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 uint16, dbname string, tlsState *tls.ConnectionState) (*TiDBContext, 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 PlanReplayerHandler ¶
type PlanReplayerHandler struct {
// contains filtered or unexported fields
}
PlanReplayerHandler is the handler for dumping plan replayer file.
func (PlanReplayerHandler) ServeHTTP ¶
func (prh PlanReplayerHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
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
// SetColumnInfo 设置statement中返回行数据信息
// PgSQL Modified
SetColumnInfo(columns []*ColumnInfo)
// GetColumnInfo 获取statement中返回行数据信息
// PgSQL Modified
GetColumnInfo() []*ColumnInfo
// SetArgs 在bind阶段绑定参数具体值
// PgSQL Modified
SetArgs(args []types.Datum)
// GetArgs 获取Args的具体值
// PgSQL Modified
GetArgs() []types.Datum
// GetResultFormat 获取结果返回的格式 0 为 Text, 1 为 Binary
// PgSQL Modified
GetResultFormat() []int16
// SetResultFormat 设置结果返回的格式 0 为 Text, 1 为 Binary
// PgSQL Modified
SetResultFormat(rf []int16)
// GetOIDs returns the postgres OIDs
// PgSQL Modified
GetOIDs() []uint32
// SetOIDs set the postgres OIDs
// PgSQL Modified
SetOIDs(pgOIDs []uint32)
}
PreparedStatement is the interface to use a prepared statement.
type RangeDetail ¶
type RangeDetail struct {
StartKey []byte `json:"start_key"`
EndKey []byte `json:"end_key"`
StartKeyHex string `json:"start_key_hex"`
EndKeyHex string `json:"end_key_hex"`
}
RangeDetail contains detail information about a particular range
type RegionDetail ¶
type RegionDetail struct {
RangeDetail `json:",inline"`
RegionID uint64 `json:"region_id"`
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 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
IsPrepareStmt() bool
}
ResultSet is the result set of an query.
type Server ¶
type Server struct {
DatabaseMode
// contains filtered or unexported fields
}
Server is the MySQL protocol server
func (*Server) AddOscProcess ¶
func (s *Server) AddOscProcess(p *util.OscProcessInfo)
AddOscProcess implements util.SessionManager.
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) InitGlobalConnID ¶
InitGlobalConnID initialize global connection id.
func (*Server) InitOscProcessList ¶
func (s *Server) InitOscProcessList()
func (*Server) KillAllConnections ¶
func (s *Server) KillAllConnections()
KillAllConnections kills all connections when server is not gracefully shutdown.
func (*Server) KillOscProcess ¶
KillOscProcess implements util.SessionManager.
func (*Server) ShowOscProcessList ¶
func (s *Server) ShowOscProcessList() map[string]*util.OscProcessInfo
func (*Server) ShowOscProcessListWithWrite ¶
func (s *Server) ShowOscProcessListWithWrite() map[string]*util.OscProcessInfo
ShowOscProcessListWithWrite implements util.SessionManager.
func (*Server) ShowProcessList ¶
func (s *Server) ShowProcessList() map[uint64]*util.ProcessInfo
ShowProcessList implements the SessionManager interface.
func (*Server) ShowTxnList ¶
ShowTxnList shows all txn info for displaying in `TIDB_TRX`
func (*Server) Stats ¶
func (s *Server) Stats(vars *variable.SessionVars) (map[string]interface{}, error)
Stats returns the server statistics.
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.
func (*Server) UpdateTLSConfig ¶
UpdateTLSConfig implements the SessionManager interface.
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 TableRanges ¶
type TableRanges struct {
TableName string `json:"name"`
TableID int64 `json:"id"`
Range RangeDetail `json:"table"`
Record RangeDetail `json:"record"`
Index RangeDetail `json:"index"`
Indices map[string]RangeDetail `json:"indices,omitempty"`
}
TableRanges is the response data for list table's ranges. It contains ranges list for record and indices as well as the whole table.
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 ¶
TiDBContext implements QueryCtx.
func (*TiDBContext) Close ¶
func (tc *TiDBContext) Close() error
Close implements QueryCtx Close method.
func (*TiDBContext) CurrentDB ¶
func (tc *TiDBContext) CurrentDB() string
CurrentDB implements QueryCtx CurrentDB method.
func (*TiDBContext) ExecuteStmt ¶
ExecuteStmt implements QueryCtx interface.
func (*TiDBContext) FieldList ¶
func (tc *TiDBContext) FieldList(table string) (columns []*ColumnInfo, err error)
FieldList implements QueryCtx FieldList method.
func (*TiDBContext) GetStatement ¶
func (tc *TiDBContext) GetStatement(stmtID int) PreparedStatement
GetStatement implements QueryCtx GetStatement method.
func (*TiDBContext) GetWarnings ¶
func (tc *TiDBContext) GetWarnings() []stmtctx.SQLWarn
GetWarnings implements QueryCtx GetWarnings method.
func (*TiDBContext) MysqlPrepare ¶
func (tc *TiDBContext) MysqlPrepare(sql string) (statement PreparedStatement, columns, params []*ColumnInfo, err error)
Prepare implements QueryCtx Prepare method.
func (*TiDBContext) NeedPassword ¶
func (tc *TiDBContext) NeedPassword(user *auth.UserIdentity) bool
NeedPassword implements QueryCtx NeedPassword method
func (*TiDBContext) Prepare ¶
func (tc *TiDBContext) Prepare(sql string, name string) (statement PreparedStatement, columns, params []*ColumnInfo, 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 uint16, dbname string, tlsState *tls.ConnectionState) (*TiDBContext, error)
OpenCtx implements IDriver.
type TiDBStatement ¶
type TiDBStatement struct {
// contains filtered or unexported fields
}
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) GetColumnInfo ¶
func (ts *TiDBStatement) GetColumnInfo() []*ColumnInfo
GetColumnInfo 获取 TiDBStatement 中返回行数据信息
func (*TiDBStatement) GetOIDs ¶
func (ts *TiDBStatement) GetOIDs() []uint32
GetOIDs return OIDs for the current statement
func (*TiDBStatement) GetParamsType ¶
func (ts *TiDBStatement) GetParamsType() []byte
GetParamsType implements PreparedStatement GetParamsType method.
func (*TiDBStatement) GetResultFormat ¶
func (ts *TiDBStatement) GetResultFormat() []int16
GetResultFormat 获取结果返回的格式 0 为 Text, 1 为 Binary
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) SetArgs ¶
func (ts *TiDBStatement) SetArgs(args []types.Datum)
SetArgs 进行参数绑定值
func (*TiDBStatement) SetColumnInfo ¶
func (ts *TiDBStatement) SetColumnInfo(columns []*ColumnInfo)
SetColumnInfo 设置 TiDBStatement 中返回行数据信息 如果有返回数据的语句,则存储返回数据的结构,如果没有则为空
func (*TiDBStatement) SetOIDs ¶
func (ts *TiDBStatement) SetOIDs(pgOIDs []uint32)
SetOIDs set OIDs for the current statement
func (*TiDBStatement) SetParamsType ¶
func (ts *TiDBStatement) SetParamsType(paramsType []byte)
SetParamsType implements PreparedStatement SetParamsType method.
func (*TiDBStatement) SetResultFormat ¶
func (ts *TiDBStatement) SetResultFormat(rf []int16)
SetResultFormat 设置结果返回的格式 0 为 Text, 1 为 Binary
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.