pingcap/tidb

DDL command DROP TABLE is not atomic

Open

#29,147 opened on Oct 26, 2021

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Go (40,090 stars) (6,186 forks)batch import
help wantedseverity/moderatesig/sql-infratype/bugtype/compatibility

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
DROP TABLE t1, t1; -- MySQL ( error 1066 did not drop table) vs TiDB error  ( error 1051 dropped table)
SHOW TABLES LIKE 't1'; -- MySQL shows table existing vs. TiDB shows no table

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

In both MySQL 5.7 and 8.0:

mysql [localhost:5731] {msandbox} (test) > DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected (0.00 sec)

mysql [localhost:5731] {msandbox} (test) > CREATE TABLE t1 (a INT);
Query OK, 0 rows affected (0.01 sec)

mysql [localhost:5731] {msandbox} (test) > DROP TABLE t1, t1; -- MySQL ( error 1066 did not drop table) vs TiDB error  ( error 1051 dropped table)
ERROR 1066 (42000): Not unique table/alias: 't1'
mysql [localhost:5731] {msandbox} (test) > SHOW TABLES LIKE 't1'; -- MySQL shows table existing vs. TiDB shows no table
+---------------------+
| Tables_in_test (t1) |
+---------------------+
| t1                  |
+---------------------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

tidb> DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected (0.01 sec)

tidb> CREATE TABLE t1 (a INT);
Query OK, 0 rows affected (0.00 sec)

tidb> DROP TABLE t1, t1; -- MySQL ( error 1066 did not drop table) vs TiDB error  ( error 1051 dropped table)
ERROR 1051 (42S02): Unknown table 'test.t1'
tidb> SHOW TABLES LIKE 't1'; -- MySQL shows table existing vs. TiDB shows no table
Empty set (0.00 sec)

4. What is your TiDB version? (Required)

+-------------------------+--------------------------------------------------------------------------+
| Variable_name           | Value                                                                    |
+-------------------------+--------------------------------------------------------------------------+
| innodb_version          | 5.6.25                                                                   |
| protocol_version        | 10                                                                       |
| tidb_analyze_version    | 2                                                                        |
| tidb_row_format_version | 2                                                                        |
| tls_version             | TLSv1,TLSv1.1,TLSv1.2                                                    |
| version                 | 5.7.25-TiDB-v5.2.1                                                       |
| version_comment         | TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible |
| version_compile_machine | x86_64                                                                   |
| version_compile_os      | osx10.8                                                                  |
+-------------------------+--------------------------------------------------------------------------+

Contributor guide