diff options
author | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-05-25 17:01:38 -0300 |
---|---|---|
committer | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-05-25 17:01:38 -0300 |
commit | 3c279d9a5a45d734c7cdd2b641520e199e342f95 (patch) | |
tree | fead1c9e257aedfb5c08da6db9ed7997e8af9fcf /mysql-test/include | |
parent | a3c080be7ac95ce7f6f384a07f9ff0b31fd33a0f (diff) | |
download | mariadb-git-3c279d9a5a45d734c7cdd2b641520e199e342f95.tar.gz |
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).
Diffstat (limited to 'mysql-test/include')
-rw-r--r-- | mysql-test/include/mix1.inc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index 66648aaf1bf..fe6abe13892 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -1351,6 +1351,13 @@ connection con1; SELECT * FROM t1; ROLLBACK; +--echo # Switch to connection con2 +connection con2; +ROLLBACK; + +--echo # Switch to connection con1 +connection con1; + --echo # 2. test for serialized update: CREATE TABLE t2 (a INT); @@ -1435,6 +1442,7 @@ connection con2; --reap SELECT * FROM t1; +--enable_abort_on_error connection default; disconnect con1; disconnect con2; @@ -1556,3 +1564,36 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) DROP TABLE t1; --echo End of 5.1 tests + +--echo # +--echo # Bug#42643: InnoDB does not support replication of TRUNCATE TABLE +--echo # +--echo # Check that a TRUNCATE TABLE statement, needing an exclusive meta +--echo # data lock, waits for a shared metadata lock owned by a concurrent +--echo # transaction. +--echo # + +eval CREATE TABLE t1 (a INT) ENGINE=$engine_type; +INSERT INTO t1 VALUES (1),(2),(3); +BEGIN; +SELECT * FROM t1 ORDER BY a; +--echo # Connection con1 +connect (con1, localhost, root,,); +--send TRUNCATE TABLE t1; +--echo # Connection default +connection default; +let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist + WHERE state='Waiting for table' AND info='TRUNCATE TABLE t1'; +--source include/wait_condition.inc +SELECT * FROM t1 ORDER BY a; +ROLLBACK; +--echo # Connection con1 +connection con1; +--echo # Reaping TRUNCATE TABLE +--reap +SELECT * FROM t1; +--echo # Disconnect con1 +disconnect con1; +--echo # Connection default +connection default; +DROP TABLE t1; |