Documentation ¶
Index ¶
- Constants
- Variables
- type MockConn
- func (m *MockConn) Close() error
- func (m *MockConn) Datas() []byte
- func (m *MockConn) LocalAddr() net.Addr
- func (m *MockConn) Read(b []byte) (n int, err error)
- func (m *MockConn) RemoteAddr() net.Addr
- func (m *MockConn) SetDeadline(t time.Time) error
- func (m *MockConn) SetReadDeadline(t time.Time) error
- func (m *MockConn) SetWriteDeadline(t time.Time) error
- func (m *MockConn) Write(b []byte) (n int, err error)
- type Packet
- type Packets
- func (p *Packets) Append(rawdata []byte) error
- func (p *Packets) AppendColumns(columns []*querypb.Field) error
- func (p *Packets) AppendEOF(flags uint16, warnings uint16) error
- func (p *Packets) AppendOKWithEOFHeader(affectedRows, lastInsertID uint64, flags uint16, warnings uint16) error
- func (p *Packets) Flush() error
- func (p *Packets) Next() ([]byte, error)
- func (p *Packets) ParseERR(data []byte) error
- func (p *Packets) ParseOK(data []byte) (*proto.OK, error)
- func (p *Packets) ReadColumns(colNumber int) ([]*querypb.Field, error)
- func (p *Packets) ReadComQueryResponse() (*proto.OK, int, error, error)
- func (p *Packets) ReadEOF() error
- func (p *Packets) ReadOK() error
- func (p *Packets) ReadStatementPrepareResponse(clientFlags uint32) (*proto.Statement, error)
- func (p *Packets) ResetSeq()
- func (p *Packets) Write(payload []byte) error
- func (p *Packets) WriteCommand(command byte, payload []byte) error
- func (p *Packets) WriteERR(errorCode uint16, sqlState string, format string, args ...interface{}) error
- func (p *Packets) WriteOK(affectedRows, lastInsertID uint64, flags uint16, warnings uint16) error
- func (p *Packets) WriteStatementPrepareResponse(clientFlags uint32, stmt *proto.Statement) error
- type Stream
Constants ¶
const (
// PACKET_BUFFER_SIZE is how much we buffer for reading.
PACKET_BUFFER_SIZE = 32 * 1024
)
const ( // PACKET_MAX_SIZE used for the max packet size. PACKET_MAX_SIZE = (1<<24 - 1) // (16MB - 1) )
Variables ¶
var ( // ErrBadConn used for the error of bad connection. ErrBadConn = errors.New("connection.was.bad") // ErrMalformPacket used for the bad packet. ErrMalformPacket = errors.New("Malform.packet.error") )
Functions ¶
This section is empty.
Types ¶
type MockConn ¶
type MockConn struct {
// contains filtered or unexported fields
}
MockConn used to mock a net.Conn for testing purposes.
func (*MockConn) RemoteAddr ¶
RemoteAddr implements the net.Conn interface.
func (*MockConn) SetDeadline ¶
SetDeadline implements the net.Conn interface.
func (*MockConn) SetReadDeadline ¶
SetReadDeadline implements the net.Conn interface.
func (*MockConn) SetWriteDeadline ¶
SetWriteDeadline implements the net.Conn interface.
type Packets ¶
type Packets struct {
// contains filtered or unexported fields
}
Packets presents the stream tuple.
func (*Packets) Append ¶
Append appends packets to buffer but not write to stream. This is underlying packet unit. NOTICE: SequenceID++
func (*Packets) AppendColumns ¶
AppendColumns used to append column to columns.
func (*Packets) AppendOKWithEOFHeader ¶
func (p *Packets) AppendOKWithEOFHeader(affectedRows, lastInsertID uint64, flags uint16, warnings uint16) error
AppendOKWithEOFHeader appends OK packet to the stream buffer with EOF header.
func (*Packets) ReadColumns ¶
ReadColumns used to read all columns from the stream buffer.
func (*Packets) ReadComQueryResponse ¶
ReadComQueryResponse used to read query command response and parse the column count. http://dev.mysql.com/doc/internals/en/com-query-response.html#packet-ProtocolText::Resultset Returns: ok, colNumbs, myerr, err
myerr is the error who was send by MySQL server, the client does not close the connection. if err is not nil, we(the client) will close the connection.
func (*Packets) ReadStatementPrepareResponse ¶
ReadStatementPrepareResponse -- read the stmt prepare response by client from the server.
func (*Packets) WriteCommand ¶
WriteCommand writes a command packet to the wire.
func (*Packets) WriteERR ¶
func (p *Packets) WriteERR(errorCode uint16, sqlState string, format string, args ...interface{}) error
WriteERR writes ERR packet to the wire.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream represents the stream tuple.