@@ -4173,3 +4173,41 @@ func TestExchangeTiDBRowID(t *testing.T) {
41734173 "6 6 3" ,
41744174 "8 8 30001" ))
41754175}
4176+
4177+ func TestIssue66077ExchangePartitionDifferentDefinitionsWithShardRowIDBits (t * testing.T ) {
4178+ store := testkit .CreateMockStore (t )
4179+ tk := testkit .NewTestKit (t , store )
4180+ tk .MustExec ("set @@session.tidb_enable_clustered_index = off" )
4181+ tk .MustExec ("set @@session.tidb_shard_row_id_bits = 4" )
4182+ tk .MustExec ("create database sbtest" )
4183+ tk .MustExec ("use sbtest" )
4184+
4185+ tk .MustExec (`CREATE TABLE sbtest1 (
4186+ id int NOT NULL,
4187+ k int NOT NULL DEFAULT '0',
4188+ c char(120) NOT NULL DEFAULT '',
4189+ pad char(60) NOT NULL DEFAULT '',
4190+ PRIMARY KEY (id) /*T![clustered_index] NONCLUSTERED */,
4191+ KEY k_1 (k)
4192+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin` )
4193+
4194+ tblInfo , err := tk .Session ().GetInfoSchema ().TableInfoByName (ast .NewCIStr ("sbtest" ), ast .NewCIStr ("sbtest1" ))
4195+ require .NoError (t , err )
4196+ require .Equal (t , uint64 (4 ), tblInfo .ShardRowIDBits )
4197+ require .Equal (t , uint64 (4 ), tblInfo .MaxShardRowIDBits )
4198+
4199+ tk .MustExec (`CREATE TABLE sbtest1_partition (
4200+ id int NOT NULL,
4201+ k int NOT NULL DEFAULT '0',
4202+ c char(120) NOT NULL DEFAULT '',
4203+ pad char(60) NOT NULL DEFAULT '',
4204+ PRIMARY KEY (id) /*T![clustered_index] NONCLUSTERED */,
4205+ KEY k_1 (k)
4206+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T! SHARD_ROW_ID_BITS=4 */
4207+ PARTITION BY RANGE (id)
4208+ (PARTITION 1M VALUES LESS THAN (1000000),
4209+ PARTITION 5M VALUES LESS THAN (5000000),
4210+ PARTITION 10M VALUES LESS THAN (10000000),
4211+ PARTITION 100M VALUES LESS THAN (100000000))` )
4212+ tk .MustExec ("alter table sbtest1_partition exchange partition 1M with table sbtest1" )
4213+ }
0 commit comments