tools

package
v0.0.0-...-584552c Latest Latest
Warning

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

Go to latest
Published: May 21, 2018 License: Apache-2.0 Imports: 16 Imported by: 4

Documentation

Index

Constants

View Source
const (
	OK_HEADER            byte = 0x00
	LOCAL_IN_FILE_HEADER byte = 0xfb
	EOF_HEADER           byte = 0xfe
	ERR_HEADER           byte = 0xff
)

Status codes

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

View Source
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
)
View Source
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)
)
View Source
const (
	JSONB_NULL_LITERAL  byte = 0x00
	JSONB_TRUE_LITERAL  byte = 0x01
	JSONB_FALSE_LITERAL byte = 0x02
)
View Source
const (
	TimeFormat = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

func BitCount

func BitCount(bitmap []byte) int

Calculate total bit counts in a bitmap

func ByteCountFromBitCount

func ByteCountFromBitCount(n int) int

func DecodeJsonBinary

func DecodeJsonBinary(data []byte, useDecimal bool) ([]byte, error)

func FormatBinaryDate

func FormatBinaryDate(n int, data []byte) ([]byte, error)

func FormatBinaryDateTime

func FormatBinaryDateTime(n int, data []byte) ([]byte, error)

func FormatBinaryTime

func FormatBinaryTime(n int, data []byte) ([]byte, error)

func GetBit

func GetBit(bitmap []byte, off int) byte

Get the bit set at offset position in bitmap

func LocalIPv4s

func LocalIPv4s() ([]string, error)

func PStack

func PStack() string

func ParseDecimalType

func ParseDecimalType(data []byte, precision, decimals int, useDecimal bool) (interface{}, int, error)

func ReadBigEndianFixedLengthInteger

func ReadBigEndianFixedLengthInteger(buf []byte) uint64

big-endian

func ReadBinaryFloat32

func ReadBinaryFloat32(data []byte) float32

func ReadBinaryFloat64

func ReadBinaryFloat64(data []byte) float64

func ReadBinaryInt8

func ReadBinaryInt8(b []byte) int8

func ReadBinaryInt16

func ReadBinaryInt16(data []byte) int16

func ReadBinaryInt24

func ReadBinaryInt24(data []byte) int32

func ReadBinaryInt32

func ReadBinaryInt32(data []byte) int32

func ReadBinaryInt64

func ReadBinaryInt64(data []byte) int64

func ReadBinaryUint8

func ReadBinaryUint8(b []byte) uint8

func ReadBinaryUint16

func ReadBinaryUint16(data []byte) uint16

func ReadBinaryUint24

func ReadBinaryUint24(data []byte) uint32

func ReadBinaryUint32

func ReadBinaryUint32(data []byte) uint32

func ReadBinaryUint64

func ReadBinaryUint64(data []byte) uint64

func ReadLengthEncodedInteger

func ReadLengthEncodedInteger(b []byte) (num uint64, isNull bool, n int)

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

func ReadLengthEncodedString(b []byte) ([]byte, bool, int, error)

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

func ReadLittleEndianFixedLengthInteger(buf []byte) uint64

little-endian

func Scramble41

func Scramble41(scramble, password []byte) []byte

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 SkipLengthEncodedString(b []byte) (int, error)

func UnsafeGetString

func UnsafeGetString(b []byte) (s string)

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.

func (*AtomicBool) Get

func (i *AtomicBool) Get() bool

Get atomically returns the current value.

func (*AtomicBool) Set

func (i *AtomicBool) Set(n bool)

Set atomically sets n as new 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.

type Logger

type Logger interface {
	Print(v ...interface{})
}

Logger is used to log critical error messages.

Jump to

Keyboard shortcuts

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