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

TiDB Update with Natural join on Partitioned table results are not consistent with mysql. #31629

Closed
ramanich1 opened this issue Jan 12, 2022 · 2 comments · Fixed by #31779
Closed
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/planner SIG: Planner sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@ramanich1
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t1;

CREATE TABLE t1(partkey int,nokey int
) PARTITION BY HASH(partkey) PARTITIONS 3;

INSERT INTO t1 VALUES (1, 1) , (10, 10);

SELECT * FROM t1;
UPDATE t1 AS A NATURAL JOIN t1 B SET A.partkey = 2, B.nokey = 3;
SELECT * FROM t1;

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

mysql> SELECT * FROM t1;
+---------+-------+
| partkey | nokey |
+---------+-------+
|       1 |     1 |
|      10 |    10 |
+---------+-------+
2 rows in set (0.00 sec)
mysql> UPDATE t1 AS A NATURAL JOIN t1 B SET A.partkey = 2, B.nokey = 3;
ERROR 1706 (HY000): Primary key/partition key update is not allowed since the table is updated both as 'A' and 'B'

3. What did you see instead (Required)

mysql> SELECT * FROM t1;
+---------+-------+
| partkey | nokey |
+---------+-------+
|       1 |     1 |
|      10 |    10 |
+---------+-------+
2 rows in set (0.00 sec)

mysql> UPDATE t1 AS A NATURAL JOIN t1 B SET A.partkey = 2, B.nokey = 3;
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> SELECT * FROM t1;
+---------+-------+
| partkey | nokey |
+---------+-------+
|       2 |     3 |
|       2 |     3 |
|       2 |     1 |
|       2 |    10 |
+---------+-------+
4 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

| Release Version: v5.4.0-alpha-264-g6efa36df6
Edition: Community
Git Commit Hash: 6efa36df6cff325106f67ecfe3d79816ba37ca6a
Git Branch: master
UTC Build Time: 2021-12-28 02:03:55
GoVersion: go1.17.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
@ramanich1 ramanich1 added the type/bug The issue is confirmed as a bug. label Jan 12, 2022
@ChenPeng2013 ChenPeng2013 added affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. severity/critical sig/planner SIG: Planner labels Jan 13, 2022
@mjonss
Copy link
Contributor

mjonss commented Jan 13, 2022

I don't think it is critical, maybe major, due to non common command (update with natural join on it-self).

@mjonss
Copy link
Contributor

mjonss commented Jan 13, 2022

/component tablepartition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/planner SIG: Planner 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.

5 participants