Skip to content

Commit da1fe40

Browse files
Add skipped columns information
- Fix go-mysql-org#504
1 parent 803944a commit da1fe40

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

replication/row_event.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ type RowsEvent struct {
522522
ColumnBitmap2 []byte
523523

524524
//rows: invalid: int64, float64, bool, []byte, string
525-
Rows [][]interface{}
525+
Rows [][]interface{}
526+
SkippedColumns [][]int
526527

527528
parseTime bool
528529
timestampStringLocation *time.Location
@@ -583,6 +584,7 @@ func (e *RowsEvent) Decode(data []byte) error {
583584
if e.needBitmap2 {
584585
rowsLen += e.ColumnCount
585586
}
587+
e.SkippedColumns = make([][]int, 0, rowsLen)
586588
e.Rows = make([][]interface{}, 0, rowsLen)
587589

588590
for pos < len(data) {
@@ -608,6 +610,7 @@ func isBitSet(bitmap []byte, i int) bool {
608610

609611
func (e *RowsEvent) decodeRows(data []byte, table *TableMapEvent, bitmap []byte) (int, error) {
610612
row := make([]interface{}, e.ColumnCount)
613+
skips := make([]int, 0)
611614

612615
pos := 0
613616

@@ -629,6 +632,7 @@ func (e *RowsEvent) decodeRows(data []byte, table *TableMapEvent, bitmap []byte)
629632
var err error
630633
for i := 0; i < int(e.ColumnCount); i++ {
631634
if !isBitSet(bitmap, i) {
635+
skips = append(skips, i)
632636
continue
633637
}
634638

@@ -649,6 +653,7 @@ func (e *RowsEvent) decodeRows(data []byte, table *TableMapEvent, bitmap []byte)
649653
}
650654

651655
e.Rows = append(e.Rows, row)
656+
e.SkippedColumns = append(e.SkippedColumns, skips)
652657
return pos, nil
653658
}
654659

0 commit comments

Comments
 (0)