Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl: when enable global index on partition table, unique index constraint not normal #40145

Closed
jiyfhust opened this issue Dec 23, 2022 · 4 comments · Fixed by #41437
Closed
Assignees
Labels
component/tablepartition This issue is related to Table Partition of TiDB. feature/developing the related feature is in development severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@jiyfhust
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

1. enable global index

tidb.toml:
enable-global-index = true

2. create test_t1 with global index p_a
mysql> CREATE TABLE `test_t1` (
  `a` int(11) DEFAULT NULL,
  `b` int(11) DEFAULT NULL,
  `c` int(11) DEFAULT NULL,
  UNIQUE KEY `p_a` (`a`),
  KEY `p_b` (`b`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE (`c`)
(PARTITION `p0` VALUES LESS THAN (10),
 PARTITION `p1` VALUES LESS THAN (MAXVALUE));

3. insert data

mysql> insert into test_t1 values(1,1,1);
Query OK, 1 row affected (0.01 sec)

mysql> insert into test_t1 values(1,1,11);
Query OK, 1 row affected (0.00 sec)

because there is a unique index p_a on column a, it should report a duplicat error.
 
4. add log on tidb, print index type:

 ["index type"] [table=test_t1] [index=p_a] [global=false]
 ["index type"] [table=test_t1] [index=p_b] [global=false]

2. What did you expect to see? (Required)


ERROR 1062 (23000): Duplicate entry '1' for key 'test_t1.p_a'

3. What did you see instead (Required)

no error

4. What is your TiDB version? (Required)

master

@jiyfhust jiyfhust added the type/bug The issue is confirmed as a bug. label Dec 23, 2022
@jiyfhust
Copy link
Contributor Author

/cc @tiancaiamao @crazycs520

@jebter jebter added the sig/sql-infra SIG: SQL Infra label Dec 26, 2022
@mjonss
Copy link
Contributor

mjonss commented Dec 27, 2022

As an issue this has currently low priority, since global index is not yet supported, and does not really work yet. We hope to work on it after we implemented #38535 and other missing MySQL features like alter a non-partitioned table to a partitioned table and vice versa.

@mjonss mjonss added the component/tablepartition This issue is related to Table Partition of TiDB. label Dec 27, 2022
@jiyfhust
Copy link
Contributor Author

hi @mjonss ,can i give a small pr to fix it, it seems not complex,just one line is enough.
In the example above, index(p_a) is a global index,but create table forget to set the flag, then the error occur.

@mjonss
Copy link
Contributor

mjonss commented Dec 28, 2022

hi @mjonss ,can i give a small pr to fix it, it seems not complex,just one line is enough. In the example above, index(p_a) is a global index,but create table forget to set the flag, then the error occur.

@jiyfhust of course, all patches are welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tablepartition This issue is related to Table Partition of TiDB. feature/developing the related feature is in development severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants