diff options
author | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2009-01-09 08:20:32 -0200 |
---|---|---|
committer | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2009-01-09 08:20:32 -0200 |
commit | 8dbb9c885d42fd03b997a507d10620c1a55fa44d (patch) | |
tree | a733a91258824cd53ed4fd4e4ab04fa2d2a34a68 /mysql-test/include/commit.inc | |
parent | e35fc57bd30473be8bad038f53b34302a4d2e724 (diff) | |
download | mariadb-git-8dbb9c885d42fd03b997a507d10620c1a55fa44d.tar.gz |
Bug#37016: TRUNCATE TABLE removes some rows but not all
The special TRUNCATE TABLE (DDL) transaction wasn't being properly
rolled back if a error occurred during row by row deletion. The
error can be caused by a foreign key restriction imposed by InnoDB
SE and would cause the server to erroneously issue a implicit
commit.
The solution is to rollback the transaction if a truncation via row
by row deletion fails, otherwise commit. All effects of a TRUNCATE
ABLE operation are rolled back if a row by row deletion fails.
mysql-test/include/commit.inc:
Truncate always starts a transaction and commits at the end.
The commit at the end increases the count by two, one is the
storage engine commit and the other is the binary log.
mysql-test/r/commit_1innodb.result:
Update test case results.
mysql-test/r/innodb_mysql.result:
Update test case results.
mysql-test/t/innodb_mysql.test:
Add test case for Bug#37016
sql/sql_delete.cc:
Move truncation using row by row deletion to its own function.
If row by row deletion fails, rollback the transaction.
Remove the meddling with disabling and enabling of autocommit
as TRUNCATE transaction is now explicitly ended (committed
or rolled back).
Diffstat (limited to 'mysql-test/include/commit.inc')
-rw-r--r-- | mysql-test/include/commit.inc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc index 48b0eac12e5..de5eca8b1f6 100644 --- a/mysql-test/include/commit.inc +++ b/mysql-test/include/commit.inc @@ -617,10 +617,10 @@ call p_verify_status_increment(0, 0, 0, 0); --echo --echo # No test because of Bug#8729 "rename table fails on temporary table" ---echo # 24. DDL: TRUNCATE TEMPORARY TABLE, does not start a transaction +--echo # 24. DDL: TRUNCATE TEMPORARY TABLE --echo truncate table t2; -call p_verify_status_increment(2, 0, 2, 0); +call p_verify_status_increment(4, 0, 4, 0); commit; --echo # There is nothing left to commit call p_verify_status_increment(0, 0, 0, 0); @@ -733,7 +733,7 @@ call p_verify_status_increment(1, 0, 1, 0); rename table t4 to t3; call p_verify_status_increment(1, 0, 1, 0); truncate table t3; -call p_verify_status_increment(2, 2, 2, 2); +call p_verify_status_increment(4, 4, 2, 2); create view v1 as select * from t2; call p_verify_status_increment(1, 0, 1, 0); check table t1; |