tidb: github.com/pingcap/tidb/server Index | Files

package server

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

Index

Package Files

buffered_read_conn.go column.go conn.go conn_stmt.go driver.go driver_tidb.go http_handler.go http_status.go packetio.go server.go sql_info_fetcher.go statistics_handler.go tokenlimiter.go util.go

type ColumnInfo Uses

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 Uses

func (column *ColumnInfo) Dump(buffer []byte) []byte

Dump dumps ColumnInfo to bytes.

type CorsHandler Uses

type CorsHandler struct {
    // contains filtered or unexported fields
}

CorsHandler adds Cors Header if `cors` config is set.

func (CorsHandler) ServeHTTP Uses

func (h CorsHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type FrameItem Uses

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 Uses

func NewFrameItemFromRegionKey(key []byte) (frame *FrameItem, err error)

NewFrameItemFromRegionKey creates a FrameItem with region's startKey or endKey, returns err when key is illegal.

type IDriver Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

type RegionFrameRange struct {
    // contains filtered or unexported fields
}

RegionFrameRange contains a frame range info which the region covered.

type RegionMeta Uses

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 Uses

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 Uses

type Server struct {
    // contains filtered or unexported fields
}

Server is the MySQL protocol server

func NewServer Uses

func NewServer(cfg *config.Config, driver IDriver) (*Server, error)

NewServer creates a new Server.

func (*Server) Close Uses

func (s *Server) Close()

Close closes the server.

func (*Server) ConnectionCount Uses

func (s *Server) ConnectionCount() int

ConnectionCount gets current connection count.

func (*Server) GetProcessInfo Uses

func (s *Server) GetProcessInfo(id uint64) (*util.ProcessInfo, bool)

GetProcessInfo implements the SessionManager interface.

func (*Server) GracefulDown Uses

func (s *Server) GracefulDown(ctx context.Context, done chan struct{})

GracefulDown waits all clients to close.

func (*Server) Kill Uses

func (s *Server) Kill(connectionID uint64, query bool)

Kill implements the SessionManager interface.

func (*Server) KillAllConnections Uses

func (s *Server) KillAllConnections()

KillAllConnections kills all connections when server is not gracefully shutdown.

func (*Server) Run Uses

func (s *Server) Run() error

Run runs the server.

func (*Server) ShowProcessList Uses

func (s *Server) ShowProcessList() map[uint64]*util.ProcessInfo

ShowProcessList implements the SessionManager interface.

func (*Server) TryGracefulDown Uses

func (s *Server) TryGracefulDown()

TryGracefulDown will try to gracefully close all connection first with timeout. if timeout, will close all connection directly.

type StatsHandler Uses

type StatsHandler struct {
    // contains filtered or unexported fields
}

StatsHandler is the handler for dumping statistics.

func (StatsHandler) ServeHTTP Uses

func (sh StatsHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type StatsHistoryHandler Uses

type StatsHistoryHandler struct {
    // contains filtered or unexported fields
}

StatsHistoryHandler is the handler for dumping statistics.

func (StatsHistoryHandler) ServeHTTP Uses

func (sh StatsHistoryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type TableRegions Uses

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 Uses

type TiDBContext struct {
    // contains filtered or unexported fields
}

TiDBContext implements QueryCtx.

func (*TiDBContext) AffectedRows Uses

func (tc *TiDBContext) AffectedRows() uint64

AffectedRows implements QueryCtx AffectedRows method.

func (*TiDBContext) Auth Uses

func (tc *TiDBContext) Auth(user *auth.UserIdentity, auth []byte, salt []byte) bool

Auth implements QueryCtx Auth method.

func (*TiDBContext) Close Uses

func (tc *TiDBContext) Close() error

Close implements QueryCtx Close method.

func (*TiDBContext) CommitTxn Uses

func (tc *TiDBContext) CommitTxn(ctx context.Context) error

CommitTxn implements QueryCtx CommitTxn method.

func (*TiDBContext) CurrentDB Uses

func (tc *TiDBContext) CurrentDB() string

CurrentDB implements QueryCtx CurrentDB method.

func (*TiDBContext) Execute Uses

func (tc *TiDBContext) Execute(ctx context.Context, sql string) (rs []ResultSet, err error)

Execute implements QueryCtx Execute method.

func (*TiDBContext) FieldList Uses

func (tc *TiDBContext) FieldList(table string) (columns []*ColumnInfo, err error)

FieldList implements QueryCtx FieldList method.

func (*TiDBContext) GetSessionVars Uses

func (tc *TiDBContext) GetSessionVars() *variable.SessionVars

GetSessionVars return SessionVars.

func (*TiDBContext) GetStatement Uses

func (tc *TiDBContext) GetStatement(stmtID int) PreparedStatement

GetStatement implements QueryCtx GetStatement method.

func (*TiDBContext) LastInsertID Uses

func (tc *TiDBContext) LastInsertID() uint64

LastInsertID implements QueryCtx LastInsertID method.

func (*TiDBContext) LastMessage Uses

func (tc *TiDBContext) LastMessage() string

LastMessage implements QueryCtx LastMessage method.

func (*TiDBContext) Prepare Uses

func (tc *TiDBContext) Prepare(sql string) (statement PreparedStatement, columns, params []*ColumnInfo, err error)

Prepare implements QueryCtx Prepare method.

func (*TiDBContext) RollbackTxn Uses

func (tc *TiDBContext) RollbackTxn()

RollbackTxn implements QueryCtx RollbackTxn method.

func (*TiDBContext) SetClientCapability Uses

func (tc *TiDBContext) SetClientCapability(flags uint32)

SetClientCapability implements QueryCtx SetClientCapability method.

func (*TiDBContext) SetCommandValue Uses

func (tc *TiDBContext) SetCommandValue(command byte)

SetCommandValue implements QueryCtx SetCommandValue method.

func (*TiDBContext) SetProcessInfo Uses

func (tc *TiDBContext) SetProcessInfo(sql string, t time.Time, command byte, maxExecutionTime uint64)

SetProcessInfo implements QueryCtx SetProcessInfo method.

func (*TiDBContext) SetSessionManager Uses

func (tc *TiDBContext) SetSessionManager(sm util.SessionManager)

SetSessionManager implements the QueryCtx interface.

func (*TiDBContext) SetValue Uses

func (tc *TiDBContext) SetValue(key fmt.Stringer, value interface{})

SetValue implements QueryCtx SetValue method.

func (*TiDBContext) ShowProcess Uses

func (tc *TiDBContext) ShowProcess() *util.ProcessInfo

ShowProcess implements QueryCtx ShowProcess method.

func (*TiDBContext) Status Uses

func (tc *TiDBContext) Status() uint16

Status implements QueryCtx Status method.

func (*TiDBContext) Value Uses

func (tc *TiDBContext) Value(key fmt.Stringer) interface{}

Value implements QueryCtx Value method.

func (*TiDBContext) WarningCount Uses

func (tc *TiDBContext) WarningCount() uint16

WarningCount implements QueryCtx WarningCount method.

type TiDBDriver Uses

type TiDBDriver struct {
    // contains filtered or unexported fields
}

TiDBDriver implements IDriver.

func NewTiDBDriver Uses

func NewTiDBDriver(store kv.Storage) *TiDBDriver

NewTiDBDriver creates a new TiDBDriver.

func (*TiDBDriver) OpenCtx Uses

func (qd *TiDBDriver) OpenCtx(connID uint64, capability uint32, collation uint8, dbname string, tlsState *tls.ConnectionState) (QueryCtx, error)

OpenCtx implements IDriver.

type TiDBStatement Uses

type TiDBStatement struct {
    // contains filtered or unexported fields
}

TiDBStatement implements PreparedStatement.

func (*TiDBStatement) AppendParam Uses

func (ts *TiDBStatement) AppendParam(paramID int, data []byte) error

AppendParam implements PreparedStatement AppendParam method.

func (*TiDBStatement) BoundParams Uses

func (ts *TiDBStatement) BoundParams() [][]byte

BoundParams implements PreparedStatement BoundParams method.

func (*TiDBStatement) Close Uses

func (ts *TiDBStatement) Close() error

Close implements PreparedStatement Close method.

func (*TiDBStatement) Execute Uses

func (ts *TiDBStatement) Execute(ctx context.Context, args []types.Datum) (rs ResultSet, err error)

Execute implements PreparedStatement Execute method.

func (*TiDBStatement) GetParamsType Uses

func (ts *TiDBStatement) GetParamsType() []byte

GetParamsType implements PreparedStatement GetParamsType method.

func (*TiDBStatement) GetResultSet Uses

func (ts *TiDBStatement) GetResultSet() ResultSet

GetResultSet gets ResultSet associated this statement

func (*TiDBStatement) ID Uses

func (ts *TiDBStatement) ID() int

ID implements PreparedStatement ID method.

func (*TiDBStatement) NumParams Uses

func (ts *TiDBStatement) NumParams() int

NumParams implements PreparedStatement NumParams method.

func (*TiDBStatement) Reset Uses

func (ts *TiDBStatement) Reset()

Reset implements PreparedStatement Reset method.

func (*TiDBStatement) SetParamsType Uses

func (ts *TiDBStatement) SetParamsType(paramsType []byte)

SetParamsType implements PreparedStatement SetParamsType method.

func (*TiDBStatement) StoreResultSet Uses

func (ts *TiDBStatement) StoreResultSet(rs ResultSet)

StoreResultSet stores ResultSet for stmt fetching

type Token Uses

type Token struct {
}

Token is used as a permission to keep on running.

type TokenLimiter Uses

type TokenLimiter struct {
    // contains filtered or unexported fields
}

TokenLimiter is used to limit the number of concurrent tasks.

func NewTokenLimiter Uses

func NewTokenLimiter(count uint) *TokenLimiter

NewTokenLimiter creates a TokenLimiter with count tokens.

func (*TokenLimiter) Get Uses

func (tl *TokenLimiter) Get() *Token

Get obtains a token.

func (*TokenLimiter) Put Uses

func (tl *TokenLimiter) Put(tk *Token)

Put releases the token.

Package server imports 79 packages (graph) and is imported by 32 packages. Updated 2019-09-10. Refresh now. Tools for package owners.