protocol

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultAddr        = ""
	DefaultProductName = "mysql"
)
View Source
const (
	DefaultPort                  = 3306
	DefaultMaxPacketSize         = 0
	DefaultCharset               = CharSetUTF8
	DefaultAuthPluginDataPartLen = 20

	SupportVersion = "5.7.9"

	DefaultServerCapability = ClientLongPassword |
		ClientFoundRows |
		ClientLongColumnFlag |
		ClientProtocol41 |
		ClientPluginAuth

	DefaultHandshakeServerCapabilities = DefaultServerCapability |
		ClientConnectWithDB

	DefaultSSLRequestCapabilities = DefaultServerCapability |
		ClientSSL

	DefaultServerStatus = ServerStatusAutocommit

	DefaultAuthPluginName = auth.MySQLNativePasswordID
)
View Source
const (
	DateTimeFormat = "2006-01-02 15:04:05"
)
View Source
const (
	MaxSequenceID = SequenceID(255)
)

Variables

View Source
var ErrExist = errors.New("exist")

ErrExist is returned when the specified object is exist.

View Source
var ErrInvalid = errors.New("invalid")

ErrInvalid is returned when the packet is invalid.

View Source
var ErrNotExist = errors.New("not exist")

ErrNotExist is returned when the specified object is not exist.

View Source
var ErrNotSupported = errors.New("not supported")

ErrNotSupported is returned when the packet is not supported.

View Source
var ErrTooManyConnections = errors.New("too many connections")

ErrTooManyConnections is returned when the connection is too many.

Functions

func CalculateNullBitmapLength added in v1.3.0

func CalculateNullBitmapLength(numFields int, offset int) int

CalculateNullBitmapLength calculates the length of the null bitmap.

func NewColumnDef added in v1.1.0

func NewColumnDef(opts ...ColumnDefOption) *columnDef

NewColumnDef returns a new columnDef.

func NewPacket added in v1.1.0

func NewPacket(opts ...PacketOption) *packet

NewPacket returns a new MySQL packet.

func NewPacketHeaderWithReader added in v1.1.0

func NewPacketHeaderWithReader(reader io.Reader) (*packet, error)

NewPacketHeaderWithReader returns a new MySQL packet from the reader.

func NewPacketWithPacketReader added in v1.1.0

func NewPacketWithPacketReader(reader *PacketReader) (*packet, error)

NewPacketWithPacketReader returns a new MySQL packet from the packet reader.

func NewPacketWithReader added in v1.1.0

func NewPacketWithReader(reader io.Reader) (*packet, error)

NewPacketWithReader returns a new MySQL packet from the reader.

func NewPreparedStatmentWith added in v1.3.0

func NewPreparedStatmentWith(prePkt *StmtPrepare, resPkt *StmtPrepareResponse) stmt.PreparedStatement

NewPreparedStatmentWith creates a new prepared statement with the packet.

func NewTextResultSetRowValueFrom added in v1.1.0

func NewTextResultSetRowValueFrom(t query.DataType, v any) (string, error)

NewTextResultSetRowValueFrom returns a new ResultSetRowValue from the specified DataType and value.

func WithConnCapability added in v1.3.0

func WithConnCapability(c Capability) func(*conn)

WithConnCapabilities sets capabilities.

func WithConnDatabase added in v1.1.0

func WithConnDatabase(name string) func(*conn)

WithConnDatabase sets a database name.

func WithConnID added in v1.1.0

func WithConnID(id uint64) func(*conn)

Withuint64 sets a connection ID.

func WithConnSeverStatus added in v1.3.0

func WithConnSeverStatus(s ServerStatus) func(*conn)

WithConnSeverStatus sets the server status.

func WithConnTLSConn added in v1.1.3

func WithConnTLSConn(s *tls.Conn) func(*conn)

WithConnTLSConnectionState sets a TLS connection state.

func WithConnTracer added in v1.1.0

func WithConnTracer(t tracer.Context) func(*conn)

WithConnTracer sets a tracer context.

func WithConnUUID added in v1.1.0

func WithConnUUID(id uuid.UUID) func(*conn)

WithConnUUID sets a UUID.

Types

type AttributeMap added in v1.1.0

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

AttributeMap represents a map of attributes.

func NewAttributeMap added in v1.1.0

func NewAttributeMap() *AttributeMap

NewAttributeMap returns a new AttributeMap.

func (*AttributeMap) AddAttribute added in v1.1.0

func (attrMap *AttributeMap) AddAttribute(key, value string)

AddAttribute adds an attribute.

func (*AttributeMap) AttributeKeys added in v1.1.0

func (attrMap *AttributeMap) AttributeKeys() []string

AttributeKeys returns the attribute keys.

func (*AttributeMap) Attributes added in v1.1.0

func (attrMap *AttributeMap) Attributes() map[string]string

Attributes returns the attributes.

func (*AttributeMap) LookupAttribute added in v1.1.0

func (attrMap *AttributeMap) LookupAttribute(key string) (string, bool)

type AuthSwitchRequest added in v1.1.0

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

AuthSwitchRequest represents the MySQL Protocol::AuthSwitchRequest packet.

func NewAuthSwitchRequest added in v1.1.0

func NewAuthSwitchRequest(opts ...AuthSwitchRequestOption) *AuthSwitchRequest

NewAuthSwitchRequest creates a new AuthSwitchRequest packet.

func NewAuthSwitchRequestFromReader added in v1.1.0

func NewAuthSwitchRequestFromReader(reader io.Reader) (*AuthSwitchRequest, error)

NewAuthSwitchRequestFromReader returns a new AuthSwitchRequest from the reader.

func (*AuthSwitchRequest) AuthData added in v1.1.0

func (pkt *AuthSwitchRequest) AuthData() string

AuthData returns the auth data.

func (*AuthSwitchRequest) Bytes added in v1.1.0

func (pkt *AuthSwitchRequest) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (AuthSwitchRequest) Capability added in v1.1.0

func (pkt AuthSwitchRequest) Capability() Capability

Capabilitys returns the packet capability flags.

func (AuthSwitchRequest) HeaderBytes added in v1.3.0

func (pkt AuthSwitchRequest) HeaderBytes() []byte

HeaderBytes returns the packet header bytes.

func (AuthSwitchRequest) IsEOF added in v1.1.0

func (pkt AuthSwitchRequest) IsEOF() bool

IsEOF returns true if the packet is an EOF packet.

func (AuthSwitchRequest) Payload added in v1.1.0

func (pkt AuthSwitchRequest) Payload() []byte

Payload returns the packet payload.

func (AuthSwitchRequest) PayloadHeaderByte added in v1.3.0

func (pkt AuthSwitchRequest) PayloadHeaderByte() (byte, error)

PayloadHeaderByte returns the payload header byte.

func (AuthSwitchRequest) PayloadLength added in v1.1.0

func (pkt AuthSwitchRequest) PayloadLength() uint32

PayloadLength returns the packet payload length.

func (*AuthSwitchRequest) PluginName added in v1.1.0

func (pkt *AuthSwitchRequest) PluginName() string

PluginName returns the plugin name.

func (AuthSwitchRequest) ReadHeader added in v1.1.0

func (pkt AuthSwitchRequest) ReadHeader() error

ReadHeader reads the packet header.

func (AuthSwitchRequest) ReadPayload added in v1.1.0

func (pkt AuthSwitchRequest) ReadPayload() error

ReadPayload reads the packet payload.

func (AuthSwitchRequest) Reader added in v1.1.0

func (pkt AuthSwitchRequest) Reader() *PacketReader

Reader returns the packet reader.

func (AuthSwitchRequest) SequenceID added in v1.1.0

func (pkt AuthSwitchRequest) SequenceID() SequenceID

SequenceID returns the packet sequence ID.

func (AuthSwitchRequest) ServerStatus added in v1.3.0

func (pkt AuthSwitchRequest) ServerStatus() ServerStatus

ServerStatus returns the packet server status.

func (AuthSwitchRequest) SetCapability added in v1.1.0

func (pkt AuthSwitchRequest) SetCapability(flags Capability)

SetCapabilitys sets the packet capability flags.

func (AuthSwitchRequest) SetCapabilityDisabled added in v1.1.0

func (pkt AuthSwitchRequest) SetCapabilityDisabled(flag Capability)

SetDisabled unsets the specified flag.

func (AuthSwitchRequest) SetCapabilityEnabled added in v1.1.0

func (pkt AuthSwitchRequest) SetCapabilityEnabled(flag Capability)

SetEnabled sets the specified flag.

func (AuthSwitchRequest) SetOptions added in v1.1.0

func (pkt AuthSwitchRequest) SetOptions(opts ...PacketOption)

SetOptions sets the options.

func (AuthSwitchRequest) SetPayload added in v1.1.0

func (pkt AuthSwitchRequest) SetPayload(payload []byte)

SetPayload sets the packet payload.

func (AuthSwitchRequest) SetPayloadLength added in v1.3.0

func (pkt AuthSwitchRequest) SetPayloadLength(l int)

SetPayloadLength sets only the payload length without the payload bytes.

func (AuthSwitchRequest) SetSequenceID added in v1.1.0

func (pkt AuthSwitchRequest) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

func (AuthSwitchRequest) SetServerStatus added in v1.3.0

func (pkt AuthSwitchRequest) SetServerStatus(status ServerStatus)

SetServerStatus sets the packet server status.

func (*AuthSwitchRequest) Status added in v1.1.0

func (pkt *AuthSwitchRequest) Status() byte

Status returns the status.

type AuthSwitchRequestOption added in v1.1.0

type AuthSwitchRequestOption func(*AuthSwitchRequest)

AuthSwitchRequestOption represents the AuthSwitchRequest option function.

func WithAuthSwitchRequestAuthData added in v1.1.0

func WithAuthSwitchRequestAuthData(authData string) AuthSwitchRequestOption

WithAuthSwitchRequestAuthData returns an AuthSwitchRequestOptionFn to set the auth data.

func WithAuthSwitchRequestPluginName added in v1.1.0

func WithAuthSwitchRequestPluginName(pluginName string) AuthSwitchRequestOption

WithAuthSwitchRequestPluginName returns an AuthSwitchRequestOptionFn to set the plugin name.

type BinaryResultSet added in v1.3.0

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

BinaryResultSet represents a MySQL binary resultset response packet.

func NewBinaryResultSet added in v1.3.0

func NewBinaryResultSet(opts ...BinaryResultSetOption) (*BinaryResultSet, error)

NewBinaryResultSet returns a new binary resultset response packet.

func NewBinaryResultSetFromReader added in v1.3.0

func NewBinaryResultSetFromReader(reader io.Reader, opts ...BinaryResultSetOption) (*BinaryResultSet, error)

NewBinaryResultSetFromReader returns a new binary resultset response packet from the specified reader.

func NewBinaryResultSetFromTextResultSet added in v1.3.0

func NewBinaryResultSetFromTextResultSet(txtRs *TextResultSet, opts ...BinaryResultSetOption) (*BinaryResultSet, error)

NewBinaryResultSetFromTextResultSet creates a new BinaryResultSet from a TextResultSet.

func (*BinaryResultSet) Bytes added in v1.3.0

func (pkt *BinaryResultSet) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (BinaryResultSet) Capability added in v1.3.0

func (pkt BinaryResultSet) Capability() Capability

Capabilitys returns the packet capability flags.

func (BinaryResultSet) HeaderBytes added in v1.3.0

func (pkt BinaryResultSet) HeaderBytes() []byte

HeaderBytes returns the packet header bytes.

func (BinaryResultSet) IsEOF added in v1.3.0

func (pkt BinaryResultSet) IsEOF() bool

IsEOF returns true if the packet is an EOF packet.

func (BinaryResultSet) Payload added in v1.3.0

func (pkt BinaryResultSet) Payload() []byte

Payload returns the packet payload.

func (BinaryResultSet) PayloadHeaderByte added in v1.3.0

func (pkt BinaryResultSet) PayloadHeaderByte() (byte, error)

PayloadHeaderByte returns the payload header byte.

func (BinaryResultSet) PayloadLength added in v1.3.0

func (pkt BinaryResultSet) PayloadLength() uint32

PayloadLength returns the packet payload length.

func (BinaryResultSet) ReadHeader added in v1.3.0

func (pkt BinaryResultSet) ReadHeader() error

ReadHeader reads the packet header.

func (BinaryResultSet) ReadPayload added in v1.3.0

func (pkt BinaryResultSet) ReadPayload() error

ReadPayload reads the packet payload.

func (BinaryResultSet) Reader added in v1.3.0

func (pkt BinaryResultSet) Reader() *PacketReader

Reader returns the packet reader.

func (*BinaryResultSet) Rows added in v1.3.0

func (pkt *BinaryResultSet) Rows() []BinaryResultSetRow

Rows returns the rows.

func (BinaryResultSet) SequenceID added in v1.3.0

func (pkt BinaryResultSet) SequenceID() SequenceID

SequenceID returns the packet sequence ID.

func (BinaryResultSet) ServerStatus added in v1.3.0

func (pkt BinaryResultSet) ServerStatus() ServerStatus

ServerStatus returns the packet server status.

func (BinaryResultSet) SetCapability added in v1.3.0

func (pkt BinaryResultSet) SetCapability(flags Capability)

SetCapabilitys sets the packet capability flags.

func (BinaryResultSet) SetCapabilityDisabled added in v1.3.0

func (pkt BinaryResultSet) SetCapabilityDisabled(flag Capability)

SetDisabled unsets the specified flag.

func (BinaryResultSet) SetCapabilityEnabled added in v1.3.0

func (pkt BinaryResultSet) SetCapabilityEnabled(flag Capability)

SetEnabled sets the specified flag.

func (*BinaryResultSet) SetOptions added in v1.3.0

func (pkt *BinaryResultSet) SetOptions(opts ...BinaryResultSetOption)

SetOptions sets the options.

func (BinaryResultSet) SetPayload added in v1.3.0

func (pkt BinaryResultSet) SetPayload(payload []byte)

SetPayload sets the packet payload.

func (BinaryResultSet) SetPayloadLength added in v1.3.0

func (pkt BinaryResultSet) SetPayloadLength(l int)

SetPayloadLength sets only the payload length without the payload bytes.

func (BinaryResultSet) SetSequenceID added in v1.3.0

func (pkt BinaryResultSet) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

func (BinaryResultSet) SetServerStatus added in v1.3.0

func (pkt BinaryResultSet) SetServerStatus(status ServerStatus)

SetServerStatus sets the packet server status.

type BinaryResultSetColumn added in v1.3.0

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

