Documentation ¶
Index ¶
- Constants
- Variables
- func ColumnCount(payload []byte) (count uint64, err error)
- func PackColumn(field *querypb.Field) []byte
- func PackEOF(e *EOF) []byte
- func PackERR(e *ERR) []byte
- func PackOK(o *OK) []byte
- func PackStatementExecute(stmtID uint32, parameters []sqltypes.Value) ([]byte, error)
- func PackStatementPrepare(stmt *Statement) []byte
- func UnPackERR(data []byte) error
- func UnPackStatementExecute(data []byte, prepare *Statement, ...) error
- func UnpackColumn(payload []byte) (*querypb.Field, error)
- type Auth
- func (a *Auth) AuthResponse() []byte
- func (a *Auth) Charset() uint8
- func (a *Auth) CleanAuthResponse()
- func (a *Auth) ClientFlags() uint32
- func (a *Auth) Database() string
- func (a *Auth) Pack(capabilityFlags uint32, charset uint8, username string, password string, ...) []byte
- func (a *Auth) UnPack(payload []byte) error
- func (a *Auth) User() string
- type EOF
- type ERR
- type Greeting
- type OK
- type Statement
Constants ¶
const ( // DefaultAuthPluginName is the default plugin name. DefaultAuthPluginName = "mysql_native_password" // DefaultServerCapability is the default server capability. DefaultServerCapability = sqldb.CLIENT_LONG_PASSWORD | sqldb.CLIENT_LONG_FLAG | sqldb.CLIENT_CONNECT_WITH_DB | sqldb.CLIENT_PROTOCOL_41 | sqldb.CLIENT_TRANSACTIONS | sqldb.CLIENT_MULTI_STATEMENTS | sqldb.CLIENT_PLUGIN_AUTH | sqldb.CLIENT_DEPRECATE_EOF | sqldb.CLIENT_SECURE_CONNECTION // DefaultClientCapability is the default client capability. DefaultClientCapability = sqldb.CLIENT_LONG_PASSWORD | sqldb.CLIENT_LONG_FLAG | sqldb.CLIENT_PROTOCOL_41 | sqldb.CLIENT_TRANSACTIONS | sqldb.CLIENT_MULTI_STATEMENTS | sqldb.CLIENT_PLUGIN_AUTH | sqldb.CLIENT_DEPRECATE_EOF | sqldb.CLIENT_SECURE_CONNECTION )
const ( // EOF_PACKET is the EOF packet. EOF_PACKET byte = 0xfe )
const ( // ERR_PACKET is the error packet byte. ERR_PACKET byte = 0xff )
const ( // OK_PACKET is the OK byte. OK_PACKET byte = 0x00 )
Variables ¶
var ( // DefaultSalt is the default salt bytes. DefaultSalt = []byte{ 0x77, 0x63, 0x6a, 0x6d, 0x61, 0x22, 0x23, 0x27, 0x38, 0x26, 0x55, 0x58, 0x3b, 0x5d, 0x44, 0x78, 0x53, 0x73, 0x6b, 0x41} )
Functions ¶
func ColumnCount ¶
ColumnCount returns the column count.
func PackColumn ¶
PackColumn used to pack the column packet.
func PackStatementExecute ¶
PackStatementExecute -- used to pack the stmt execute packet from the client. https://dev.mysql.com/doc/internals/en/com-stmt-execute.html
func PackStatementPrepare ¶
PackStatementPrepare -- used to pack the stmt prepare resp packet.
func UnPackERR ¶
UnPackERR parses the error packet and returns a sqldb.SQLError. https://dev.mysql.com/doc/internals/en/packet-ERR_Packet.html
func UnPackStatementExecute ¶
func UnPackStatementExecute(data []byte, prepare *Statement, parseValueFn func(*common.Buffer, querypb.Type) (interface{}, error)) error
UnPackStatementExecute -- unpack the stmt-execute packet from client.
func UnpackColumn ¶
UnpackColumn used to unpack the column packet. http://dev.mysql.com/doc/internals/en/com-query-response.html#packet-Protocol::ColumnDefinition41
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth packet.
func (*Auth) AuthResponse ¶
AuthResponse returns the auth response.
func (*Auth) CleanAuthResponse ¶
func (a *Auth) CleanAuthResponse()
CleanAuthResponse used to set the authResponse to nil. To improve the heap gc cost.
func (*Auth) ClientFlags ¶
ClientFlags returns the client flags.
func (*Auth) Pack ¶
func (a *Auth) Pack(capabilityFlags uint32, charset uint8, username string, password string, salt []byte, database string) []byte
Pack used to pack a HandshakeResponse41 packet.
func (*Auth) UnPack ¶
UnPack parses the handshake sent by the client. https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::HandshakeResponse41
type Greeting ¶
type Greeting struct { Charset uint8 // Capabilities is the current set of features this connection // is using. It is the features that are both supported by // the client and the server, and currently in use. // It is set after the initial handshake. Capability uint32 ConnectionID uint32 Salt []byte // contains filtered or unexported fields }
Greeting used for greeting packet.
func NewGreeting ¶
NewGreeting creates a new Greeting.
func (*Greeting) Pack ¶
Pack used to pack the greeting packet. https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::HandshakeV10
type OK ¶
type OK struct { Header byte // 0x00 AffectedRows uint64 LastInsertID uint64 StatusFlags uint16 Warnings uint16 }
OK used for OK packet.
type Statement ¶
type Statement struct { Header byte // 0x00 ID uint32 ColumnCount uint16 ParamCount uint16 Warnings uint16 ParamsType []int32 ColumnNames []string BindVars map[string]*querypb.BindVariable }
Statement -- stmt struct.
func UnPackStatementPrepare ¶
UnPackStatementPrepare -- used to unpack the stmt-prepare-response packet. https://dev.mysql.com/doc/internals/en/com-stmt-prepare-response.html