Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Support ALTER TABLE t REORGANIZE PARTITION (pingcap#8114)"
Browse files Browse the repository at this point in the history
This reverts commit 129d619.
Rustin170506 committed Mar 21, 2023
1 parent 35921ef commit 93ba2a9
Showing 7 changed files with 2 additions and 17 deletions.
3 changes: 1 addition & 2 deletions cdc/entry/schema/snapshot.go
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 0 additions & 2 deletions cdc/entry/schema_storage_test.go
Original file line number Diff line number Diff line change
@@ -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",
1 change: 0 additions & 1 deletion pkg/filter/filter.go
Original file line number Diff line number Diff line change
@@ -54,7 +54,6 @@ var allowDDLList = []timodel.ActionType{
timodel.ActionAlterIndexVisibility,
timodel.ActionMultiSchemaChange,
timodel.ActionExchangeTablePartition,
timodel.ActionReorganizePartition,
timodel.ActionAlterTTLInfo,
timodel.ActionAlterTTLRemove,
}
1 change: 0 additions & 1 deletion pkg/filter/filter_test.go
Original file line number Diff line number Diff line change
@@ -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, "", ""))
1 change: 0 additions & 1 deletion pkg/filter/utils_test.go
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion pkg/sink/codec/canal/canal_entry.go
Original file line number Diff line number Diff line change
@@ -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
9 changes: 0 additions & 9 deletions tests/integration_tests/partition_table/data/prepare.sql
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 93ba2a9

Please sign in to comment.