Documentation
¶
Index ¶
- Constants
- Variables
- func IsAuthMoreData(data []byte) bool
- func IsAuthSwitchRequest(data []byte) bool
- func IsEOF(data []byte) bool
- func IsErr(data []byte) bool
- func IsLocalInfileRequest(data []byte) bool
- func IsOK(data []byte) bool
- func IsPing(data []byte) bool
- func IsQuery(data []byte) bool
- func IsQuit(data []byte) bool
- func ParseAuthMoreData(data []byte) ([]byte, error)
- func ParseColumnCount(data []byte) (uint64, error)
- type Attribute
- type AuthSwitchRequest
- type BinaryResultSetRow
- type Column
- type ColumnDefinition
- func (p *ColumnDefinition) Dump(capabilities core.CapabilityFlag) ([]byte, error)
- func (p *ColumnDefinition) GetCharSet() *core.Collation
- func (p *ColumnDefinition) GetDatabase() string
- func (p *ColumnDefinition) GetDecimals() byte
- func (p *ColumnDefinition) GetFlags() core.ColumnDefinitionFlag
- func (p *ColumnDefinition) GetLength() uint32
- func (p *ColumnDefinition) GetName() string
- func (p *ColumnDefinition) GetTable() string
- func (p *ColumnDefinition) GetType() core.TableColumnType
- func (p *ColumnDefinition) String() string
- type ColumnValue
- type EOF
- type ERR
- type Handshake
- type HandshakeResponse
- type Header
- type OK
- type Packet
- type Row
- type SSLRequest
- type Simple
- type StmtExecute
- type StmtPrepareOKFirst
- type TextResultSetRow
- type Value
Constants ¶
const ( OKPacketHeader = 0x00 EOFPacketHeader = 0xfe ErrPacketHeader = 0xff AuthSwitchRequestPacketHeader = 0xfe AuthMoreDataPacketHeader = 0x01 LocalInfileRequest = 0xfb )
const ( SESSION_TRACK_SYSTEM_VARIABLES = 0x00 SESSION_TRACK_SCHEMA = 0x01 SESSION_TRACK_STATE_CHANGE = 0x02 SESSION_TRACK_GTIDS = 0x03 )
Variables ¶
var (
ErrPacketData = errors.New("packet: data error")
)
var FixedLengthInteger fixedLengthInteger
var LengthEncodedInteger lengthEncodedInteger
var LengthEncodedString lengthEncodedString
var NulTerminatedString nulTerminatedString
Functions ¶
func IsAuthMoreData ¶
func IsAuthSwitchRequest ¶
func IsLocalInfileRequest ¶
func ParseAuthMoreData ¶
func ParseColumnCount ¶
Types ¶
type AuthSwitchRequest ¶
type AuthSwitchRequest struct { Header PayloadHeader uint8 AuthPlugin core.AuthenticationPlugin AuthData []byte }
func ParseAuthSwitchRequest ¶
func ParseAuthSwitchRequest(data []byte) (*AuthSwitchRequest, error)
type BinaryResultSetRow ¶
func (*BinaryResultSetRow) NullBitMapGet ¶
func (p *BinaryResultSetRow) NullBitMapGet(index int) bool
type Column ¶
type Column interface { Packet GetDatabase() string GetTable() string GetName() string GetCharSet() *core.Collation GetLength() uint32 GetType() core.TableColumnType GetFlags() core.ColumnDefinitionFlag GetDecimals() byte String() string }
func ParseColumnDefinition ¶
type ColumnDefinition ¶
type ColumnDefinition struct { Header Catalog string // def Schema string Table string OrgTable string Name string OrgName string NextLength uint64 // 0x0c CharacterSet *core.Collation ColumnLength uint32 ColumnType core.TableColumnType Flags core.ColumnDefinitionFlag Decimals uint8 }
ColumnDefinition https://dev.mysql.com/doc/internals/en/com-query-response.html#column-definition
func (*ColumnDefinition) Dump ¶
func (p *ColumnDefinition) Dump(capabilities core.CapabilityFlag) ([]byte, error)
func (*ColumnDefinition) GetCharSet ¶
func (p *ColumnDefinition) GetCharSet() *core.Collation
func (*ColumnDefinition) GetDatabase ¶
func (p *ColumnDefinition) GetDatabase() string
func (*ColumnDefinition) GetDecimals ¶
func (p *ColumnDefinition) GetDecimals() byte
func (*ColumnDefinition) GetFlags ¶
func (p *ColumnDefinition) GetFlags() core.ColumnDefinitionFlag
func (*ColumnDefinition) GetLength ¶
func (p *ColumnDefinition) GetLength() uint32
func (*ColumnDefinition) GetName ¶
func (p *ColumnDefinition) GetName() string
func (*ColumnDefinition) GetTable ¶
func (p *ColumnDefinition) GetTable() string
func (*ColumnDefinition) GetType ¶
func (p *ColumnDefinition) GetType() core.TableColumnType
func (*ColumnDefinition) String ¶
func (p *ColumnDefinition) String() string
type ColumnValue ¶
type ColumnValue interface { IsNull() bool Value() Value DumpText() ([]byte, error) DumpBinary() ([]byte, error) String() string }
func NewColumnValue ¶
func NewColumnValue(isNull bool, val interface{}, mysqlType core.TableColumnType) ColumnValue
type EOF ¶
type EOF struct { Header EOFHeader uint8 WarningCount uint16 StatusFlags core.StatusFlag }
EOF https://dev.mysql.com/doc/internals/en/packet-EOF_Packet.html
type ERR ¶
type ERR struct { Header ERRHeader uint8 ErrorCode core.Code SqlStateMarker byte SqlState string ErrorMessage string }
ERR https://dev.mysql.com/doc/internals/en/packet-ERR_Packet.html
type Handshake ¶
type Handshake struct { Header ProtocolVersion uint8 ServerVersion string ConnectionId uint32 Salt1 []byte CapabilityFlags core.CapabilityFlag CharacterSet *core.Collation StatusFlags core.StatusFlag ExtendedCapabilityFlags core.CapabilityFlag AuthPluginDataLen uint8 Salt2 []byte AuthPlugin core.AuthenticationPlugin }
Handshake https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::Handshake
func ParseHandshake ¶
func (*Handshake) GetAuthData ¶
func (*Handshake) GetCapabilities ¶
func (p *Handshake) GetCapabilities() core.CapabilityFlag
func (*Handshake) SetCapabilities ¶
func (p *Handshake) SetCapabilities(capabilities core.CapabilityFlag)
type HandshakeResponse ¶
type HandshakeResponse struct { Header ClientCapabilityFlags core.CapabilityFlag MaxPacketSize uint32 CharacterSet *core.Collation Username []byte // interpreted by CharacterSet AuthRes []byte Database []byte // interpreted by CharacterSet AuthPlugin core.AuthenticationPlugin AttributeLen uint64 Attributes []Attribute }
HandshakeResponse https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::HandshakeResponse
func ParseHandshakeResponse ¶
func ParseHandshakeResponse(bs []byte) (*HandshakeResponse, error)
func (*HandshakeResponse) AddAttribute ¶
func (p *HandshakeResponse) AddAttribute(key string, val string)
func (*HandshakeResponse) Dump ¶
func (p *HandshakeResponse) Dump(capabilities core.CapabilityFlag) ([]byte, error)
func (*HandshakeResponse) GetUsername ¶
func (p *HandshakeResponse) GetUsername() string
type Header ¶
func (*Header) SetSequence ¶
type OK ¶
type OK struct { Header OKHeader uint8 AffectedRows uint64 LastInsertId uint64 StatusFlags core.StatusFlag WarningCount uint16 Info []byte SessionStateChanges []byte // todo }
OK https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html
type Packet ¶
type Packet interface { SetSequence(int) Dump(core.CapabilityFlag) ([]byte, error) }
func NewColumnCount ¶
type SSLRequest ¶
type SSLRequest struct { Header ClientCapabilityFlags core.CapabilityFlag MaxPacketSize uint32 CharacterSet *core.Collation }
func ParseSSLRequest ¶
func ParseSSLRequest(data []byte) (*SSLRequest, error)
func (*SSLRequest) Dump ¶
func (p *SSLRequest) Dump(capabilities core.CapabilityFlag) ([]byte, error)
type Simple ¶
func NewAuthSwitchResponse ¶
type StmtExecute ¶
type StmtExecute struct { Header ComStmtExecute uint8 StmtId uint32 Flags uint8 IterationCount uint32 NullBitMap []byte NewParamsBoundFlag uint8 ParamType []byte ParamValue []byte }
StmtExecute https://dev.mysql.com/doc/internals/en/com-stmt-execute.html
func NewStmtExecute ¶
func NewStmtExecute() *StmtExecute
func (*StmtExecute) CreateNullBitMap ¶
func (p *StmtExecute) CreateNullBitMap(paramCount int)
func (*StmtExecute) Dump ¶
func (p *StmtExecute) Dump(capabilities core.CapabilityFlag) ([]byte, error)
func (*StmtExecute) NullBitMapSet ¶
func (p *StmtExecute) NullBitMapSet(paramCount, index int)
type StmtPrepareOKFirst ¶
type StmtPrepareOKFirst struct { Header Status uint8 StmtId uint32 ColumnCount uint16 ParamCount uint16 WarningCount uint16 }
StmtPrepareOKFirst https://dev.mysql.com/doc/internals/en/com-stmt-prepare-response.html#packet-COM_STMT_PREPARE_OK
func ParseStmtPrepareOKFirst ¶
func ParseStmtPrepareOKFirst(data []byte) (*StmtPrepareOKFirst, error)
type TextResultSetRow ¶
TextResultSetRow https://dev.mysql.com/doc/internals/en/com-query-response.html#packet-ProtocolText::ResultsetRow
func NewTextResultSetRow ¶
func NewTextResultSetRow(row Row) *TextResultSetRow
func (*TextResultSetRow) Dump ¶
func (p *TextResultSetRow) Dump(capabilities core.CapabilityFlag) ([]byte, error)