Skip to content

Commit

Permalink
Merge pull request go-mysql-org#2 from perepechaev/master
Browse files Browse the repository at this point in the history
Multiply rows for event rows
  • Loading branch information
siddontang committed Jan 15, 2015
2 parents 75746a7 + b69b502 commit bebe11e
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 bebe11e

Please sign in to comment.