Skip to content

Commit

Permalink
add binlog filter ddl event type (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
asddongmen authored Jan 19, 2024
1 parent 26d9efe commit 3600af4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
21 changes: 18 additions & 3 deletions pkg/binlog-filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,33 @@ const (
DropPrimaryKey EventType = "drop primary key"
DropUniqueKey EventType = "drop unique key"
ModifyDefaultValue EventType = "modify default value"
ModifyConstraint EventType = "modify constaints"
ModifyConstraint EventType = "modify constraint"
ModifyColumnsOrder EventType = "modify columns order"
ModifyCharset EventType = "modify charset"
ModifyCollation EventType = "modify collation"
RemoveAutoIncrement EventType = "remove auto increment"
ModifyStorageEngine EventType = "modify storage engine"
ReorganizePartion EventType = "reorganize table partition"
ReorganizePartition EventType = "reorganize table partition"
RebuildPartition EventType = "rebuild table partition"
CoalescePartition EventType = "coalesce table partition"
SplitPartition EventType = "split table partition"
ExchangePartition EventType = "exchange table partition"

ModifySchemaCharsetAndCollate EventType = "modify schema charset and collate"
ModifyTableCharsetAndCollate EventType = "modify table charset and collate"
ModifyTableComment EventType = "modify table comment"
RecoverTable EventType = "recover table"
AlterTablePartitioning EventType = "alter table partitioning"
RemovePartitioning EventType = "remove table partitioning"
AddColumn EventType = "add column"
SetDefaultValue EventType = "set default value"
RebaseAutoID EventType = "rebase auto_increment ID"
AddPrimaryKey EventType = "add primary key"
AlterIndexVisibility EventType = "alter index visibility"
AlterTTLInfo EventType = "alter ttl info"
AlterTTLRemove EventType = "alter ttl remove"
MultiSchemaChange EventType = "multi schema change"

// NullEvent is used to represents unsupported ddl event type when we
// convert a ast.StmtNode or a string to EventType.
NullEvent EventType = ""
Expand Down Expand Up @@ -141,7 +156,7 @@ func ClassifyEvent(event EventType) (EventType, error) {
ModifyCollation,
RemoveAutoIncrement,
ModifyStorageEngine,
ReorganizePartion,
ReorganizePartition,
RebuildPartition,
CoalescePartition,
SplitPartition,
Expand Down
19 changes: 17 additions & 2 deletions pkg/binlog-filter/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,26 @@ func toEventType(es string) (EventType, error) {
ModifyCollation,
RemoveAutoIncrement,
ModifyStorageEngine,
ReorganizePartion,
ReorganizePartition,
RebuildPartition,
CoalescePartition,
SplitPartition,
ExchangePartition:
ExchangePartition,

ModifySchemaCharsetAndCollate,
ModifyTableCharsetAndCollate,
ModifyTableComment,
RecoverTable,
AlterTablePartitioning,
RemovePartitioning,
AddColumn,
SetDefaultValue,
RebaseAutoID,
AddPrimaryKey,
AlterIndexVisibility,
AlterTTLInfo,
AlterTTLRemove,
MultiSchemaChange:
return event, nil
case CreateSchema: // alias of CreateDatabase
return CreateDatabase, nil
Expand Down

0 comments on commit 3600af4

Please sign in to comment.