mysql

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

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

Go to latest
Published: Aug 28, 2015 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package mysql wraps the C client library for MySQL.

Index

Constants

View Source
const (
	// ErrDupEntry is C.ER_DUP_ENTRY
	ErrDupEntry = C.ER_DUP_ENTRY

	// ErrLockWaitTimeout is C.ER_LOCK_WAIT_TIMEOUT
	ErrLockWaitTimeout = C.ER_LOCK_WAIT_TIMEOUT

	// ErrLockDeadlock is C.ER_LOCK_DEADLOCK
	ErrLockDeadlock = C.ER_LOCK_DEADLOCK

	// ErrOptionPreventsStatement is C.ER_OPTION_PREVENTS_STATEMENT
	ErrOptionPreventsStatement = C.ER_OPTION_PREVENTS_STATEMENT

	// ErrDataTooLong is C.ER_DATA_TOO_LONG
	ErrDataTooLong = C.ER_DATA_TOO_LONG

	// ErrServerLost is C.CR_SERVER_LOST.
	// It's hard-coded for now because it causes problems on import.
	ErrServerLost = 2013

	// RedactedPassword is the password value used in redacted configs
	RedactedPassword = "****"
)

Variables

This section is empty.

Functions

func BuildValue

func BuildValue(bytes []byte, fieldType uint32) sqltypes.Value

BuildValue returns a sqltypes.Value from the passed in fields

func Connect

func Connect(params sqldb.ConnParams) (sqldb.Conn, error)

Connect uses the connection parameters to connect and returns the connection

func EnableSSL

func EnableSSL(connParams *sqldb.ConnParams)

EnableSSL will set the right flag on the parameters

func SslEnabled

func SslEnabled(connParams *sqldb.ConnParams) bool

SslEnabled returns if SSL is enabled

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection encapsulates a C mysql library connection

func (*Connection) Close

func (conn *Connection) Close()

Close closes the mysql connection

func (*Connection) CloseResult

func (conn *Connection) CloseResult()

CloseResult finishes the result set

func (*Connection) ExecuteFetch

func (conn *Connection) ExecuteFetch(query string, maxrows int, wantfields bool) (qr *proto.QueryResult, err error)

ExecuteFetch executes the query on the connection

func (*Connection) ExecuteFetchMap

func (conn *Connection) ExecuteFetchMap(query string) (map[string]string, error)

ExecuteFetchMap returns a map from column names to cell data for a query that should return exactly 1 row.

func (*Connection) ExecuteStreamFetch

func (conn *Connection) ExecuteStreamFetch(query string) (err error)

ExecuteStreamFetch starts a streaming query to mysql. Use FetchNext on the Connection until it returns nil or error

func (*Connection) FetchNext

func (conn *Connection) FetchNext() (row []sqltypes.Value, err error)

FetchNext returns the next row for a query

func (*Connection) Fields

func (conn *Connection) Fields() (fields []proto.Field)

Fields returns the current fields description for the query

func (*Connection) GetCharset

func (conn *Connection) GetCharset() (cs proto.Charset, err error)

GetCharset returns the current numerical values of the per-session character set variables.

func (*Connection) ID

func (conn *Connection) ID() int64

ID returns the MySQL thread_id of the connection.

func (*Connection) IsClosed

func (conn *Connection) IsClosed() bool

IsClosed returns if the connection was ever closed

func (*Connection) ReadPacket

func (conn *Connection) ReadPacket() ([]byte, error)

ReadPacket reads a raw packet from the MySQL connection.

A MySQL packet is "a single SQL statement sent to the MySQL server, a single row that is sent to the client, or a binary log event sent from a master replication server to a slave." -MySQL 5.1 Reference Manual

func (*Connection) SendCommand

func (conn *Connection) SendCommand(command uint32, data []byte) error

SendCommand sends a raw command to the MySQL server.

func (*Connection) SetCharset

func (conn *Connection) SetCharset(cs proto.Charset) error

SetCharset changes the per-session character set variables.

func (*Connection) Shutdown

func (conn *Connection) Shutdown()

Shutdown invokes the low-level shutdown call on the socket associated with a MySQL connection to stop ongoing communication. This is necessary when a thread is blocked in a MySQL I/O call, such as ReadPacket(), and another thread wants to cancel the operation. We can't use mysql_close() because it isn't thread-safe.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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