mysql

package
v0.0.0-...-2166858 Latest Latest
Warning

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

Go to latest
Published: May 28, 2016 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package mysql wraps the C client library for MySQL.

Index

Constants

View Source
const (
	DUP_ENTRY                 = C.ER_DUP_ENTRY
	LOCK_WAIT_TIMEOUT         = C.ER_LOCK_WAIT_TIMEOUT
	LOCK_DEADLOCK             = C.ER_LOCK_DEADLOCK
	OPTION_PREVENTS_STATEMENT = C.ER_OPTION_PREVENTS_STATEMENT

	REDACTED_PASSWORD = "****"
)

Variables

This section is empty.

Functions

func BuildValue

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

Types

type Connection

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

func Connect

func Connect(params ConnectionParams) (conn *Connection, err error)

func (*Connection) Close

func (conn *Connection) Close()

func (*Connection) CloseResult

func (conn *Connection) CloseResult()

func (*Connection) ExecuteFetch

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

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)

when using ExecuteStreamFetch, use FetchNext on the Connection until it returns nil or error

func (*Connection) FetchNext

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

func (*Connection) Fields

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

func (*Connection) ForceClose

func (conn *Connection) ForceClose()

ForceClose closes a MySQL connection forcibly at the socket level, instead of gracefully through mysql_close(). This is necessary when a thread is blocked in a call to ReadPacket(), and another thread wants to cancel the read. We can't use mysql_close() because it isn't safe to use while another thread is blocked in an I/O call on that MySQL connection.

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

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.

type ConnectionParams

type ConnectionParams struct {
	Host       string `json:"host"`
	Port       int    `json:"port"`
	Uname      string `json:"uname"`
	Pass       string `json:"pass"`
	DbName     string `json:"dbname"`
	UnixSocket string `json:"unix_socket"`
	Charset    string `json:"charset"`
	Flags      uint64 `json:"flags"`

	// the following flags are only used for 'Change Master' command
	// for now (along with flags |= 2048 for CLIENT_SSL)
	SslCa     string `json:"ssl_ca"`
	SslCaPath string `json:"ssl_ca_path"`
	SslCert   string `json:"ssl_cert"`
	SslKey    string `json:"ssl_key"`
}

func (*ConnectionParams) EnableMultiStatements

func (c *ConnectionParams) EnableMultiStatements()

func (*ConnectionParams) EnableSSL

func (c *ConnectionParams) EnableSSL()

func (*ConnectionParams) Redact

func (c *ConnectionParams) Redact()

func (*ConnectionParams) SslEnabled

func (c *ConnectionParams) SslEnabled() bool

type SqlError

type SqlError struct {
	Num     int
	Message string
	Query   string
}

func NewSqlError

func NewSqlError(number int, format string, args ...interface{}) *SqlError

func (*SqlError) Error

func (se *SqlError) Error() string

func (*SqlError) Number

func (se *SqlError) Number() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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