Documentation ¶
Overview ¶
GoMySQL - A MySQL client library for Go
Copyright 2010-2011 Phil Bayfield. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
GoMySQL - A MySQL client library for Go ¶
Copyright 2010-2011 Phil Bayfield. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
GoMySQL - A MySQL client library for Go ¶
Copyright 2010-2011 Phil Bayfield. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
GoMySQL - A MySQL client library for Go ¶
Copyright 2010-2011 Phil Bayfield. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
GoMySQL - A MySQL client library for Go ¶
Copyright 2010-2011 Phil Bayfield. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
GoMySQL - A MySQL client library for Go ¶
Copyright 2010-2011 Phil Bayfield. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
GoMySQL - A MySQL client library for Go ¶
Copyright 2010-2011 Phil Bayfield. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
GoMySQL - A MySQL client library for Go ¶
Copyright 2010-2011 Phil Bayfield. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
GoMySQL - A MySQL client library for Go ¶
Copyright 2010-2011 Phil Bayfield. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
GoMySQL - A MySQL client library for Go ¶
Copyright 2010-2011 Phil Bayfield. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
GoMySQL - A MySQL client library for Go ¶
Copyright 2010-2011 Phil Bayfield. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
GoMySQL - A MySQL client library for Go ¶
Copyright 2010-2011 Phil Bayfield. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
- Constants
- type Client
- func (c *Client) ChangeDb(dbname string) (err error)
- func (c *Client) Close() (err error)
- func (c *Client) Commit() (err error)
- func (c *Client) Connect(network, raddr, user, passwd string, dbname ...string) (err error)
- func (c *Client) Escape(s string) (esc string)
- func (c *Client) FreeResult() (err error)
- func (c *Client) InitStmt() (stmt *Statement, err error)
- func (c *Client) MoreResults() bool
- func (c *Client) NextResult() (more bool, err error)
- func (c *Client) Prepare(sql string) (stmt *Statement, err error)
- func (c *Client) Query(sql string) (err error)
- func (c *Client) Rollback() (err error)
- func (c *Client) SetAutoCommit(state bool) (err error)
- func (c *Client) Start() (err error)
- func (c *Client) StoreResult() (result *Result, err error)
- func (c *Client) UseResult() (result *Result, err error)
- type ClientError
- type ClientFlag
- type Date
- type DateTime
- type Errno
- type Errstr
- type ExecuteFlag
- type Field
- type FieldFlag
- type FieldType
- type Map
- type Refresh
- type Result
- type Row
- type ServerError
- type ServerStatus
- type Shutdown
- type Statement
- func (s *Statement) BindParams(params ...interface{}) (err error)
- func (s *Statement) BindResult(params ...interface{}) (err error)
- func (s *Statement) Close() (err error)
- func (s *Statement) Execute() (err error)
- func (s *Statement) Fetch() (eof bool, err error)
- func (s *Statement) FetchColumn() *Field
- func (s *Statement) FetchColumns() []*Field
- func (s *Statement) FieldCount() uint64
- func (s *Statement) FreeResult() (err error)
- func (s *Statement) MoreResults() bool
- func (s *Statement) NextResult() (more bool, err error)
- func (s *Statement) ParamCount() uint16
- func (s *Statement) Prepare(sql string) (err error)
- func (s *Statement) Reset() (err error)
- func (s *Statement) RowCount() uint64
- func (s *Statement) SendLongData(num int, data []byte) (err error)
- func (s *Statement) StoreResult() (err error)
- type Time
Constants ¶
const ( COM_QUIT command = iota + 1 COM_INIT_DB COM_QUERY COM_FIELD_LIST COM_CREATE_DB COM_DROP_DB COM_REFRESH COM_SHUTDOWN COM_STATISTICS COM_PROCESS_INFO COM_CONNECT COM_PROCESS_KILL COM_DEBUG COM_PING COM_TIME COM_DELAYED_INSERT COM_CHANGE_USER COM_BINLOG_DUMP COM_TABLE_DUMP COM_CONNECT_OUT COM_REGISTER_SLAVE COM_STMT_PREPARE COM_STMT_EXECUTE COM_STMT_SEND_LONG_DATA COM_STMT_CLOSE COM_STMT_RESET COM_SET_OPTION COM_STMT_FETCH )
const ( CR_UNKNOWN_ERROR Errno = 2000 CR_UNKNOWN_ERROR_STR Errstr = "Unknown MySQL error" CR_SOCKET_CREATE_ERROR Errno = 2001 CR_SOCKET_CREATE_ERROR_STR Errstr = "Can't create UNIX socket (%d)" CR_CONNECTION_ERROR Errno = 2002 CR_CONNECTION_ERROR_STR Errstr = "Can't connect to local MySQL server through socket '%s'" CR_CONN_HOST_ERROR Errno = 2003 CR_CONN_HOST_ERROR_STR Errstr = "Can't connect to MySQL server on '%s'" CR_IPSOCK_ERROR Errno = 2004 CR_IPSOCK_ERROR_STR Errstr = "Can't create TCP/IP socket (%d)" CR_UNKNOWN_HOST Errno = 2005 CR_UNKNOWN_HOST_STR Errstr = "Uknown MySQL server host '%s' (%d)" CR_SERVER_GONE_ERROR Errno = 2006 CR_SERVER_GONE_ERROR_STR Errstr = "MySQL server has gone away" CR_VERSION_ERROR Errno = 2007 CR_VERSION_ERROR_STR Errstr = "Protocol mismatch; server version = %d, client version = %d" CR_OUT_OF_MEMORY Errno = 2008 CR_OUT_OF_MEMORY_STR Errstr = "MySQL client ran out of memory" CR_WRONG_HOST_INFO Errno = 2009 CR_WRONG_HOST_INFO_STR Errstr = "Wrong host info" CR_LOCALHOST_CONNECTION Errno = 2010 CR_LOCALHOST_CONNECTION_STR Errstr = "Localhost via UNIX socket" CR_TCP_CONNECTION Errno = 2011 CR_TCP_CONNECTION_STR Errstr = "%s via TCP/IP" CR_SERVER_HANDSHAKE_ERR Errno = 2012 CR_SERVER_HANDSHAKE_ERR_STR Errstr = "Error in server handshake" CR_SERVER_LOST Errno = 2013 CR_SERVER_LOST_STR Errstr = "Lost connection to MySQL server during query" CR_COMMANDS_OUT_OF_SYNC Errno = 2014 CR_COMMANDS_OUT_OF_SYNC_STR Errstr = "Commands out of sync; you can't run this command now" CR_NAMEDPIPE_CONNECTION Errno = 2015 CR_NAMEDPIPE_CONNECTION_STR Errstr = "Named pipe: %s" CR_NAMEDPIPEWAIT_ERROR Errno = 2016 CR_NAMEDPIPEWAIT_ERROR_STR Errstr = "Can't wait for named pipe to host: %s pipe: %s (%lu)" CR_NAMEDPIPEOPEN_ERROR Errno = 2017 CR_NAMEDPIPEOPEN_ERROR_STR Errstr = "Can't open named pipe to host: %s pipe: %s (%lu)" CR_NAMEDPIPESETSTATE_ERROR Errno = 2018 CR_NAMEDPIPESETSTATE_ERROR_STR Errstr = "Can't set state of named pipe to host: %s pipe: %s (%lu)" CR_CANT_READ_CHARSET Errno = 2019 CR_CANT_READ_CHARSET_STR Errstr = "Can't initialize character set %s (path: %s)" CR_NET_PACKET_TOO_LARGE Errno = 2020 CR_NET_PACKET_TOO_LARGE_STR Errstr = "Got packet bigger than 'max_allowed_packet' bytes" CR_EMBEDDED_CONNECTION Errno = 2021 CR_EMBEDDED_CONNECTION_STR Errstr = "Embedded server" CR_PROBE_SLAVE_STATUS Errno = 2022 CR_PROBE_SLAVE_STATUS_STR Errstr = "Error on SHOW SLAVE STATUS:" CR_PROBE_SLAVE_HOSTS Errno = 2023 CR_PROBE_SLAVE_HOSTS_STR Errstr = "Error on SHOW SLAVE HOSTS:" CR_PROBE_SLAVE_CONNECT Errno = 2024 CR_PROBE_SLAVE_CONNECT_STR Errstr = "Error connecting to slave:" CR_PROBE_MASTER_CONNECT Errno = 2025 CR_PROBE_MASTER_CONNECT_STR Errstr = "Error connecting to master:" CR_SSL_CONNECTION_ERROR Errno = 2026 CR_SSL_CONNECTION_ERROR_STR Errstr = "SSL connection error" CR_MALFORMED_PACKET Errno = 2027 CR_MALFORMED_PACKET_STR Errstr = "Malformed Packet" CR_WRONG_LICENSE Errno = 2028 CR_WRONG_LICENSE_STR Errstr = "This client library is licensed only for use with MySQL servers having '%s' license" CR_NULL_POINTER Errno = 2029 CR_NULL_POINTER_STR Errstr = "Invalid use of null pointer" CR_NO_PREPARE_STMT Errno = 2030 CR_NO_PREPARE_STMT_STR Errstr = "Statement not prepared" CR_PARAMS_NOT_BOUND Errno = 2031 CR_PARAMS_NOT_BOUND_STR Errstr = "No data supplied for parameters in prepared statement" CR_DATA_TRUNCATED Errno = 2032 CR_DATA_TRUNCATED_STR Errstr = "Data truncated" CR_NO_PARAMETERS_EXISTS Errno = 2033 CR_NO_PARAMETERS_EXISTS_STR Errstr = "No parameters exist in the statement" CR_INVALID_PARAMETER_NO Errno = 2034 CR_INVALID_PARAMETER_NO_STR Errstr = "Invalid parameter number" CR_INVALID_BUFFER_USE Errno = 2035 CR_INVALID_BUFFER_USE_STR Errstr = "Can't send long data for non-string/non-binary data types (parameter: %d)" CR_UNSUPPORTED_PARAM_TYPE Errno = 2036 CR_UNSUPPORTED_PARAM_TYPE_STR Errstr = "Using unsupported parameter type: %s (parameter: %d)" CR_CONN_UNKNOW_PROTOCOL Errno = 2047 CR_CONN_UNKNOW_PROTOCOL_STR Errstr = "Wrong or unknown protocol" CR_SECURE_AUTH Errno = 2049 CR_SECURE_AUTH_STR Errstr = "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)" CR_FETCH_CANCELED Errno = 2050 CR_FETCH_CANCELED_STR Errstr = "Row retrieval was canceled by mysql_stmt_close() call" CR_NO_DATA Errno = 2051 CR_NO_DATA_STR Errstr = "Attempt to read column without prior row fetch" CR_NO_STMT_METADATA Errno = 2052 CR_NO_STMT_METADATA_STR Errstr = "Prepared statement contains no metadata" CR_NO_RESULT_SET Errno = 2053 CR_NO_RESULT_SET_STR Errstr = "Attempt to read a row while there is no result set associated with the statement" CR_NOT_IMPLEMENTED Errno = 2054 CR_NOT_IMPLEMENTED_STR Errstr = "This feature is not implemented yet" CR_SERVER_LOST_EXTENDED Errno = 2055 CR_SERVER_LOST_EXTENDED_STR Errstr = "Lost connection to MySQL server at '%s', system error: %d" CR_STMT_CLOSED Errno = 2056 CR_STMT_CLOSED_STR Errstr = "Statement closed indirectly because of a preceeding %s() call" CR_NEW_STMT_METADATA Errno = 2057 CR_NEW_STMT_METADATA_STR Errstr = "" /* 174-byte string literal not displayed */ CR_ALREADY_CONNECTED Errno = 2058 CR_ALREADY_CONNECTED_STR Errstr = "This handle is already connected" CR_AUTH_PLUGIN_CANNOT_LOAD Errno = 2059 CR_AUTH_PLUGIN_CANNOT_LOAD_STR Errstr = "Authentication plugin '%s' cannot be loaded: %s" )
const ( // General VERSION = "0.3.2" DEFAULT_PORT = "3306" DEFAULT_SOCKET = "/var/run/mysqld/mysqld.sock" MAX_PACKET_SIZE = 1<<24 - 1 PROTOCOL_41 = 41 PROTOCOL_40 = 40 DEFAULT_PROTOCOL = PROTOCOL_41 // Connection types TCP = "tcp" UNIX = "unix" // Log methods LOG_SCREEN = 0x0 LOG_FILE = 0x1 // Result storage methods RESULT_UNUSED = 0x0 RESULT_STORED = 0x1 RESULT_USED = 0x2 RESULT_FREE = 0x3 )
Constants
const ( PACKET_INIT packetType = 1 << iota PACKET_AUTH PACKET_OK PACKET_ERROR PACKET_CMD PACKET_RESULT PACKET_FIELD PACKET_ROW PACKET_EOF PACKET_PREPARE_OK PACKET_PARAM PACKET_LONG_DATA PACKET_EXECUTE PACKET_ROW_BINARY )
Packet types
const SCRAMBLE_LENGTH_323 = 8
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Mutex for thread safety sync.Mutex // Logging LogLevel uint8 LogType uint8 LogFile *os.File Reconnect bool // Result AffectedRows uint64 LastInsertId uint64 Warnings uint16 // contains filtered or unexported fields }
Client struct
func (*Client) MoreResults ¶
Check if more results are available
func (*Client) NextResult ¶
Move to the next available result
func (*Client) SetAutoCommit ¶
Set autocommit
func (*Client) StoreResult ¶
Fetch all rows for a result and store it, returning the result set
type ClientError ¶
Client error struct
type ClientFlag ¶
type ClientFlag uint32
const ( CLIENT_LONG_PASSWORD ClientFlag = 1 << iota CLIENT_FOUND_ROWS CLIENT_LONG_FLAG CLIENT_CONNECT_WITH_DB CLIENT_NO_SCHEMA CLIENT_COMPRESS CLIENT_ODBC CLIENT_LOCAL_FILES CLIENT_IGNORE_SPACE CLIENT_PROTOCOL_41 CLIENT_INTERACTIVE CLIENT_SSL CLIENT_IGNORE_SIGPIPE CLIENT_TRANSACTIONS CLIENT_RESERVED CLIENT_SECURE_CONN CLIENT_MULTI_STATEMENTS CLIENT_MULTI_RESULTS )
type ExecuteFlag ¶
type ExecuteFlag byte
const ( CURSOR_TYPE_NO_CURSOR ExecuteFlag = 0 CURSOR_TYPE_READ_ONLY ExecuteFlag = 1 << iota CURSOR_TYPE_FOR_UPDATE CURSOR_TYPE_SCROLLABLE )
type Field ¶
type Field struct { Database string Table string Name string Length uint32 Type FieldType Flags FieldFlag Decimals uint8 }
Field type
type FieldType ¶
type FieldType byte
const ( FIELD_TYPE_DECIMAL FieldType = iota FIELD_TYPE_TINY FIELD_TYPE_SHORT FIELD_TYPE_LONG FIELD_TYPE_FLOAT FIELD_TYPE_DOUBLE FIELD_TYPE_NULL FIELD_TYPE_TIMESTAMP FIELD_TYPE_LONGLONG FIELD_TYPE_INT24 FIELD_TYPE_DATE FIELD_TYPE_TIME FIELD_TYPE_DATETIME FIELD_TYPE_YEAR FIELD_TYPE_NEWDATE FIELD_TYPE_VARCHAR FIELD_TYPE_BIT )
type ServerError ¶
Server error struct
type ServerStatus ¶
type ServerStatus uint16
const ( SERVER_STATUS_IN_TRANS ServerStatus = 1 << iota SERVER_STATUS_AUTOCOMMIT )
const ( SERVER_MORE_RESULTS_EXISTS ServerStatus = 1 << (iota + 3) SERVER_QUERY_NO_GOOD_INDEX_USED SERVER_QUERY_NO_INDEX_USED SERVER_STATUS_CURSOR_EXISTS SERVER_STATUS_LAST_ROW_SENT SERVER_STATUS_DB_DROPPED SERVER_STATUS_NO_BACKSLASH_ESCAPES SERVER_STATUS_METADATA_CHANGED )
type Statement ¶
type Statement struct { // Result AffectedRows uint64 LastInsertId uint64 Warnings uint16 // contains filtered or unexported fields }
Prepared statement struct
func (*Statement) BindParams ¶
Bind params
func (*Statement) BindResult ¶
Bind result
func (*Statement) SendLongData ¶
Send long data