-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ddl: Global index more restrictions (#55440)
close #55424
- Loading branch information
Showing
8 changed files
with
234 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
set tidb_enable_global_index=OFF; | ||
create table t (a int, b int, unique index idx(a) global); | ||
Error 8200 (HY000): Unsupported Global Index on non-partitioned table | ||
create table t (a int, b int, index idx(a) global); | ||
Error 8200 (HY000): Unsupported Global Index on non-partitioned table | ||
create table t (a int, b int, unique index idx(a) global) partition by hash(b) partitions 3; | ||
Error 1503 (HY000): A UNIQUE INDEX must include all columns in the table's partitioning function | ||
create table t (a int, b int, index idx(a) global) partition by hash(b) partitions 3; | ||
Error 8200 (HY000): Unsupported GLOBAL IndexOption when tidb_enable_global_index is disabled | ||
create table t3(a int not null, b int, primary key(a) nonclustered, unique idx_b(b) global) partition by hash(a) partitions 3; | ||
Error 1503 (HY000): A UNIQUE INDEX must include all columns in the table's partitioning function | ||
create table t (a int primary key nonclustered, b int) partition by hash(b) partitions 3; | ||
Error 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function | ||
create table t (a int, b int, unique key (a)) partition by hash(a) partitions 3; | ||
alter table t partition by hash(b) partitions 3; | ||
Error 1503 (HY000): A UNIQUE INDEX must include all columns in the table's partitioning function | ||
alter table t partition by hash(b) partitions 3 update indexes (a global); | ||
Error 1503 (HY000): A UNIQUE INDEX must include all columns in the table's partitioning function | ||
alter table t add index idxErr (b) global; | ||
Error 8200 (HY000): Unsupported Global IndexOption on non-unique index | ||
alter table t add unique index idxErr (b) global; | ||
Error 1503 (HY000): A UNIQUE INDEX must include all columns in the table's partitioning function | ||
create index idxErr on t (b) global; | ||
Error 8200 (HY000): Unsupported Global IndexOption on non-unique index | ||
create unique index idxErr on t (b) global; | ||
Error 1503 (HY000): A UNIQUE INDEX must include all columns in the table's partitioning function | ||
alter table t remove partitioning; | ||
alter table t add index idxErr (b) global; | ||
Error 8200 (HY000): Unsupported Global Index on non-partitioned table | ||
alter table t add unique index idxErr (b) global; | ||
Error 8200 (HY000): Unsupported Global Index on non-partitioned table | ||
create index idxErr on t (b) global; | ||
Error 8200 (HY000): Unsupported Global Index on non-partitioned table | ||
create unique index idxErr on t (b) global; | ||
Error 8200 (HY000): Unsupported Global Index on non-partitioned table | ||
drop table t; | ||
set tidb_enable_global_index=ON; | ||
create table t (a int, b int, unique index idx(a) global); | ||
Error 8200 (HY000): Unsupported Global Index on non-partitioned table | ||
create table t (a int, b int, index idx(a) global); | ||
Error 8200 (HY000): Unsupported Global Index on non-partitioned table | ||
create table t (a int, b int, index idx(a) global) partition by hash(b) partitions 3; | ||
Error 8200 (HY000): Unsupported GLOBAL IndexOption on non-unique index | ||
create table t (a int not null, b int, primary key(a) nonclustered, unique idx_b(b) global) partition by hash(a) partitions 3; | ||
drop table t; | ||
create table t (a int key global, b int) partition by hash(b) partitions 3; | ||
Error 1503 (HY000): A CLUSTERED INDEX must include all columns in the table's partitioning function | ||
create table t (a int unique, b int) partition by hash(b) partitions 3; | ||
Error 8264 (HY000): Global Index is needed for index 'a', since the unique index is not including all partitioning columns, and GLOBAL is not given as IndexOption | ||
create table t (a int unique key, b int) partition by hash(b) partitions 3; | ||
Error 8264 (HY000): Global Index is needed for index 'a', since the unique index is not including all partitioning columns, and GLOBAL is not given as IndexOption | ||
create table t (a int primary key nonclustered, b int) partition by hash(b) partitions 3; | ||
Error 8264 (HY000): Global Index is needed for index 'PRIMARY', since the unique index is not including all partitioning columns, and GLOBAL is not given as IndexOption | ||
CREATE TABLE `t` ( | ||
`a` int(11) NOT NULL, | ||
`b` int(11) DEFAULT NULL, | ||
PRIMARY KEY (`a`) /*T![clustered_index] NONCLUSTERED */ /*T![global_index] GLOBAL */ | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | ||
PARTITION BY HASH (`b`) PARTITIONS 3; | ||
show create table t; | ||
Table Create Table | ||
t CREATE TABLE `t` ( | ||
`a` int(11) NOT NULL, | ||
`b` int(11) DEFAULT NULL, | ||
PRIMARY KEY (`a`) /*T![clustered_index] NONCLUSTERED */ /*T![global_index] GLOBAL */ | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | ||
PARTITION BY HASH (`b`) PARTITIONS 3 | ||
drop table t; | ||
create table t (a int, b int, unique key (a)) partition by hash(a) partitions 3; | ||
alter table t partition by hash(b) partitions 3; | ||
Error 8264 (HY000): Global Index is needed for index 'a', since the unique index is not including all partitioning columns, and GLOBAL is not given as IndexOption | ||
alter table t partition by hash(b) partitions 3 UPDATE INDEXES (a GLOBAL); | ||
alter table t add index idxErr (b) global; | ||
Error 8200 (HY000): Unsupported Global IndexOption on non-unique index | ||
alter table t add unique index idxOK (a) global; | ||
alter table t add unique index idxErr (b) global; | ||
Error 8200 (HY000): Unsupported Global IndexOption on index including all columns in the partitioning expression | ||
create index idxErr on t (b) global; | ||
Error 8200 (HY000): Unsupported Global IndexOption on non-unique index | ||
create unique index idxOK2 on t (a) global; | ||
create unique index idxErr on t (b) global; | ||
Error 8200 (HY000): Unsupported Global IndexOption on index including all columns in the partitioning expression |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
set tidb_enable_global_index=OFF; | ||
-- error 8200 | ||
create table t (a int, b int, unique index idx(a) global); | ||
-- error 8200 | ||
create table t (a int, b int, index idx(a) global); | ||
-- error 1503 | ||
create table t (a int, b int, unique index idx(a) global) partition by hash(b) partitions 3; | ||
-- error 8200 | ||
create table t (a int, b int, index idx(a) global) partition by hash(b) partitions 3; | ||
-- error 1503 | ||
create table t3(a int not null, b int, primary key(a) nonclustered, unique idx_b(b) global) partition by hash(a) partitions 3; | ||
-- error 1503 | ||
create table t (a int primary key nonclustered, b int) partition by hash(b) partitions 3; | ||
create table t (a int, b int, unique key (a)) partition by hash(a) partitions 3; | ||
-- error 1503 | ||
alter table t partition by hash(b) partitions 3; | ||
-- error 1503 | ||
alter table t partition by hash(b) partitions 3 update indexes (a global); | ||
-- error 8200 | ||
alter table t add index idxErr (b) global; | ||
-- error 1503 | ||
alter table t add unique index idxErr (b) global; | ||
-- error 8200 | ||
create index idxErr on t (b) global; | ||
-- error 1503 | ||
create unique index idxErr on t (b) global; | ||
alter table t remove partitioning; | ||
-- error 8200 | ||
alter table t add index idxErr (b) global; | ||
-- error 8200 | ||
alter table t add unique index idxErr (b) global; | ||
-- error 8200 | ||
create index idxErr on t (b) global; | ||
-- error 8200 | ||
create unique index idxErr on t (b) global; | ||
drop table t; | ||
|
||
set tidb_enable_global_index=ON; | ||
-- error 8200 | ||
create table t (a int, b int, unique index idx(a) global); | ||
-- error 8200 | ||
create table t (a int, b int, index idx(a) global); | ||
-- error 8200 | ||
create table t (a int, b int, index idx(a) global) partition by hash(b) partitions 3; | ||
create table t (a int not null, b int, primary key(a) nonclustered, unique idx_b(b) global) partition by hash(a) partitions 3; | ||
drop table t; | ||
-- error 1503 | ||
create table t (a int key global, b int) partition by hash(b) partitions 3; | ||
-- error 8264 | ||
create table t (a int unique, b int) partition by hash(b) partitions 3; | ||
-- error 8264 | ||
create table t (a int unique key, b int) partition by hash(b) partitions 3; | ||
-- error 8264 | ||
create table t (a int primary key nonclustered, b int) partition by hash(b) partitions 3; | ||
CREATE TABLE `t` ( | ||
`a` int(11) NOT NULL, | ||
`b` int(11) DEFAULT NULL, | ||
PRIMARY KEY (`a`) /*T![clustered_index] NONCLUSTERED */ /*T![global_index] GLOBAL */ | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | ||
PARTITION BY HASH (`b`) PARTITIONS 3; | ||
show create table t; | ||
drop table t; | ||
create table t (a int, b int, unique key (a)) partition by hash(a) partitions 3; | ||
-- error 8264 | ||
alter table t partition by hash(b) partitions 3; | ||
alter table t partition by hash(b) partitions 3 UPDATE INDEXES (a GLOBAL); | ||
-- error 8200 | ||
alter table t add index idxErr (b) global; | ||
alter table t add unique index idxOK (a) global; | ||
-- error 8200 | ||
alter table t add unique index idxErr (b) global; | ||
-- error 8200 | ||
create index idxErr on t (b) global; | ||
create unique index idxOK2 on t (a) global; | ||
-- error 8200 | ||
create unique index idxErr on t (b) global; |