Open davidshiz opened 2 years ago
when set autocommit =0,the row data in the table cannot be deleted, as follows:
mysql> set autocommit=0;
Query OK, 0 rows affected (0.01 sec)
mysql> show variables like 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit | OFF |
+---------------+-------+
1 row in set (0.01 sec)
mysql> CREATE TABLE `test` (`id` int(11) DEFAULT NULL);
Query OK, 0 rows affected (0.02 sec)
mysql> insert into test values (1),(2),(3);
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select * from test;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
+------+
3 rows in set (0.00 sec)
mysql> delete from test where id = 1;
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> select * from test;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
+------+
3 rows in set (0.00 sec)
However, when set autocommit = 1, the data can be deleted successfully. as follows:
mysql> set autocommit =1;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from test;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
+------+
3 rows in set (0.00 sec)
mysql> delete from test where id = 1;
Query OK, 1 row affected (0.01 sec)
mysql> select * from test;
+------+
| id |
+------+
| 2 |
| 3 |
+------+
2 rows in set (0.01 sec)
So, this parameter autocommit should not affect the result set.
Describe the solution you'd like Tianmu DDL should not be affected by the Autocommit;
Additional context
DELETE & UPDATE have similar problems. as follows