packet

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinaryVal2MySQL added in v0.3.0

func BinaryVal2MySQL(v *proto.Value) ([]byte, error)

func BinaryVal2MySQLLen added in v0.3.0

func BinaryVal2MySQLLen(v *proto.Value) (int, error)

func IsEOFPacket

func IsEOFPacket(data []byte) bool

Packet parsing methods, for generic packets.

IsEOFPacket determines whether or not a Content packet is a "true" EOF. DO NOT blindly compare the first byte of a packet to EOFPacket as you might do for other packet types, as 0xfe is overloaded as a first byte.

Per https://dev.mysql.com/doc/internals/en/packet-EOF_Packet.html, a packet starting with 0xfe but having length >= 9 (on top of 4 byte header) is not a true EOF but a LengthEncodedInteger (typically preceding a LengthEncodedString). Thus, all EOF checks must validate the payload size before exiting.

More specifically, an EOF packet can have 3 different lengths (1, 5, 7) depending on the client flags that are set. 7 comes from server versions of 5.7.5 or greater where ClientDeprecateEOF is set (i.e. uses an OK packet starting with 0xfe instead of 0x00 to signal EOF). Regardless, 8 is an upper bound otherwise it would be ambiguous w.r.t. LengthEncodedIntegers.

More docs here: https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_response_packets.html

func IsErrorPacket

func IsErrorPacket(data []byte) bool

IsErrorPacket determines whether or not the packet is an error packet. Mostly here for consistency with isEOFPacket

func ParseComStmtExecute

func ParseComStmtExecute(stmts *sync.Map, data []byte) (uint32, byte, error)

func ParseEOFPacket

func ParseEOFPacket(data []byte) (warnings uint16, more bool, err error)

ParseEOFPacket returns the warning count and a boolean to indicate if there are more results to receive.

Note: This is only valid on actual EOF packets and not on OK packets with the EOF type code set, i.e. should not be used if ClientDeprecateEOF is set.

func ParseErrorPacket

func ParseErrorPacket(data []byte) error

ParseErrorPacket parses the error packet and returns a SQLError.

func ParseOKPacket

func ParseOKPacket(data []byte) (uint64, uint64, uint16, uint16, error)

func ParseStmtArgs

func ParseStmtArgs(data []byte, typ constant.FieldType, pos int) (interface{}, int, bool)

func TextVal2MySQL added in v0.3.0

func TextVal2MySQL(v *proto.Value) ([]byte, error)

func TextVal2MySQLLen added in v0.3.0

func TextVal2MySQLLen(v *proto.Value) (int, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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