summaryrefslogtreecommitdiff
path: root/mysql-test/t/trigger.test
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@macbook.gmz>2006-11-21 10:11:43 +0200
committerunknown <gkodinov/kgeorge@macbook.gmz>2006-11-21 10:11:43 +0200
commit1a0e1f1328c933d63e0bb0d99b9011058abd82cd (patch)
tree36b170c741db953fe962326cf4ec4dda69c4d289 /mysql-test/t/trigger.test
parente139c57f29dd537b14d527a159d0931f4473e0fd (diff)
downloadmariadb-git-1a0e1f1328c933d63e0bb0d99b9011058abd82cd.tar.gz
Bug#23556: TRUNCATE TABLE still maps to DELETE
This is the 5.0 part of the fix. Currently TRUNCATE command will not call delete_all_rows() in the handler (that implements the "fast" TRUNCATE for InnoDB) when there are triggers on the table. As decided by the architecture team TRUNCATE must use "fast" TRUNCATE even when there are triggers. Thus it must ignore the triggers. Made TRUNCATE to ignore the triggers and call delete_all_rows() for all storage engines to maintain engine consistency. mysql-test/r/trigger.result: Bug#23556: TRUNCATE TABLE still maps to DELETE - test case mysql-test/t/trigger.test: Bug#23556: TRUNCATE TABLE still maps to DELETE - test case sql/sql_delete.cc: Bug#23556: TRUNCATE TABLE still maps to DELETE - We implemenent fast TRUNCATE for InnoDB even if triggers are present. - TRUNCATE ignores triggers.
Diffstat (limited to 'mysql-test/t/trigger.test')
-rw-r--r--mysql-test/t/trigger.test25
1 files changed, 25 insertions, 0 deletions
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index 92320648033..dd3293b815f 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -1498,5 +1498,30 @@ update t1 set i= i+ 10 where j > 2;
select * from t1;
drop table t1;
+#
+# Bug#23556 TRUNCATE TABLE still maps to DELETE
+#
+CREATE TABLE t1 (a INT PRIMARY KEY);
+CREATE TABLE t2 (a INT PRIMARY KEY);
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
+
+CREATE TRIGGER trg_t1 BEFORE DELETE on t1 FOR EACH ROW
+ INSERT INTO t2 VALUES (OLD.a);
+
+FLUSH STATUS;
+TRUNCATE t1;
+SHOW STATUS LIKE 'handler_delete';
+SELECT COUNT(*) FROM t2;
+
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
+DELETE FROM t2;
+
+FLUSH STATUS;
+DELETE FROM t1;
+SHOW STATUS LIKE 'handler_delete';
+SELECT COUNT(*) FROM t2;
+
+DROP TRIGGER trg_t1;
+DROP TABLE t1,t2;
--echo End of 5.0 tests