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

Could insert duplicate values into a unique index with global index #52380

Closed
Defined2014 opened this issue Apr 7, 2024 · 1 comment · Fixed by #52442
Closed

Could insert duplicate values into a unique index with global index #52380

Defined2014 opened this issue Apr 7, 2024 · 1 comment · Fixed by #52442
Labels
affects-8.1 component/tablepartition This issue is related to Table Partition of TiDB. feature/developing the related feature is in development severity/major sig/sql-infra SIG: SQL Infra type/bug This issue is a bug.

Comments

@Defined2014
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

set tidb_enable_global_index=true;
CREATE TABLE `t` (
  `a` int(11) NOT NULL,
  `b` int(11) DEFAULT NULL,
  `c` int(11) DEFAULT NULL,
  PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */,
  UNIQUE KEY `idx1` (`b`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY HASH (`a`) PARTITIONS 5;

begin;
insert into t values (1, 2, 3);
insert into t values (2, 2, 3);

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

mysql> insert into t values (2, 2, 3);
ERROR 1062 (23000): Duplicate entry '2' for key 't.idx1'

3. What did you see instead (Required)

insert success

4. What is your TiDB version? (Required)

mysql> select tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                           |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.0.0-alpha-719-gc7d4c9cebb
Edition: Community
Git Commit Hash: c7d4c9cebb207bf5bf4dd4e532c44fe9ad753774
Git Branch: master
UTC Build Time: 2024-04-07 08:23:01
GoVersion: go1.21.5
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@Defined2014 Defined2014 added type/bug This issue is a bug. sig/sql-infra SIG: SQL Infra severity/major component/tablepartition This issue is related to Table Partition of TiDB. feature/developing the related feature is in development labels Apr 7, 2024
@Defined2014 Defined2014 changed the title Could insert duplicate value in to a unique index with global index Could insert duplicate values in to a unique index with global index Apr 7, 2024
@Defined2014 Defined2014 changed the title Could insert duplicate values in to a unique index with global index Could insert duplicate values into a unique index with global index Apr 7, 2024
@Defined2014
Copy link
Contributor Author

Defined2014 commented Apr 8, 2024

Caused by #42312, but it still has some problems.

A test case, it should return error

create table test_global ( a int, b int, c int)
partition by range( a ) (
	partition p1 values less than (10),
	partition p2 values less than (20),
	partition p3 values less than (30)
);
alter table test_global add unique index idx_b (b);
begin;
insert into test_global values (1, 1, 1), (8, 8, 8), (11, 11, 11), (12, 12, 12);
update test_global set a = 2, b = 12 where a = 11; -- it should return error

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

Successfully merging a pull request may close this issue.

2 participants