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

Specify non-matching partition insert record fail expectly,but successful #24746

Closed
vivid392845427 opened this issue May 19, 2021 · 4 comments · Fixed by #24872
Closed

Specify non-matching partition insert record fail expectly,but successful #24746

vivid392845427 opened this issue May 19, 2021 · 4 comments · Fixed by #24872
Assignees
Labels
severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@vivid392845427
Copy link

vivid392845427 commented May 19, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t(a int, b varchar(40), c int, primary key(b(8),a)) partition by range(a)(partition p0 values less than (5),partition p1 values less than (10), partition p2 values less than maxvalue);
insert into t partition (p0) values(4,'test',4) on duplicate key update a= a +1;
insert into t partition (p1) values(4,'test',4) on duplicate key update a= a +1;

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

mysql> insert into t partition (p1) values(4,'test',4) on duplicate key update a= a +1;
ERROR 1748 (HY000): Found a row not matching the given partition set

3. What did you see instead (Required)

mysql> insert into t partition (p1) values(4,'test',4) on duplicate key update a= a +1;
Query OK, 2 rows affected (0.01 sec)

4. What is your TiDB version? (Required)

Release Version: v5.0.1-3-g41c0f1762
Edition: Community
Git Commit Hash: 41c0f17
Git Branch: release-5.0
UTC Build Time: 2021-05-13 17:21:10
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

@vivid392845427 vivid392845427 added the type/bug The issue is confirmed as a bug. label May 19, 2021
@vivid392845427 vivid392845427 changed the title insert record Specify non-matching partition insert record fail expectly,but successful May 19, 2021
@mjonss
Copy link
Contributor

mjonss commented May 19, 2021

Issue is that the insert into t partition (p1) values(4,'test',4) on duplicate key update a= a +1; should either check the original value (4,'test',4) or disallow reading from any other partition than p1. Investigating further.

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

@mjonss
Copy link
Contributor

mjonss commented May 27, 2021

Bug

Table/Partition allowed to read from non specified partition when:
INSERT INTO t PARTITION (pN) VALUES (v) ON DUPLICATE KEY UPDATE c = new_val

if value 'v' was not in partition pN, it would still check in the other partition and if found update the value if it would result in partition pN (if not, then it would give the correct error).

1. Root Cause Analysis (RCA) (optional)

For insert, only the writing was checked against the given partitions, not the reading.

2. Symptom

Allowed to read from non specified partition

3. All Trigger Conditions (optional)

partitioned table, insert on duplicate key update reading from non specified partition, but writing to a partition in the given set.

4. Workaround (optional)

n/a cannot use explicit partition selection to limit the query for reading (only for writing)

5. Affected versions

All

6. Fixed versions

TBD

@ti-srebot
Copy link
Contributor

( FixedVersions AffectedVersions ) fields are empty.
The values in ( FixedVersions AffectedVersions ) fields are incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants