What happens to the TRUNCATE TABLE command in connection 2?

In MYSQL 5.6 you have the table t1:
CREATE TABLE t1 (
id int unsigned NOT NULL PRIMARY key) ENGINE = InnoDB;
There are two connections to the server. They execute in this order:
Connection 1> SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
Connection 1> START TRANSACTION;
Connection 1> SELECT * FROM t1 WHERE id =1;
Connection 2> TRUNCATE TABLE t1;
What happens to the TRUNCATE TABLE command in connection 2?

In MYSQL 5.6 you have the table t1:
CREATE TABLE t1 (
id int unsigned NOT NULL PRIMARY key) ENGINE = InnoDB;
There are two connections to the server. They execute in this order:
Connection 1> SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
Connection 1> START TRANSACTION;
Connection 1> SELECT * FROM t1 WHERE id =1;
Connection 2> TRUNCATE TABLE t1;
What happens to the TRUNCATE TABLE command in connection 2?

A.
It immediately proceeds and causes an implicit commit of the transaction in connection1.

B.
It runs concurrently with the transaction in connection 1 as each connection has its own
view of the data in the t1 table.

C.
It blocks waiting for a metadata lock until the transaction in connection 1 ends.

D.
It blocks waiting for a table lock until the transaction in connection 1 ends.



Leave a Reply 4

Your email address will not be published. Required fields are marked *