1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

Bug#42643: InnoDB does not support replication of TRUNCATE TABLE

The problem was that TRUNCATE TABLE didn't take a exclusive
lock on a table if it resorted to truncating via delete of
all rows in the table. Specifically for InnoDB tables, this
could break proper isolation as InnoDB ends up aborting some
granted locks when truncating a table.

The solution is to take a exclusive metadata lock before
TRUNCATE TABLE can proceed. This guarantees that no other
transaction is using the table.

Incompatible change: Truncate via delete no longer fails
if sql_safe_updates is activated (this was a undocumented
side effect).
This commit is contained in:
Davi Arnaut
2010-05-25 17:01:38 -03:00
parent a3c080be7a
commit 3c279d9a5a
38 changed files with 1471 additions and 441 deletions

View File

@@ -102,7 +102,7 @@ SELECT * FROM v1;
LOCK TABLE t1 WRITE;
--error ER_TABLE_NOT_LOCKED
SELECT * FROM v1;
--error ER_NO_SUCH_TABLE
--error ER_TABLE_NOT_LOCKED
TRUNCATE v1;
--error ER_TABLE_NOT_LOCKED
SELECT * FROM v1;
@@ -111,7 +111,7 @@ UNLOCK TABLES;
LOCK TABLE t1 WRITE, t2 WRITE;
--error ER_TABLE_NOT_LOCKED
SELECT * FROM v1;
--error ER_NO_SUCH_TABLE
--error ER_TABLE_NOT_LOCKED
TRUNCATE v1;
--error ER_TABLE_NOT_LOCKED
SELECT * FROM v1;
@@ -119,14 +119,14 @@ UNLOCK TABLES;
#
LOCK TABLE v1 WRITE;
SELECT * FROM v1;
--error ER_NO_SUCH_TABLE
--error ER_TABLE_NOT_LOCKED
TRUNCATE v1;
SELECT * FROM v1;
UNLOCK TABLES;
#
LOCK TABLE t1 WRITE, t2 WRITE, v1 WRITE;
SELECT * FROM v1;
--error ER_NO_SUCH_TABLE
--error ER_TABLE_NOT_LOCKED
TRUNCATE v1;
SELECT * FROM v1;
UNLOCK TABLES;