1
0
Fork 0

For sets and enums length is already precalculated

This commit is contained in:
Gregory Eremin 2018-11-11 14:47:33 +01:00
parent 8cbca43cf7
commit b1e0b061f0
2 changed files with 8 additions and 8 deletions

View File

@ -9,7 +9,6 @@ import (
"github.com/localhots/bocadillo/mysql"
"github.com/localhots/bocadillo/tools"
"github.com/localhots/pretty"
)
// RowsEvent contains a Rows Event.
@ -253,16 +252,14 @@ func (e *RowsEvent) decodeValue(buf *tools.Buffer, ct mysql.ColumnType, meta uin
buf.Skip(n)
return v
case mysql.ColumnTypeSet:
length = int(meta & 0xFF)
nbits := length * 8
v, n := mysql.DecodeBit(buf.Cur(), nbits, length)
pretty.Println("Decoding set", buf.Cur(), nbits, length, "-->", v)
buf.Skip(n)
return v
// Stuff
case mysql.ColumnTypeEnum:
return buf.ReadVarLen64(int(meta & 0xFF))
return buf.ReadVarLen64(length)
// Unsupported
case mysql.ColumnTypeDecimal:

View File

@ -56,7 +56,6 @@ func (r *Reader) ReadEvent() (*Event, error) {
if err := evt.Header.Decode(connBuff, r.format); err != nil {
return nil, errors.Annotate(err, "decode event header")
}
if evt.Header.NextOffset > 0 {
r.state.Offset = uint64(evt.Header.NextOffset)
}
@ -71,26 +70,29 @@ func (r *Reader) ReadEvent() (*Event, error) {
switch evt.Header.Type {
case binlog.EventTypeFormatDescription:
var fde binlog.FormatDescriptionEvent
err = fde.Decode(evt.Buffer)
err := fde.Decode(evt.Buffer)
if err != nil {
return nil, errors.Annotate(err, "decode format description event")
}
r.format = fde.FormatDescription
evt.Format = fde.FormatDescription
case binlog.EventTypeRotate:
var re binlog.RotateEvent
err = re.Decode(evt.Buffer, r.format)
err := re.Decode(evt.Buffer, r.format)
if err != nil {
return nil, errors.Annotate(err, "decode rotate event")
}
r.state = re.NextFile
case binlog.EventTypeTableMap:
var tme binlog.TableMapEvent
err = tme.Decode(evt.Buffer, r.format)
err := tme.Decode(evt.Buffer, r.format)
if err != nil {
return nil, errors.Annotate(err, "decode table map event")
}
r.tableMap[tme.TableID] = tme.TableDescription
case binlog.EventTypeWriteRowsV0,
binlog.EventTypeWriteRowsV1,
binlog.EventTypeWriteRowsV2,
@ -108,6 +110,7 @@ func (r *Reader) ReadEvent() (*Event, error) {
return nil, errors.New("Unknown table ID")
}
evt.Table = &td
case binlog.EventTypeQuery:
// Can be decoded by the receiver
case binlog.EventTypeXID: