proto

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2021 License: BSD-3-Clause Imports: 8 Imported by: 10

Documentation

Index

Constants

View Source
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
)
View Source
const (
	// EOF_PACKET is the EOF packet.
	EOF_PACKET byte = 0xfe
)
View Source
const (
	// ERR_PACKET is the error packet byte.
	ERR_PACKET byte = 0xff
)
View Source
const (
	// OK_PACKET is the OK byte.
	OK_PACKET byte = 0x00
)

Variables

View Source
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

func ColumnCount(payload []byte) (count uint64, err error)

ColumnCount returns the column count.

func PackColumn

func PackColumn(field *querypb.Field) []byte

PackColumn used to pack the column packet.

func PackEOF

func PackEOF(e *EOF) []byte

PackEOF used to pack the EOF packet.

func PackERR

func PackERR(e *ERR) []byte

PackERR used to pack the error packet.

func PackOK

func PackOK(o *OK) []byte

PackOK used to pack the OK packet.

func PackStatementExecute

func PackStatementExecute(stmtID uint32, parameters []sqltypes.Value) ([]byte, error)

PackStatementExecute -- used to pack the stmt execute packet from the client. https://dev.mysql.com/doc/internals/en/com-stmt-execute.html

func PackStatementPrepare

func PackStatementPrepare(stmt *Statement) []byte

PackStatementPrepare -- used to pack the stmt prepare resp packet.

func UnPackERR

func UnPackERR(data []byte) error

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

func UnpackColumn(payload []byte) (*querypb.Field, error)

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 NewAuth

func NewAuth() *Auth

NewAuth creates new Auth.

func (*Auth) AuthResponse

func (a *Auth) AuthResponse() []byte

AuthResponse returns the auth response.

func (*Auth) Charset

func (a *Auth) Charset() uint8

Charset returns the charset.

func (*Auth) CleanAuthResponse

func (a *Auth) CleanAuthResponse()

CleanAuthResponse used to set the authResponse to nil. To improve the heap gc cost.

func (*Auth) ClientFlags

func (a *Auth) ClientFlags() uint32

ClientFlags returns the client flags.

func (*Auth) Database

func (a *Auth) Database() string

Database returns the database.

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

func (a *Auth) UnPack(payload []byte) error

UnPack parses the handshake sent by the client. https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::HandshakeResponse41

func (*Auth) User

func (a *Auth) User() string

User returns the user.

type EOF

type EOF struct {
	Header      byte // 0x00
	Warnings    uint16
	StatusFlags uint16
}

EOF used for EOF packet.

func UnPackEOF

func UnPackEOF(data []byte) (*EOF, error)

UnPackEOF used to unpack the EOF packet. https://dev.mysql.com/doc/internals/en/packet-EOF_Packet.html This method unsed.

type ERR

type ERR struct {
	Header       byte // always 0xff
	ErrorCode    uint16
	SQLState     string
	ErrorMessage string
}

ERR is the error packet.

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

func NewGreeting(connectionID uint32, serverVersion string) *Greeting

NewGreeting creates a new Greeting.

func (*Greeting) Pack

func (g *Greeting) Pack() []byte

Pack used to pack the greeting packet. https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::HandshakeV10

func (*Greeting) Status

func (g *Greeting) Status() uint16

Status returns status of greeting.

func (*Greeting) UnPack

func (g *Greeting) UnPack(payload []byte) error

UnPack used to unpack the greeting packet.

type OK

type OK struct {
	Header       byte // 0x00
	AffectedRows uint64
	LastInsertID uint64
	StatusFlags  uint16
	Warnings     uint16
}

OK used for OK packet.

func UnPackOK

func UnPackOK(data []byte) (*OK, error)

UnPackOK used to unpack the OK packet. https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html

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

func UnPackStatementPrepare(data []byte) (*Statement, error)

UnPackStatementPrepare -- used to unpack the stmt-prepare-response packet. https://dev.mysql.com/doc/internals/en/com-stmt-prepare-response.html

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL