Skip to content

Commit b958452

Browse files
committed
detect partition table scenario
1 parent a73e827 commit b958452

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

pkg/sink/codec/simple/decoder.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,13 +543,13 @@ func (d *Decoder) buildDDLEvent(msg *message) *commonEvent.DDLEvent {
543543
result.TableInfo = tableInfo
544544

545545
result.FinishedTs = msg.CommitTs
546-
result.SchemaName = msg.Schema
547-
result.TableName = msg.Table
546+
result.SchemaName = msg.TableSchema.Schema
547+
result.TableName = msg.TableSchema.Table
548+
result.TableID = msg.TableSchema.TableID
548549
if preTableInfo != nil {
549550
result.ExtraSchemaName = preTableInfo.GetSchemaName()
550551
result.ExtraTableName = preTableInfo.GetTableName()
551552
}
552-
result.TableID = tableInfo.TableName.TableID
553553
result.MultipleTableInfos = []*commonType.TableInfo{tableInfo, preTableInfo}
554554

555555
if result.Query == "" {

pkg/sink/codec/simple/encoder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func TestE2EPartitionTable(t *testing.T) {
278278

279279
decodedDDL = dec.NextDDLEvent()
280280
for _, item := range physicalTableID {
281-
require.Contains(t, decodedDDL.GetBlockedTables().TableIDs, item)
281+
require.Contains(t, decodedDDL.GetBlockedTables().TableIDs, item, format)
282282
}
283283
}
284284
}

tests/integration_tests/partition_table/data/prepare.sql

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ drop database if exists `partition_table2`;
33
create database `partition_table`;
44
use `partition_table`;
55

6-
create table t (a int, primary key (a)) partition by hash(a) partitions 5;
7-
insert into t values (1),(2),(3),(4),(5),(6);
8-
insert into t values (7),(8),(9);
9-
alter table t truncate partition p3;
10-
update t set a=a+10 where a=2;
6+
-- create table t (a int, primary key (a)) partition by hash(a) partitions 5;
7+
-- insert into t values (1),(2),(3),(4),(5),(6);
8+
-- insert into t values (7),(8),(9);
9+
-- alter table t truncate partition p3;
10+
-- update t set a=a+10 where a=2;
1111

1212

1313
create table t1 (a int primary key) PARTITION BY RANGE ( a ) ( PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11),PARTITION p2 VALUES LESS THAN (21));
@@ -21,38 +21,38 @@ alter table t1 drop partition p1;
2121
insert into t1 values (7),(8),(9);
2222
update t1 set a=a+10 where a=9;
2323

24-
/* Remove partitioning + add partitioning back again */
25-
alter table t remove partitioning;
26-
insert into t values (20),(21),(22),(23),(24),(25);
27-
alter table t partition by hash (a) partitions 5;
28-
insert into t values (30),(31),(32),(33),(34),(35);
24+
-- /* Remove partitioning + add partitioning back again */
25+
-- alter table t remove partitioning;
26+
-- insert into t values (20),(21),(22),(23),(24),(25);
27+
-- alter table t partition by hash (a) partitions 5;
28+
-- insert into t values (30),(31),(32),(33),(34),(35);
2929

3030
/* exchange partition case 1: source table and target table in same database */
3131
create table t2 (a int primary key);
3232
ALTER TABLE t1 EXCHANGE PARTITION p3 WITH TABLE t2;
3333
insert into t2 values (100),(101),(102),(103),(104),(105); /*these values will be replicated to in downstream t2*/
3434
insert into t1 values (25),(29); /*these values will be replicated to in downstream t1.p3*/
3535

36-
/* exchange partition ccase 2: source table and target table in different database */
37-
create database `partition_table2`;
38-
create table partition_table2.t2 (a int primary key);
39-
ALTER TABLE t1 EXCHANGE PARTITION p3 WITH TABLE partition_table2.t2;
40-
insert into partition_table2.t2 values (1002),(1012),(1022),(1032),(1042),(1052); /*these values will be replicated to in downstream t2*/
41-
insert into t1 values (21),(28); /*these values will be replicated to in downstream t1.p3*/
42-
43-
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));
44-
insert into t1 values (-1),(6),(13);
45-
update t1 set a=a-22 where a=20;
46-
delete from t1 where a = 5;
47-
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));
48-
insert into t1 values (-3),(5),(14),(22),(30),(100);
49-
update t1 set a=a-16 where a=12;
50-
delete from t1 where a = 29;
51-
ALTER TABLE t1 REORGANIZE PARTITION p2,p3,p4,pMax INTO (PARTITION pRest VALUES LESS THAN (MAXVALUE));
52-
53-
/* Change partitioning to key based and then back to range */
54-
alter table t1 partition by key(a) partitions 7;
55-
insert into t1 values (-2001),(2001),(2002),(-2002),(-2003),(2003),(-2004),(2004),(-2005),(2005),(2006),(-2006),(2007),(-2007);
56-
ALTER TABLE t1 partition by range(a) (partition p0 values less than (5), PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (26), PARTITION p4 VALUES LESS THAN (35), PARTITION pMax VALUES LESS THAN (MAXVALUE));
36+
-- /* exchange partition ccase 2: source table and target table in different database */
37+
-- create database `partition_table2`;
38+
-- create table partition_table2.t2 (a int primary key);
39+
-- ALTER TABLE t1 EXCHANGE PARTITION p3 WITH TABLE partition_table2.t2;
40+
-- insert into partition_table2.t2 values (1002),(1012),(1022),(1032),(1042),(1052); /*these values will be replicated to in downstream t2*/
41+
-- insert into t1 values (21),(28); /*these values will be replicated to in downstream t1.p3*/
42+
--
43+
-- 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));
44+
-- insert into t1 values (-1),(6),(13);
45+
-- update t1 set a=a-22 where a=20;
46+
-- delete from t1 where a = 5;
47+
-- 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));
48+
-- insert into t1 values (-3),(5),(14),(22),(30),(100);
49+
-- update t1 set a=a-16 where a=12;
50+
-- delete from t1 where a = 29;
51+
-- ALTER TABLE t1 REORGANIZE PARTITION p2,p3,p4,pMax INTO (PARTITION pRest VALUES LESS THAN (MAXVALUE));
52+
--
53+
-- /* Change partitioning to key based and then back to range */
54+
-- alter table t1 partition by key(a) partitions 7;
55+
-- insert into t1 values (-2001),(2001),(2002),(-2002),(-2003),(2003),(-2004),(2004),(-2005),(2005),(2006),(-2006),(2007),(-2007);
56+
-- ALTER TABLE t1 partition by range(a) (partition p0 values less than (5), PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (26), PARTITION p4 VALUES LESS THAN (35), PARTITION pMax VALUES LESS THAN (MAXVALUE));
5757

5858
create table finish_mark (a int primary key);

0 commit comments

Comments
 (0)