BinaryResultSetColumn represents a MySQL binary resultset row response packet.

func NewBinaryResultSetColumn added in v1.3.0

func NewBinaryResultSetColumn(opts ...BinaryResultSetColumnOption) (*BinaryResultSetColumn, error)

NewBinaryResultSetColumn returns a new BinaryResultSetColumn.

func NewBinaryResultSetColumnFromReader added in v1.3.0

func NewBinaryResultSetColumnFromReader(reader *PacketReader, opts ...BinaryResultSetColumnOption) (*BinaryResultSetColumn, error)

NewBinaryResultSetColumnFromReader returns a new BinaryResultSetColumn from the reader.

func (*BinaryResultSetColumn) Bytes added in v1.3.0

func (column *BinaryResultSetColumn) Bytes() ([]byte, error)

Bytes returns the bytes.

func (*BinaryResultSetColumn) Type added in v1.3.0

func (column *BinaryResultSetColumn) Type() FieldType

Type returns the type.

func (*BinaryResultSetColumn) Value added in v1.3.0

func (column *BinaryResultSetColumn) Value() (any, error)

Value returns the value.

type BinaryResultSetColumnOption added in v1.3.0

type BinaryResultSetColumnOption func(*BinaryResultSetColumn) error

BinaryResultSetColumnOption represents a MySQL binary resultset row option.

func WithBinaryResultSetColumnBytes added in v1.3.0

func WithBinaryResultSetColumnBytes(b []byte) BinaryResultSetColumnOption

WithBinaryResultSetRowBytes returns a binary resultset row option to set the bytes.

func WithBinaryResultSetColumnType added in v1.3.0

func WithBinaryResultSetColumnType(t FieldType) BinaryResultSetColumnOption

WithBinaryResultSetRowType returns a binary resultset row option to set the type.

func WithBinaryResultSetColumnValue added in v1.3.0

func WithBinaryResultSetColumnValue(v any) BinaryResultSetColumnOption

WithBinaryResultSetRowValue returns a binary resultset row option to set the value.

type BinaryResultSetOption added in v1.3.0

type BinaryResultSetOption func(*BinaryResultSet)

BinaryResultSetOption represents a COM_QUERY binary resultset option.

func WithBinaryResultSetCapability added in v1.3.0

func WithBinaryResultSetCapability(c Capability) BinaryResultSetOption

WithBinaryResultSetCapabilities returns a binary resultset option to set the capabilities.

func WithBinaryResultSetColumnDefs added in v1.3.0

func WithBinaryResultSetColumnDefs(colDefs []ColumnDef) BinaryResultSetOption

WithBinaryResultSetColumnDefs returns a binary resultset option to set the column definitions.

func WithBinaryResultSetRows added in v1.3.0

func WithBinaryResultSetRows(rows []BinaryResultSetRow) BinaryResultSetOption

WithBinaryResultSetRows returns a binary resultset option to set the rows.

func WithBinaryResultSetServerStatus added in v1.3.0

func WithBinaryResultSetServerStatus(s ServerStatus) BinaryResultSetOption

WithBinaryResultSetServerStatus returns a binary resultset option to set the server status.

type BinaryResultSetRow added in v1.3.0

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

BinaryResultSetRow represents a MySQL binary resultset row response packet.

func NewBinaryResultSetRow added in v1.3.0

func NewBinaryResultSetRow(opts ...BinaryResultSetRowOption) *BinaryResultSetRow

NewBinaryResultSetRow returns a new BinaryResultSetRow.

func NewBinaryResultSetRowFromReader added in v1.3.0

func NewBinaryResultSetRowFromReader(reader *PacketReader, opts ...BinaryResultSetRowOption) (*BinaryResultSetRow, error)

NewBinaryResultSetRowFromReader returns a new BinaryResultSetRow from the reader.

func NewBinaryResultSetRowFromTextResultSetRow added in v1.3.0

func NewBinaryResultSetRowFromTextResultSetRow(columDefs []ColumnDef, txtRow ResultSetRow) (*BinaryResultSetRow, error)

NewBinaryResultSetRowFromTextResultSetRow creates a new BinaryResultSetRow from a TextResultSetRow.

func (*BinaryResultSetRow) Bytes added in v1.3.0

func (row *BinaryResultSetRow) Bytes() ([]byte, error)

Bytes returns the bytes.

func (BinaryResultSetRow) Capability added in v1.3.0

func (pkt BinaryResultSetRow) Capability() Capability

Capabilitys returns the packet capability flags.

func (BinaryResultSetRow) HeaderBytes added in v1.3.0

func (pkt BinaryResultSetRow) HeaderBytes() []byte

HeaderBytes returns the packet header bytes.

func (BinaryResultSetRow) IsEOF added in v1.3.0

func (pkt BinaryResultSetRow) IsEOF() bool

IsEOF returns true if the packet is an EOF packet.

func (BinaryResultSetRow) Payload added in v1.3.0

func (pkt BinaryResultSetRow) Payload() []byte

Payload returns the packet payload.

func (BinaryResultSetRow) PayloadHeaderByte added in v1.3.0

func (pkt BinaryResultSetRow) PayloadHeaderByte() (byte, error)

PayloadHeaderByte returns the payload header byte.

func (BinaryResultSetRow) PayloadLength added in v1.3.0

func (pkt BinaryResultSetRow) PayloadLength() uint32

PayloadLength returns the packet payload length.

func (BinaryResultSetRow) ReadHeader added in v1.3.0

func (pkt BinaryResultSetRow) ReadHeader() error

ReadHeader reads the packet header.

func (BinaryResultSetRow) ReadPayload added in v1.3.0

func (pkt BinaryResultSetRow) ReadPayload() error

ReadPayload reads the packet payload.

func (BinaryResultSetRow) Reader added in v1.3.0

func (pkt BinaryResultSetRow) Reader() *PacketReader

Reader returns the packet reader.

func (BinaryResultSetRow) SequenceID added in v1.3.0

func (pkt BinaryResultSetRow) SequenceID() SequenceID

SequenceID returns the packet sequence ID.

func (BinaryResultSetRow) ServerStatus added in v1.3.0

func (pkt BinaryResultSetRow) ServerStatus() ServerStatus

ServerStatus returns the packet server status.

func (BinaryResultSetRow) SetCapability added in v1.3.0

func (pkt BinaryResultSetRow) SetCapability(flags Capability)

SetCapabilitys sets the packet capability flags.

func (BinaryResultSetRow) SetCapabilityDisabled added in v1.3.0

func (pkt BinaryResultSetRow) SetCapabilityDisabled(flag Capability)

SetDisabled unsets the specified flag.

func (BinaryResultSetRow) SetCapabilityEnabled added in v1.3.0

func (pkt BinaryResultSetRow) SetCapabilityEnabled(flag Capability)

SetEnabled sets the specified flag.

func (BinaryResultSetRow) SetOptions added in v1.3.0

func (pkt BinaryResultSetRow) SetOptions(opts ...PacketOption)

SetOptions sets the options.

func (BinaryResultSetRow) SetPayload added in v1.3.0

func (pkt BinaryResultSetRow) SetPayload(payload []byte)

SetPayload sets the packet payload.

func (BinaryResultSetRow) SetPayloadLength added in v1.3.0

func (pkt BinaryResultSetRow) SetPayloadLength(l int)

SetPayloadLength sets only the payload length without the payload bytes.

func (BinaryResultSetRow) SetSequenceID added in v1.3.0

func (pkt BinaryResultSetRow) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

func (BinaryResultSetRow) SetServerStatus added in v1.3.0

func (pkt BinaryResultSetRow) SetServerStatus(status ServerStatus)

SetServerStatus sets the packet server status.

type BinaryResultSetRowOption added in v1.3.0

type BinaryResultSetRowOption func(*BinaryResultSetRow)

BinaryResultSetRowOption represents a MySQL binary resultset row option.

func WithBinaryResultSetRowColumnDefs added in v1.3.0

func WithBinaryResultSetRowColumnDefs(columnDefs []ColumnDef) BinaryResultSetRowOption

WithBinaryResultSetRowColumnDefs returns a binary resultset row option to set the column definitions.

func WithBinaryResultSetRowColumns added in v1.3.0

func WithBinaryResultSetRowColumns(columns []*BinaryResultSetColumn) BinaryResultSetRowOption

WithBinaryResultSetRowColumns returns a binary resultset row option to set the columns.

func WithBinaryResultSetRowNullBitmap added in v1.3.0

func WithBinaryResultSetRowNullBitmap(nullBitmap *NullBitmap) BinaryResultSetRowOption

WithBinaryResultSetRowNullBitmap returns a binary resultset row option to set the null bitmap.

type Capability added in v1.1.0

type Capability uint32

Capability represents a MySQL Capability Flag.

const (
	// ClientLongPassword represents the CLIENT_LONG_PASSWORD capability flag.
	ClientLongPassword Capability = 1
	// ClientFoundRows represents the CLIENT_FOUND_ROWS capability flag.
	ClientFoundRows Capability = 2
	// ClientLongColumnFlag represents the CLIENT_LONG_FLAG capability flag.
	ClientLongColumnFlag Capability = 4
	// ClientConnectWithDB represents the CLIENT_CONNECT_WITH_DB capability flag.
	ClientConnectWithDB Capability = 8
	// ClientNoSchema represents the CLIENT_NO_SCHEMA capability flag.
	ClientNoSchema Capability = 16
	// ClientCompress represents the CLIENT_COMPRESS capability flag.
	ClientCompress Capability = 32
	// ClientODBC represents the CLIENT_ODBC capability flag.
	ClientODBC Capability = 64
	// ClientLocalFiles represents the CLIENT_LOCAL_FILES capability flag.
	ClientLocalFiles Capability = 128
	// ClientIgnoreSpace represents the CLIENT_IGNORE_SPACE capability flag.
	ClientIgnoreSpace Capability = 256
	// ClientProtocol41 represents the CLIENT_PROTOCOL_41 capability flag.
	ClientProtocol41 Capability = 512
	// ClientInteractive represents the CLIENT_INTERACTIVE capability flag.
	ClientInteractive Capability = 1024
	// ClientSSL represents the CLIENT_SSL capability flag.
	ClientSSL Capability = 2048
	// ClientIgnoreSIGPIPE represents the CLIENT_IGNORE_SIGPIPE capability flag.
	ClientIgnoreSIGPIPE Capability = 4096
	// ClientTransactions represents the CLIENT_TRANSACTIONS capability flag.
	ClientTransactions Capability = 8192
	// ClientReserved represents the CLIENT_RESERVED capability flag.
	ClientReserved Capability = 16384
	// ClientSecureConnection represents the CLIENT_SECURE_CONNECTION capability flag.
	ClientSecureConnection Capability = 32768
	// ClientMultiStatements represents the CLIENT_MULTI_STATEMENTS capability flag.
	ClientMultiStatements Capability = 65536
	// ClientMultiResults represents the CLIENT_MULTI_RESULTS capability flag.
	ClientMultiResults Capability = 131072
	// ClientPSMultiResults represents the CLIENT_PS_MULTI_RESULTS capability flag.
	ClientPSMultiResults Capability = 262144
	// ClientPluginAuth represents the CLIENT_PLUGIN_AUTH capability flag.
	ClientPluginAuth Capability = 524288
	// ClientConnectAttrs represents the CLIENT_CONNECT_ATTRS capability flag.
	ClientConnectAttrs Capability = 1048576
	// ClientPluginAuthLenencClientData represents the CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA capability flag.
	ClientPluginAuthLenencClientData Capability = 2097152
	// ClientCanHandleExpiredPasswords represents the CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS capability flag.
	ClientCanHandleExpiredPasswords Capability = 4194304
	// ClientSessionTrack represents the CLIENT_SESSION_TRACK capability flag.
	ClientSessionTrack Capability = 8388608
	// ClientDeprecateEOF represents the CLIENT_DEPRECATE_EOF capability flag.
	ClientDeprecateEOF Capability = 16777216
	// ClientCapabilitiyClientOptionalResultsetMetadata represents the CLIENT_OPTIONAL_RESULTSET_METADATA capability flag.
	ClientOptionalResultsetMetadata Capability = 33554432
	// ClientZstdCompressionAlgorithm represents the CLIENT_ZSTD_COMPRESSION_ALGORITHMS capability flag.
	ClientZstdCompressionAlgorithm Capability = 67108864
	// ClientQueryAttributes represents the CLIENT_QUERY_ATTRIBUTES capability flag.
	ClientQueryAttributes Capability = 134217728
	// CapabilityMultiFactoryAuth represents the CLIENT_MULTI_FACTORY_AUTH capability flag.
	CapabilityMultiFactoryAuth Capability = 67108864
	// ClientCapabilityExtension represents the CLIENT_CAPABILITY_EXTENSION capability flag.
	ClientCapabilityExtension Capability = 268435456
	// ClientSSLVerifyServerCert represents the CLIENT_SSL_VERIFY_SERVER_CERT capability flag.
	ClientSSLVerifyServerCert Capability = 536870912
	// ClientRemenberOptions represents the CLIENT_REMENBER_OPTIONS capability flag.
	ClientRemenberOptions Capability = 1073741824
)

func NewCapabilityFromBytes added in v1.1.0

func NewCapabilityFromBytes(data []byte) Capability

ToBytes returns the capability flag as bytes.

func (Capability) IsDisabled added in v1.1.0

func (c Capability) IsDisabled(flag Capability) bool

IsDisabled returns true if the specified flag is not set.

func (Capability) IsEnabled added in v1.1.0

func (c Capability) IsEnabled(flag Capability) bool

IsEnabled returns true if the specified flag is set.

type CertConfig added in v1.1.3

type CertConfig interface {
	// SetClientAuthType sets a client authentication type.
	SetClientAuthType(authType tls.ClientAuthType)
	// SetServerKeyFile sets a SSL server key file.
	SetServerKeyFile(file string) error
	// SetServerCertFile sets a SSL server certificate file.
	SetServerCertFile(file string) error
	// SetRootCertFile sets a SSL root certificates.
	SetRootCertFiles(files ...string) error
	// SetServerKey sets a SSL server key.
	SetServerKey(key []byte)
	// SetServerCert sets a SSL server certificate.
	SetServerCert(cert []byte)
	// SetRootCerts sets a SSL root certificates.
	SetRootCerts(certs ...[]byte)
	// SetTLSConfig sets a TLS configuration.
	SetTLSConfig(tlsConfig *tls.Config)
	// TLSConfig returns a TLS configuration from the configuration.
	TLSConfig() (*tls.Config, error)
}

CertConfig represents a TLS configuration interface.

type CharSet added in v1.1.0

