mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +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:
@ -99,7 +99,7 @@ LOCK TABLE t1 WRITE;
|
||||
SELECT * FROM v1;
|
||||
ERROR HY000: Table 'v1' was not locked with LOCK TABLES
|
||||
TRUNCATE v1;
|
||||
ERROR 42S02: Table 'test.v1' doesn't exist
|
||||
ERROR HY000: Table 'v1' was not locked with LOCK TABLES
|
||||
SELECT * FROM v1;
|
||||
ERROR HY000: Table 'v1' was not locked with LOCK TABLES
|
||||
UNLOCK TABLES;
|
||||
@ -107,7 +107,7 @@ LOCK TABLE t1 WRITE, t2 WRITE;
|
||||
SELECT * FROM v1;
|
||||
ERROR HY000: Table 'v1' was not locked with LOCK TABLES
|
||||
TRUNCATE v1;
|
||||
ERROR 42S02: Table 'test.v1' doesn't exist
|
||||
ERROR HY000: Table 'v1' was not locked with LOCK TABLES
|
||||
SELECT * FROM v1;
|
||||
ERROR HY000: Table 'v1' was not locked with LOCK TABLES
|
||||
UNLOCK TABLES;
|
||||
@ -117,7 +117,7 @@ c1
|
||||
1
|
||||
3
|
||||
TRUNCATE v1;
|
||||
ERROR 42S02: Table 'test.v1' doesn't exist
|
||||
ERROR HY000: Table 'v1' was not locked with LOCK TABLES
|
||||
SELECT * FROM v1;
|
||||
c1
|
||||
1
|
||||
@ -129,7 +129,7 @@ c1
|
||||
1
|
||||
3
|
||||
TRUNCATE v1;
|
||||
ERROR 42S02: Table 'test.v1' doesn't exist
|
||||
ERROR HY000: Table 'v1' was not locked with LOCK TABLES
|
||||
SELECT * FROM v1;
|
||||
c1
|
||||
1
|
||||
|
Reference in New Issue
Block a user