Documentation ¶
Index ¶
- Constants
- Variables
- func NewCOMPacket(b []byte, ctx *Context) (interface{}, error)
- type AwaitingReplyPacket
- type COMPacket
- type ClientAuthResendPacket
- type ClientFlags
- type ClientHandshakePacket
- type CloseQueryPacket
- type Command
- type CommandType
- type Context
- type CountReader
- type EOFPacket
- type ErrorPacket
- type ExecuteQueryPacket
- type FieldListPacket
- type FieldType
- type OKPacket
- type Parser
- type PrepareQueryPacket
- type PrepareResultPacket
- type QueryPacket
- type QuitPacket
- type ResultFieldNumPacket
- type ResultFieldPacket
- type ResultNonePacket
- type ResultPacket
- type ResultRecordPacket
- type ResultState
- type ServerHandshakePacket
- type State
- type Stmt
- type StringV
- type UintV
Constants ¶
View Source
const ( Sleep CommandType = 0x00 Quit = 0x01 InitDB = 0x02 Query = 0x03 FieldList = 0x04 CreateDB = 0x05 DropDB = 0x06 Refresh = 0x07 Shutdown = 0x08 Statistics = 0x09 ProcessInfo = 0x0a Prepare = 0x16 Execute = 0x17 SendLongData = 0x18 Close = 0x19 Reset = 0x1a SetOption = 0x1b Fetch = 0x1c )
Variables ¶
View Source
var ErrNotEnoughBuffer = errors.New("not enough buffer")
View Source
var ReuseBufferMaxSize = 1024 * 1024
ReuseBufferMaxSize represent maximum size of buffer to reuse. When size of buffer is bigger than this, buffer will be destroy and create agein to free a big bunch of memory.
Functions ¶
func NewCOMPacket ¶
Types ¶
type AwaitingReplyPacket ¶
type AwaitingReplyPacket struct { }
func NewAwaitingReplyPacket ¶
func NewAwaitingReplyPacket(b []byte) (*AwaitingReplyPacket, error)
type COMPacket ¶
type COMPacket struct { Type CommandType Raw []byte }
func (*COMPacket) CommandType ¶
func (p *COMPacket) CommandType() CommandType
type ClientAuthResendPacket ¶
type ClientAuthResendPacket struct { }
func NewClientAuthResendPacket ¶
func NewClientAuthResendPacket(b []byte) (*ClientAuthResendPacket, error)
type ClientFlags ¶
type ClientFlags uint32
const ( ClientLongPassword ClientFlags = 1 << iota // 0000_0001 ClientFoundRows // 0000_0002 ClientLongFlag // 0000_0004 ClientConnectWithDB // 0000_0008 ClientNoSchema // 0000_0010 ClientCompress // 0000_0020 ClientODBC // 0000_0040 ClientLocalFiles // 0000_0080 ClientIgnoreSpace // 0000_0100 ClientProtocol41 // 0000_0200 ClientInteractive // 0000_0400 ClientSSL // 0000_0800 ClientIgnoreSIGPIPE // 0000_1000 ClientTransactions // 0000_2000 ClientReserved // 0000_4000 ClientSecureConn // 0000_8000 ClientMultiStatements // 0001_0000 ClientMultiResults // 0002_0000 ClientPSMultiResults // 0004_0000 ClientPluginAuth // 0008_0000 ClientConnectAttrs // 0010_0000 ClientPluginAuthLenEncClientData // 0020_0000 ClientCanHandleExpiredPasswords // 0040_0000 ClientSessionTrack // 0080_0000 ClientDeprecateEOF // 0100_0000 ClientOptionalResultsetMetadata // 0200_0000 ClientZstdCompressionAlgorithm // 0400_0000 MultiFactorAuthorization // 0800_0000 ClientCapabilityExtension // 1000_0000 ClientSSLVerifyServerCert // 2000_0000 ClientRememberOptions // 4000_0000 )
type ClientHandshakePacket ¶
type ClientHandshakePacket struct { ClientFlags ClientFlags MaxPacketSize uint32 Charset uint8 Username string HashedPassword *StringV Database string }
func NewClientHandshakePacket ¶
func NewClientHandshakePacket(b []byte) (*ClientHandshakePacket, error)
type CloseQueryPacket ¶
type CloseQueryPacket struct {
StatementID uint32
}
func NewCloseQueryPacket ¶
func NewCloseQueryPacket(b []byte) (*CloseQueryPacket, error)
type Command ¶
type Command interface {
CommandType() CommandType
}
type CommandType ¶
type CommandType int
type Context ¶
type Context struct { ClientFlags ClientFlags // Compression support WillCompress bool Compressing bool State State // Server status ResultState ResultState FieldNCurr uint64 FieldNMax uint64 // Prepare statements PreparedStmts map[uint32]Stmt // Client status LastCommand CommandType Data interface{} }
Context represents the context for a connection.
func (*Context) IsClientDeprecateEOF ¶
type CountReader ¶
type EOFPacket ¶
func NewEOFPacket ¶
type ErrorPacket ¶
func NewErrorPacket ¶
func NewErrorPacket(b []byte) (*ErrorPacket, error)
type ExecuteQueryPacket ¶
type ExecuteQueryPacket struct { StatementID uint32 CursorType uint8 Types []FieldType Parameters []interface{} }
func NewExecuteQueryPacket ¶
func NewExecuteQueryPacket(b []byte, ctx *Context) (*ExecuteQueryPacket, error)
func (*ExecuteQueryPacket) CommandType ¶
func (p *ExecuteQueryPacket) CommandType() CommandType
type FieldListPacket ¶
func NewFieldListPacket ¶
func NewFieldListPacket(b []byte) (*FieldListPacket, error)
func (*FieldListPacket) CommandType ¶
func (pkt *FieldListPacket) CommandType() CommandType
type OKPacket ¶
type OKPacket struct { AffectedRows *UintV InsertID *UintV Status uint16 WarningCount uint16 Message string }
func NewOKPacket ¶
type Parser ¶
type Parser struct { PktLens []int SeqNums []uint8 Body []byte Detail interface{} // contains filtered or unexported fields }
func NewFromClient ¶
NewFromServer creates a parser to parse packet from client.
func NewFromServer ¶
NewFromServer creates a parser to parse packet from server.
func (*Parser) ContextData ¶
func (pa *Parser) ContextData() interface{}
func (*Parser) PacketRawLen ¶
func (*Parser) SetContextData ¶
func (pa *Parser) SetContextData(d interface{})
func (*Parser) ShareContext ¶
type PrepareQueryPacket ¶
type PrepareQueryPacket struct {
Query string
}
func NewPrepareQueryPacket ¶
func NewPrepareQueryPacket(b []byte) (*PrepareQueryPacket, error)
func (*PrepareQueryPacket) CommandType ¶
func (p *PrepareQueryPacket) CommandType() CommandType
type PrepareResultPacket ¶
type PrepareResultPacket struct { StatementID uint32 FieldCount uint16 ParameterCount uint16 WarningCount uint16 }
func NewPrepareResultPacket ¶
func NewPrepareResultPacket(b []byte) (*PrepareResultPacket, error)
type QueryPacket ¶
type QueryPacket struct {
Query string
}
func NewQueryPacket ¶
func NewQueryPacket(b []byte) (*QueryPacket, error)
func (*QueryPacket) CommandType ¶
func (p *QueryPacket) CommandType() CommandType
type QuitPacket ¶
type QuitPacket struct{}
func (*QuitPacket) CommandType ¶
func (pkt *QuitPacket) CommandType() CommandType
type ResultFieldNumPacket ¶
type ResultFieldNumPacket struct {
Num uint64
}
type ResultFieldPacket ¶
type ResultFieldPacket struct { ResultPacket Database *StringV Table *StringV TableOrigin *StringV Column *StringV ColumnOrigin *StringV Charset uint16 Length uint32 Type uint8 Flag uint16 DotN uint8 Default *StringV }
func NewResultFieldPacket ¶
func NewResultFieldPacket(b []byte) (*ResultFieldPacket, error)
type ResultNonePacket ¶
type ResultNonePacket struct { ResultPacket AffectedRows *UintV InsertID *UintV ServerStatus uint16 WarningCount uint16 Message *StringV }
func NewResultNonePacket ¶
func NewResultNonePacket(b []byte) (*ResultNonePacket, error)
type ResultPacket ¶
type ResultPacket struct { }
type ResultRecordPacket ¶
type ResultRecordPacket struct { ResultPacket Columns []*StringV }
func NewResultRecordPacket ¶
func NewResultRecordPacket(b []byte, nfields int) (*ResultRecordPacket, error)
type ResultState ¶
type ResultState int
const ( Fields ResultState = iota + 1 Records PrepareParamsAndColumns PrepareParams PrepareColumns )
type ServerHandshakePacket ¶
type ServerHandshakePacket struct { ProtocolVersion uint8 ServerVersion string ThreadID uint32 ScrambleBuffer uint64 Filter uint8 ServerCapability uint16 Charset uint8 ServerStatus uint16 }
func NewServerHandshakePacket ¶
func NewServerHandshakePacket(b []byte) (*ServerHandshakePacket, error)
Click to show internal directories.
Click to hide internal directories.