Documentation
¶
Index ¶
- Constants
- func BitCount(bitmap []byte) int
- func ByteCountFromBitCount(n int) int
- func DecodeJsonBinary(data []byte, useDecimal bool) ([]byte, error)
- func FormatBinaryDate(n int, data []byte) ([]byte, error)
- func FormatBinaryDateTime(n int, data []byte) ([]byte, error)
- func FormatBinaryTime(n int, data []byte) ([]byte, error)
- func GetBit(bitmap []byte, off int) byte
- func LocalIPv4s() ([]string, error)
- func PStack() string
- func ParseDecimalType(data []byte, precision, decimals int, useDecimal bool) (interface{}, int, error)
- func ReadBigEndianFixedLengthInteger(buf []byte) uint64
- func ReadBinaryFloat32(data []byte) float32
- func ReadBinaryFloat64(data []byte) float64
- func ReadBinaryInt8(b []byte) int8
- func ReadBinaryInt16(data []byte) int16
- func ReadBinaryInt24(data []byte) int32
- func ReadBinaryInt32(data []byte) int32
- func ReadBinaryInt64(data []byte) int64
- func ReadBinaryUint8(b []byte) uint8
- func ReadBinaryUint16(data []byte) uint16
- func ReadBinaryUint24(data []byte) uint32
- func ReadBinaryUint32(data []byte) uint32
- func ReadBinaryUint64(data []byte) uint64
- func ReadLengthEncodedInteger(b []byte) (num uint64, isNull bool, n int)
- func ReadLengthEncodedString(b []byte) ([]byte, bool, int, error)
- func ReadLittleEndianFixedLengthInteger(buf []byte) uint64
- func Scramble41(scramble, password []byte) []byte
- func SkipLengthEncodedString(b []byte) (int, error)
- func UnsafeGetString(b []byte) (s string)
- type AtomicBool
- type AtomicString
- type Logger
Constants ¶
const ( OK_HEADER byte = 0x00 LOCAL_IN_FILE_HEADER byte = 0xfb EOF_HEADER byte = 0xfe ERR_HEADER byte = 0xff )
Status codes
const ( MYSQL_TYPE_DECIMAL byte = iota MYSQL_TYPE_TINY MYSQL_TYPE_SHORT MYSQL_TYPE_LONG MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24 MYSQL_TYPE_DATE MYSQL_TYPE_TIME MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR MYSQL_TYPE_BIT MYSQL_TYPE_TIMESTAMP2 // 5.6+ MYSQL_TYPE_DATETIME2 MYSQL_TYPE_TIME2 )
Types
const ( MYSQL_TYPE_JSON byte = iota + 0xf5 MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY )
const ( JSONB_SMALL_OBJECT byte = iota // small JSON object JSONB_LARGE_OBJECT // large JSON object JSONB_SMALL_ARRAY // small JSON array JSONB_LARGE_ARRAY // large JSON array JSONB_LITERAL // literal (true/false/null) JSONB_INT16 // int16 JSONB_UINT16 // uint16 JSONB_INT32 // int32 JSONB_UINT32 // uint32 JSONB_INT64 // int64 JSONB_UINT64 // uint64 JSONB_DOUBLE // double JSONB_STRING // string JSONB_OPAQUE byte = 0x0f // custom data (any MySQL data type) )
const ( JSONB_NULL_LITERAL byte = 0x00 JSONB_TRUE_LITERAL byte = 0x01 JSONB_FALSE_LITERAL byte = 0x02 )
const (
TimeFormat = "2006-01-02 15:04:05"
)
Variables ¶
This section is empty.
Functions ¶
func ByteCountFromBitCount ¶
func LocalIPv4s ¶
func ParseDecimalType ¶
func ReadBigEndianFixedLengthInteger ¶
big-endian
func ReadBinaryFloat32 ¶
func ReadBinaryFloat64 ¶
func ReadBinaryInt8 ¶
func ReadBinaryInt16 ¶
func ReadBinaryInt24 ¶
func ReadBinaryInt32 ¶
func ReadBinaryInt64 ¶
func ReadBinaryUint8 ¶
func ReadBinaryUint16 ¶
func ReadBinaryUint24 ¶
func ReadBinaryUint32 ¶
func ReadBinaryUint64 ¶
func ReadLengthEncodedInteger ¶
https://dev.mysql.com/doc/internals/en/integer.html#packet-Protocol::LengthEncodedInteger returns the number read, whether the value is NULL and the number of bytes read
func ReadLengthEncodedString ¶
https://dev.mysql.com/doc/internals/en/string.html#packet-Protocol::LengthEncodedString returns the string read as a bytes slice, wheter the value is NULL, the number of bytes read and an error, in case the string is longer than the input slice
func ReadLittleEndianFixedLengthInteger ¶
little-endian
func Scramble41 ¶
scramble41() returns a scramble buffer based on the following formula: SHA1(password) XOR SHA1(20-byte public seed from server CONCAT SHA1(SHA1(password)))
func SkipLengthEncodedString ¶
func UnsafeGetString ¶
vitess:hack string 和 slice no-copy转换,string和slice的转换只需要拷贝底层的指针,而不是内存拷贝
Types ¶
type AtomicBool ¶
type AtomicBool struct {
// contains filtered or unexported fields
}
AtomicBool gives an atomic boolean variable.
func NewAtomicBool ¶
func NewAtomicBool(n bool) AtomicBool
NewAtomicBool initializes a new AtomicBool with a given value.
type AtomicString ¶
type AtomicString struct {
// contains filtered or unexported fields
}
AtomicString gives you atomic-style APIs for string, but it's only a convenience wrapper that uses a mutex. So, it's not as efficient as the rest of the atomic types.
func (*AtomicString) CompareAndSwap ¶
func (s *AtomicString) CompareAndSwap(oldval, newval string) (swqpped bool)
CompareAndSwap atomatically swaps the old with the new value.
func (*AtomicString) Get ¶
func (s *AtomicString) Get() string
Get atomically returns the current value.
func (*AtomicString) Set ¶
func (s *AtomicString) Set(str string)
Set atomically sets str as new value.