Documentation ¶
Index ¶
- type BaseRows
- func (r *BaseRows) Bytes() int
- func (r *BaseRows) Close() error
- func (r *BaseRows) Datas() []byte
- func (r *BaseRows) Fields() []*querypb.Field
- func (r *BaseRows) LastError() error
- func (r *BaseRows) LastInsertID() uint64
- func (r *BaseRows) Next() bool
- func (r *BaseRows) RowValues() ([]sqltypes.Value, error)
- func (r *BaseRows) RowsAffected() uint64
- type BinaryRows
- type Cond
- type CondList
- type CondType
- type Conn
- type Func
- type Handler
- type Listener
- type RowMode
- type Rows
- type Session
- func (s *Session) Addr() string
- func (s *Session) Charset() uint8
- func (s *Session) Close()
- func (s *Session) ID() uint32
- func (s *Session) LastQueryTime() time.Time
- func (s *Session) Salt() []byte
- func (s *Session) Schema() string
- func (s *Session) Scramble() []byte
- func (s *Session) SetSchema(schema string)
- func (s *Session) User() string
- type SessionTuple
- type Statement
- type TestHandler
- func (th *TestHandler) AddQuery(query string, result *sqltypes.Result)
- func (th *TestHandler) AddQueryDelay(query string, result *sqltypes.Result, delayMs int)
- func (th *TestHandler) AddQueryError(query string, err error)
- func (th *TestHandler) AddQueryErrorPattern(queryPattern string, err error)
- func (th *TestHandler) AddQueryPanic(query string)
- func (th *TestHandler) AddQueryPattern(queryPattern string, expectedResult *sqltypes.Result)
- func (th *TestHandler) AddQueryStream(query string, result *sqltypes.Result)
- func (th *TestHandler) AddQuerys(query string, results ...*sqltypes.Result)
- func (th *TestHandler) AuthCheck(s *Session) error
- func (th *TestHandler) ComInitDB(s *Session, db string) error
- func (th *TestHandler) ComQuery(s *Session, query string, bindVariables map[string]*querypb.BindVariable, ...) error
- func (th *TestHandler) GetQueryCalledNum(query string) int
- func (th *TestHandler) NewSession(s *Session)
- func (th *TestHandler) ResetAll()
- func (th *TestHandler) ResetErrors()
- func (th *TestHandler) ResetPatternErrors()
- func (th *TestHandler) ServerVersion() string
- func (th *TestHandler) SessionCheck(s *Session) error
- func (th *TestHandler) SessionClosed(s *Session)
- func (th *TestHandler) SessionDec(s *Session)
- func (th *TestHandler) SessionInc(s *Session)
- func (th *TestHandler) SetServerVersion()
- type TextRows
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRows ¶
type BaseRows struct {
// contains filtered or unexported fields
}
BaseRows --
func (*BaseRows) LastInsertID ¶
LastInsertID implements the Rows interface.
func (*BaseRows) Next ¶
Next implements the Rows interface. http://dev.mysql.com/doc/internals/en/com-query-response.html#packet-ProtocolText::ResultsetRow
func (*BaseRows) RowValues ¶
RowValues implements the Rows interface. https://dev.mysql.com/doc/internals/en/com-query-response.html#packet-ProtocolText::ResultsetRow
func (*BaseRows) RowsAffected ¶
RowsAffected implements the Rows interface.
type BinaryRows ¶
type BinaryRows struct {
BaseRows
}
BinaryRows presents binary row tuple.
func (*BinaryRows) RowValues ¶
func (r *BinaryRows) RowValues() ([]sqltypes.Value, error)
RowValues implements the Rows interface. https://dev.mysql.com/doc/internals/en/binary-protocol-resultset-row.html
type Cond ¶
type Cond struct { // Cond type. Type CondType // Query string Query string // Query results Result *sqltypes.Result // Panic or Not Panic bool // Return Error if Error is not nil Error error // Delay(ms) for results return Delay int }
Cond presents a condition tuple.
type CondList ¶
type CondList struct {
// contains filtered or unexported fields
}
CondList presents a list of Cond.
type Conn ¶
type Conn interface { Ping() error Quit() Close() error Closed() bool Cleanup() NextPacket() ([]byte, error) // ConnectionID is the connection id at greeting. ConnectionID() uint32 InitDB(db string) error Command(command byte) error Query(sql string) (Rows, error) Exec(sql string) error FetchAll(sql string, maxrows int) (*sqltypes.Result, error) FetchAllWithFunc(sql string, maxrows int, fn Func) (*sqltypes.Result, error) ComStatementPrepare(sql string) (*Statement, error) }
Conn interface.
type Func ¶
Func calls on every rows.Next. If func returns error, the row.Next() is interrupted and the error is return.
type Handler ¶
type Handler interface { ServerVersion() string SetServerVersion() NewSession(session *Session) SessionInc(session *Session) SessionDec(session *Session) SessionClosed(session *Session) SessionCheck(session *Session) error AuthCheck(session *Session) error ComInitDB(session *Session, database string) error ComQuery(session *Session, query string, bindVariables map[string]*querypb.BindVariable, callback func(*sqltypes.Result) error) error }
Handler interface.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener is a connection handler.
func MockMysqlServer ¶
MockMysqlServer creates a new mock mysql server.
func MockMysqlServerWithPort ¶
MockMysqlServerWithPort creates a new mock mysql server with port.
func NewListener ¶
NewListener creates a new Listener.
type Rows ¶
type Rows interface { Next() bool Close() error Datas() []byte Bytes() int RowsAffected() uint64 LastInsertID() uint64 LastError() error Fields() []*querypb.Field RowValues() ([]sqltypes.Value, error) }
Rows presents row cursor interface.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a client connection with greeting and auth.
func (*Session) LastQueryTime ¶
LastQueryTime returns the lastQueryTime.
type SessionTuple ¶
type SessionTuple struct {
// contains filtered or unexported fields
}
SessionTuple presents a session tuple.
type Statement ¶
type Statement struct { ID uint32 ParamCount uint16 PrepareStmt string ParamsType []int32 ColumnNames []string BindVars map[string]*querypb.BindVariable // contains filtered or unexported fields }
Statement --
func (*Statement) ComStatementClose ¶
ComStatementClose -- close the stmt.
func (*Statement) ComStatementExecute ¶
ComStatementExecute -- statement execute write.
func (*Statement) ComStatementQuery ¶
ComStatementExecute -- statement execute write.
func (*Statement) ComStatementReset ¶
ComStatementReset -- reset the stmt.
type TestHandler ¶
type TestHandler struct {
// contains filtered or unexported fields
}
TestHandler is the handler for testing.
func NewTestHandler ¶
func NewTestHandler(log *xlog.Log) *TestHandler
NewTestHandler creates new Handler.
func (*TestHandler) AddQuery ¶
func (th *TestHandler) AddQuery(query string, result *sqltypes.Result)
AddQuery used to add a query and its expected result.
func (*TestHandler) AddQueryDelay ¶
func (th *TestHandler) AddQueryDelay(query string, result *sqltypes.Result, delayMs int)
AddQueryDelay used to add a query and returns the expected result after delay_ms.
func (*TestHandler) AddQueryError ¶
func (th *TestHandler) AddQueryError(query string, err error)
AddQueryError used to add a query which will be rejected by a error.
func (*TestHandler) AddQueryErrorPattern ¶
func (th *TestHandler) AddQueryErrorPattern(queryPattern string, err error)
AddQueryErrorPattern used to add an query pattern with errors.
func (*TestHandler) AddQueryPanic ¶
func (th *TestHandler) AddQueryPanic(query string)
AddQueryPanic used to add query but underflying blackhearted.
func (*TestHandler) AddQueryPattern ¶
func (th *TestHandler) AddQueryPattern(queryPattern string, expectedResult *sqltypes.Result)
AddQueryPattern adds an expected result for a set of queries. These patterns are checked if no exact matches from AddQuery() are found. This function forces the addition of begin/end anchors (^$) and turns on case-insensitive matching mode. This code was derived from https://github.com/youtube/vitess.
func (*TestHandler) AddQueryStream ¶
func (th *TestHandler) AddQueryStream(query string, result *sqltypes.Result)
AddQueryStream used to add a stream query.
func (*TestHandler) AddQuerys ¶
func (th *TestHandler) AddQuerys(query string, results ...*sqltypes.Result)
AddQuerys used to add new query rule.
func (*TestHandler) AuthCheck ¶
func (th *TestHandler) AuthCheck(s *Session) error
AuthCheck implements the interface.
func (*TestHandler) ComInitDB ¶
func (th *TestHandler) ComInitDB(s *Session, db string) error
ComInitDB implements the interface.
func (*TestHandler) ComQuery ¶
func (th *TestHandler) ComQuery(s *Session, query string, bindVariables map[string]*querypb.BindVariable, callback func(qr *sqltypes.Result) error) error
ComQuery implements the interface.
func (*TestHandler) GetQueryCalledNum ¶
func (th *TestHandler) GetQueryCalledNum(query string) int
GetQueryCalledNum returns how many times db executes a certain query. This code was derived from https://github.com/youtube/vitess.
func (*TestHandler) NewSession ¶
func (th *TestHandler) NewSession(s *Session)
NewSession implements the interface.
func (*TestHandler) ResetErrors ¶
func (th *TestHandler) ResetErrors()
ResetErrors used to reset all the errors.
func (*TestHandler) ResetPatternErrors ¶
func (th *TestHandler) ResetPatternErrors()
ResetPatternErrors used to reset all the errors pattern.
func (*TestHandler) ServerVersion ¶
func (th *TestHandler) ServerVersion() string
ServerVersion implements the interface.
func (*TestHandler) SessionCheck ¶
func (th *TestHandler) SessionCheck(s *Session) error
SessionCheck implements the interface.
func (*TestHandler) SessionClosed ¶
func (th *TestHandler) SessionClosed(s *Session)
SessionClosed implements the interface.
func (*TestHandler) SessionDec ¶
func (th *TestHandler) SessionDec(s *Session)
SessionDec implements the interface.
func (*TestHandler) SessionInc ¶
func (th *TestHandler) SessionInc(s *Session)
SessionInc implements the interface.
func (*TestHandler) SetServerVersion ¶
func (th *TestHandler) SetServerVersion()
SetServerVersion implements the interface.