mysqlx

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2018 License: MPL-2.0 Imports: 29 Imported by: 0

README

mysqlx

MySQL driver for Go's (golang) database/sql package and MySQL X Protocol.

GoDoc Build Status Codecov Go Report Card

It requires Go 1.10+.

Status

Alpha quality. Do not use in production!

You are, however, is encouraged to try it in development and report bugs.

Data source format

mysqlx://username:password@host:port/database?_param=value&session_variable=value&…

All query parameters that are not starting with _ are used as session variables and are set whenever a connection is opened. Parameters starting with _ are listed below:

TODO

  • Real TLS support.
  • Binary strings.
  • Large uint64.
  • More tests for correct connection closing.
  • More concurrent tests.
  • Benchmarks.
  • Support for https://github.com/gogo/protobuf (?)
  • Charsets.
  • Time zones.
  • Real prepared statements.
  • Named values.
  • Expose notices and warnings (?).

Documentation

Overview

Package mysqlx provides a MySQL driver for Go's database/​sql package and MySQL X Protocol.

Index

Constants

This section is empty.

Variables

View Source
var Driver driverType

Driver implements database/sql/driver.Driver and database/sql/driver.DriverContext interfaces. It has no internal state.

Functions

func ReadMessage

func ReadMessage(r io.Reader) (proto.Message, []byte, error)

ReadMessage reads and returns one next protocol message, or low-level error. Notices are unwrapped: SessionVariableChanged, SessionStateChanged, and Warning are returned, and raw Frame is never returned. TODO un-export (currently required for mitm-proxy)

Types

type AuthMethod

type AuthMethod string
const (
	AuthPlain   AuthMethod = "PLAIN"
	AuthMySQL41 AuthMethod = "MYSQL41"
)

type Connector

type Connector struct {
	Host     string
	Port     uint16
	Database string
	Username string
	Password string

	AuthMethod AuthMethod

	SessionVariables map[string]string

	Trace func(format string, v ...interface{})
}

Connector implements database/sql/driver.Connector interface.

func ParseDataSource

func ParseDataSource(dataSource string) (*Connector, error)

ParseDataSource returns Connector for given data source.

func (*Connector) Connect

func (connector *Connector) Connect(ctx context.Context) (driver.Conn, error)

Connect returns a new connection to the database.

The provided context.Context is for dialing purposes only (see net.DialContext) and is not used for other purposes.

The returned connection must be used only by one goroutine at a time.

func (*Connector) Driver

func (connector *Connector) Driver() driver.Driver

Driver returns the underlying Driver of the Connector, mainly to maintain compatibility with the Driver method on sql.DB.

func (*Connector) URL

func (connector *Connector) URL() *url.URL

URL returns data source as an URL.

type Error

type Error struct {
	Severity Severity
	Code     uint32
	SQLState string
	Msg      string
}

Error represents MySQL X Protocol error message. It's not used for transport-level errors.

func (*Error) Error

func (e *Error) Error() string

Error returns error string in a formal similar to mysql and mysqlsh client programs.

type Severity

type Severity byte

Severity represents Error severity level.

const (
	// SeverityError indicates the current message sequence is aborted for the given error
	// and the session is ready for more.
	SeverityError Severity = 0

	// SeverityFatal indicates the client should not expect the server to continue handling any further messages
	// and should close the connection.
	SeverityFatal Severity = 1
)

func (Severity) String

func (s Severity) String() string

Directories

Path Synopsis
internal
proto/mysqlx
Package mysqlx is a generated protocol buffer package.
Package mysqlx is a generated protocol buffer package.
proto/mysqlx_connection
Package mysqlx_connection is a generated protocol buffer package.
Package mysqlx_connection is a generated protocol buffer package.
proto/mysqlx_crud
Package mysqlx_crud is a generated protocol buffer package.
Package mysqlx_crud is a generated protocol buffer package.
proto/mysqlx_datatypes
Package mysqlx_datatypes is a generated protocol buffer package.
Package mysqlx_datatypes is a generated protocol buffer package.
proto/mysqlx_expect
Package mysqlx_expect is a generated protocol buffer package.
Package mysqlx_expect is a generated protocol buffer package.
proto/mysqlx_expr
Package mysqlx_expr is a generated protocol buffer package.
Package mysqlx_expr is a generated protocol buffer package.
proto/mysqlx_notice
Package mysqlx_notice is a generated protocol buffer package.
Package mysqlx_notice is a generated protocol buffer package.
proto/mysqlx_resultset
Package mysqlx_resultset is a generated protocol buffer package.
Package mysqlx_resultset is a generated protocol buffer package.
proto/mysqlx_session
Package mysqlx_session is a generated protocol buffer package.
Package mysqlx_session is a generated protocol buffer package.
proto/mysqlx_sql
Package mysqlx_sql is a generated protocol buffer package.
Package mysqlx_sql is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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