Skip to content

Add skipped columns information #505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion replication/row_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,8 @@ type RowsEvent struct {
ColumnBitmap2 []byte

//rows: invalid: int64, float64, bool, []byte, string
Rows [][]interface{}
Rows [][]interface{}
SkippedColumns [][]int

parseTime bool
timestampStringLocation *time.Location
Expand Down Expand Up @@ -907,6 +908,7 @@ func (e *RowsEvent) Decode(data []byte) error {
if e.needBitmap2 {
rowsLen += e.ColumnCount
}
e.SkippedColumns = make([][]int, 0, rowsLen)
e.Rows = make([][]interface{}, 0, rowsLen)

for pos < len(data) {
Expand All @@ -932,6 +934,7 @@ func isBitSet(bitmap []byte, i int) bool {

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

pos := 0

Expand All @@ -953,6 +956,7 @@ func (e *RowsEvent) decodeRows(data []byte, table *TableMapEvent, bitmap []byte)
var err error
for i := 0; i < int(e.ColumnCount); i++ {
if !isBitSet(bitmap, i) {
skips = append(skips, i)
continue
}

Expand All @@ -973,6 +977,7 @@ func (e *RowsEvent) decodeRows(data []byte, table *TableMapEvent, bitmap []byte)
}

e.Rows = append(e.Rows, row)
e.SkippedColumns = append(e.SkippedColumns, skips)
return pos, nil
}

Expand Down