type CharSet uint8

CharSet represents a MySQL Character Set.

const (
	// CharSetLatin1 represents the latin1 character set.
	CharSetLatin1 CharSet = 0x08
	// CharSetUTF8 represents the utf8 character set.
	CharSetUTF8 CharSet = 0x21
	// CharSetBinary represents the binary character set.
	CharSetBinary CharSet = 0x3f
)

type ColumnCount added in v1.1.0

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

ColumnDef represents a MySQL Column Definition packet.

func NewColumnCount added in v1.1.0

func NewColumnCount(opts ...ColumnCountOption) *ColumnCount

NewColumnCount returns a new ColumnCount.

func NewColumnCountFromReader added in v1.1.0

func NewColumnCountFromReader(r io.Reader, opts ...ColumnCountOption) (*ColumnCount, error)

func (*ColumnCount) Bytes added in v1.1.0

func (pkt *ColumnCount) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (*ColumnCount) Capability added in v1.1.0

func (pkt *ColumnCount) Capability() Capability

Capability returns the capabilities.

func (*ColumnCount) ColumnCount added in v1.1.0

func (pkt *ColumnCount) ColumnCount() uint64

ColumnCount returns the column count.

func (ColumnCount) HeaderBytes added in v1.3.0

func (pkt ColumnCount) HeaderBytes() []byte

HeaderBytes returns the packet header bytes.

func (ColumnCount) IsEOF added in v1.1.0

func (pkt ColumnCount) IsEOF() bool

IsEOF returns true if the packet is an EOF packet.

func (*ColumnCount) MetadataFollows added in v1.1.0

func (pkt *ColumnCount) MetadataFollows() ResultsetMetadata

MetadataFollows returns the metadata follows.

func (ColumnCount) Payload added in v1.1.0

func (pkt ColumnCount) Payload() []byte

Payload returns the packet payload.

func (ColumnCount) PayloadHeaderByte added in v1.3.0

func (pkt ColumnCount) PayloadHeaderByte() (byte, error)

PayloadHeaderByte returns the payload header byte.

func (ColumnCount) PayloadLength added in v1.1.0

func (pkt ColumnCount) PayloadLength() uint32

PayloadLength returns the packet payload length.

func (ColumnCount) ReadHeader added in v1.1.0

func (pkt ColumnCount) ReadHeader() error

ReadHeader reads the packet header.

func (ColumnCount) ReadPayload added in v1.1.0

func (pkt ColumnCount) ReadPayload() error

ReadPayload reads the packet payload.

func (ColumnCount) Reader added in v1.1.0

func (pkt ColumnCount) Reader() *PacketReader

Reader returns the packet reader.

func (ColumnCount) SequenceID added in v1.1.0

func (pkt ColumnCount) SequenceID() SequenceID

SequenceID returns the packet sequence ID.

func (ColumnCount) ServerStatus added in v1.3.0

func (pkt ColumnCount) ServerStatus() ServerStatus

ServerStatus returns the packet server status.

func (ColumnCount) SetCapability added in v1.1.0

func (pkt ColumnCount) SetCapability(flags Capability)

SetCapabilitys sets the packet capability flags.

func (ColumnCount) SetCapabilityDisabled added in v1.1.0

func (pkt ColumnCount) SetCapabilityDisabled(flag Capability)

SetDisabled unsets the specified flag.

func (ColumnCount) SetCapabilityEnabled added in v1.1.0

func (pkt ColumnCount) SetCapabilityEnabled(flag Capability)

SetEnabled sets the specified flag.

func (*ColumnCount) SetOptions added in v1.1.0

func (pkt *ColumnCount) SetOptions(opts ...ColumnCountOption)

SetOptions sets the options.

func (ColumnCount) SetPayload added in v1.1.0

func (pkt ColumnCount) SetPayload(payload []byte)

SetPayload sets the packet payload.

func (ColumnCount) SetPayloadLength added in v1.3.0

func (pkt ColumnCount) SetPayloadLength(l int)

SetPayloadLength sets only the payload length without the payload bytes.

func (ColumnCount) SetSequenceID added in v1.1.0

func (pkt ColumnCount) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

func (ColumnCount) SetServerStatus added in v1.3.0

func (pkt ColumnCount) SetServerStatus(status ServerStatus)

SetServerStatus sets the packet server status.

type ColumnCountOption added in v1.1.0

type ColumnCountOption func(*ColumnCount)

ColumnDefOption represents a function to set a ColumnDef option.

func WithColumnCount added in v1.1.0

func WithColumnCount(c uint64) ColumnCountOption

WithColumnCount returns a ColumnCountOption that sets the column count.

func WithColumnCountCapability added in v1.3.0

func WithColumnCountCapability(c Capability) ColumnCountOption

type ColumnDef added in v1.1.0

type ColumnDef interface {
	Response
	// Catalog returns the column catalog.
	Catalog() string
	// Schema returns the column schema.
	Schema() string
	// Table returns the column table.
	Table() string
	// OrgTable returns the column original table.
	OrgTable() string
	// Name returns the column name.
	Name() string
	// OrgName returns the column original name.
	OrgName() string
	// CharSet returns the column character set.
	CharSet() uint16
	// ColLength returns the column length.
	ColLength() uint32
	// ColType returns the column type.
	ColType() uint8
	// Flags returns the column flags.
	Flags() uint16
	// Decimals returns the column decimals.
	Decimals() uint8
}

ColumnDef represents a MySQL Column Definition packet.

func NewColumnDefFromReader added in v1.1.0

func NewColumnDefFromReader(r io.Reader) (ColumnDef, error)

NewColumnDefFromReader returns a new columnDef from the reader.

func NewColumnDefsFromResultSet added in v1.1.0

func NewColumnDefsFromResultSet(rs sql.ResultSet) ([]ColumnDef, error)

NewColumnDefFromReader returns a new ColumnDef from the reader.

func NewColumnDefsFromSystemSchemaColumn added in v1.3.0

func NewColumnDefsFromSystemSchemaColumn(column system.SchemaColumn) (ColumnDef, error)

NewColumnDefFromSystemSchemaColumn returns a new ColumnDef from the system schema column.

type ColumnDefFlag added in v1.1.0

type ColumnDefFlag uint16

ColumnDefFlag represents a MySQL column definition flag.

const (
	// ColumnDefNotNULL represents the NOT_NULL column definition flag.
	ColumnDefNotNULL ColumnDefFlag = 1
	// ColumnDefPriKey represents the PRI_KEY column definition flag.
	ColumnDefPriKey ColumnDefFlag = 2
	// ColumnDefUniqueKey represents the UNIQUE_KEY column definition flag.
	ColumnDefUniqueKey ColumnDefFlag = 4
	// ColumnDefMultipleKey represents the MULTIPLE_KEY column definition flag.
	ColumnDefMultipleKey ColumnDefFlag = 8
	// ColumnDefBlob represents the BLOB column definition flag.
	ColumnDefBlob ColumnDefFlag = 16
	// ColumnDefUnsigned represents the UNSIGNED column definition flag.
	ColumnDefUnsigned ColumnDefFlag = 32
	// ColumnDefZeroFill represents the ZEROFILL column definition flag.
	ColumnDefZeroFill ColumnDefFlag = 64
	// ColumnDefBinary represents the BINARY column definition flag.
	ColumnDefBinary ColumnDefFlag = 128
	// ColumnDefEnum represents the ENUM column definition flag.
	ColumnDefEnum ColumnDefFlag = 256
	// ColumnDefAutoIncrement represents the AUTO_INCREMENT column definition flag.
	ColumnDefAutoIncrement ColumnDefFlag = 512
	// ColumnDefTimestamp represents the TIMESTAMP column definition flag.
	ColumnDefTimestamp ColumnDefFlag = 1024
	// ColumnDefSet represents the SET column definition flag.
	ColumnDefSet ColumnDefFlag = 2048
	// ColumnDefNoDefaultValue represents the NO_DEFAULT_VALUE column definition flag.
	ColumnDefNoDefaultValue ColumnDefFlag = 4096
	// ColumnDefOnUpdateNow represents the ON_UPDATE_NOW column definition flag.
	ColumnDefOnUpdateNow ColumnDefFlag = 8192
	// ColumnDefPartKey represents the PART_KEY column definition flag.
	ColumnDefPartKey ColumnDefFlag = 16384
	// ColumnDefNum represents the NUM_FLAG column definition flag.
	ColumnDefNum ColumnDefFlag = 32768
)

ColumnDefFlag constants.

type ColumnDefOption added in v1.1.0

type ColumnDefOption func(*columnDef)

ColumnDefOption represents a function to set a columnDef option.

func WithColumnDefCharSet added in v1.1.0

func WithColumnDefCharSet(charSet uint16) ColumnDefOption

WithColumnDefColLength returns a ColumnDefOption to set the column length.

func WithColumnDefDecimals added in v1.1.0

func WithColumnDefDecimals(decimals uint8) ColumnDefOption

WithColumnDefDecimals returns a ColumnDefOption to set the decimals.

func WithColumnDefFixedFieldLength added in v1.1.0

func WithColumnDefFixedFieldLength(fixedFieldLength uint64) ColumnDefOption

WithColumnDefColLength returns a ColumnDefOption to set the column length.

func WithColumnDefFlags added in v1.1.0

func WithColumnDefFlags(flags uint16) ColumnDefOption

WithColumnDefFlags returns a ColumnDefOption to set the flags.

func WithColumnDefName added in v1.1.0

func WithColumnDefName(name string) ColumnDefOption

WithColumnDefName returns a ColumnDefOption to set the name.

func WithColumnDefOrgName added in v1.1.0

func WithColumnDefOrgName(orgName string) ColumnDefOption

WithColumnDefOrgName returns a ColumnDefOption to set the original name.

func WithColumnDefOrgTable added in v1.1.0

func WithColumnDefOrgTable(orgTable string) ColumnDefOption

WithColumnDefOrgTable returns a ColumnDefOption to set the original table.

func WithColumnDefSchema added in v1.1.0

func WithColumnDefSchema(schema string) ColumnDefOption

WithColumnDefSchema returns a ColumnDefOption to set the schema.

func WithColumnDefTable added in v1.1.0

func WithColumnDefTable(table string) ColumnDefOption

WithColumnDefTable returns a ColumnDefOption to set the table.

func WithColumnDefType added in v1.1.0

func WithColumnDefType(colType uint8) ColumnDefOption

WithColumnDefColLength returns a ColumnDefOption to set the column length.

type Command added in v1.1.0

type Command interface {
	Packet
	// Type returns the command type.
	Type() CommandType
	// IsType returns nil if the command type is the specified type.
	IsType(t CommandType) error
	// SkipPayload skips the payload.
	SkipPayload() error
	// SetCapability sets the capabilities.
	SetCapability(Capability)
	// Capability returns the capabilities.
	Capability() Capability
}

Command represents a MySQL command.

func NewCommand added in v1.1.0

func NewCommand(cmdType CommandType, opts ...CommandOption) Command

NewCommand returns a new command.

func NewCommandFromReader added in v1.1.0

func NewCommandFromReader(reader io.Reader, opts ...CommandOption) (Command, error)

NewCommandFromReader returns a new command from the reader.

func NewCommandWith added in v1.1.0

func NewCommandWith(cmdType CommandType, pkt Packet, opts ...CommandOption) Command

NewCommandWith returns a new command with the specified type and packet.

type CommandHandler added in v1.1.0

type CommandHandler interface {
	// HandleQuery handles a query command.
	HandleQuery(Conn, *Query) (Response, error)
	// PrepareStatement prepares a statement.
	PrepareStatement(Conn, *StmtPrepare) (*StmtPrepareResponse, error)
	// ExecuteStatement executes a statement.
	ExecuteStatement(Conn, *StmtExecute) (Response, error)
	// CloseStatement closes a statement.
	CloseStatement(Conn, *StmtClose) (Response, error)
}

CommandHandler represents a MySQL command handler.

type CommandOption added in v1.1.0

type CommandOption func(Command)

CommandOption represents a MySQL Command option.

func WithCommandCapability added in v1.3.0

func WithCommandCapability(c Capability) CommandOption

WithCommandCapabilities returns a CommandOption that sets the capabilities.

type CommandType added in v1.1.0

type CommandType uint8

CommandType represents a MySQL command type.

const (
	// ComQuit: Command Quit.
	ComQuit CommandType = 0x01
	// ComInitDB: Command Init DB.
	ComInitDB CommandType = 0x02
	// ComQuery: Command Query.
	ComQuery CommandType = 0x03
	// ComFieldList: Command Field List.
	ComFieldList CommandType = 0x04
	// ComCreateDB: Command Create DB.
	ComCreateDB CommandType = 0x05
	// ComDropDB: Command Drop DB.
	ComDropDB CommandType = 0x06
	// ComRefresh: Command Refresh.
	ComRefresh CommandType = 0x07
	// ComShutdown: Command Shutdown.
	ComShutdown CommandType = 0x08
	// ComStatistics: Command Statistics.
	ComStatistics CommandType = 0x09
	// ComProcessInfo: Command Process Info.
	ComProcessInfo CommandType = 0x0a
	// ComConnect: Command Connect.
	ComConnect CommandType = 0x0b
	// ComProcessKill: Command Process Kill.
	ComProcessKill CommandType = 0x0c
	// ComDebug: Command Debug.
	ComDebug CommandType = 0x0d
	// ComPing: Command Ping.
	ComPing CommandType = 0x0e
	// ComTime: Command Time.
	ComTime CommandType = 0x0f
	// ComDelayedInsert: Command Delayed Insert.
	ComDelayedInsert CommandType = 0x10
	// ComChangeUser: Command Change User.
	ComChangeUser CommandType = 0x11
	// ComBinlogDump: Command Binlog Dump.
	ComBinlogDump CommandType = 0x12
	// ComTableDump: Command Table Dump.
	ComTableDump CommandType = 0x13
	// ComConnectOut: Command Connect Out.
	ComConnectOut CommandType = 0x14
	// ComRegisterSlave: Command Register Slave.
	ComRegisterSlave CommandType = 0x15
	// ComStmtPrepare: Command Stmt Prepare.
	ComStmtPrepare CommandType = 0x16
	// ComStmtExecute: Command Stmt Execute.
	ComStmtExecute CommandType = 0x17
	// ComStmtSendLongData: Command Stmt Send Long Data.
	ComStmtSendLongData CommandType = 0x18
	// ComStmtClose: Command Stmt Close.
	ComStmtClose CommandType = 0x19
	// ComStmtReset: Command Stmt Reset.
	ComStmtReset CommandType = 0x1a
	// ComStmeFetch: Command Stmt Fetch.
	ComStmtFetch CommandType = 0x1b
)

