From 0ed00c6965a4aea1d654392e707b36b17c7fffb4 Mon Sep 17 00:00:00 2001 From: lidezhu Date: Thu, 12 Mar 2026 13:27:17 +0800 Subject: [PATCH 1/4] add integration test --- .../consistent_partition_table/data/prepare.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/integration_tests/consistent_partition_table/data/prepare.sql b/tests/integration_tests/consistent_partition_table/data/prepare.sql index 567b06347c..c1018a2511 100644 --- a/tests/integration_tests/consistent_partition_table/data/prepare.sql +++ b/tests/integration_tests/consistent_partition_table/data/prepare.sql @@ -32,4 +32,14 @@ ALTER TABLE t1 REORGANIZE PARTITION p0,p2 INTO (PARTITION p0 VALUES LESS THAN (5 -- update t1 set a=a-16 where a=12; -- delete from t1 where a = 29; +/* mixed rename tables: normal table + partition table */ +RENAME TABLE t2 TO t2_mix_1, t TO t_mix_1; +insert into t2_mix_1 values (106),(107); +insert into t_mix_1 values (30),(31); + +/* reverse rename order to cover both job level table info shapes */ +RENAME TABLE t_mix_1 TO t_final, t2_mix_1 TO t2_final; +insert into t_final values (32),(33); +insert into t2_final values (108),(109); + -- create table finish_mark (a int primary key); From b27f2914afa8560e0e0600736ea4dc72cb205cd1 Mon Sep 17 00:00:00 2001 From: lidezhu Date: Thu, 12 Mar 2026 13:49:28 +0800 Subject: [PATCH 2/4] add test --- .../data/prepare.sql | 10 ----- .../conf/diff_config.toml | 9 ++++- .../conf/normal.toml | 20 +++++++++- .../data/test.sql | 40 +++++++++++++++++++ .../csv_storage_multi_tables_ddl/run.sh | 4 ++ .../multi_tables_ddl/conf/diff_config.toml | 9 ++++- .../multi_tables_ddl/conf/normal.toml | 20 +++++++++- .../multi_tables_ddl/data/test.sql | 40 +++++++++++++++++++ .../integration_tests/multi_tables_ddl/run.sh | 4 ++ 9 files changed, 140 insertions(+), 16 deletions(-) diff --git a/tests/integration_tests/consistent_partition_table/data/prepare.sql b/tests/integration_tests/consistent_partition_table/data/prepare.sql index c1018a2511..567b06347c 100644 --- a/tests/integration_tests/consistent_partition_table/data/prepare.sql +++ b/tests/integration_tests/consistent_partition_table/data/prepare.sql @@ -32,14 +32,4 @@ ALTER TABLE t1 REORGANIZE PARTITION p0,p2 INTO (PARTITION p0 VALUES LESS THAN (5 -- update t1 set a=a-16 where a=12; -- delete from t1 where a = 29; -/* mixed rename tables: normal table + partition table */ -RENAME TABLE t2 TO t2_mix_1, t TO t_mix_1; -insert into t2_mix_1 values (106),(107); -insert into t_mix_1 values (30),(31); - -/* reverse rename order to cover both job level table info shapes */ -RENAME TABLE t_mix_1 TO t_final, t2_mix_1 TO t2_final; -insert into t_final values (32),(33); -insert into t2_final values (108),(109); - -- create table finish_mark (a int primary key); diff --git a/tests/integration_tests/csv_storage_multi_tables_ddl/conf/diff_config.toml b/tests/integration_tests/csv_storage_multi_tables_ddl/conf/diff_config.toml index fc562776fc..e88bc52cb1 100644 --- a/tests/integration_tests/csv_storage_multi_tables_ddl/conf/diff_config.toml +++ b/tests/integration_tests/csv_storage_multi_tables_ddl/conf/diff_config.toml @@ -13,7 +13,14 @@ check-struct-only = false target-instance = "mysql1" - target-check-tables = ["multi_tables_ddl_test.t1_7", "multi_tables_ddl_test.t2_7"] + target-check-tables = [ + "multi_tables_ddl_test.t1_7", + "multi_tables_ddl_test.t2_7", + "multi_tables_ddl_test.rename_mix_normal_1_done", + "multi_tables_ddl_test.rename_mix_part_1_done", + "multi_tables_ddl_test.rename_mix_normal_2_done", + "multi_tables_ddl_test.rename_mix_part_2_done", + ] [data-sources] [data-sources.tidb0] diff --git a/tests/integration_tests/csv_storage_multi_tables_ddl/conf/normal.toml b/tests/integration_tests/csv_storage_multi_tables_ddl/conf/normal.toml index fa4e188af6..a85957996a 100644 --- a/tests/integration_tests/csv_storage_multi_tables_ddl/conf/normal.toml +++ b/tests/integration_tests/csv_storage_multi_tables_ddl/conf/normal.toml @@ -1,5 +1,21 @@ [filter] -rules = ["multi_tables_ddl_test.t1", "multi_tables_ddl_test.t2", "multi_tables_ddl_test.t3", "multi_tables_ddl_test.t4" ,"multi_tables_ddl_test.t1_7","multi_tables_ddl_test.t2_7", "multi_tables_ddl_test.finish_mark"] +rules = [ + "multi_tables_ddl_test.t1", + "multi_tables_ddl_test.t2", + "multi_tables_ddl_test.t3", + "multi_tables_ddl_test.t4", + "multi_tables_ddl_test.t1_7", + "multi_tables_ddl_test.t2_7", + "multi_tables_ddl_test.rename_mix_normal_1", + "multi_tables_ddl_test.rename_mix_part_1", + "multi_tables_ddl_test.rename_mix_normal_1_done", + "multi_tables_ddl_test.rename_mix_part_1_done", + "multi_tables_ddl_test.rename_mix_normal_2", + "multi_tables_ddl_test.rename_mix_part_2", + "multi_tables_ddl_test.rename_mix_normal_2_done", + "multi_tables_ddl_test.rename_mix_part_2_done", + "multi_tables_ddl_test.finish_mark", +] [sink.csv] -include-commit-ts = true \ No newline at end of file +include-commit-ts = true diff --git a/tests/integration_tests/csv_storage_multi_tables_ddl/data/test.sql b/tests/integration_tests/csv_storage_multi_tables_ddl/data/test.sql index e1a91f809a..5a6047266d 100644 --- a/tests/integration_tests/csv_storage_multi_tables_ddl/data/test.sql +++ b/tests/integration_tests/csv_storage_multi_tables_ddl/data/test.sql @@ -110,6 +110,46 @@ insert into t1_7 values(685477580, 6); insert into t2_7 values(1715679991826145, 7); insert into t2_7 values(2036854775807, 8); +create table rename_mix_normal_1 ( + id int not null, + value32 int not null, + primary key(id) +); + +create table rename_mix_part_1 ( + id int not null, + value32 int not null, + primary key(id) +) partition by hash(id) partitions 2; + +insert into rename_mix_normal_1 values(1, 10), (2, 20); +insert into rename_mix_part_1 values(11, 110), (12, 120); + +rename table rename_mix_normal_1 to rename_mix_normal_1_done, rename_mix_part_1 to rename_mix_part_1_done; + +insert into rename_mix_normal_1_done values(3, 30); +insert into rename_mix_part_1_done values(13, 130); + +create table rename_mix_part_2 ( + id int not null, + value32 int not null, + primary key(id) +) partition by hash(id) partitions 2; + +create table rename_mix_normal_2 ( + id int not null, + value32 int not null, + primary key(id) +); + +insert into rename_mix_part_2 values(21, 210), (22, 220); +insert into rename_mix_normal_2 values(31, 310), (32, 320); + +rename table rename_mix_part_2 to rename_mix_part_2_done, rename_mix_normal_2 to rename_mix_normal_2_done; + +insert into rename_mix_part_2_done values(23, 230); +insert into rename_mix_normal_2_done values(33, 330); + insert into t3 select * from t1_7; insert into t4 select * from t2_7; drop table t3, t4; diff --git a/tests/integration_tests/csv_storage_multi_tables_ddl/run.sh b/tests/integration_tests/csv_storage_multi_tables_ddl/run.sh index 1469055d40..c04c56c037 100755 --- a/tests/integration_tests/csv_storage_multi_tables_ddl/run.sh +++ b/tests/integration_tests/csv_storage_multi_tables_ddl/run.sh @@ -48,6 +48,10 @@ function run() { check_table_exists multi_tables_ddl_test.t66 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} check_table_exists multi_tables_ddl_test.t7 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} check_table_exists multi_tables_ddl_test.t88 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} + check_table_exists multi_tables_ddl_test.rename_mix_normal_1_done ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} + check_table_exists multi_tables_ddl_test.rename_mix_part_1_done ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} + check_table_exists multi_tables_ddl_test.rename_mix_normal_2_done ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} + check_table_exists multi_tables_ddl_test.rename_mix_part_2_done ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} # sync_diff can't check non-exist table, so we check expected tables are created in downstream first check_table_exists multi_tables_ddl_test.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} echo "check table exists success" diff --git a/tests/integration_tests/multi_tables_ddl/conf/diff_config.toml b/tests/integration_tests/multi_tables_ddl/conf/diff_config.toml index a2dccc4ede..fdc9237e70 100644 --- a/tests/integration_tests/multi_tables_ddl/conf/diff_config.toml +++ b/tests/integration_tests/multi_tables_ddl/conf/diff_config.toml @@ -13,7 +13,14 @@ check-struct-only = false target-instance = "mysql1" - target-check-tables = ["multi_tables_ddl_test.t1_7", "multi_tables_ddl_test.t2_7"] + target-check-tables = [ + "multi_tables_ddl_test.t1_7", + "multi_tables_ddl_test.t2_7", + "multi_tables_ddl_test.rename_mix_normal_1_done", + "multi_tables_ddl_test.rename_mix_part_1_done", + "multi_tables_ddl_test.rename_mix_normal_2_done", + "multi_tables_ddl_test.rename_mix_part_2_done", + ] [data-sources] [data-sources.tidb0] diff --git a/tests/integration_tests/multi_tables_ddl/conf/normal.toml b/tests/integration_tests/multi_tables_ddl/conf/normal.toml index fa4e188af6..a85957996a 100644 --- a/tests/integration_tests/multi_tables_ddl/conf/normal.toml +++ b/tests/integration_tests/multi_tables_ddl/conf/normal.toml @@ -1,5 +1,21 @@ [filter] -rules = ["multi_tables_ddl_test.t1", "multi_tables_ddl_test.t2", "multi_tables_ddl_test.t3", "multi_tables_ddl_test.t4" ,"multi_tables_ddl_test.t1_7","multi_tables_ddl_test.t2_7", "multi_tables_ddl_test.finish_mark"] +rules = [ + "multi_tables_ddl_test.t1", + "multi_tables_ddl_test.t2", + "multi_tables_ddl_test.t3", + "multi_tables_ddl_test.t4", + "multi_tables_ddl_test.t1_7", + "multi_tables_ddl_test.t2_7", + "multi_tables_ddl_test.rename_mix_normal_1", + "multi_tables_ddl_test.rename_mix_part_1", + "multi_tables_ddl_test.rename_mix_normal_1_done", + "multi_tables_ddl_test.rename_mix_part_1_done", + "multi_tables_ddl_test.rename_mix_normal_2", + "multi_tables_ddl_test.rename_mix_part_2", + "multi_tables_ddl_test.rename_mix_normal_2_done", + "multi_tables_ddl_test.rename_mix_part_2_done", + "multi_tables_ddl_test.finish_mark", +] [sink.csv] -include-commit-ts = true \ No newline at end of file +include-commit-ts = true diff --git a/tests/integration_tests/multi_tables_ddl/data/test.sql b/tests/integration_tests/multi_tables_ddl/data/test.sql index e1a91f809a..5a6047266d 100644 --- a/tests/integration_tests/multi_tables_ddl/data/test.sql +++ b/tests/integration_tests/multi_tables_ddl/data/test.sql @@ -110,6 +110,46 @@ insert into t1_7 values(685477580, 6); insert into t2_7 values(1715679991826145, 7); insert into t2_7 values(2036854775807, 8); +create table rename_mix_normal_1 ( + id int not null, + value32 int not null, + primary key(id) +); + +create table rename_mix_part_1 ( + id int not null, + value32 int not null, + primary key(id) +) partition by hash(id) partitions 2; + +insert into rename_mix_normal_1 values(1, 10), (2, 20); +insert into rename_mix_part_1 values(11, 110), (12, 120); + +rename table rename_mix_normal_1 to rename_mix_normal_1_done, rename_mix_part_1 to rename_mix_part_1_done; + +insert into rename_mix_normal_1_done values(3, 30); +insert into rename_mix_part_1_done values(13, 130); + +create table rename_mix_part_2 ( + id int not null, + value32 int not null, + primary key(id) +) partition by hash(id) partitions 2; + +create table rename_mix_normal_2 ( + id int not null, + value32 int not null, + primary key(id) +); + +insert into rename_mix_part_2 values(21, 210), (22, 220); +insert into rename_mix_normal_2 values(31, 310), (32, 320); + +rename table rename_mix_part_2 to rename_mix_part_2_done, rename_mix_normal_2 to rename_mix_normal_2_done; + +insert into rename_mix_part_2_done values(23, 230); +insert into rename_mix_normal_2_done values(33, 330); + insert into t3 select * from t1_7; insert into t4 select * from t2_7; drop table t3, t4; diff --git a/tests/integration_tests/multi_tables_ddl/run.sh b/tests/integration_tests/multi_tables_ddl/run.sh index 17037d380e..2cf634afbc 100755 --- a/tests/integration_tests/multi_tables_ddl/run.sh +++ b/tests/integration_tests/multi_tables_ddl/run.sh @@ -102,6 +102,10 @@ function run() { check_table_exists multi_tables_ddl_test.t66 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} check_table_exists multi_tables_ddl_test.t7 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} check_table_exists multi_tables_ddl_test.t88 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} + check_table_exists multi_tables_ddl_test.rename_mix_normal_1_done ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} + check_table_exists multi_tables_ddl_test.rename_mix_part_1_done ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} + check_table_exists multi_tables_ddl_test.rename_mix_normal_2_done ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} + check_table_exists multi_tables_ddl_test.rename_mix_part_2_done ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} # sync_diff can't check non-exist table, so we check expected tables are created in downstream first check_table_exists multi_tables_ddl_test.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} echo "check table exists success" From e7f0794ef01a57fa604607a1fed22aafc6d63129 Mon Sep 17 00:00:00 2001 From: lidezhu Date: Thu, 12 Mar 2026 14:07:26 +0800 Subject: [PATCH 3/4] f --- .../persist_storage_ddl_handlers.go | 4 +- .../schemastore/persist_storage_test.go | 116 ++++++++++++++++++ 2 files changed, 118 insertions(+), 2 deletions(-) diff --git a/logservice/schemastore/persist_storage_ddl_handlers.go b/logservice/schemastore/persist_storage_ddl_handlers.go index b06d69cb2f..b0d46c8b4d 100644 --- a/logservice/schemastore/persist_storage_ddl_handlers.go +++ b/logservice/schemastore/persist_storage_ddl_handlers.go @@ -2692,8 +2692,8 @@ func buildDDLEventForRenameTables(rawEvent *PersistedDDLEvent, tableFilter filte continue } allFiltered = false - if isPartitionTable(rawEvent.TableInfo) { - allPhysicalIDs := getAllPartitionIDs(rawEvent.TableInfo) + if isPartitionTable(tableInfo) { + allPhysicalIDs := getAllPartitionIDs(tableInfo) if !ignorePrevTable { if !notSyncPrevTable { // only when the previous table is not filtered and not NotSync, we add the query and table info diff --git a/logservice/schemastore/persist_storage_test.go b/logservice/schemastore/persist_storage_test.go index b85a56cd57..b16d8c1872 100644 --- a/logservice/schemastore/persist_storage_test.go +++ b/logservice/schemastore/persist_storage_test.go @@ -3459,6 +3459,122 @@ func TestBuildPersistedDDLEventEscapesIdentifiers(t *testing.T) { }) } +func TestBuildDDLEventForRenameTablesForPartitionTable(t *testing.T) { + normalInfo := newEligibleTableInfoForTest(200, "normal_new") + partitionInfo := newEligiblePartitionTableInfoForTest(300, "partition_new", []model.PartitionDefinition{ + {ID: 301}, + {ID: 302}, + }) + partitionInfo2 := newEligiblePartitionTableInfoForTest(400, "partition_new_2", []model.PartitionDefinition{ + {ID: 401}, + {ID: 402}, + }) + + t.Run("normal table then partition table", func(t *testing.T) { + rawEvent := &PersistedDDLEvent{ + Type: byte(model.ActionRenameTables), + SchemaID: 110, + SchemaName: "target_normal", + TableName: normalInfo.Name.O, + TableInfo: normalInfo, + Query: "RENAME TABLE `source_normal`.`normal_old` TO `target_normal`.`normal_new`;" + + "RENAME TABLE `source_partition`.`partition_old` TO `target_partition`.`partition_new`;", + FinishedTs: 1010, + SchemaIDs: []int64{100, 111}, + SchemaNames: []string{"target_normal", "target_partition"}, + ExtraSchemaIDs: []int64{100, 101}, + ExtraSchemaNames: []string{"source_normal", "source_partition"}, + ExtraTableNames: []string{"normal_old", "partition_old"}, + MultipleTableInfos: []*model.TableInfo{ + normalInfo, + partitionInfo, + }, + } + + ddlEvent, ok, err := buildDDLEventForRenameTables(rawEvent, nil, 301) + require.NoError(t, err) + require.True(t, ok) + require.Equal(t, []int64{common.DDLSpanTableID, 200, 301, 302}, ddlEvent.BlockedTables.TableIDs) + require.Equal(t, []commonEvent.SchemaIDChange{ + {TableID: 301, OldSchemaID: 101, NewSchemaID: 111}, + {TableID: 302, OldSchemaID: 101, NewSchemaID: 111}, + }, ddlEvent.UpdatedSchemas) + require.NotNil(t, ddlEvent.TableInfo) + require.Equal(t, int64(300), ddlEvent.GetTableID()) + require.Equal(t, "target_partition", ddlEvent.TableInfo.GetSchemaName()) + require.Equal(t, "partition_new", ddlEvent.TableInfo.GetTableName()) + }) + + t.Run("partition table then normal table", func(t *testing.T) { + rawEvent := &PersistedDDLEvent{ + Type: byte(model.ActionRenameTables), + SchemaID: 111, + SchemaName: "target_partition", + TableName: partitionInfo.Name.O, + TableInfo: partitionInfo, + Query: "RENAME TABLE `source_partition`.`partition_old` TO `target_partition`.`partition_new`;" + + "RENAME TABLE `source_normal`.`normal_old` TO `target_normal`.`normal_new`;", + FinishedTs: 1010, + SchemaIDs: []int64{111, 110}, + SchemaNames: []string{"target_partition", "target_normal"}, + ExtraSchemaIDs: []int64{111, 100}, + ExtraSchemaNames: []string{"source_partition", "source_normal"}, + ExtraTableNames: []string{"partition_old", "normal_old"}, + MultipleTableInfos: []*model.TableInfo{ + partitionInfo, + normalInfo, + }, + } + + ddlEvent, ok, err := buildDDLEventForRenameTables(rawEvent, nil, 200) + require.NoError(t, err) + require.True(t, ok) + require.Equal(t, []int64{common.DDLSpanTableID, 301, 302, 200}, ddlEvent.BlockedTables.TableIDs) + require.Equal(t, []commonEvent.SchemaIDChange{ + {TableID: 200, OldSchemaID: 100, NewSchemaID: 110}, + }, ddlEvent.UpdatedSchemas) + require.NotNil(t, ddlEvent.TableInfo) + require.Equal(t, int64(200), ddlEvent.GetTableID()) + require.Equal(t, "target_normal", ddlEvent.TableInfo.GetSchemaName()) + require.Equal(t, "normal_new", ddlEvent.TableInfo.GetTableName()) + }) + + t.Run("multiple partition tables", func(t *testing.T) { + rawEvent := &PersistedDDLEvent{ + Type: byte(model.ActionRenameTables), + SchemaID: 111, + SchemaName: "target_partition", + TableName: partitionInfo.Name.O, + TableInfo: partitionInfo, + Query: "RENAME TABLE `source_partition`.`partition_old` TO `target_partition`.`partition_new`;" + + "RENAME TABLE `source_partition_2`.`partition_old_2` TO `target_partition_2`.`partition_new_2`;", + FinishedTs: 1010, + SchemaIDs: []int64{111, 121}, + SchemaNames: []string{"target_partition", "target_partition_2"}, + ExtraSchemaIDs: []int64{111, 120}, + ExtraSchemaNames: []string{"source_partition", "source_partition_2"}, + ExtraTableNames: []string{"partition_old", "partition_old_2"}, + MultipleTableInfos: []*model.TableInfo{ + partitionInfo, + partitionInfo2, + }, + } + + ddlEvent, ok, err := buildDDLEventForRenameTables(rawEvent, nil, 402) + require.NoError(t, err) + require.True(t, ok) + require.Equal(t, []int64{common.DDLSpanTableID, 301, 302, 401, 402}, ddlEvent.BlockedTables.TableIDs) + require.Equal(t, []commonEvent.SchemaIDChange{ + {TableID: 401, OldSchemaID: 120, NewSchemaID: 121}, + {TableID: 402, OldSchemaID: 120, NewSchemaID: 121}, + }, ddlEvent.UpdatedSchemas) + require.NotNil(t, ddlEvent.TableInfo) + require.Equal(t, int64(400), ddlEvent.GetTableID()) + require.Equal(t, "target_partition_2", ddlEvent.TableInfo.GetSchemaName()) + require.Equal(t, "partition_new_2", ddlEvent.TableInfo.GetTableName()) + }) +} + func TestParseRenameTablesQueryInfos(t *testing.T) { cases := []struct { name string From 324e73f3257b10f06e32d254014ead9b51de18d2 Mon Sep 17 00:00:00 2001 From: lidezhu Date: Thu, 12 Mar 2026 14:20:10 +0800 Subject: [PATCH 4/4] r --- logservice/schemastore/persist_storage_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/logservice/schemastore/persist_storage_test.go b/logservice/schemastore/persist_storage_test.go index b16d8c1872..2505ae73d6 100644 --- a/logservice/schemastore/persist_storage_test.go +++ b/logservice/schemastore/persist_storage_test.go @@ -3480,7 +3480,7 @@ func TestBuildDDLEventForRenameTablesForPartitionTable(t *testing.T) { Query: "RENAME TABLE `source_normal`.`normal_old` TO `target_normal`.`normal_new`;" + "RENAME TABLE `source_partition`.`partition_old` TO `target_partition`.`partition_new`;", FinishedTs: 1010, - SchemaIDs: []int64{100, 111}, + SchemaIDs: []int64{110, 111}, SchemaNames: []string{"target_normal", "target_partition"}, ExtraSchemaIDs: []int64{100, 101}, ExtraSchemaNames: []string{"source_normal", "source_partition"}, @@ -3496,6 +3496,7 @@ func TestBuildDDLEventForRenameTablesForPartitionTable(t *testing.T) { require.True(t, ok) require.Equal(t, []int64{common.DDLSpanTableID, 200, 301, 302}, ddlEvent.BlockedTables.TableIDs) require.Equal(t, []commonEvent.SchemaIDChange{ + {TableID: 200, OldSchemaID: 100, NewSchemaID: 110}, {TableID: 301, OldSchemaID: 101, NewSchemaID: 111}, {TableID: 302, OldSchemaID: 101, NewSchemaID: 111}, }, ddlEvent.UpdatedSchemas) @@ -3517,7 +3518,7 @@ func TestBuildDDLEventForRenameTablesForPartitionTable(t *testing.T) { FinishedTs: 1010, SchemaIDs: []int64{111, 110}, SchemaNames: []string{"target_partition", "target_normal"}, - ExtraSchemaIDs: []int64{111, 100}, + ExtraSchemaIDs: []int64{101, 100}, ExtraSchemaNames: []string{"source_partition", "source_normal"}, ExtraTableNames: []string{"partition_old", "normal_old"}, MultipleTableInfos: []*model.TableInfo{ @@ -3531,6 +3532,8 @@ func TestBuildDDLEventForRenameTablesForPartitionTable(t *testing.T) { require.True(t, ok) require.Equal(t, []int64{common.DDLSpanTableID, 301, 302, 200}, ddlEvent.BlockedTables.TableIDs) require.Equal(t, []commonEvent.SchemaIDChange{ + {TableID: 301, OldSchemaID: 101, NewSchemaID: 111}, + {TableID: 302, OldSchemaID: 101, NewSchemaID: 111}, {TableID: 200, OldSchemaID: 100, NewSchemaID: 110}, }, ddlEvent.UpdatedSchemas) require.NotNil(t, ddlEvent.TableInfo) @@ -3551,7 +3554,7 @@ func TestBuildDDLEventForRenameTablesForPartitionTable(t *testing.T) { FinishedTs: 1010, SchemaIDs: []int64{111, 121}, SchemaNames: []string{"target_partition", "target_partition_2"}, - ExtraSchemaIDs: []int64{111, 120}, + ExtraSchemaIDs: []int64{101, 120}, ExtraSchemaNames: []string{"source_partition", "source_partition_2"}, ExtraTableNames: []string{"partition_old", "partition_old_2"}, MultipleTableInfos: []*model.TableInfo{ @@ -3565,6 +3568,8 @@ func TestBuildDDLEventForRenameTablesForPartitionTable(t *testing.T) { require.True(t, ok) require.Equal(t, []int64{common.DDLSpanTableID, 301, 302, 401, 402}, ddlEvent.BlockedTables.TableIDs) require.Equal(t, []commonEvent.SchemaIDChange{ + {TableID: 301, OldSchemaID: 101, NewSchemaID: 111}, + {TableID: 302, OldSchemaID: 101, NewSchemaID: 111}, {TableID: 401, OldSchemaID: 120, NewSchemaID: 121}, {TableID: 402, OldSchemaID: 120, NewSchemaID: 121}, }, ddlEvent.UpdatedSchemas)