Skip to content

Commit

Permalink
Multiply rows for event rows
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Perepechaev committed Jan 14, 2015
1 parent 75746a7 commit b69b502
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions replication/row_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ type RowsEvent struct {
tables map[uint64]*TableMapEvent
needBitmap2 bool

Table *TableMapEvent

TableID uint64

Flags uint16
Expand Down Expand Up @@ -245,22 +247,27 @@ func (e *RowsEvent) Decode(data []byte) error {
pos += bitCount
}

tableEvent, ok := e.tables[e.TableID]
var ok bool
e.Table, ok = e.tables[e.TableID]
if !ok {
return fmt.Errorf("invalid table id %d, no correspond table map event", e.TableID)
}

var err error
if n, err = e.decodeRows(data[pos:], tableEvent, e.ColumnBitmap1); err != nil {
return err
}
pos += n

if e.needBitmap2 {
if n, err = e.decodeRows(data[pos:], tableEvent, e.ColumnBitmap2); err != nil {
// ... repeat rows until event-end
for pos < len(data) {
if n, err = e.decodeRows(data[pos:], e.Table, e.ColumnBitmap1); err != nil {
return err
}
pos += n

if e.needBitmap2 {
if n, err = e.decodeRows(data[pos:], e.Table, e.ColumnBitmap2); err != nil {
return err
}
pos += n
}
}

return nil
Expand Down

0 comments on commit b69b502

Please sign in to comment.