func (CommandType) String added in v1.1.0

func (t CommandType) String() string

String returns the string representation of the command type.

type Config added in v1.1.0

type Config interface {
	TLSConfig

	// SetAddress sets a listen address.
	SetAddress(host string)
	// SetPort sets a listen port.
	SetPort(port int)
	// Address returns a listen address.
	Address() string
	// Port returns a listen port.
	Port() int

	// SetProuctName sets a product name to the configuration.
	SetProductName(v string)
	// SetProductVersion sets a product version to the configuration.
	SetProductVersion(v string)
	// ProductName returns the product name from the configuration.
	ProductName() string
	// ProductVersion returns the product version from the configuration.
	ProductVersion() string

	// ServerVersion returns the server version for the handshake.
	ServerVersion() string

	// SetCapability sets the capability flags to the configuration.
	SetCapability(c Capability)
	// Capability returns the capability flags from the configuration.
	Capability() Capability

	// SetServerStatus sets the server status to the configuration.
	SetServerStatus(status ServerStatus)
	// ServerStatus returns the server status from the configuration.
	ServerStatus() ServerStatus

	// SetAuthPluginName sets the auth plugin name to the configuration.
	SetAuthPluginName(v string)
	// AuthPluginName returns the auth plugin name from the configuration.
	AuthPluginName() string
}

Config represents a MySQL server configuration.

func NewDefaultConfig added in v1.1.0

func NewDefaultConfig() Config

NewDefaultConfig returns a default configuration instance.

type Conn added in v1.1.0

type Conn interface {
	mysqlnet.Conn
	SetDatabase(db string)
	SetCapability(c Capability)
	Database() string
	IsTLSConnection() bool
	TLSConn() *tls.Conn
	Capability() Capability
	ServerStatus() ServerStatus
	PacketReader() *PacketReader
	ResponsePacket(resMsg Response, opts ...ResponseOption) error
	ResponsePackets(resMsgs []Response, opts ...ResponseOption) error
	ResponseOK(opts ...OKOption) error
	ResponseError(err error, opts ...ERROption) error
}

func NewConnWith added in v1.1.0

func NewConnWith(netConn net.Conn, opts ...ConnOption) Conn

NewConnWith returns a connection with a raw connection.

type ConnOption added in v1.1.0

type ConnOption = func(*conn)

ConnOption represents a connection option.

type Counter added in v1.1.0

type Counter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Counter is a counter.

func NewCounter added in v1.1.0

func NewCounter() *Counter

NewCounter returns a new counter.

func NewCounterWith added in v1.1.0

func NewCounterWith(count int32) *Counter

NewCounterWith returns a new counter with the specified count.

func (*Counter) Count added in v1.1.0

func (counter *Counter) Count() int32

Count returns the count.

func (*Counter) Inc added in v1.1.0

func (counter *Counter) Inc() int32

Inc increments the counter and returns the new value.

type CursorType added in v1.3.0

type CursorType uint8
const (
	// CursorTypeNoCursor indicates that no cursor is used.
	CursorTypeNoCursor CursorType = 0
	// CursorTypeReadOnly indicates that the cursor is read-only.
	CursorTypeReadOnly CursorType = 1
	// CursorTypeForUpdate indicates that the cursor is for update.
	CursorTypeForUpdate CursorType = 2
	// CursorTypeScrollable indicates that the cursor is scrollable.
	CursorTypeScrollable CursorType = 4
)

func (CursorType) IsEnabled added in v1.3.0

func (statFlag CursorType) IsEnabled(flag CursorType) bool

IsEnabled returns true if the status flag is enabled.

type EOF added in v1.1.0

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

EOF represents a MySQL EOF packet.

func NewEOF added in v1.1.0

func NewEOF(opts ...EOFOption) (*EOF, error)

NewEOF returns a new EOF packet.

func NewEOFFromReader added in v1.1.0

func NewEOFFromReader(reader io.Reader, opts ...EOFOption) (*EOF, error)

NewEOFFromReader returns a new EOF packet from the reader.

func (*EOF) Bytes added in v1.1.0

func (pkt *EOF) Bytes() ([]byte, error)

Bytes returns a byte sequence of the EOF packet.

func (EOF) Capability added in v1.1.0

func (pkt EOF) Capability() Capability

Capabilitys returns the packet capability flags.

func (*EOF) Header added in v1.1.0

func (pkt *EOF) Header() uint8

Header returns the header.

func (EOF) HeaderBytes added in v1.3.0

func (pkt EOF) HeaderBytes() []byte

HeaderBytes returns the packet header bytes.

func (EOF) IsEOF added in v1.1.0

func (pkt EOF) IsEOF() bool

IsEOF returns true if the packet is an EOF packet.

func (EOF) Payload added in v1.1.0

func (pkt EOF) Payload() []byte

Payload returns the packet payload.

func (EOF) PayloadHeaderByte added in v1.3.0

func (pkt EOF) PayloadHeaderByte() (byte, error)

PayloadHeaderByte returns the payload header byte.

func (EOF) PayloadLength added in v1.1.0

func (pkt EOF) PayloadLength() uint32

PayloadLength returns the packet payload length.

func (EOF) ReadHeader added in v1.1.0

func (pkt EOF) ReadHeader() error

ReadHeader reads the packet header.

func (EOF) ReadPayload added in v1.1.0

func (pkt EOF) ReadPayload() error

ReadPayload reads the packet payload.

func (EOF) Reader added in v1.1.0

func (pkt EOF) Reader() *PacketReader

Reader returns the packet reader.

func (EOF) SequenceID added in v1.1.0

func (pkt EOF) SequenceID() SequenceID

SequenceID returns the packet sequence ID.

func (EOF) ServerStatus added in v1.3.0

func (pkt EOF) ServerStatus() ServerStatus

ServerStatus returns the packet server status.

func (EOF) SetCapability added in v1.1.0

func (pkt EOF) SetCapability(flags Capability)

SetCapabilitys sets the packet capability flags.

func (EOF) SetCapabilityDisabled added in v1.1.0

func (pkt EOF) SetCapabilityDisabled(flag Capability)

SetDisabled unsets the specified flag.

func (EOF) SetCapabilityEnabled added in v1.1.0

func (pkt EOF) SetCapabilityEnabled(flag Capability)

SetEnabled sets the specified flag.

func (EOF) SetOptions added in v1.1.0

func (pkt EOF) SetOptions(opts ...PacketOption)

SetOptions sets the options.

func (EOF) SetPayload added in v1.1.0

func (pkt EOF) SetPayload(payload []byte)

SetPayload sets the packet payload.

func (EOF) SetPayloadLength added in v1.3.0

func (pkt EOF) SetPayloadLength(l int)

SetPayloadLength sets only the payload length without the payload bytes.

func (EOF) SetSequenceID added in v1.1.0

func (pkt EOF) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

func (EOF) SetServerStatus added in v1.3.0

func (pkt EOF) SetServerStatus(status ServerStatus)

SetServerStatus sets the packet server status.

func (*EOF) Warnings added in v1.1.0

func (pkt *EOF) Warnings() uint16

Warnings returns the number of warnings.

type EOFOption added in v1.1.0

type EOFOption func(*EOF) error

EOFOption represents a MySQL EOF packet option.

func WithEOFCSecuenceID added in v1.1.0

func WithEOFCSecuenceID(n SequenceID) EOFOption

WithEOFCSecuenceID returns a EOFOption that sets the sequence ID.

func WithEOFCapability added in v1.1.0

func WithEOFCapability(c Capability) EOFOption

WithEOFCapability returns a EOFOption that sets the capability flag.

func WithEOFServerStatus added in v1.3.0

func WithEOFServerStatus(status ServerStatus) EOFOption

WithEOFServerStatus returns a EOFOption that sets the server status flag.

func WithEOFWarnings added in v1.1.0

func WithEOFWarnings(warnings uint16) EOFOption

WithEOFWarnings returns a EOFOption that sets the number of warnings.

type ERR added in v1.1.0

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

ERR represents a MySQL ERR packet.

func NewERR added in v1.1.0

func NewERR(opts ...ERROption) (*ERR, error)

NewERR returns a new ERR packet.

func NewERRFromError added in v1.1.0

func NewERRFromError(err error, opts ...ERROption) (*ERR, error)

NewERRFromError returns a new ERR packet with the error.

func NewERRFromReader added in v1.1.0

func NewERRFromReader(reader io.Reader, opts ...ERROption) (*ERR, error)

NewERRFromReader returns a new ERR packet from the reader.

func (*ERR) Bytes added in v1.1.0

func (pkt *ERR) Bytes() ([]byte, error)

Bytes returns a byte sequence of the ERR packet.

func (ERR) Capability added in v1.1.0

func (pkt ERR) Capability() Capability

Capabilitys returns the packet capability flags.

func (*ERR) Code added in v1.1.0

func (pkt *ERR) Code() uint16

Code returns the error code.

func (*ERR) ErrMsg added in v1.1.0

func (pkt *ERR) ErrMsg() string

ErrMsg returns the error message.

func (*ERR) Header added in v1.1.0

func (pkt *ERR) Header() uint8

Header returns the header.

func (ERR) HeaderBytes added in v1.3.0

func (pkt ERR) HeaderBytes() []byte

HeaderBytes returns the packet header bytes.

func (ERR) IsEOF added in v1.1.0

func (pkt ERR) IsEOF() bool

IsEOF returns true if the packet is an EOF packet.

func (ERR) Payload added in v1.1.0

func (pkt ERR) Payload() []byte

Payload returns the packet payload.

func (ERR) PayloadHeaderByte added in v1.3.0

func (pkt ERR) PayloadHeaderByte() (byte, error)

PayloadHeaderByte returns the payload header byte.

func (ERR) PayloadLength added in v1.1.0

func (pkt ERR) PayloadLength() uint32

PayloadLength returns the packet payload length.

func (ERR) ReadHeader added in v1.1.0

func (pkt ERR) ReadHeader() error

ReadHeader reads the packet header.

func (ERR) ReadPayload added in v1.1.0

func (pkt ERR) ReadPayload() error

ReadPayload reads the packet payload.

func (ERR) Reader added in v1.1.0

func (pkt ERR) Reader() *PacketReader

Reader returns the packet reader.

func (ERR) SequenceID added in v1.1.0

func (pkt ERR) SequenceID() SequenceID

SequenceID returns the packet sequence ID.

func (ERR) ServerStatus added in v1.3.0

func (pkt ERR) ServerStatus() ServerStatus

ServerStatus returns the packet server status.

func (ERR) SetCapability added in v1.1.0

func (pkt ERR) SetCapability(flags Capability)

SetCapabilitys sets the packet capability flags.

func (ERR) SetCapabilityDisabled added in v1.1.0

func (pkt ERR) SetCapabilityDisabled(flag Capability)

SetDisabled unsets the specified flag.

func (ERR) SetCapabilityEnabled added in v1.1.0

func (pkt ERR) SetCapabilityEnabled(flag Capability)

SetEnabled sets the specified flag.

func (ERR) SetOptions added in v1.1.0

func (pkt ERR) SetOptions(opts ...PacketOption)

SetOptions sets the options.

func (ERR) SetPayload added in v1.1.0

func (pkt ERR) SetPayload(payload []byte)

SetPayload sets the packet payload.

func (ERR) SetPayloadLength added in v1.3.0

func (pkt ERR) SetPayloadLength(l int)

SetPayloadLength sets only the payload length without the payload bytes.

func (ERR) SetSequenceID added in v1.1.0

func (pkt ERR) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

func (ERR) SetServerStatus added in v1.3.0

func (pkt ERR) SetServerStatus(status ServerStatus)

SetServerStatus sets the packet server status.

func (*ERR) State added in v1.1.0

func (pkt *ERR) State() ErrCode

State returns the state.

func (*ERR) StateMarker added in v1.1.0

func (pkt *ERR) StateMarker() string

StateMarker returns the state marker.

type ERROption added in v1.1.0

type ERROption func(*ERR) error

ERROption represents a MySQL ERR packet option.

func WithERRCapability added in v1.1.0

func WithERRCapability(c Capability) ERROption

WithERRCapability sets the error capability.

func WithERRCode added in v1.1.0

func WithERRCode(code uint16) ERROption

WithERRCode sets the error code.

func WithERRMessage added in v1.1.0

func WithERRMessage(errMsg string) ERROption

WithERRMessage sets the error message.

func WithERRSecuenceID added in v1.1.0

func WithERRSecuenceID(n SequenceID) ERROption

WithERRSecuenceID sets the sequence ID.

func WithERRState added in v1.1.0

func WithERRState(state string) ERROption

WithERRState sets the state.

type ErrCode added in v1.1.0

type ErrCode = sql.Code

ErrCode represents a standard error code.

type Field added in v1.3.0

type Field = stmt.Field

Field represents a field.

type FieldType added in v1.3.0

type FieldType = stmt.FieldType

FieldType represents a field type.

type GenericResponse added in v1.1.0

type GenericResponse interface {
	Header() uint8
}

func NewGenericResponseFromReader added in v1.1.0

func NewGenericResponseFromReader(r io.Reader, opts ...GenericResponseOption) (GenericResponse, error)

NewOKFromReader returns a new OK packet from the reader.

type GenericResponseOption added in v1.1.0

type GenericResponseOption func(*genericResponse)

GenericResponseOption represents a MySQL generic response option.

func WithGenericResponseCapability added in v1.1.0

func WithGenericResponseCapability(c Capability) GenericResponseOption

WithGenericResponseCapability returns a generic response option to set the capabilities.

type Handshake added in v1.1.0

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

Handshake represents a MySQL Handshake packet.

func NewHandshake added in v1.1.0

func NewHandshake(opts ...HandshakeOption) *Handshake

NewHandshake returns a new MySQL Handshake packet.

func NewHandshakeFromReader added in v1.1.0

func NewHandshakeFromReader(reader io.Reader) (*Handshake, error)

NewHandshakeFromReader returns a new MySQL Handshake packet from the specified reader.

func (*Handshake) AuthPluginData added in v1.1.0

func (pkt *Handshake) AuthPluginData() []byte

AuthPluginData returns the auth plugin data.

func (*Handshake) AuthPluginName added in v1.1.0

func (pkt *Handshake) AuthPluginName() string

AuthPluginName returns the auth plugin name.

func (*Handshake) Bytes added in v1.1.0

func (pkt *Handshake) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (Handshake) Capability added in v1.1.0

func (pkt Handshake) Capability() Capability

