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

Alter Partition Truncate and Drop with partition name twice - TiDb results not consistent with mysql #31681

Closed
ramanich1 opened this issue Jan 13, 2022 · 4 comments · Fixed by #31782
Assignees
Labels
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/moderate 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)

set tidb_enable_list_partition=on;
Drop table if exists t1;
create table t1 (a int)
partition by list (a)
(partition p1 values in (0));
alter table t1 truncate partition p1,p1;
alter table t1 drop partition p1,p1;
 select partition_name, partition_description, table_rows,table_name from information_schema.partitions where table_schema ='test' and table_name= 't1';

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

mysql> alter table t1 truncate partition p1,p1;
Query OK, 0 rows affected (0.01 sec)

mysql> alter table t1 drop partition p1,p1;
ERROR 1508 (HY000): Cannot remove all partitions, use DROP TABLE instead

3. What did you see instead (Required)

mysql> alter table t1 truncate partition p1,p1; 
ERROR 8214 (HY000): Cancelled DDL job

mysql> alter table t1 drop partition p1,p1;
Query OK, 0 rows affected (0.00 sec)

mysql>  select partition_name, partition_description, table_rows,table_name from information_schema.partitions where table_schema ='test' and table_name= 't1';
+----------------+-----------------------+------------+------------+
| partition_name | partition_description | table_rows | table_name |
+----------------+-----------------------+------------+------------+
| p1             | 0                     |          0 | t1         |
+----------------+-----------------------+------------+------------+
1 row in set (0.01 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 13, 2022
@jebter jebter added 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. labels Jan 14, 2022
@bb7133
Copy link
Member

bb7133 commented Jan 14, 2022

I do not think this is a common case and can be easily workaround.

@bb7133 bb7133 added component/tablepartition This issue is related to Table Partition of TiDB. severity/moderate and removed severity/major labels Jan 14, 2022
@CbcWestwolf
Copy link
Member

/assign mjonss

@mjonss
Copy link
Contributor

mjonss commented Jan 18, 2022

TRUNCATE PARTITION in MySQL allows duplicate partition names, so we will also do it.
DROP PARTITION in MySQL has a bit more elaborate errors :)

mysql> CREATE TABLE `t1` (
  `a` int DEFAULT NULL
)
PARTITION BY LIST (`a`)
(PARTITION p1 VALUES IN (0) ENGINE = InnoDB,
 PARTITION p2 VALUES IN (1) ENGINE = InnoDB,
 PARTITION p3 VALUES IN (3) ENGINE = InnoDB);
mysql> alter table t1 drop partition p1,p1;
ERROR 1507 (HY000): Error in list of partitions to DROP
mysql> alter table t1 drop partition p1,p1,p1;
ERROR 1508 (HY000): Cannot remove all partitions, use DROP TABLE instead
mysql> alter table t1 drop partition p1,p1,p9;
ERROR 1508 (HY000): Cannot remove all partitions, use DROP TABLE instead

@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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/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.

6 participants