This statement commits a transaction inside of the TIDB server.
In the absence of a
START TRANSACTION statement, the default behavior of TiDB is that every statement will be its own transaction and autocommit. This behavior ensures MySQL compatibility.
mysql> CREATE TABLE t1 (a int NOT NULL PRIMARY KEY); Query OK, 0 rows affected (0.12 sec) mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO t1 VALUES (1); Query OK, 1 row affected (0.00 sec) mysql> COMMIT; Query OK, 0 rows affected (0.01 sec)
- TiDB 2.1 uses Optimistic Locking. It is important to consider that a
COMMITstatement might fail because rows have been modified by another transaction. This changes in later versions of TiDB, where pessimistic locking is available.
- By default,
PRIMARY KEYconstraint checks are deferred until statement commit. This behavior can be changed by setting