Capabilitys returns the packet capability flags.

func (*Handshake) CharacterSet added in v1.1.0

func (pkt *Handshake) CharacterSet() CharSet

CharacterSet returns the character set.

func (*Handshake) ConnectionID added in v1.1.0

func (pkt *Handshake) ConnectionID() uint32

ConnectionID returns the connection ID.

func (Handshake) HeaderBytes added in v1.3.0

func (pkt Handshake) HeaderBytes() []byte

HeaderBytes returns the packet header bytes.

func (Handshake) IsEOF added in v1.1.0

func (pkt Handshake) IsEOF() bool

IsEOF returns true if the packet is an EOF packet.

func (Handshake) Payload added in v1.1.0

func (pkt Handshake) Payload() []byte

Payload returns the packet payload.

func (Handshake) PayloadHeaderByte added in v1.3.0

func (pkt Handshake) PayloadHeaderByte() (byte, error)

PayloadHeaderByte returns the payload header byte.

func (Handshake) PayloadLength added in v1.1.0

func (pkt Handshake) PayloadLength() uint32

PayloadLength returns the packet payload length.

func (*Handshake) ProtocolVersion added in v1.1.0

func (pkt *Handshake) ProtocolVersion() ProtocolVersion

ProtocolVersion returns the protocol version.

func (Handshake) ReadHeader added in v1.1.0

func (pkt Handshake) ReadHeader() error

ReadHeader reads the packet header.

func (Handshake) ReadPayload added in v1.1.0

func (pkt Handshake) ReadPayload() error

ReadPayload reads the packet payload.

func (Handshake) Reader added in v1.1.0

func (pkt Handshake) Reader() *PacketReader

Reader returns the packet reader.

func (Handshake) SequenceID added in v1.1.0

func (pkt Handshake) SequenceID() SequenceID

SequenceID returns the packet sequence ID.

func (Handshake) ServerStatus added in v1.3.0

func (pkt Handshake) ServerStatus() ServerStatus

ServerStatus returns the packet server status.

func (*Handshake) ServerVersion added in v1.1.0

func (pkt *Handshake) ServerVersion() string

ServerVersion returns the server version.

func (Handshake) SetCapability added in v1.1.0

func (pkt Handshake) SetCapability(flags Capability)

SetCapabilitys sets the packet capability flags.

func (Handshake) SetCapabilityDisabled added in v1.1.0

func (pkt Handshake) SetCapabilityDisabled(flag Capability)

SetDisabled unsets the specified flag.

func (Handshake) SetCapabilityEnabled added in v1.1.0

func (pkt Handshake) SetCapabilityEnabled(flag Capability)

SetEnabled sets the specified flag.

func (Handshake) SetOptions added in v1.1.0

func (pkt Handshake) SetOptions(opts ...PacketOption)

SetOptions sets the options.

func (Handshake) SetPayload added in v1.1.0

func (pkt Handshake) SetPayload(payload []byte)

SetPayload sets the packet payload.

func (Handshake) SetPayloadLength added in v1.3.0

func (pkt Handshake) SetPayloadLength(l int)

SetPayloadLength sets only the payload length without the payload bytes.

func (Handshake) SetSequenceID added in v1.1.0

func (pkt Handshake) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

func (Handshake) SetServerStatus added in v1.3.0

func (pkt Handshake) SetServerStatus(status ServerStatus)

SetServerStatus sets the packet server status.

type HandshakeOption added in v1.1.0

type HandshakeOption func(*Handshake)

HandshakeOption represents a MySQL Handshake option.

func WithHandshakeAuthPluginData added in v1.1.0

func WithHandshakeAuthPluginData(v []byte) HandshakeOption

WithHandshakeAuthPluginData1 sets the auth plugin data.

func WithHandshakeAuthPluginName added in v1.1.0

func WithHandshakeAuthPluginName(v string) HandshakeOption

WithHandshakeAuthPluginData2 sets the auth plugin name.

func WithHandshakeCapability added in v1.1.0

func WithHandshakeCapability(v Capability) HandshakeOption

WithHandshakeCapability sets the capability flags.

func WithHandshakeCharacterSet added in v1.1.0

func WithHandshakeCharacterSet(v CharSet) HandshakeOption

WithHandshakeCharacterSet sets the character set.

func WithHandshakeConnectionID added in v1.1.0

func WithHandshakeConnectionID(v uint32) HandshakeOption

WithHandshakeConnectionID sets the connection ID.

func WithHandshakeProtocolVersion added in v1.1.0

func WithHandshakeProtocolVersion(v ProtocolVersion) HandshakeOption

WithHandshakeProtocolVersion sets the protocol version.

func WithHandshakeServerStatus added in v1.3.0

func WithHandshakeServerStatus(v ServerStatus) HandshakeOption

WithHandshakeServerStatus sets the status flags.

func WithHandshakeServerVersion added in v1.1.0

func WithHandshakeServerVersion(v string) HandshakeOption

WithHandshakeServerVersion sets the server version.

type HandshakeResponse added in v1.1.0

type HandshakeResponse struct {
	Capabilitys Capability

	*AttributeMap
	// contains filtered or unexported fields
}

HandshakeResponse represents a MySQL Handshake Response packet.

func NewHandshakeResponse added in v1.1.0

func NewHandshakeResponse(opts ...HandshakeResponseOption) *HandshakeResponse

NewHandshakeResponse returns a new HandshakeResponse.

func NewHandshakeResponseFromReader added in v1.1.0

func NewHandshakeResponseFromReader(reader io.Reader) (*HandshakeResponse, error)

NewHandshakeResponseFromReader returns a new HandshakeResponse from the reader.

func (*HandshakeResponse) AutMethod added in v1.2.0

func (pkt *HandshakeResponse) AutMethod() (auth.AuthMethod, error)

AutMethod returns the authentication method.

func (*HandshakeResponse) AuthResponse added in v1.1.0

func (pkt *HandshakeResponse) AuthResponse() []byte

AuthResponse returns the auth response.

func (*HandshakeResponse) Bytes added in v1.1.0

func (pkt *HandshakeResponse) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (*HandshakeResponse) Capability added in v1.1.0

func (pkt *HandshakeResponse) Capability() Capability

Capabilitys returns the capability flags.

func (*HandshakeResponse) CharSet added in v1.1.0

func (pkt *HandshakeResponse) CharSet() uint8

CharSet returns the character set.

func (*HandshakeResponse) ClientPluginName added in v1.1.0

func (pkt *HandshakeResponse) ClientPluginName() string

ClientPluginName returns the client plugin name.

func (*HandshakeResponse) Database added in v1.1.0

func (pkt *HandshakeResponse) Database() string

Database returns the database.

func (HandshakeResponse) HeaderBytes added in v1.3.0

func (pkt HandshakeResponse) HeaderBytes() []byte

HeaderBytes returns the packet header bytes.

func (HandshakeResponse) IsEOF added in v1.1.0

func (pkt HandshakeResponse) IsEOF() bool

IsEOF returns true if the packet is an EOF packet.

func (*HandshakeResponse) MaxPacketSize added in v1.1.0

func (pkt *HandshakeResponse) MaxPacketSize() uint32

MaxPacketSize returns the max packet size.

func (HandshakeResponse) Payload added in v1.1.0

func (pkt HandshakeResponse) Payload() []byte

Payload returns the packet payload.

func (HandshakeResponse) PayloadHeaderByte added in v1.3.0

func (pkt HandshakeResponse) PayloadHeaderByte() (byte, error)

PayloadHeaderByte returns the payload header byte.

func (HandshakeResponse) PayloadLength added in v1.1.0

func (pkt HandshakeResponse) PayloadLength() uint32

PayloadLength returns the packet payload length.

func (HandshakeResponse) ReadHeader added in v1.1.0

func (pkt HandshakeResponse) ReadHeader() error

ReadHeader reads the packet header.

func (HandshakeResponse) ReadPayload added in v1.1.0

func (pkt HandshakeResponse) ReadPayload() error

ReadPayload reads the packet payload.

func (HandshakeResponse) Reader added in v1.1.0

func (pkt HandshakeResponse) Reader() *PacketReader

Reader returns the packet reader.

func (HandshakeResponse) SequenceID added in v1.1.0

func (pkt HandshakeResponse) SequenceID() SequenceID

SequenceID returns the packet sequence ID.

func (HandshakeResponse) ServerStatus added in v1.3.0

func (pkt HandshakeResponse) ServerStatus() ServerStatus

ServerStatus returns the packet server status.

func (HandshakeResponse) SetCapability added in v1.1.0

func (pkt HandshakeResponse) SetCapability(flags Capability)

SetCapabilitys sets the packet capability flags.

func (HandshakeResponse) SetCapabilityDisabled added in v1.1.0

func (pkt HandshakeResponse) SetCapabilityDisabled(flag Capability)

SetDisabled unsets the specified flag.

func (HandshakeResponse) SetCapabilityEnabled added in v1.1.0

func (pkt HandshakeResponse) SetCapabilityEnabled(flag Capability)

SetEnabled sets the specified flag.

func (HandshakeResponse) SetOptions added in v1.1.0

func (pkt HandshakeResponse) SetOptions(opts ...PacketOption)

SetOptions sets the options.

func (HandshakeResponse) SetPayload added in v1.1.0

func (pkt HandshakeResponse) SetPayload(payload []byte)

SetPayload sets the packet payload.

func (HandshakeResponse) SetPayloadLength added in v1.3.0

func (pkt HandshakeResponse) SetPayloadLength(l int)

SetPayloadLength sets only the payload length without the payload bytes.

func (HandshakeResponse) SetSequenceID added in v1.1.0

func (pkt HandshakeResponse) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

func (HandshakeResponse) SetServerStatus added in v1.3.0

func (pkt HandshakeResponse) SetServerStatus(status ServerStatus)

SetServerStatus sets the packet server status.

func (*HandshakeResponse) Username added in v1.1.0

func (pkt *HandshakeResponse) Username() string

Username returns the username.

func (*HandshakeResponse) ZstdCompressionLevel added in v1.1.0

func (pkt *HandshakeResponse) ZstdCompressionLevel() uint8

ZstdCompressionLevel returns the Zstd compression level.

type HandshakeResponseOption added in v1.1.0

type HandshakeResponseOption func(*HandshakeResponse)

HandshakeResponseOption represents a HandshakeResponse option.

type Message

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

Message represents a MySQL message.

func (*Message) Length added in v1.3.0

func (msg *Message) Length() uint32

Length returns the message length.

func (*Message) Payload

func (msg *Message) Payload() []byte

Payload returns the message payload.

func (*Message) Type added in v1.3.0

func (msg *Message) Type() uint8

Type returns the message type.

type NullBitmap added in v1.3.0

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

NullBitmap represents a MySQL null bitmap.

func NewNullBitmap added in v1.3.0

func NewNullBitmap(opts ...NullBitmapOption) *NullBitmap

NewNullBitmap creates a new NullBitmap with the given length.

func (*NullBitmap) Bytes added in v1.3.0

func (bmap *NullBitmap) Bytes() []byte

Bytes returns the bytes of the NullBitmap.

func (*NullBitmap) IsNull added in v1.3.0

func (bmap *NullBitmap) IsNull(i int) bool

IsNull returns true if the i-th bit is null.

func (*NullBitmap) NumFields added in v1.3.0

func (bmap *NullBitmap) NumFields() int

NumFields returns the number of fields of the NullBitmap.

func (*NullBitmap) Offset added in v1.3.0

func (bmap *NullBitmap) Offset() int

Offset returns the offset of the NullBitmap.

func (*NullBitmap) SetNull added in v1.3.0

func (bmap *NullBitmap) SetNull(i int, v bool)

SetNull sets the null value of the NullBitmap.

func (*NullBitmap) SetNumFields added in v1.3.0

func (bmap *NullBitmap) SetNumFields(numFields int)

SetNumFields sets the number of fields of the NullBitmap.

func (*NullBitmap) SetOffset added in v1.3.0

func (bmap *NullBitmap) SetOffset(offset int)

SetOffset sets the offset of the NullBitmap.

type NullBitmapOption added in v1.3.0

type NullBitmapOption func(*NullBitmap)

NullBitmapOption represents a MySQL NullBitmap option.

func WithNullBitmapBytes added in v1.3.0

func WithNullBitmapBytes(bytes []byte) NullBitmapOption

WithNullBitmapBytes sets the bytes of the NullBitmap.

func WithNullBitmapNumFields added in v1.3.0

func WithNullBitmapNumFields(numFields int) NullBitmapOption

WithNullBitmapNumFields sets the number of fields of the NullBitmap.

func WithNullBitmapOffset added in v1.3.0

func WithNullBitmapOffset(offset int) NullBitmapOption

WithNullBitmapOffset sets the offset of the NullBitmap.

type OK added in v1.1.0

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

OK represents a MySQL OK packet.

func NewOK added in v1.1.0

func NewOK(opts ...OKOption) (*OK, error)

NewOK returns a new OK packet.

func NewOKFromReader added in v1.1.0

func NewOKFromReader(reader io.Reader, opts ...OKOption) (*OK, error)

NewOKFromReader returns a new OK packet from the reader.

func (*OK) AffectedRows added in v1.1.0

func (pkt *OK) AffectedRows() uint64

AffectedRows returns the number of affected rows.

func (*OK) Bytes added in v1.1.0

func (pkt *OK) Bytes() ([]byte, error)

Bytes returns a byte sequence of the OK packet.

func (OK) Capability added in v1.1.0

func (pkt OK) Capability() Capability

Capabilitys returns the packet capability flags.

func (*OK) Err added in v1.1.0

func (pkt *OK) Err() bool

Err returns true if the packet is an ERR packet.

func (*OK) Header added in v1.1.0

func (pkt *OK) Header() uint8

Header returns the header.

func (OK) HeaderBytes added in v1.3.0

func (pkt OK) HeaderBytes() []byte

HeaderBytes returns the packet header bytes.

func (*OK) Info added in v1.1.0

func (pkt *OK) Info() string

Info returns the info.

func (OK) IsEOF added in v1.1.0

func (pkt OK) IsEOF() bool

IsEOF returns true if the packet is an EOF packet.

func (*OK) LastInsertID added in v1.1.0

func (pkt *OK) LastInsertID() uint64

LastInsertID returns the last insert ID.

func (*OK) OK added in v1.1.0

func (pkt *OK) OK() bool

OK returns true if the packet is an OK packet.

func (OK) Payload added in v1.1.0

func (pkt OK) Payload() []byte

Payload returns the packet payload.

func (OK) PayloadHeaderByte added in v1.3.0

