Skip to content

Commit

Permalink
binlog: fix binlog filter type (#775)
Browse files Browse the repository at this point in the history
close #776
  • Loading branch information
asddongmen authored Mar 5, 2024
1 parent a6014db commit 9f9bea8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/binlog-filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const (
RemovePartitioning EventType = "remove table partitioning"
AddColumn EventType = "add column"
SetDefaultValue EventType = "set default value"
RebaseAutoID EventType = "rebase auto_increment ID"
RebaseAutoID EventType = "rebase auto id"
AddPrimaryKey EventType = "add primary key"
AlterIndexVisibility EventType = "alter index visibility"
AlterTTLInfo EventType = "alter ttl info"
Expand Down Expand Up @@ -248,7 +248,7 @@ func NewBinlogEvent(caseSensitive bool, rules []*BinlogEventRule) (*BinlogEvent,

for _, rule := range rules {
if err := b.AddRule(rule); err != nil {
log.Error("invalid binlog event rule", zap.Error(err))
log.Error("invalid binlog event rule", zap.Any("rule", rule), zap.Error(err))
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/binlog-filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (t *testFilterSuite) TestFilter(c *C) {
{"xxx_*", "abc_*", []EventType{AllDML, NoneDDL}, nil, nil, Ignore},
{"yyy_*", "abc_*", []EventType{EventType("ALL DML")}, nil, nil, Do},
{"Test_1_*", "abc*", []EventType{"wrong event"}, []string{"^DROP\\s+PROCEDURE", "^CREATE\\s+PROCEDURE"}, nil, Ignore},
{"cdc", "t1", []EventType{RebaseAutoID}, nil, nil, Ignore},
}

cases := []struct {
Expand All @@ -57,6 +58,7 @@ func (t *testFilterSuite) TestFilter(c *C) {
{"yyy_1", "abc_1", InsertEvent, "", Do},
{"yyy_1", "abc_1", CreateIndex, "", Ignore},
{"test_1_a", "abc1", DropView, "", Ignore},
{"cdc", "t1", RebaseAutoID, "", Ignore},
}

// initial binlog event filter
Expand Down Expand Up @@ -275,6 +277,7 @@ func (t *testFilterSuite) TestToEventType(c *C) {
{"add table partition", AddTablePartition, nil},
{"drop taBle partition", DropTablePartition, nil},
{"truncate tablE parTition", TruncateTablePartition, nil},
{"rebase auto id", RebaseAutoID, nil},
{"xxx", NullEvent, errors.NotValidf("event type %s", "xxx")},
{"I don't know", NullEvent, errors.NotValidf("event type %s", "I don't know")},
}
Expand Down Expand Up @@ -318,6 +321,7 @@ func (t *testFilterSuite) TestClassifyEvent(c *C) {
{AlterTable, ddl, nil},
{AddTablePartition, ddl, nil},
{DropTablePartition, incompatibleDDL, nil},
{RebaseAutoID, incompatibleDDL, nil},
{TruncateTablePartition, incompatibleDDL, nil},
{"create", NullEvent, errors.NotValidf("event type %s", "create")},
{EventType("xxx"), NullEvent, errors.NotValidf("event type %s", "xxx")},
Expand Down

0 comments on commit 9f9bea8

Please sign in to comment.