Documentation ¶
Index ¶
- type ColumnInfo
- type CorsHandler
- type IDriver
- type PreparedStatement
- type QueryCtx
- 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) SetDomain(dom *domain.Domain)
- func (s *Server) ShowProcessList() map[uint64]*util.ProcessInfo
- func (s *Server) TryGracefulDown()
- func (s *Server) UpdateTLSConfig(cfg *tls.Config)
- type Session
- type Token
- type TokenLimiter
- type TxnState
- func (st *TxnState) BatchGet(ctx context.Context, keys []kv.Key) (map[string][]byte, error)
- func (st *TxnState) Commit(ctx context.Context) error
- func (st *TxnState) Delete(k kv.Key) error
- func (st *TxnState) Discard()
- func (st *TxnState) Flush() (int, error)
- func (st *TxnState) Get(ctx context.Context, k kv.Key) ([]byte, error)
- func (st *TxnState) GetMemBuffer() kv.MemBuffer
- func (st *TxnState) GoString() string
- func (st *TxnState) Iter(k kv.Key, upperBound kv.Key) (kv.Iterator, error)
- func (st *TxnState) IterReverse(k kv.Key) (kv.Iterator, error)
- func (st *TxnState) NewStagingBuffer() kv.MemBuffer
- func (st *TxnState) Rollback() error
- func (st *TxnState) Set(k kv.Key, v []byte) error
- func (st *TxnState) Size() int
- func (st *TxnState) String() string
- func (st *TxnState) Valid() bool
- type ZDBContext
- func (tc *ZDBContext) AffectedRows() uint64
- func (tc *ZDBContext) Auth(user *auth.UserIdentity, auth []byte, salt []byte) bool
- func (tc *ZDBContext) Close() error
- func (tc *ZDBContext) CommitTxn(ctx context.Context) error
- func (tc *ZDBContext) CurrentDB() string
- func (tc *ZDBContext) ExecuteStmt(ctx context.Context, stmt ast.StmtNode) (ResultSet, error)
- func (tc *ZDBContext) FieldList(table string) (columns []*ColumnInfo, err error)
- func (tc *ZDBContext) GetHistorySQL() string
- func (tc *ZDBContext) GetSessionVars() *variable.SessionVars
- func (tc *ZDBContext) GetStatement(stmtID int) PreparedStatement
- func (tc *ZDBContext) LastInsertID() uint64
- func (tc *ZDBContext) LastMessage() string
- func (tc *ZDBContext) Parse(ctx context.Context, sql string) ([]ast.StmtNode, error)
- func (tc *ZDBContext) Prepare(sql string) (statement PreparedStatement, columns, params []*ColumnInfo, err error)
- func (tc *ZDBContext) RollbackTxn()
- func (tc *ZDBContext) SetClientCapability(flags uint32)
- func (tc *ZDBContext) SetCommandValue(command byte)
- func (tc *ZDBContext) SetProcessInfo(sql string, t time.Time, command byte, maxExecutionTime uint64)
- func (tc *ZDBContext) SetSessionManager(sm util.SessionManager)
- func (tc *ZDBContext) SetValue(key fmt.Stringer, value interface{})
- func (tc *ZDBContext) ShowProcess() *util.ProcessInfo
- func (tc *ZDBContext) Status() uint16
- func (tc *ZDBContext) Value(key fmt.Stringer) interface{}
- func (tc *ZDBContext) WarningCount() uint16
- type ZDBDriver
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 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 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 // ExecuteStmt executes a SQL statement. ExecuteStmt(context.Context, ast.StmtNode) (ResultSet, error) // Parse parses a SQL to statement node. Parse(ctx context.Context, sql string) ([]ast.StmtNode, 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 //For debug GetHistorySQL() string SetCommandValue(command byte) SetSessionManager(util.SessionManager) }
QueryCtx is the interface to execute command.
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.
func (*Server) UpdateTLSConfig ¶
UpdateTLSConfig implements the SessionManager interface.
type Session ¶
type Session interface { sctx.Context Status() uint16 // Flag of current status, such as autocommit. ExecuteStmt(context.Context, ast.StmtNode) (sqlexec.RecordSet, error) Execute(context.Context, string) (sqlexec.RecordSet, error) Parse(ctx context.Context, sql string) ([]ast.StmtNode, error) String() string // String is used to debug. CommitTxn(context.Context) error RollbackTxn(context.Context) SetConnectionID(uint64) SetCollation(coID int) error Close() // FieldList returns fields list of a table. FieldList(tableName string) (fields []*ast.ResultField, err error) AffectedRows() uint64 GetHistorySQL() string }
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.
type TxnState ¶
type TxnState struct { // States of a TxnState should be one of the followings: // Invalid: kv.Transaction == nil && txnFuture == nil // Pending: kv.Transaction == nil && txnFuture != nil // Valid: kv.Transaction != nil && txnFuture == nil kv.Transaction // contains filtered or unexported fields }
TxnState wraps kv.Transaction to provide a new kv.Transaction. 1. It holds all statement related modification in the buffer before flush to the txn, so if execute statement meets error, the txn won't be made dirty. 2. It's a lazy transaction, that means it's a txnFuture before StartTS() is really need.
func (*TxnState) GetMemBuffer ¶
GetMemBuffer overrides the Transaction interface.
func (*TxnState) IterReverse ¶
IterReverse overrides the Transaction interface.
func (*TxnState) NewStagingBuffer ¶
NewStagingBuffer returns a new child write buffer.
type ZDBContext ¶
type ZDBContext struct {
// contains filtered or unexported fields
}
func (*ZDBContext) AffectedRows ¶
func (tc *ZDBContext) AffectedRows() uint64
func (*ZDBContext) Auth ¶
func (tc *ZDBContext) Auth(user *auth.UserIdentity, auth []byte, salt []byte) bool
Auth implements QueryCtx Auth method.
func (*ZDBContext) Close ¶
func (tc *ZDBContext) Close() error
Close implements QueryCtx Close method.
func (*ZDBContext) CommitTxn ¶
func (tc *ZDBContext) CommitTxn(ctx context.Context) error
CommitTxn implements QueryCtx CommitTxn method.
func (*ZDBContext) CurrentDB ¶
func (tc *ZDBContext) CurrentDB() string
CurrentDB implements QueryCtx CurrentDB method.
func (*ZDBContext) ExecuteStmt ¶
ExecuteStmt implements QueryCtx interface.
func (*ZDBContext) FieldList ¶
func (tc *ZDBContext) FieldList(table string) (columns []*ColumnInfo, err error)
FieldList implements QueryCtx FieldList method.
func (*ZDBContext) GetHistorySQL ¶
func (tc *ZDBContext) GetHistorySQL() string
func (*ZDBContext) GetSessionVars ¶
func (tc *ZDBContext) GetSessionVars() *variable.SessionVars
func (*ZDBContext) GetStatement ¶
func (tc *ZDBContext) GetStatement(stmtID int) PreparedStatement
GetStatement implements QueryCtx GetStatement method.
func (*ZDBContext) LastInsertID ¶
func (tc *ZDBContext) LastInsertID() uint64
LastInsertID implements QueryCtx LastInsertID method.
func (*ZDBContext) LastMessage ¶
func (tc *ZDBContext) LastMessage() string
LastMessage implements QueryCtx LastMessage method.
func (*ZDBContext) Prepare ¶
func (tc *ZDBContext) Prepare(sql string) (statement PreparedStatement, columns, params []*ColumnInfo, err error)
Prepare implements QueryCtx Prepare method.
func (*ZDBContext) RollbackTxn ¶
func (tc *ZDBContext) RollbackTxn()
RollbackTxn implements QueryCtx RollbackTxn method.
func (*ZDBContext) SetClientCapability ¶
func (tc *ZDBContext) SetClientCapability(flags uint32)
SetClientCapability implements QueryCtx SetClientCapability method.
func (*ZDBContext) SetCommandValue ¶
func (tc *ZDBContext) SetCommandValue(command byte)
SetCommandValue implements QueryCtx SetCommandValue method.
func (*ZDBContext) SetProcessInfo ¶
func (tc *ZDBContext) SetProcessInfo(sql string, t time.Time, command byte, maxExecutionTime uint64)
SetProcessInfo implements QueryCtx SetProcessInfo method.
func (*ZDBContext) SetSessionManager ¶
func (tc *ZDBContext) SetSessionManager(sm util.SessionManager)
SetSessionManager implements the QueryCtx interface.
func (*ZDBContext) ShowProcess ¶
func (tc *ZDBContext) ShowProcess() *util.ProcessInfo
ShowProcess implements QueryCtx ShowProcess method.
func (*ZDBContext) Status ¶
func (tc *ZDBContext) Status() uint16
func (*ZDBContext) WarningCount ¶
func (tc *ZDBContext) WarningCount() uint16
WarningCount implements QueryCtx WarningCount method.
type ZDBDriver ¶
type ZDBDriver struct {
// contains filtered or unexported fields
}