func (pkt OK) PayloadHeaderByte() (byte, error)

PayloadHeaderByte returns the payload header byte.

func (OK) PayloadLength added in v1.1.0

func (pkt OK) PayloadLength() uint32

PayloadLength returns the packet payload length.

func (OK) ReadHeader added in v1.1.0

func (pkt OK) ReadHeader() error

ReadHeader reads the packet header.

func (OK) ReadPayload added in v1.1.0

func (pkt OK) ReadPayload() error

ReadPayload reads the packet payload.

func (OK) Reader added in v1.1.0

func (pkt OK) Reader() *PacketReader

Reader returns the packet reader.

func (OK) SequenceID added in v1.1.0

func (pkt OK) SequenceID() SequenceID

SequenceID returns the packet sequence ID.

func (OK) ServerStatus added in v1.3.0

func (pkt OK) ServerStatus() ServerStatus

ServerStatus returns the packet server status.

func (*OK) SessionStateInfo added in v1.1.0

func (pkt *OK) SessionStateInfo() string

SessionStateInfo returns the session state info.

func (OK) SetCapability added in v1.1.0

func (pkt OK) SetCapability(flags Capability)

SetCapabilitys sets the packet capability flags.

func (OK) SetCapabilityDisabled added in v1.1.0

func (pkt OK) SetCapabilityDisabled(flag Capability)

SetDisabled unsets the specified flag.

func (OK) SetCapabilityEnabled added in v1.1.0

func (pkt OK) SetCapabilityEnabled(flag Capability)

SetEnabled sets the specified flag.

func (OK) SetOptions added in v1.1.0

func (pkt OK) SetOptions(opts ...PacketOption)

SetOptions sets the options.

func (OK) SetPayload added in v1.1.0

func (pkt OK) SetPayload(payload []byte)

SetPayload sets the packet payload.

func (OK) SetPayloadLength added in v1.3.0

func (pkt OK) SetPayloadLength(l int)

SetPayloadLength sets only the payload length without the payload bytes.

func (OK) SetSequenceID added in v1.1.0

func (pkt OK) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

func (OK) SetServerStatus added in v1.3.0

func (pkt OK) SetServerStatus(status ServerStatus)

SetServerStatus sets the packet server status.

func (*OK) Warnings added in v1.1.0

func (pkt *OK) Warnings() uint16

Warnings returns the number of warnings.

type OKOption added in v1.1.0

type OKOption func(*OK)

OKOption represents a MySQL OK packet option.

func WithOKAffectedRows added in v1.1.0

func WithOKAffectedRows(v uint64) OKOption

WithOKAffectedRows returns a OKOption that sets the number of affected rows.

func WithOKCapability added in v1.1.0

func WithOKCapability(c Capability) OKOption

WithOKCapability returns a OKOption that sets the capability flag.

func WithOKLastInsertID added in v1.1.0

func WithOKLastInsertID(v uint64) OKOption

WithOKLastInsertID returns a OKOption that sets the last insert ID.

func WithOKSecuenceID added in v1.1.0

func WithOKSecuenceID(n SequenceID) OKOption

WithOKSecuenceID returns a OKOption that sets the sequence ID.

func WithOKServerStatus added in v1.3.0

func WithOKServerStatus(v ServerStatus) OKOption

WithOKServerStatus returns a OKOption that sets the server status flag.

func WithOKWarnings added in v1.1.0

func WithOKWarnings(v uint16) OKOption

WithOKWarnings returns a OKOption that sets the number of warnings.

type Packet added in v1.1.0

type Packet interface {
	PacketIdentifier
	// SetSequenceID sets the packet sequence ID.
	SetSequenceID(n SequenceID)
	// SetPayload sets the packet payload.
	SetPayload(payload []byte)
	// SetPayloadLength sets only the payload length without the payload bytes.
	SetPayloadLength(l int)
	// SetCapability sets the packet capability flags.
	SetCapability(Capability)
	// SetServerStatus sets the packet server status.
	SetServerStatus(ServerStatus)
	// SequenceID returns the packet sequence ID.
	SequenceID() SequenceID
	// PayloadLength returns the packet payload length.
	PayloadLength() uint32
	// Payload returns the packet payload.
	Payload() []byte
	// Capability returns the packet capability flags.
	Capability() Capability
	// ServerStatus returns the packet server status.
	ServerStatus() ServerStatus
	// Reader returns the packet reader.
	Reader() *PacketReader
	// Bytes returns the packet bytes.
	Bytes() ([]byte, error)
}

Packet represents a MySQL packet.

type PacketIdentifier added in v1.1.0

type PacketIdentifier interface {
	IsEOF() bool
}

PacketIdentifier represents a MySQL packet identifier.

type PacketOption added in v1.1.0

type PacketOption func(Packet)

PacketOption represents a packet option.

func WithPacketCapability added in v1.1.0

func WithPacketCapability(flags Capability) PacketOption

WithPacketCapability returns a packet option to set the capability flags.

func WithPacketPayload added in v1.1.0

func WithPacketPayload(payload []byte) PacketOption

WithPacketPayload returns a packet option to set the payload.

func WithPacketSequenceID added in v1.1.0

func WithPacketSequenceID(n SequenceID) PacketOption

WithPacketSequenceID returns a packet option to set the sequence ID.

func WithPacketServerStatus added in v1.3.0

func WithPacketServerStatus(status ServerStatus) PacketOption

WithPacketServerStatus returns a packet option to set the server status.

type PacketReader added in v1.1.0

type PacketReader struct {
	*binary.Reader
}

PacketReader represents a packet reader of MySQL protocol.

func NewPacketReaderWithBytes added in v1.3.0

func NewPacketReaderWithBytes(data []byte) *PacketReader

NewPacketReaderWithBytes returns a new packet reader with the specified bytes.

func NewPacketReaderWithReader added in v1.3.0

func NewPacketReaderWithReader(reader io.Reader) *PacketReader

NewPacketReaderWithReader returns a new packet reader with the specified reader.

func (*PacketReader) PeekCapability added in v1.1.0

func (reader *PacketReader) PeekCapability() (Capability, error)

PeekCapabilitys reads the capability flags.

func (*PacketReader) ReadCapability added in v1.1.0

func (reader *PacketReader) ReadCapability() (Capability, error)

ReadCapabilitys reads the capability flags.

func (*PacketReader) ReadDatetimeBytes added in v1.3.0

func (reader *PacketReader) ReadDatetimeBytes() ([]byte, error)

ReadFieldBytes reads the field bytes.

func (*PacketReader) ReadFieldBytes added in v1.3.0

func (reader *PacketReader) ReadFieldBytes(t FieldType) ([]byte, error)

ReadFieldBytes reads the field bytes.

func (*PacketReader) ReadFieldValue added in v1.3.0

func (reader *PacketReader) ReadFieldValue(t FieldType) (any, error)

ReadFieldValue reads the field value.

type PacketWriter added in v1.1.0

type PacketWriter struct {
	*binary.Writer
}

PacketWriter represents a packet writer of MySQL protocol.

func NewPacketWriter added in v1.1.0

func NewPacketWriter() *PacketWriter

NewPacketWriter returns a new packet writer.

func (*PacketWriter) WriteCapability added in v1.1.0

func (w *PacketWriter) WriteCapability(c Capability) error

WriteCapabilitys writes the capability flags.

func (*PacketWriter) WriteCommandType added in v1.1.0

func (w *PacketWriter) WriteCommandType(cmd Command) error

WriteCommandType writes a command type.

func (*PacketWriter) WriteEOF added in v1.1.0

func (w *PacketWriter) WriteEOF(opts ...any) error

WriteEOF writes a EOF packet.

func (*PacketWriter) WriteErr added in v1.1.0

func (w *PacketWriter) WriteErr(opts ...any) error

WriteErr writes a ERR packet.

func (*PacketWriter) WriteFieldBytes added in v1.3.0

func (w *PacketWriter) WriteFieldBytes(t FieldType, v []byte) error

WriteFieldBytes writes a field bytes.

func (*PacketWriter) WriteFieldValue added in v1.3.0

func (w *PacketWriter) WriteFieldValue(t FieldType, v any) error

WriteFieldValue writes a field value.

func (*PacketWriter) WriteFillerBytes added in v1.1.0

func (w *PacketWriter) WriteFillerBytes(b byte, n int) error

WriteFillerBytes writes the filler bytes.

func (*PacketWriter) WriteOK added in v1.1.0

func (w *PacketWriter) WriteOK(opts ...any) error

WriteOK writes a OK packet.

func (*PacketWriter) WritePacket added in v1.1.0

func (w *PacketWriter) WritePacket(pkt Response) error

WritePacket writes a packet.

type ProtocolVersion added in v1.1.0

type ProtocolVersion uint8

ProtocolVersion represents a MySQL Protocol Version.

const (
	ProtocolVersion10 ProtocolVersion = 10
)

type Query added in v1.1.0

type Query struct {
	Command
	// contains filtered or unexported fields
}

Query represents a COM_QUERY packet.

func NewQuery added in v1.1.0

func NewQuery(opts ...QueryOption) (*Query, error)

NewQuery returns a new MySQL Query packet.

func NewQueryFromCommand added in v1.1.0

func NewQueryFromCommand(cmd Command, opts ...QueryOption) (*Query, error)

NewQueryFromCommand returns a new MySQL Query packet from the specified command.

func NewQueryFromReader added in v1.1.0

func NewQueryFromReader(reader io.Reader, opts ...QueryOption) (*Query, error)

NewQueryFromReader returns a new MySQL Query packet from the specified reader.

func (*Query) Bytes added in v1.1.0

func (pkt *Query) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (*Query) Query added in v1.1.0

func (pkt *Query) Query() string

Query returns the query.

type QueryOption added in v1.1.0

type QueryOption func(*Query)

QueryOption represents a MySQL Query option.

func WithQueryCapability added in v1.3.0

func WithQueryCapability(c Capability) QueryOption

WithQueryCapabilities returns a QueryOption that sets the capabilities.

func WithQueryString added in v1.1.0

func WithQueryString(v string) QueryOption

WithQuery returns a QueryOption that sets the query.

type QueryParameter added in v1.1.0

type QueryParameter struct {
	Type uint16
	Name string
}

QueryParameter represents a COM_QUERY parameter.

type Response added in v1.1.0

type Response interface {
	// SetCapability sets the capability flags.
	SetCapability(Capability)
	// SetSequenceID sets the sequence ID.
	SetSequenceID(SequenceID)
	// Bytes returns the packet bytes.
	Bytes() ([]byte, error)
}

Response represents a response.

func NewResponseWithError added in v1.1.0

func NewResponseWithError(err error) (Response, error)

NewResponseWithError returns a new response with the specified error.

type ResponseOption added in v1.1.0

type ResponseOption func(Response)

ResponseOption represents a response option.

func WithResponseCapability added in v1.1.0

func WithResponseCapability(c Capability) ResponseOption

WithResponseCapability returns a response option to set the capability.

func WithResponseSequenceID added in v1.1.0

func WithResponseSequenceID(s SequenceID) ResponseOption

WithResponseSequenceID returns a response option to set the sequence ID.

type ResultSetRow added in v1.1.0

type ResultSetRow interface {
	SetSequenceID(n SequenceID)
	Columns() []any
	Bytes() ([]byte, error)
}

ResultSetRow represents a MySQL resultset row.

func NewTextResultSetRowFrom added in v1.1.0

func NewTextResultSetRowFrom(schema sql.ResultSetSchema, rsRow sql.ResultSetRow) (ResultSetRow, error)

NewTextResultSetRowFrom returns a new ResultSetRow from the specified ResultSetSchema and ResultSetRow.

func NewTextResultSetRowsFromResultSet added in v1.1.0

func NewTextResultSetRowsFromResultSet(rs sql.ResultSet) ([]ResultSetRow, error)

NewTextResultSetRowsFromResultSet returns a new ResultSetRow list from the specified ResultSet.

type ResultsetMetadata added in v1.1.0

type ResultsetMetadata = uint8
const (
	// ResultsetMetadataNone represents the MYSQL_RESULT_METADATA_NONE.
	ResultsetMetadataNone ResultsetMetadata = 0
	// ResultsetMetadataFull represents the MYSQL_RESULT_METADATA_FULL.
	ResultsetMetadataFull ResultsetMetadata = 1
)

type SSLRequest added in v1.1.0

type SSLRequest struct {
	Capabilitys Capability
	// contains filtered or unexported fields
}

SSLRequest represents a MySQL SSLRequest packet.

func NewSSLRequest added in v1.1.0

func NewSSLRequest(opts ...SSLRequestOption) (*SSLRequest, error)

NewSSLRequest returns a new MySQL SSLRequest packet.

func NewSSLRequestFromReader added in v1.1.0

func NewSSLRequestFromReader(reader io.Reader) (*SSLRequest, error)

NewSSLRequestFromReader returns a new MySQL SSLRequest packet from the specified reader.

func (*SSLRequest) Bytes added in v1.1.0

func (pkt *SSLRequest) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (*SSLRequest) Capability added in v1.1.0

func (pkt *SSLRequest) Capability() Capability

Capabilitys returns the capability flags.

func (*SSLRequest) CharacterSet added in v1.1.0

func (pkt *SSLRequest) CharacterSet() CharSet

CharacterSet returns the character set.

func (SSLRequest) HeaderBytes added in v1.3.0

func (pkt SSLRequest) HeaderBytes() []byte

HeaderBytes returns the packet header bytes.

func (SSLRequest) IsEOF added in v1.1.0

func (pkt SSLRequest) IsEOF() bool

IsEOF returns true if the packet is an EOF packet.

func (SSLRequest) Payload added in v1.1.0

func (pkt SSLRequest) Payload() []byte

Payload returns the packet payload.

func (SSLRequest) PayloadHeaderByte added in v1.3.0

func (pkt SSLRequest) PayloadHeaderByte() (byte, error)

PayloadHeaderByte returns the payload header byte.

func (SSLRequest) PayloadLength added in v1.1.0

func (pkt SSLRequest) PayloadLength() uint32

PayloadLength returns the packet payload length.

func (SSLRequest) ReadHeader added in v1.1.0

func (pkt SSLRequest) ReadHeader() error

ReadHeader reads the packet header.

func (SSLRequest) ReadPayload added in v1.1.0

func (pkt SSLRequest) ReadPayload() error

ReadPayload reads the packet payload.

func (SSLRequest) Reader added in v1.1.0

func (pkt SSLRequest) Reader() *PacketReader

Reader returns the packet reader.

func (SSLRequest) SequenceID added in v1.1.0

func (pkt SSLRequest) SequenceID() SequenceID

