diff options
author | unknown <anozdrin/alik@quad.> | 2008-03-12 16:13:33 +0300 |
---|---|---|
committer | unknown <anozdrin/alik@quad.> | 2008-03-12 16:13:33 +0300 |
commit | 326c4e90589dd87792eacfa6e8746bc486a10ba0 (patch) | |
tree | 949c8a892915fb127195051b1d08b313100f7a6b /mysql-test/t/trigger-trans.test | |
parent | aafb492d594776ead1014163461d30cbf9ca5772 (diff) | |
download | mariadb-git-326c4e90589dd87792eacfa6e8746bc486a10ba0.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.
mysql-test/r/trigger-trans.result:
Update result file.
mysql-test/t/trigger-trans.test:
A test case for Bug#34643: TRUNCATE crash if trigger and foreign key.
sql/sql_delete.cc:
Do not process triggers in TRUNCATE.
Diffstat (limited to 'mysql-test/t/trigger-trans.test')
-rw-r--r-- | mysql-test/t/trigger-trans.test | 32 |
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 |