summaryrefslogtreecommitdiff
path: root/mysql-test/t/trigger-trans.test
diff options
context:
space:
mode:
authoranozdrin/alik@quad. <>2008-03-12 16:13:33 +0300
committeranozdrin/alik@quad. <>2008-03-12 16:13:33 +0300
commit2b09a99340a066f1710045df42da1f43ff1d711b (patch)
tree949c8a892915fb127195051b1d08b313100f7a6b /mysql-test/t/trigger-trans.test
parent93a0992854bc9c1bfe8537972baa75653be2f65d (diff)
downloadmariadb-git-2b09a99340a066f1710045df42da1f43ff1d711b.tar.gz
A fix for Bug#34643: TRUNCATE crash if trigger and foreign key.
In cases when TRUNCATE was executed by invoking mysql_delete() rather than by table recreation (for example, when TRUNCATE was issued on InnoDB table with is referenced by foreign key) triggers were invoked. In debug builds this also led to crash because of an assertion, which assumes that some preliminary actions take place before trigger invocation, which doesn't happen in case of TRUNCATE. The fix is not to execute triggers in mysql_delete() when this function is used by TRUNCATE.
Diffstat (limited to 'mysql-test/t/trigger-trans.test')
-rw-r--r--mysql-test/t/trigger-trans.test32
1 files changed, 32 insertions, 0 deletions
diff --git a/mysql-test/t/trigger-trans.test b/mysql-test/t/trigger-trans.test
index 8103a1ba0b1..5db5b982773 100644
--- a/mysql-test/t/trigger-trans.test
+++ b/mysql-test/t/trigger-trans.test
@@ -128,5 +128,37 @@ drop table t1, t2, t3;
disconnect connection_update;
disconnect connection_aux;
+#
+# Bug#34643: TRUNCATE crash if trigger and foreign key.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=innodb;
+CREATE TABLE t2(b INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=innodb;
+
+INSERT INTO t1 VALUES (1);
+
+CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW SET @a = 1;
+CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW SET @b = 1;
+
+SET @a = 0;
+SET @b = 0;
+
+TRUNCATE t1;
+
+SELECT @a, @b;
+
+INSERT INTO t1 VALUES (1);
+
+DELETE FROM t1;
+
+SELECT @a, @b;
+
+DROP TABLE t2, t1;
+
--echo End of 5.0 tests