← Back to team overview

maria-discuss team mailing list archive

transactions and UNLOCK TABLES

 

In this MySQL manual page:
http://dev.mysql.com/doc/refman/5.6/en/implicit-commit.html

I read:
"UNLOCK TABLES commits a transaction only if any tables currently have been locked with LOCK TABLES to acquire nontransactional table locks."

However, this doesn't seem to be the case, at least with MariaDB 10.0:

MariaDB [test]> CREATE OR REPLACE TABLE m (c INT) ENGINE = InnoDB;
Query OK, 0 rows affected (0.39 sec)

MariaDB [test]> CREATE OR REPLACE TABLE t (c INT UNIQUE) ENGINE = InnoDB;
Query OK, 0 rows affected (0.54 sec)

MariaDB [test]> SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
Query OK, 0 rows affected (0.00 sec)

MariaDB [test]> START TRANSACTION;
Query OK, 0 rows affected (0.00 sec)

MariaDB [test]> INSERT INTO m VALUES (1);
Query OK, 1 row affected (0.00 sec)

MariaDB [test]> INSERT INTO t VALUES (1);
Query OK, 1 row affected (0.00 sec)

MariaDB [test]> UNLOCK TABLES;
Query OK, 0 rows affected (0.00 sec)

MariaDB [test]> SELECT @@in_transaction;
+------------------+
| @@in_transaction |
+------------------+
|                1 |
+------------------+
1 row in set (0.00 sec)

--
So, could you please confirm that UNLOCK TABLES is transaction-safe? If it isn't, could someone please explain in which cases it isn't?

Regards
Federico



Follow ups