proto

package
v2.0.0-alpha3+incompat... Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2015 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VT_DECIMAL     = 0
	VT_TINY        = 1
	VT_SHORT       = 2
	VT_LONG        = 3
	VT_FLOAT       = 4
	VT_DOUBLE      = 5
	VT_NULL        = 6
	VT_TIMESTAMP   = 7
	VT_LONGLONG    = 8
	VT_INT24       = 9
	VT_DATE        = 10
	VT_TIME        = 11
	VT_DATETIME    = 12
	VT_YEAR        = 13
	VT_NEWDATE     = 14
	VT_VARCHAR     = 15
	VT_BIT         = 16
	VT_NEWDECIMAL  = 246
	VT_ENUM        = 247
	VT_SET         = 248
	VT_TINY_BLOB   = 249
	VT_MEDIUM_BLOB = 250
	VT_LONG_BLOB   = 251
	VT_BLOB        = 252
	VT_VAR_STRING  = 253
	VT_STRING      = 254
	VT_GEOMETRY    = 255
)

These numbers should exactly match values defined in dist/mysql-5.1.52/include/mysql/mysql_com.h

View Source
const (
	// VT_ZEROVALUE_FLAG is not part of the MySQL specification and only used in unit tests.
	VT_ZEROVALUE_FLAG    = 0
	VT_NOT_NULL_FLAG     = 1   /* Field can't be NULL */
	VT_PRI_KEY_FLAG      = 2   /* Field is part of a primary key */
	VT_UNIQUE_KEY_FLAG   = 4   /* Field is part of a unique key */
	VT_MULTIPLE_KEY_FLAG = 8   /* Field is part of a key */
	VT_BLOB_FLAG         = 16  /* Field is a blob */
	VT_UNSIGNED_FLAG     = 32  /* Field is unsigned */
	VT_ZEROFILL_FLAG     = 64  /* Field is zerofill */
	VT_BINARY_FLAG       = 128 /* Field is binary   */
	/* The following are only sent to new clients */
	VT_ENUM_FLAG             = 256   /* field is an enum */
	VT_AUTO_INCREMENT_FLAG   = 512   /* field is a autoincrement field */
	VT_TIMESTAMP_FLAG        = 1024  /* Field is a timestamp */
	VT_SET_FLAG              = 2048  /* field is a set */
	VT_NO_DEFAULT_VALUE_FLAG = 4096  /* Field doesn't have default value */
	VT_ON_UPDATE_NOW_FLAG    = 8192  /* Field is set to NOW on UPDATE */
	VT_NUM_FLAG              = 32768 /* Field is num (for clients) */
)

MySQL field flags bitset values e.g. to distinguish between signed and unsigned integer. Comments are taken from the original source code. These numbers should exactly match values defined in dist/mysql-5.1.52/include/mysql_com.h

Variables

This section is empty.

Functions

func CharsetToProto

func CharsetToProto(c *Charset) *pbb.Charset

CharsetToProto converts a Charset to a proto3

func Convert

func Convert(field Field, val sqltypes.Value) (interface{}, error)

Convert takes a type and a value, and returns the type: - nil for NULL value - uint64 for unsigned BIGINT values - int64 for all other integer values (signed and unsigned) - float64 for floating point values that fit in a float - []byte for everything else

func FieldsToProto3

func FieldsToProto3(f []Field) []*pbq.Field

FieldsToProto3 converts an internal []Field to the proto3 version

func Proto3ToRows

func Proto3ToRows(rows []*pbq.Row) [][]sqltypes.Value

Proto3ToRows converts a proto3 []Row to an internal data structure.

func QueryResultToProto3

func QueryResultToProto3(qr *QueryResult) *pbq.QueryResult

QueryResultToProto3 converts an internal QueryResult to the proto3 version

func RowsToProto3

func RowsToProto3(rows [][]sqltypes.Value) []*pbq.Row

RowsToProto3 converts an internal [][]sqltypes.Value to the proto3 version

Types

type Charset

type Charset struct {
	Client int // @@session.character_set_client
	Conn   int // @@session.collation_connection
	Server int // @@session.collation_server
}

Charset contains the per-statement character set settings that accompany binlog QUERY_EVENT entries.

func ProtoToCharset

func ProtoToCharset(c *pbb.Charset) *Charset

ProtoToCharset converts a proto to a Charset

func (*Charset) MarshalBson

func (charset *Charset) MarshalBson(buf *bytes2.ChunkedWriter, key string)

MarshalBson bson-encodes Charset.

func (*Charset) UnmarshalBson

func (charset *Charset) UnmarshalBson(buf *bytes.Buffer, kind byte)

UnmarshalBson bson-decodes into Charset.

type Field

type Field struct {
	Name  string
	Type  int64
	Flags int64
}

Field describes a column returned by MySQL.

func Proto3ToFields

func Proto3ToFields(f []*pbq.Field) []Field

Proto3ToFields converts a proto3 []Fields to an internal data structure.

func (*Field) MarshalBson

func (field *Field) MarshalBson(buf *bytes2.ChunkedWriter, key string)

MarshalBson bson-encodes Field.

func (*Field) UnmarshalBson

func (field *Field) UnmarshalBson(buf *bytes.Buffer, kind byte)

UnmarshalBson bson-decodes into Field.

type QueryResult

type QueryResult struct {
	Fields       []Field
	RowsAffected uint64
	InsertId     uint64
	Rows         [][]sqltypes.Value
	Err          *RPCError
}

QueryResult is the structure returned by the mysql library. When transmitted over the wire, the Rows all come back as strings and lose their original sqltypes. use Fields.Type to convert them back if needed, using the following functions.

func Proto3ToQueryResult

func Proto3ToQueryResult(qr *pbq.QueryResult) *QueryResult

Proto3ToQueryResult converts a proto3 QueryResult to an internal data structure.

func Proto3ToQueryResults

func Proto3ToQueryResults(qr []*pbq.QueryResult) []QueryResult

Proto3ToQueryResults converts an array os proto3 QueryResult to an internal data structure.

func (*QueryResult) MarshalBson

func (queryResult *QueryResult) MarshalBson(buf *bytes2.ChunkedWriter, key string)

MarshalBson bson-encodes QueryResult.

func (*QueryResult) UnmarshalBson

func (queryResult *QueryResult) UnmarshalBson(buf *bytes.Buffer, kind byte)

UnmarshalBson bson-decodes into QueryResult.

type RPCError

type RPCError struct {
	Code    int64
	Message string
}

RPCError is the structure that is returned by each RPC call, which contains the error information for that call.

func (*RPCError) MarshalBson

func (rPCError *RPCError) MarshalBson(buf *bytes2.ChunkedWriter, key string)

MarshalBson bson-encodes RPCError.

func (*RPCError) UnmarshalBson

func (rPCError *RPCError) UnmarshalBson(buf *bytes.Buffer, kind byte)

UnmarshalBson bson-decodes into RPCError.

Jump to

Keyboard shortcuts

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