SequenceID returns the packet sequence ID.

func (SSLRequest) ServerStatus added in v1.3.0

func (pkt SSLRequest) ServerStatus() ServerStatus

ServerStatus returns the packet server status.

func (SSLRequest) SetCapability added in v1.1.0

func (pkt SSLRequest) SetCapability(flags Capability)

SetCapabilitys sets the packet capability flags.

func (SSLRequest) SetCapabilityDisabled added in v1.1.0

func (pkt SSLRequest) SetCapabilityDisabled(flag Capability)

SetDisabled unsets the specified flag.

func (SSLRequest) SetCapabilityEnabled added in v1.1.0

func (pkt SSLRequest) SetCapabilityEnabled(flag Capability)

SetEnabled sets the specified flag.

func (SSLRequest) SetOptions added in v1.1.0

func (pkt SSLRequest) SetOptions(opts ...PacketOption)

SetOptions sets the options.

func (SSLRequest) SetPayload added in v1.1.0

func (pkt SSLRequest) SetPayload(payload []byte)

SetPayload sets the packet payload.

func (SSLRequest) SetPayloadLength added in v1.3.0

func (pkt SSLRequest) SetPayloadLength(l int)

SetPayloadLength sets only the payload length without the payload bytes.

func (SSLRequest) SetSequenceID added in v1.1.0

func (pkt SSLRequest) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

func (SSLRequest) SetServerStatus added in v1.3.0

func (pkt SSLRequest) SetServerStatus(status ServerStatus)

SetServerStatus sets the packet server status.

type SSLRequestOption added in v1.1.0

type SSLRequestOption func(*SSLRequest) error

SSLRequestOption represents a MySQL SSLRequest option.

func WithSSLRequestCapability added in v1.1.0

func WithSSLRequestCapability(v Capability) SSLRequestOption

WithSSLRequestCapabilitys sets the capability flags.

func WithSSLRequestCharacterSet added in v1.1.0

func WithSSLRequestCharacterSet(v CharSet) SSLRequestOption

WithSSLRequestCharacterSet sets the character set.

type SequenceID added in v1.1.0

type SequenceID uint8

SequenceID represents a MySQL packet sequence ID.

func (SequenceID) Next added in v1.1.0

func (n SequenceID) Next() SequenceID

Next returns the next sequence ID.

type Server added in v1.1.0

type Server struct {
	Config
	auth.Manager
	mysqlnet.ConnManager
	tracer.Tracer

	CommandHandler
	// contains filtered or unexported fields
}

Server represents a MySQL protocol server.

func NewServer added in v1.1.0

func NewServer() *Server

NewServer returns a new server instance.

func (*Server) Capability added in v1.1.2

func (server *Server) Capability() Capability

Capability returns the capability flags from the configuration.

func (*Server) GenerateHandshakeForConn added in v1.1.0

func (server *Server) GenerateHandshakeForConn(conn mysqlnet.Conn) (*Handshake, error)

GenerateHandshakeForConn returns a handshake packet for the specified connection and server status.

func (*Server) Restart added in v1.1.0

func (server *Server) Restart() error

Restart restarts the server.

func (*Server) SetCommandHandler added in v1.1.0

func (server *Server) SetCommandHandler(h CommandHandler)

SetCommandHandler sets a command handler.

func (*Server) SetTracer added in v1.1.0

func (server *Server) SetTracer(t tracer.Tracer)

SetTracer sets a tracing tracer.

func (*Server) Start added in v1.1.0

func (server *Server) Start() error

Start starts the server.

func (*Server) Stop added in v1.1.0

func (server *Server) Stop() error

Stop stops the server.

type ServerStatus added in v1.3.0

type ServerStatus uint16

ServerStatus represents a MySQL server status flag.

const (
	ServerStatusInTrans            ServerStatus = 1
	ServerStatusAutocommit         ServerStatus = 2
	ServerMoreResultsExists        ServerStatus = 8
	ServerQueryNoGoodIndexUsed     ServerStatus = 16
	ServerQueryNoIndexUsed         ServerStatus = 32
	ServerStatusCursorExists       ServerStatus = 64
	ServerStatusLastRowSent        ServerStatus = 128
	ServerStatusDBDropped          ServerStatus = 256
	ServerStatusNoBackslashEscapes ServerStatus = 512
	ServerStatusMetadataChanged    ServerStatus = 1024
	ServerQueryWasSlow             ServerStatus = 2048
	ServerPsOutParams              ServerStatus = 4096
	ServerStatusInTransReadonly    ServerStatus = 8192
	ServerSessionStateChanged      ServerStatus = (1 << 14)
)

func (ServerStatus) IsEnabled added in v1.3.0

func (statFlag ServerStatus) IsEnabled(flag ServerStatus) bool

IsEnabled returns true if the status flag is enabled.

type StatementBindSendType added in v1.3.0

type StatementBindSendType uint8

StatementBindSendType represents a statement bind send type.

const (
	// StatementBindSendTypeToServer represents a statement bind send type to server.
	StatementBindSendTypeToServer StatementBindSendType = 0x01
)

func (StatementBindSendType) IsToServer added in v1.3.0

func (t StatementBindSendType) IsToServer() bool

IsToServer returns true if the statement bind send type is to server.

type StatementID added in v1.3.0

type StatementID = stmt.StatementID

StatementID is the type of statement ID.

type Status added in v1.3.0

type Status uint8

Status represents a status.

const (
	// StatusOK represents OK status.
	StatusOK Status = 0x00
)

func (Status) IsOk added in v1.3.0

func (s Status) IsOk() bool

IsOk returns true if the status is OK.

type StmtClose added in v1.3.0

type StmtClose struct {
	Command
	// contains filtered or unexported fields
}

StmtClose represents a COM_STMT_CLOSE packet.

func NewStmtCloseFromCommand added in v1.3.0

func NewStmtCloseFromCommand(cmd Command, opts ...StmtCloseOption) (*StmtClose, error)

NewStmtCloseFromCommand creates a new StmtClose from a Command.

func NewStmtCloseFromReader added in v1.3.0

func NewStmtCloseFromReader(reader io.Reader, opts ...StmtCloseOption) (*StmtClose, error)

NewStmtCloseFromReader reads a COM_STMT_CLOSE packet.

func (*StmtClose) Bytes added in v1.3.0

func (pkt *StmtClose) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (*StmtClose) StatementID added in v1.3.0

func (pkt *StmtClose) StatementID() StatementID

StatementID returns the statement ID.

type StmtCloseOption added in v1.3.0

type StmtCloseOption func(*StmtClose)

StmtCloseOption represents a MySQL StmtClose option.

func WithStmtCloseStatementID added in v1.3.0

func WithStmtCloseStatementID(stmdID StatementID) StmtCloseOption

WithStmtCloseStatementID sets the statement ID.

type StmtExecute added in v1.3.0

type StmtExecute struct {
	Command
	// contains filtered or unexported fields
}

StmtExecute represents a COM_STMT_EXECUTE packet.

func NewStmtExecuteFromCommand added in v1.3.0

func NewStmtExecuteFromCommand(cmd Command, opts ...StmtExecuteOption) (*StmtExecute, error)

NewStmtExecuteFromCommand creates a new StmtExecute from a Command.

func NewStmtExecuteFromReader added in v1.3.0

func NewStmtExecuteFromReader(reader io.Reader, opts ...StmtExecuteOption) (*StmtExecute, error)

NewStmtExecuteFromReader reads a COM_STMT_EXECUTE packet.

func (*StmtExecute) Bytes added in v1.3.0

func (pkt *StmtExecute) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (*StmtExecute) CursorType added in v1.3.0

func (pkt *StmtExecute) CursorType() CursorType

CursorType returns the cursor type.

func (*StmtExecute) Parameters added in v1.3.0

func (pkt *StmtExecute) Parameters() []stmt.Parameter

Parameters returns the parameters.

func (*StmtExecute) StatementID added in v1.3.0

func (pkt *StmtExecute) StatementID() StatementID

StatementID returns the statement ID.

type StmtExecuteOption added in v1.3.0

type StmtExecuteOption func(*StmtExecute)

StmtExecuteOption represents a MySQL StmtExecute option.

func WithStmtExecuteBindSendType added in v1.3.0

func WithStmtExecuteBindSendType(bindSendType StatementBindSendType) StmtExecuteOption

WithStmtExecuteBindSendType sets the bind send type.

func WithStmtExecuteCursorType added in v1.3.0

func WithStmtExecuteCursorType(cursorType CursorType) StmtExecuteOption

WithStmtExecuteCursorType sets the cursor type.

func WithStmtExecuteIterationCount added in v1.3.0

func WithStmtExecuteIterationCount(iterCnt uint32) StmtExecuteOption

WithStmtExecuteIterationCount sets the iteration count.

func WithStmtExecuteNullBitmap added in v1.3.0

func WithStmtExecuteNullBitmap(nullBitmap *NullBitmap) StmtExecuteOption

WithStmtExecuteNullBitmap sets the null bitmap.

func WithStmtExecuteNumParams added in v1.3.0

func WithStmtExecuteNumParams(numParams uint16) StmtExecuteOption

WithStmtExecuteNumParams sets the number of parameters.

func WithStmtExecuteStatementCapability added in v1.3.0

func WithStmtExecuteStatementCapability(c Capability) StmtExecuteOption

WithStmtExecuteStatementCapability sets the statement capability.

func WithStmtExecuteStatementID added in v1.3.0

func WithStmtExecuteStatementID(stmdID StatementID) StmtExecuteOption

WithStmtExecuteStatementID sets the statement ID.

func WithStmtExecuteStatementManager added in v1.3.0

func WithStmtExecuteStatementManager(stmtMgr stmt.StatementManager) StmtExecuteOption

WithStmtExecuteBindSendType sets the bind send type.

type StmtPrepare added in v1.3.0

type StmtPrepare struct {
	Command
	// contains filtered or unexported fields
}

StmtPrepare represents a COM_STMT_PREPARE packet.

func NewStmtPrepareFromCommand added in v1.3.0

func NewStmtPrepareFromCommand(cmd Command, opts ...StmtPrepareOption) (*StmtPrepare, error)

NewStmtPrepareFromCommand creates a new StmtPrepare from a Command.

func NewStmtPrepareFromReader added in v1.3.0

func NewStmtPrepareFromReader(reader io.Reader, opts ...StmtPrepareOption) (*StmtPrepare, error)

NewStmtPrepareFromReader reads a COM_STMT_PREPARE packet.

func (*StmtPrepare) Bytes added in v1.3.0

func (pkt *StmtPrepare) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (*StmtPrepare) DatabaseName added in v1.3.0

func (pkt *StmtPrepare) DatabaseName() string

DatabaseName returns the database name.

func (*StmtPrepare) ParameterColumnNames added in v1.3.0

func (pkt *StmtPrepare) ParameterColumnNames() []string

SetParameterColumnNames sets the parameter column names.

func (*StmtPrepare) Query added in v1.3.0

func (pkt *StmtPrepare) Query() string

Query returns the query string.

func (*StmtPrepare) ResultSetColumnNames added in v1.3.0

func (pkt *StmtPrepare) ResultSetColumnNames() []string

SetResultSetColumnNames sets the result set column names.

func (*StmtPrepare) Statement added in v1.3.0

func (pkt *StmtPrepare) Statement() query.Statement

Statement returns the statement.

func (*StmtPrepare) TableNames added in v1.3.0

func (pkt *StmtPrepare) TableNames() []string

TableNames returns the table names.

type StmtPrepareOption added in v1.3.0

type StmtPrepareOption func(*StmtPrepare)

StmtPrepareOption represents a MySQL StmtPrepare option.

func WithStmtPrepareCapability added in v1.3.0

func WithStmtPrepareCapability(c Capability) StmtPrepareOption

WithStmtPrepareCapability sets the capability.

func WithStmtPrepareDatabase added in v1.3.0

func WithStmtPrepareDatabase(dbName string) StmtPrepareOption

WithStmtPrepareDatabase sets the database name.

func WithStmtPrepareQuery added in v1.3.0

func WithStmtPrepareQuery(query string) StmtPrepareOption

WithStmtPrepareQuery sets the query string.

func WithStmtPrepareServerStatus added in v1.3.0

func WithStmtPrepareServerStatus(s ServerStatus) StmtPrepareOption

WithStmtPrepareServerStatus sets the server status.

type StmtPrepareResponse added in v1.3.0

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

StmtPrepareResponse represents a MySQL Prepare Response packet.

func NewStmtPrepareResponse added in v1.3.0

func NewStmtPrepareResponse(opts ...StmtPrepareResponseOption) *StmtPrepareResponse

NewStmtPrepareResponse returns a new StmtPrepareResponse.

func NewStmtPrepareResponseFromBytes added in v1.3.0

func NewStmtPrepareResponseFromBytes(data []byte, opts ...StmtPrepareResponseOption) (*StmtPrepareResponse, error)

NewStmtPrepareResponseFromBytes returns a new StmtPrepareResponse from the bytes.

func NewStmtPrepareResponseFromReader added in v1.3.0

func NewStmtPrepareResponseFromReader(reader io.Reader, opts ...StmtPrepareResponseOption) (*StmtPrepareResponse, error)

NewStmtPrepareResponseFromReader returns a new StmtPrepareResponse from the reader.

func (*StmtPrepareResponse) Bytes added in v1.3.0

func (pkt *StmtPrepareResponse) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (StmtPrepareResponse) Capability added in v1.3.0

func (pkt StmtPrepareResponse) Capability() Capability

Capabilitys returns the packet capability flags.

func (*StmtPrepareResponse) Columns added in v1.3.0

func (pkt *StmtPrepareResponse) Columns() []ColumnDef

Columns returns the columns.

func (StmtPrepareResponse) HeaderBytes added in v1.3.0

func (pkt StmtPrepareResponse) HeaderBytes() []byte

HeaderBytes returns the packet header bytes.

func (StmtPrepareResponse) IsEOF added in v1.3.0

func (pkt StmtPrepareResponse) IsEOF() bool

IsEOF returns true if the packet is an EOF packet.

func (*StmtPrepareResponse) Params added in v1.3.0

func (pkt *StmtPrepareResponse) Params() []ColumnDef

Params returns the params.

func (StmtPrepareResponse) Payload added in v1.3.0

func (pkt StmtPrepareResponse) Payload() []byte

Payload returns the packet payload.

func (StmtPrepareResponse) PayloadHeaderByte added in v1.3.0

func (pkt StmtPrepareResponse) PayloadHeaderByte() (byte, error)

PayloadHeaderByte returns the payload header byte.

