func (p *Packets) WriteOK(affectedRows, lastInsertID uint64, flags uint16, warnings uint16) error {
	ok := &proto.OK{
		AffectedRows: affectedRows,
		LastInsertID: lastInsertID,
		StatusFlags:  flags,
		Warnings:     warnings,
	}
	return p.Write(proto.PackOK(ok))
}
WriteOK writes OK packet to the wire.
package packet
import (
	"fmt"
	"net"
	"github.com/xelabs/go-mysqlstack/proto"
	"github.com/xelabs/go-mysqlstack/sqldb"
	"github.com/xelabs/go-mysqlstack/sqlparser/depends/common"
	querypb "github.com/xelabs/go-mysqlstack/sqlparser/depends/query"
	"github.com/xelabs/go-mysqlstack/sqlparser/depends/sqltypes"
)
const (
	PACKET_MAX_SIZE = (1<<24 - 1)  
)
type Packet struct {
	SequenceID byte
	Datas      []byte
}
type Packets struct {
	seq    uint8
	stream *Stream
}
func NewPackets(c net.Conn) *Packets {
	return &Packets{
		stream: NewStream(c, PACKET_MAX_SIZE),
	}
}
func (p *Packets) Next() ([]byte, error) {
	pkt, err := p.stream.Read()
	if err != nil {
		return nil, err
	}
	if pkt.SequenceID != p.seq {
		return nil, sqldb.NewSQLErrorf(sqldb.ER_MALFORMED_PACKET, "pkt.read.seq[%v]!=pkt.actual.seq[%v]", pkt.SequenceID, p.seq)
	}
	p.seq++
	return pkt.Datas, nil
}
func (p *Packets) Write(payload []byte) error {
	payLen := len(payload)
	pkt := common.NewBuffer(64)
	pkt.WriteU24(uint32(payLen))
	pkt.WriteU8(p.seq)
	pkt.WriteBytes(payload)
	if err := p.stream.Write(pkt.Datas()); err != nil {
		return err
	}
	p.seq++
	return nil
}
func (p *Packets) WriteCommand(command byte, payload []byte) error {
	p.seq = 0
	pkt := common.NewBuffer(64)
	payLen := len(payload)
	pkt.WriteU24(uint32(1 + payLen))
	pkt.WriteU8(p.seq)
	pkt.WriteU8(command)
	pkt.WriteBytes(payload)
	if err := p.stream.Write(pkt.Datas()); err != nil {
		return err
	}
	p.seq++
	return nil
}
func (p *Packets) ResetSeq() {
	p.seq = 0
}
func (p *Packets) ParseOK(data []byte) (*proto.OK, error) {
	return proto.UnPackOK(data)
}