From 93ba2a9c1410dddc88f02d0384e6597b2dc791ef Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Tue, 21 Mar 2023 18:09:15 +0800 Subject: [PATCH] Revert "Support ALTER TABLE t REORGANIZE PARTITION (#8114)" This reverts commit 129d6192ef23cfdeca0b0401ede2ca3630c0aa82. --- cdc/entry/schema/snapshot.go | 3 +-- cdc/entry/schema_storage_test.go | 2 -- pkg/filter/filter.go | 1 - pkg/filter/filter_test.go | 1 - pkg/filter/utils_test.go | 1 - pkg/sink/codec/canal/canal_entry.go | 2 +- tests/integration_tests/partition_table/data/prepare.sql | 9 --------- 7 files changed, 2 insertions(+), 17 deletions(-) diff --git a/cdc/entry/schema/snapshot.go b/cdc/entry/schema/snapshot.go index 2f4991eb0ca..eb7c9eb394a 100644 --- a/cdc/entry/schema/snapshot.go +++ b/cdc/entry/schema/snapshot.go @@ -496,8 +496,7 @@ func (s *Snapshot) DoHandleDDL(job *timodel.Job) error { } case timodel.ActionTruncateTablePartition, timodel.ActionAddTablePartition, - timodel.ActionDropTablePartition, - timodel.ActionReorganizePartition: + timodel.ActionDropTablePartition: err := s.inner.updatePartition(getWrapTableInfo(job), job.BinlogInfo.FinishedTS) if err != nil { return errors.Trace(err) diff --git a/cdc/entry/schema_storage_test.go b/cdc/entry/schema_storage_test.go index 8bf0faf7ca0..3a283a462a5 100644 --- a/cdc/entry/schema_storage_test.go +++ b/cdc/entry/schema_storage_test.go @@ -822,8 +822,6 @@ func TestSchemaStorage(t *testing.T) { "alter table test_ddl2.simple_test1 add primary key pk(id)", // ActionAddPrimaryKey "ALTER TABLE test_ddl2.simple_test1 ALTER id SET DEFAULT 18", // ActionSetDefaultValue "ALTER TABLE test_ddl2.simple_test1 CHARACTER SET = utf8mb4", // ActionModifyTableCharsetAndCollate - - "ALTER TABLE test_ddl2.employees REORGANIZE PARTITION p3 INTO (PARTITION p2 VALUES LESS THAN (15), PARTITION p3 VALUES LESS THAN (20))", // ActionReorganizePartition // "recover table test_ddl2.employees", // ActionRecoverTable this ddl can't work on mock tikv "DROP TABLE test_ddl2.employees", diff --git a/pkg/filter/filter.go b/pkg/filter/filter.go index cf186cceeda..27a90d42af4 100644 --- a/pkg/filter/filter.go +++ b/pkg/filter/filter.go @@ -54,7 +54,6 @@ var allowDDLList = []timodel.ActionType{ timodel.ActionAlterIndexVisibility, timodel.ActionMultiSchemaChange, timodel.ActionExchangeTablePartition, - timodel.ActionReorganizePartition, timodel.ActionAlterTTLInfo, timodel.ActionAlterTTLRemove, } diff --git a/pkg/filter/filter_test.go b/pkg/filter/filter_test.go index e4c53b35e68..f449cc2be69 100644 --- a/pkg/filter/filter_test.go +++ b/pkg/filter/filter_test.go @@ -177,7 +177,6 @@ func TestShouldDiscardDDL(t *testing.T) { require.False(t, filter.ShouldDiscardDDL(timodel.ActionAlterIndexVisibility, "", "")) require.False(t, filter.ShouldDiscardDDL(timodel.ActionMultiSchemaChange, "", "")) require.False(t, filter.ShouldDiscardDDL(timodel.ActionExchangeTablePartition, "", "")) - require.False(t, filter.ShouldDiscardDDL(timodel.ActionReorganizePartition, "", "")) // Discard sequence DDL. require.True(t, filter.ShouldDiscardDDL(timodel.ActionAddForeignKey, "", "")) diff --git a/pkg/filter/utils_test.go b/pkg/filter/utils_test.go index 6bceab98604..824c40731d6 100644 --- a/pkg/filter/utils_test.go +++ b/pkg/filter/utils_test.go @@ -98,7 +98,6 @@ func TestDDLToEventType(t *testing.T) { {"Alter table test.t1 drop partition t11", timodel.ActionDropTablePartition, bf.DropTablePartition, nil}, {"Alter table test.t1 add partition (partition p3 values less than (2002))", timodel.ActionDropTablePartition, bf.DropTablePartition, nil}, {"Alter table test.t1 truncate partition t11", timodel.ActionDropTablePartition, bf.DropTablePartition, nil}, - {"Alter table test.t1 reorganize partition p11 into (partition p1 values less than (10), partition p2 values less than (20))", timodel.ActionReorganizePartition, bf.AlterTable, nil}, {"alter table add i", timodel.ActionAddIndex, bf.NullEvent, cerror.ErrConvertDDLToEventTypeFailed}, } p := parser.New() diff --git a/pkg/sink/codec/canal/canal_entry.go b/pkg/sink/codec/canal/canal_entry.go index 809074dc72c..25e6506e1ab 100644 --- a/pkg/sink/codec/canal/canal_entry.go +++ b/pkg/sink/codec/canal/canal_entry.go @@ -265,7 +265,7 @@ func convertDdlEventType(e *model.DDLEvent) canal.EventType { case mm.ActionAddColumn, mm.ActionDropColumn, mm.ActionModifyColumn, mm.ActionRebaseAutoID, mm.ActionSetDefaultValue, mm.ActionModifyTableComment, mm.ActionRenameIndex, mm.ActionAddTablePartition, mm.ActionDropTablePartition, mm.ActionModifyTableCharsetAndCollate, mm.ActionTruncateTablePartition, - mm.ActionAlterIndexVisibility, mm.ActionMultiSchemaChange, mm.ActionReorganizePartition, + mm.ActionAlterIndexVisibility, mm.ActionMultiSchemaChange, // AddColumns and DropColumns are removed in TiDB v6.2.0, see https://github.com/pingcap/tidb/pull/35862. mm.ActionAddColumns, mm.ActionDropColumns: return canal.EventType_ALTER diff --git a/tests/integration_tests/partition_table/data/prepare.sql b/tests/integration_tests/partition_table/data/prepare.sql index 3dc28c3b0b1..6c37555fa3d 100644 --- a/tests/integration_tests/partition_table/data/prepare.sql +++ b/tests/integration_tests/partition_table/data/prepare.sql @@ -26,13 +26,4 @@ ALTER TABLE t1 EXCHANGE PARTITION p3 WITH TABLE t2; insert into t2 values (100),(101),(102),(103),(104),(105); /*these values will be replicated to in downstream t2*/ insert into t1 values (25),(29); /*these values will be replicated to in downstream t1.p3*/ -ALTER TABLE t1 REORGANIZE PARTITION p0,p2 INTO (PARTITION p0 VALUES LESS THAN (5), PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (21)); -insert into t1 values (-1),(6),(13); -update t1 set a=a-22 where a=20; -delete from t1 where a = 5; -ALTER TABLE t1 REORGANIZE PARTITION p2,p3,p4 INTO (PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (26), PARTITION p4 VALUES LESS THAN (35), PARTITION pMax VALUES LESS THAN (MAXVALUE)); -insert into t1 values (-3),(5),(14),(22),(30),(100); -update t1 set a=a-16 where a=12; -delete from t1 where a = 29; - create table finish_mark (a int primary key);