Documentation ¶
Index ¶
- Variables
- func DecodeBit(data []byte, nbits int, length int) (v uint64, n int)
- func DecodeDate(v uint32) string
- func DecodeDatetime(v uint64) time.Time
- func DecodeDatetime2(data []byte, dec uint16) (time.Time, int)
- func DecodeFloat32(data []byte) float32
- func DecodeFloat64(data []byte) float64
- func DecodeJSON(data []byte) ([]byte, error)
- func DecodeStringEOF(data []byte) []byte
- func DecodeStringLenEnc(data []byte) (str []byte, size int)
- func DecodeStringNullTerm(data []byte) []byte
- func DecodeStringVarLen(data []byte, n int) []byte
- func DecodeTime(v uint32) string
- func DecodeTime2(data []byte, dec uint16) (string, int)
- func DecodeTimestamp(data []byte, dec uint16) (time.Time, int)
- func DecodeTimestamp2(data []byte, dec uint16) (time.Time, int)
- func DecodeUint16(data []byte) uint16
- func DecodeUint24(data []byte) uint32
- func DecodeUint32(data []byte) uint32
- func DecodeUint48(data []byte) uint64
- func DecodeUint64(data []byte) uint64
- func DecodeUint8(data []byte) uint8
- func DecodeUintLenEnc(data []byte) (v uint64, isNull bool, size int)
- func DecodeVarLen64(data []byte, s int) uint64
- func DecodeVarLen64BigEndian(data []byte) uint64
- func DecodeYear(v uint8) uint16
- func EncodeStringVarLen(data, str []byte)
- func EncodeUint16(data []byte, v uint16)
- func EncodeUint24(data []byte, v uint32)
- func EncodeUint32(data []byte, v uint32)
- func EncodeUint48(data []byte, v uint64)
- func EncodeUint64(data []byte, v uint64)
- func EncodeUint8(data []byte, v uint8)
- func EncodeUintLenEnc(data []byte, v uint64, isNull bool) (size int)
- func SignUint16(v uint16) int16
- func SignUint24(v uint32) int32
- func SignUint32(v uint32) int32
- func SignUint64(v uint64) int64
- func SignUint8(v uint8) int8
- type ColumnType
- type Decimal
Constants ¶
This section is empty.
Variables ¶
var Timezone = time.UTC
Timezone is set for decoded datetime values.
Functions ¶
func DecodeDate ¶
DecodeDate decodes DATE value. Spec: https://dev.mysql.com/doc/refman/8.0/en/datetime.html
func DecodeDatetime ¶
DecodeDatetime decodes DATETIME value. Spec: https://dev.mysql.com/doc/refman/8.0/en/datetime.html
func DecodeDatetime2 ¶
DecodeDatetime2 decodes DATETIME v2 value. Spec: https://dev.mysql.com/doc/refman/8.0/en/datetime.html Implementation borrowed from https://github.com/siddontang/go-mysql/
func DecodeFloat32 ¶
DecodeFloat32 decodes a float value into a float32.
func DecodeFloat64 ¶
DecodeFloat64 decodes a double value into a float64.
func DecodeJSON ¶
DecodeJSON decodes JSON into raw bytes. Implementation borrowed from https://github.com/siddontang/go-mysql/
func DecodeStringEOF ¶
DecodeStringEOF copies given slice of bytes as a new string.
func DecodeStringLenEnc ¶
DecodeStringLenEnc decodes a length-encoded string from a given slice of bytes.
func DecodeStringNullTerm ¶
DecodeStringNullTerm decodes a null terminated string from a given slice of bytes.
func DecodeStringVarLen ¶
DecodeStringVarLen decodes a varible-length string from a given slice of bytes.
func DecodeTime ¶
DecodeTime decodes TIME value. Spec: https://dev.mysql.com/doc/refman/8.0/en/time.html
func DecodeTime2 ¶
DecodeTime2 decodes TIME v2 value. Implementation borrowed from https://github.com/siddontang/go-mysql/
func DecodeTimestamp ¶
DecodeTimestamp decodes TIMESTAMP value. Spec: https://dev.mysql.com/doc/refman/8.0/en/datetime.html Implementation borrowed from https://github.com/siddontang/go-mysql/
func DecodeTimestamp2 ¶
DecodeTimestamp2 decodes TIMESTAMP v2 value. Spec: https://dev.mysql.com/doc/refman/8.0/en/datetime.html Implementation borrowed from https://github.com/siddontang/go-mysql/
func DecodeUint16 ¶
DecodeUint16 decodes a uint16 value from a given slice of bytes.
func DecodeUint24 ¶
DecodeUint24 decodes 3 bytes as uint32 value from a given slice of bytes.
func DecodeUint32 ¶
DecodeUint32 decodes a uint32 value from a given slice of bytes.
func DecodeUint48 ¶
DecodeUint48 decodes 6 bytes as uint64 value from a given slice of bytes.
func DecodeUint64 ¶
DecodeUint64 decodes a uint64 value from a given slice of bytes.
func DecodeUint8 ¶
DecodeUint8 decodes a uint8 value from a given slice of bytes.
func DecodeUintLenEnc ¶
DecodeUintLenEnc decodes a length-encoded integer from a given slice of bytes.
To convert a length-encoded integer into its numeric value, check the first byte: If it is < 0xFB, treat it as a 1-byte integer. If it is 0xFC, it is followed by a 2-byte integer. If it is 0xFD, it is followed by a 3-byte integer. If it is 0xFE, it is followed by a 8-byte integer. Depending on the context, the first byte may also have other meanings: If it is 0xFB, it is represents a NULL in a ProtocolText::ResultsetRow. If it is 0xFF and is the first byte of an ERR_Packet Caution: If the first byte of a packet is a length-encoded integer and its byte value is 0xFE, you must check the length of the packet to verify that it has enough space for a 8-byte integer. If not, it may be an EOF_Packet instead.
func DecodeVarLen64 ¶
DecodeVarLen64 decodes a number of given size in bytes using Little Endian.
func DecodeVarLen64BigEndian ¶
DecodeVarLen64BigEndian decodes a number of given size in bytes using Big Endian.
func DecodeYear ¶
DecodeYear decodes YEAR value. Spec: https://dev.mysql.com/doc/refman/8.0/en/year.html
func EncodeStringVarLen ¶
func EncodeStringVarLen(data, str []byte)
EncodeStringVarLen encodes a variable-length string into a given slice of bytes.
func EncodeUint16 ¶
EncodeUint16 encodes given uint16 value into a slice of bytes.
func EncodeUint24 ¶
EncodeUint24 encodes given uint32 value as a 3-byte integer into a slice of bytes.
func EncodeUint32 ¶
EncodeUint32 encodes given uint32 value into a slice of bytes.
func EncodeUint48 ¶
EncodeUint48 encodes given uint64 value as a 6-byte integer into a slice of bytes.
func EncodeUint64 ¶
EncodeUint64 encodes given uint64 value into a slice of bytes.
func EncodeUint8 ¶
EncodeUint8 encodes given uint8 value into a slice of bytes.
func EncodeUintLenEnc ¶
EncodeUintLenEnc writes a length-encoded integer into a given slice of bytes and returns the length of an encoded value.
To convert a number value into a length-encoded integer: If the value is < 251, it is stored as a 1-byte integer. If the value is ≥ 251 and < (2^16), it is stored as 0xFC + 2-byte integer. If the value is ≥ (2^16) and < (2^24), it is stored as 0xFD + 3-byte integer. If the value is ≥ (2^24) and < (2^64) it is stored as 0xFE + 8-byte integer. Note: up to MySQL 3.22, 0xFE was followed by a 4-byte integer.
Types ¶
type ColumnType ¶
type ColumnType byte
ColumnType represents MySQL column type.
const ( ColumnTypeDecimal ColumnType = 0x00 ColumnTypeTiny ColumnType = 0x01 ColumnTypeShort ColumnType = 0x02 ColumnTypeLong ColumnType = 0x03 ColumnTypeFloat ColumnType = 0x04 ColumnTypeDouble ColumnType = 0x05 ColumnTypeNull ColumnType = 0x06 ColumnTypeTimestamp ColumnType = 0x07 ColumnTypeLonglong ColumnType = 0x08 ColumnTypeInt24 ColumnType = 0x09 ColumnTypeDate ColumnType = 0x0a ColumnTypeTime ColumnType = 0x0b ColumnTypeDatetime ColumnType = 0x0c ColumnTypeYear ColumnType = 0x0d ColumnTypeNewDate ColumnType = 0x0e ColumnTypeVarchar ColumnType = 0x0f ColumnTypeBit ColumnType = 0x10 ColumnTypeTimestamp2 ColumnType = 0x11 ColumnTypeDatetime2 ColumnType = 0x12 ColumnTypeTime2 ColumnType = 0x13 ColumnTypeJSON ColumnType = 0xF5 ColumnTypeNewDecimal ColumnType = 0xF6 ColumnTypeEnum ColumnType = 0xF7 ColumnTypeSet ColumnType = 0xF8 ColumnTypeTinyblob ColumnType = 0xF9 ColumnTypeMediumblob ColumnType = 0xFA ColumnTypeLongblob ColumnType = 0xFB ColumnTypeBlob ColumnType = 0xFC ColumnTypeVarstring ColumnType = 0xFD ColumnTypeString ColumnType = 0xFE ColumnTypeGeometry ColumnType = 0xFF )
Spec: https://dev.mysql.com/doc/internals/en/com-query-response.html#column-type
func (ColumnType) String ¶
func (ct ColumnType) String() string
type Decimal ¶
type Decimal struct {
// contains filtered or unexported fields
}
Decimal represents a decimal type that retains precision until converted to a float. It is designed to be marshaled into JSON without losing precision.
func DecodeDecimal ¶
DecodeDecimal decodes a decimal value. Implementation borrowed from https://github.com/siddontang/go-mysql/
func NewDecimal ¶
NewDecimal creates a new decimal with given value.
func (Decimal) Float64 ¶
Float64 returns a float representation of the decimal. Precision could be lost.
func (Decimal) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the decimal.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal/mysql
Package mysql provides a MySQL driver for Go's database/sql package.
|
Package mysql provides a MySQL driver for Go's database/sql package. |