Documentation ¶
Index ¶
- func BinaryVal2MySQL(v *proto.Value) ([]byte, error)
- func BinaryVal2MySQLLen(v *proto.Value) (int, error)
- func IsEOFPacket(data []byte) bool
- func IsErrorPacket(data []byte) bool
- func ParseComStmtExecute(stmts *sync.Map, data []byte) (uint32, byte, error)
- func ParseEOFPacket(data []byte) (warnings uint16, more bool, err error)
- func ParseErrorPacket(data []byte) error
- func ParseOKPacket(data []byte) (uint64, uint64, uint16, uint16, error)
- func ParseStmtArgs(data []byte, typ constant.FieldType, pos int) (interface{}, int, bool)
- func TextVal2MySQL(v *proto.Value) ([]byte, error)
- func TextVal2MySQLLen(v *proto.Value) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsEOFPacket ¶
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 ¶
IsErrorPacket determines whether or not the packet is an error packet. Mostly here for consistency with isEOFPacket
func ParseComStmtExecute ¶
func ParseEOFPacket ¶
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 ¶
ParseErrorPacket parses the error packet and returns a SQLError.
func ParseStmtArgs ¶
Types ¶
This section is empty.