func (StmtPrepareResponse) PayloadLength added in v1.3.0

func (pkt StmtPrepareResponse) PayloadLength() uint32

PayloadLength returns the packet payload length.

func (StmtPrepareResponse) ReadHeader added in v1.3.0

func (pkt StmtPrepareResponse) ReadHeader() error

ReadHeader reads the packet header.

func (StmtPrepareResponse) ReadPayload added in v1.3.0

func (pkt StmtPrepareResponse) ReadPayload() error

ReadPayload reads the packet payload.

func (StmtPrepareResponse) Reader added in v1.3.0

func (pkt StmtPrepareResponse) Reader() *PacketReader

Reader returns the packet reader.

func (*StmtPrepareResponse) ResultSetMetadata added in v1.3.0

func (pkt *StmtPrepareResponse) ResultSetMetadata() ResultsetMetadata

ResultSetMetadata returns the result set metadata.

func (StmtPrepareResponse) SequenceID added in v1.3.0

func (pkt StmtPrepareResponse) SequenceID() SequenceID

SequenceID returns the packet sequence ID.

func (StmtPrepareResponse) ServerStatus added in v1.3.0

func (pkt StmtPrepareResponse) ServerStatus() ServerStatus

ServerStatus returns the packet server status.

func (StmtPrepareResponse) SetCapability added in v1.3.0

func (pkt StmtPrepareResponse) SetCapability(flags Capability)

SetCapabilitys sets the packet capability flags.

func (StmtPrepareResponse) SetCapabilityDisabled added in v1.3.0

func (pkt StmtPrepareResponse) SetCapabilityDisabled(flag Capability)

SetDisabled unsets the specified flag.

func (StmtPrepareResponse) SetCapabilityEnabled added in v1.3.0

func (pkt StmtPrepareResponse) SetCapabilityEnabled(flag Capability)

SetEnabled sets the specified flag.

func (StmtPrepareResponse) SetOptions added in v1.3.0

func (pkt StmtPrepareResponse) SetOptions(opts ...PacketOption)

SetOptions sets the options.

func (StmtPrepareResponse) SetPayload added in v1.3.0

func (pkt StmtPrepareResponse) SetPayload(payload []byte)

SetPayload sets the packet payload.

func (StmtPrepareResponse) SetPayloadLength added in v1.3.0

func (pkt StmtPrepareResponse) SetPayloadLength(l int)

SetPayloadLength sets only the payload length without the payload bytes.

func (StmtPrepareResponse) SetSequenceID added in v1.3.0

func (pkt StmtPrepareResponse) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

func (StmtPrepareResponse) SetServerStatus added in v1.3.0

func (pkt StmtPrepareResponse) SetServerStatus(status ServerStatus)

SetServerStatus sets the packet server status.

func (*StmtPrepareResponse) SetStatementID added in v1.3.0

func (pkt *StmtPrepareResponse) SetStatementID(stmtID StatementID)

SetStatementID sets the statement ID.

func (*StmtPrepareResponse) StatementID added in v1.3.0

func (pkt *StmtPrepareResponse) StatementID() StatementID

StatementID returns the statement ID.

func (*StmtPrepareResponse) WarningCount added in v1.3.0

func (pkt *StmtPrepareResponse) WarningCount() uint16

WarningCount returns the warning count.

type StmtPrepareResponseOption added in v1.3.0

type StmtPrepareResponseOption func(*StmtPrepareResponse)

StmtPrepareResponseOption represents a StmtPrepareResponse option.

func WithStmtPrepareResponseCapability added in v1.3.0

func WithStmtPrepareResponseCapability(c Capability) StmtPrepareResponseOption

WithStmtPrepareResponseCapability sets the capabilitys.

func WithStmtPrepareResponseColumns added in v1.3.0

func WithStmtPrepareResponseColumns(columns []ColumnDef) StmtPrepareResponseOption

WithStmtPrepareResponseColumns sets the columns.

func WithStmtPrepareResponseParams added in v1.3.0

func WithStmtPrepareResponseParams(params []ColumnDef) StmtPrepareResponseOption

WithStmtPrepareResponseParams sets the params.

func WithStmtPrepareResponseResultSetMetadata added in v1.3.0

func WithStmtPrepareResponseResultSetMetadata(metadata ResultsetMetadata) StmtPrepareResponseOption

WithStmtPrepareResponseResultSetMetadata sets the result set metadata.

func WithStmtPrepareResponseServerStatus added in v1.3.0

func WithStmtPrepareResponseServerStatus(status ServerStatus) StmtPrepareResponseOption

WithStmtPrepareResponseServerStatus sets the server status.

func WithStmtPrepareResponseStatementID added in v1.3.0

func WithStmtPrepareResponseStatementID(stmdID StatementID) StmtPrepareResponseOption

WithStmtPrepareResponseStatementID sets the statement ID.

func WithStmtPrepareResponseWarningCount added in v1.3.0

func WithStmtPrepareResponseWarningCount(warningCount uint16) StmtPrepareResponseOption

WithStmtPrepareResponseWarningCount sets the warning count.

type StmtReset added in v1.3.0

type StmtReset struct {
	Command
	// contains filtered or unexported fields
}

StmtReset represents a COM_STMT_RESET packet.

func NewStmtResetFromCommand added in v1.3.0

func NewStmtResetFromCommand(cmd Command, opts ...StmtResetOption) (*StmtReset, error)

NewStmtResetFromCommand creates a new StmtReset from a Command.

func NewStmtResetFromReader added in v1.3.0

func NewStmtResetFromReader(reader io.Reader, opts ...StmtResetOption) (*StmtReset, error)

NewStmtResetFromReader reads a COM_STMT_RESET packet.

func (*StmtReset) Bytes added in v1.3.0

func (pkt *StmtReset) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (*StmtReset) StatementID added in v1.3.0

func (pkt *StmtReset) StatementID() StatementID

StatementID returns the statement ID.

type StmtResetOption added in v1.3.0

type StmtResetOption func(*StmtReset)

StmtResetOption represents a MySQL StmtReset option.

func WithStmtResetStatementID added in v1.3.0

func WithStmtResetStatementID(stmdID StatementID) StmtResetOption

WithStmtResetStatementID sets the statement ID.

type String added in v1.1.0

type String interface {
	Value() string
	IsNull() bool
}

String represents a MySQL string.

func NewNull added in v1.1.0

func NewNull(v string) String

NewNull returns a new null string.

func NewString added in v1.1.0

func NewString(v string) String

NewString returns a new string.

type TLSConfig added in v1.1.3

type TLSConfig interface {
	CertConfig

	// SetTLSEnabled sets a TLS enabled flag.
	SetTLSEnabled(enabled bool)
	// IsEnabled returns true if the TLS is enabled.
	IsTLSEnabled() bool
}

TLSConfig represents a TLS configuration interface.

type TextResultSet added in v1.1.0

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

TextResultSet represents a MySQL text resultset response packet.

func NewTextResultSet added in v1.1.0

func NewTextResultSet(opts ...TextResultSetOption) (*TextResultSet, error)

NewTextResultSet returns a new text resultset response packet.

func NewTextResultSetFromReader added in v1.1.0

func NewTextResultSetFromReader(reader io.Reader, opts ...TextResultSetOption) (*TextResultSet, error)

NewTextResultSetFromReader returns a new text resultset response packet from the specified reader.

func NewTextResultSetFromResultSet added in v1.1.0

func NewTextResultSetFromResultSet(rs sql.ResultSet) (*TextResultSet, error)

TextResultSet represents a MySQL text resultset response packet.

func (*TextResultSet) Bytes added in v1.1.0

func (pkt *TextResultSet) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (*TextResultSet) Capability added in v1.3.0

func (pkt *TextResultSet) Capability() Capability

Capability returns the capabilities.

func (*TextResultSet) ColumnCount added in v1.3.0

func (pkt *TextResultSet) ColumnCount() uint64

ColumnCount returns the column count.

func (*TextResultSet) ColumnDefs added in v1.3.0

func (pkt *TextResultSet) ColumnDefs() []ColumnDef

ColumnDefs returns the column definitions.

func (*TextResultSet) Rows added in v1.1.0

func (pkt *TextResultSet) Rows() []ResultSetRow

Rows returns the rows.

func (*TextResultSet) SetCapability added in v1.1.0

func (pkt *TextResultSet) SetCapability(c Capability)

SetCapability sets a capability flag.

func (*TextResultSet) SetOptions added in v1.1.0

func (pkt *TextResultSet) SetOptions(opts ...TextResultSetOption)

SetOptions sets the options.

func (*TextResultSet) SetSequenceID added in v1.1.0

func (pkt *TextResultSet) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

type TextResultSetOption added in v1.1.0

type TextResultSetOption func(*TextResultSet)

TextResultSetOption represents a COM_QUERY text resultset option.

func WithTextResultSetCapability added in v1.3.0

func WithTextResultSetCapability(c Capability) TextResultSetOption

WithTextResultSetCapabilities returns a text resultset option to set the capabilities.

func WithTextResultSetColumnDefs added in v1.1.0

func WithTextResultSetColumnDefs(colDefs []ColumnDef) TextResultSetOption

WithTextResultSetColumnDefs returns a text resultset option to set the column definitions.

func WithTextResultSetMetadataFollows added in v1.1.0

func WithTextResultSetMetadataFollows(m ResultsetMetadata) TextResultSetOption

WithTextResultSetMetadataFollows returns a text resultset option to set the metadata follows.

func WithTextResultSetRows added in v1.1.0

func WithTextResultSetRows(rows []ResultSetRow) TextResultSetOption

WithTextResultSetRows returns a text resultset option to set the rows.

type TextResultSetRow added in v1.1.0

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

TextResultSetRow represents a MySQL text resultset row response packet.

func NewTextResultSetRow added in v1.1.0

func NewTextResultSetRow(opts ...TextResultSetRowOption) *TextResultSetRow

NewTextResultSetRow returns a new TextResultSetRow.

func NewTextResultSetRowFromReader added in v1.1.0

func NewTextResultSetRowFromReader(reader *PacketReader, opts ...TextResultSetRowOption) (*TextResultSetRow, error)

NewTextResultSetRowFromReader returns a new TextResultSetRow from the reader.

func (*TextResultSetRow) Bytes added in v1.1.0

func (row *TextResultSetRow) Bytes() ([]byte, error)

Bytes returns the packet bytes.

func (TextResultSetRow) Capability added in v1.1.0

func (pkt TextResultSetRow) Capability() Capability

Capabilitys returns the packet capability flags.

func (*TextResultSetRow) Columns added in v1.1.0

func (row *TextResultSetRow) Columns() []any

Columns returns the columns.

func (TextResultSetRow) HeaderBytes added in v1.3.0

func (pkt TextResultSetRow) HeaderBytes() []byte

HeaderBytes returns the packet header bytes.

func (TextResultSetRow) IsEOF added in v1.1.0

func (pkt TextResultSetRow) IsEOF() bool

IsEOF returns true if the packet is an EOF packet.

func (TextResultSetRow) Payload added in v1.1.0

func (pkt TextResultSetRow) Payload() []byte

Payload returns the packet payload.

func (TextResultSetRow) PayloadHeaderByte added in v1.3.0

func (pkt TextResultSetRow) PayloadHeaderByte() (byte, error)

PayloadHeaderByte returns the payload header byte.

func (TextResultSetRow) PayloadLength added in v1.1.0

func (pkt TextResultSetRow) PayloadLength() uint32

PayloadLength returns the packet payload length.

func (*TextResultSetRow) ReadColumn added in v1.1.0

func (row *TextResultSetRow) ReadColumn() (string, error)

ReadColumn reads a column.

func (TextResultSetRow) ReadHeader added in v1.1.0

func (pkt TextResultSetRow) ReadHeader() error

ReadHeader reads the packet header.

func (TextResultSetRow) ReadPayload added in v1.1.0

func (pkt TextResultSetRow) ReadPayload() error

ReadPayload reads the packet payload.

func (TextResultSetRow) Reader added in v1.1.0

func (pkt TextResultSetRow) Reader() *PacketReader

Reader returns the packet reader.

func (TextResultSetRow) SequenceID added in v1.1.0

func (pkt TextResultSetRow) SequenceID() SequenceID

SequenceID returns the packet sequence ID.

func (TextResultSetRow) ServerStatus added in v1.3.0

func (pkt TextResultSetRow) ServerStatus() ServerStatus

ServerStatus returns the packet server status.

func (TextResultSetRow) SetCapability added in v1.1.0

func (pkt TextResultSetRow) SetCapability(flags Capability)

SetCapabilitys sets the packet capability flags.

func (TextResultSetRow) SetCapabilityDisabled added in v1.1.0

func (pkt TextResultSetRow) SetCapabilityDisabled(flag Capability)

SetDisabled unsets the specified flag.

func (TextResultSetRow) SetCapabilityEnabled added in v1.1.0

func (pkt TextResultSetRow) SetCapabilityEnabled(flag Capability)

SetEnabled sets the specified flag.

func (*TextResultSetRow) SetOptions added in v1.1.0

func (row *TextResultSetRow) SetOptions(opts ...TextResultSetRowOption)

SetOptions sets the options.

func (TextResultSetRow) SetPayload added in v1.1.0

func (pkt TextResultSetRow) SetPayload(payload []byte)

SetPayload sets the packet payload.

func (TextResultSetRow) SetPayloadLength added in v1.3.0

func (pkt TextResultSetRow) SetPayloadLength(l int)

SetPayloadLength sets only the payload length without the payload bytes.

func (TextResultSetRow) SetSequenceID added in v1.1.0

func (pkt TextResultSetRow) SetSequenceID(n SequenceID)

SetSequenceID sets the packet sequence ID.

func (TextResultSetRow) SetServerStatus added in v1.3.0

func (pkt TextResultSetRow) SetServerStatus(status ServerStatus)

SetServerStatus sets the packet server status.

type TextResultSetRowOption added in v1.1.0

type TextResultSetRowOption func(*TextResultSetRow)

TextResultSetRowOption represents a MySQL text resultset row option.

func WithTextResultSetRowColmunCount added in v1.1.0

func WithTextResultSetRowColmunCount(c uint64) TextResultSetRowOption

WithTextResultSetRowColmunCount returns a text resultset row option to set the column count.

func WithTextResultSetRowColmuns added in v1.1.0

func WithTextResultSetRowColmuns(columns []string) TextResultSetRowOption

WithTextResultSetRowColmuns returns a text resultset row option to set the columns.

type Type added in v1.1.0

type Type byte

Type represents a packet type.

Jump to

Keyboard shortcuts

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