From 3600af4bea521bd63deafa87c721348ae15aee04 Mon Sep 17 00:00:00 2001 From: dongmen <20351731+asddongmen@users.noreply.github.com> Date: Fri, 19 Jan 2024 14:06:17 +0800 Subject: [PATCH] add binlog filter ddl event type (#766) close pingcap/tidb-tools#767, ref pingcap/tiflow#10511 --- pkg/binlog-filter/filter.go | 21 ++++++++++++++++++--- pkg/binlog-filter/util.go | 19 +++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/pkg/binlog-filter/filter.go b/pkg/binlog-filter/filter.go index a4e38aa8..567bd6d6 100644 --- a/pkg/binlog-filter/filter.go +++ b/pkg/binlog-filter/filter.go @@ -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 = "" @@ -141,7 +156,7 @@ func ClassifyEvent(event EventType) (EventType, error) { ModifyCollation, RemoveAutoIncrement, ModifyStorageEngine, - ReorganizePartion, + ReorganizePartition, RebuildPartition, CoalescePartition, SplitPartition, diff --git a/pkg/binlog-filter/util.go b/pkg/binlog-filter/util.go index f031109c..e076ba62 100644 --- a/pkg/binlog-filter/util.go +++ b/pkg/binlog-filter/util.go @@ -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