Documentation ¶
Index ¶
- type BinaryRow
- type Conn
- func (c *Conn) Close()
- func (c *Conn) DrainResults() error
- func (c *Conn) EndWriterBuffering() error
- func (c *Conn) GetTLSClientCerts() []*x509.Certificate
- func (c *Conn) ID() uint32
- func (c *Conn) IsClosed() bool
- func (c *Conn) ParseRow(ctx context.Context, data []byte, fields []*Field) (proto.Row, error)
- func (c *Conn) ReadEphemeralPacket() ([]byte, error)
- func (c *Conn) ReadEphemeralPacketDirect() ([]byte, error)
- func (c *Conn) ReadOnePacket() ([]byte, error)
- func (c *Conn) ReadPacket() ([]byte, error)
- func (c *Conn) ReadPacketFacade() ([]byte, error)
- func (c *Conn) RecycleReadPacket()
- func (c *Conn) RecycleWritePacket()
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) ResetSequence()
- func (c *Conn) SetConnectionID(connectionID uint32)
- func (c *Conn) SetReadTimeout(readTimeout time.Duration)
- func (c *Conn) SetUserName(userName string)
- func (c *Conn) SetWriteTimeout(writeTimeout time.Duration)
- func (c *Conn) StartEphemeralPacket(length int) []byte
- func (c *Conn) StartWriterBuffering()
- func (c *Conn) StatusFlags() uint16
- func (c *Conn) String() string
- func (c *Conn) UserName() string
- func (c *Conn) WriteBinaryRows(result *Result) error
- func (c *Conn) WriteEOFPacket(flags uint16, warnings uint16) error
- func (c *Conn) WriteEndResult(capabilities uint32, more bool, affectedRows, lastInsertID uint64, ...) error
- func (c *Conn) WriteEphemeralPacket() error
- func (c *Conn) WriteErrorPacket(errorCode uint16, sqlState string, format string, args ...interface{}) error
- func (c *Conn) WriteErrorPacketFromError(err error) error
- func (c *Conn) WriteFields(capabilities uint32, fields []*Field) error
- func (c *Conn) WriteOKPacket(affectedRows, lastInsertID uint64, flags uint16, warnings uint16) error
- func (c *Conn) WriteOKPacketWithEOFHeader(affectedRows, lastInsertID uint64, flags uint16, warnings uint16) error
- func (c *Conn) WritePacket(data []byte) error
- func (c *Conn) WritePrepare(capabilities uint32, prepare *proto.Stmt) error
- func (c *Conn) WriteRows(result *Result) error
- func (c *Conn) WriteTextRows(result *Result) error
- type Field
- type Result
- type ResultSet
- type TextRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct { ReadTimeout time.Duration // I/O read timeout WriteTimeout time.Duration // I/O write timeout // contains filtered or unexported fields }
Conn is a connection between a client and a server, using the MySQL binary protocol. It is built on top of an existing net.Conn, that has already been established.
Use Connect on the client side to create a connection. Use NewListener to create a server side and listen for connections.
func NewConn ¶
NewConn is an internal method to create a Conn. Used by client and server side for common creation code.
func (*Conn) Close ¶
func (c *Conn) Close()
Close closes the connection. It can be called from a different go routine to interrupt the current connection.
func (*Conn) DrainResults ¶ added in v0.4.0
DrainResults will read all packets for a result set and ignore them.
func (*Conn) EndWriterBuffering ¶
EndWriterBuffering must be called to terminate startWriteBuffering.
func (*Conn) GetTLSClientCerts ¶
func (c *Conn) GetTLSClientCerts() []*x509.Certificate
GetTLSClientCerts gets TLS certificates.
func (*Conn) IsClosed ¶
IsClosed returns true if this connection was ever closed by the Close() method. Note if the other side closes the connection, but Close() wasn't called, this will return false.
func (*Conn) ReadEphemeralPacket ¶
ReadEphemeralPacket attempts to read a packet into buffer. Do not use this method if the contents of the packet needs to be kept after the next ReadEphemeralPacket.
Note if the connection is closed already, an error will be returned, and it may not be io.EOF. If the connection closes while we are stuck waiting for Content, an error will also be returned, and it most likely will be io.EOF.
func (*Conn) ReadEphemeralPacketDirect ¶
ReadEphemeralPacketDirect attempts to read a packet from the socket directly. It needs to be used for the first handshake packet the server receives, so we do't buffer the SSL negotiation packet. As a shortcut, only packets smaller than MaxPacketSize can be read here. This function usually shouldn't be used - use ReadEphemeralPacket.
func (*Conn) ReadOnePacket ¶
ReadOnePacket reads a single packet into a newly allocated buffer.
func (*Conn) ReadPacket ¶
ReadPacket reads a packet from the underlying connection. It re-assembles packets that span more than one message. This method returns a generic error, not a SQLError.
func (*Conn) ReadPacketFacade ¶
ReadPacketFacade reads a packet from the underlying connection. it is the public API version, that returns a SQLError. The memory for the packet is always allocated, and it is owned by the caller after this function returns.
func (*Conn) RecycleReadPacket ¶
func (c *Conn) RecycleReadPacket()
RecycleReadPacket recycles the read packet. It needs to be called after ReadEphemeralPacket was called.
func (*Conn) RecycleWritePacket ¶
func (c *Conn) RecycleWritePacket()
RecycleWritePacket recycles the write packet. It needs to be called after WriteEphemeralPacket was called.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the underlying socket RemoteAddr().
func (*Conn) ResetSequence ¶
func (c *Conn) ResetSequence()
func (*Conn) SetConnectionID ¶ added in v0.2.0
func (*Conn) SetReadTimeout ¶ added in v0.5.0
func (*Conn) SetUserName ¶ added in v0.2.0
func (*Conn) SetWriteTimeout ¶ added in v0.5.0
func (*Conn) StartEphemeralPacket ¶
func (*Conn) StartWriterBuffering ¶
func (c *Conn) StartWriterBuffering()
StartWriterBuffering starts using buffered writes. This should be terminated by a call to endWriteBuffering.
func (*Conn) StatusFlags ¶
func (*Conn) WriteBinaryRows ¶
func (*Conn) WriteEOFPacket ¶
WriteEOFPacket writes an EOF packet, through the buffer, and doesn't flush (as it is used as part of a query result).
func (*Conn) WriteEndResult ¶
func (c *Conn) WriteEndResult(capabilities uint32, more bool, affectedRows, lastInsertID uint64, warnings uint16) error
WriteEndResult concludes the sending of a Result. if more is set to true, then it means there are more results afterwords
func (*Conn) WriteEphemeralPacket ¶
WriteEphemeralPacket writes the packet that was allocated by StartEphemeralPacket.
func (*Conn) WriteErrorPacket ¶
func (c *Conn) WriteErrorPacket(errorCode uint16, sqlState string, format string, args ...interface{}) error
WriteErrorPacket writes an error packet. Server -> Client. This method returns a generic error, not a SQLError.
func (*Conn) WriteErrorPacketFromError ¶
WriteErrorPacketFromError writes an error packet, from a regular error. See WriteErrorPacket for other info.
func (*Conn) WriteFields ¶
WriteFields writes the fields of a Result. It should be called only if there are valid Columns in the result.
func (*Conn) WriteOKPacket ¶
func (c *Conn) WriteOKPacket(affectedRows, lastInsertID uint64, flags uint16, warnings uint16) error
WriteOKPacket writes an OK packet. Server -> Client. This method returns a generic error, not a SQLError.
func (*Conn) WriteOKPacketWithEOFHeader ¶
func (c *Conn) WriteOKPacketWithEOFHeader(affectedRows, lastInsertID uint64, flags uint16, warnings uint16) error
WriteOKPacketWithEOFHeader writes an OK packet with an EOF header. This is used at the end of a result set if CapabilityClientDeprecateEOF is set. Server -> Client. This method returns a generic error, not a SQLError.
func (*Conn) WritePacket ¶
WritePacket writes a packet, possibly cutting it into multiple chunks. Note this is not very efficient, as the client probably has to build the []byte and that makes a memory copy. Try to use StartEphemeralPacket/WriteEphemeralPacket instead.
This method returns a generic error, not a SQLError.
func (*Conn) WritePrepare ¶
WritePrepare writes a prepare query response to the wire.
func (*Conn) WriteTextRows ¶ added in v0.3.0
WriteTextRows sends the rows of a Result.
type Field ¶
type Field struct { Table string OrgTable string Database string Name string OrgName string Length uint32 Flags uint FieldType constant.FieldType Decimals byte CharSet uint16 ColumnLength uint32 DefaultValueLength uint64 DefaultValue []byte }
func (*Field) DataBaseName ¶
func (*Field) TypeDatabaseName ¶
type Result ¶
type Result struct { Fields []*Field // Columns information AffectedRows uint64 InsertId uint64 Rows []proto.Row }