server

package
v0.0.0-...-14e0149 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2017 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

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(alloc arena.Allocator) []byte

Dump dumps ColumnInfo to bytes.

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"`
	IndexName string `json:"index_name,omitempty"`
	IndexID   int64  `json:"index_id,omitempty"`
}

FrameItem includes a index's or record's meta data with table's info.

func NewFrameItemFromRegionKey

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

type IDriver interface {
	// OpenCtx opens an IContext with connection id, client capability, collation and dbname.
	OpenCtx(connID uint64, capability uint32, collation uint8, dbname string) (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(args ...interface{}) (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

	// 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

	// 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{})

	// CommitTxn commits the transaction operations.
	CommitTxn() error

	// RollbackTxn undoes the transaction operations.
	RollbackTxn() error

	// WarningCount returns warning count of last executed command.
	WarningCount() uint16

	// CurrentDB returns current DB.
	CurrentDB() string

	// Execute executes a SQL statement.
	Execute(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

	SetSessionManager(util.SessionManager)

	// Cancel the execution of current transaction.
	Cancel()
}

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   []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.

func NewRegionFrameRange

func NewRegionFrameRange(region *tikv.KeyLocation) (idxRange *RegionFrameRange, err error)

NewRegionFrameRange init a NewRegionFrameRange with region info.

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, error)
	Next() ([]types.Datum, error)
	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 NewServer

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

NewServer creates a new Server.

func (*Server) Close

func (s *Server) Close()

Close closes the server.

func (*Server) ConnectionCount

func (s *Server) ConnectionCount() int

ConnectionCount gets current connection count.

func (*Server) Kill

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

Kill implements the SessionManager interface.

func (*Server) Run

func (s *Server) Run() error

Run runs the server.

func (*Server) ShowProcessList

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

ShowProcessList implements the SessionManager interface.

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) Cancel

func (tc *TiDBContext) Cancel()

Cancel implements QueryCtx Cancel method.

func (*TiDBContext) Close

func (tc *TiDBContext) Close() error

Close implements QueryCtx Close method.

func (*TiDBContext) CommitTxn

func (tc *TiDBContext) CommitTxn() error

CommitTxn implements QueryCtx CommitTxn method.

func (*TiDBContext) CurrentDB

func (tc *TiDBContext) CurrentDB() string

CurrentDB implements QueryCtx CurrentDB method.

func (*TiDBContext) Execute

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

Execute implements QueryCtx Execute method.

func (*TiDBContext) FieldList

func (tc *TiDBContext) FieldList(table string) (colums []*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) LastInsertID

func (tc *TiDBContext) LastInsertID() uint64

LastInsertID implements QueryCtx LastInsertID 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() error

RollbackTxn implements QueryCtx RollbackTxn method.

func (*TiDBContext) SetClientCapability

func (tc *TiDBContext) SetClientCapability(flags uint32)

SetClientCapability implements QueryCtx SetClientCapability 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.

func (*TiDBDriver) OpenCtx

func (qd *TiDBDriver) OpenCtx(connID uint64, capability uint32, collation uint8, dbname string) (QueryCtx, 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(args ...interface{}) (rs ResultSet, err error)

Execute implements PreparedStatement Execute method.

func (*TiDBStatement) GetParamsType

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

GetParamsType implements PreparedStatement GetParamsType method.

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.

type Token

type Token struct {
}

Token is used as a permission to keep on running.

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 int) *TokenLimiter

NewTokenLimiter creates a TokenLimiter with count tokens.

func (*TokenLimiter) Get

func (tl *TokenLimiter) Get() *Token

Get obtains a token.

func (*TokenLimiter) Put

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

Put releases the token.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL